Skip to content

Commit 32c6ca4

Browse files
committed
UnixSignals
1 parent 43728f1 commit 32c6ca4

File tree

4 files changed

+103
-5
lines changed

4 files changed

+103
-5
lines changed

adapter/codelldb/src/debug_session.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1147,7 +1147,7 @@ impl DebugSession {
11471147
if terminate {
11481148
process.kill()?;
11491149
} else {
1150-
process.detach()?;
1150+
process.detach(false)?;
11511151
}
11521152
}
11531153
}

adapter/lldb/src/lib.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ pub type ThreadID = u64;
1313
pub type BreakpointID = u32;
1414
pub type WatchpointID = u32;
1515
pub type UserID = u64;
16+
pub type SignalNumber = i32;
1617

17-
pub const INVALID_ADDRESS: Address = Address::max_value();
18+
pub const INVALID_ADDRESS: Address = Address::MAX;
1819
pub const INVALID_THREAD_ID: ThreadID = 0;
1920
pub const INVALID_PROCESS_ID: ProcessID = 0;
2021
pub const INVALID_BREAK_ID: BreakpointID = 0;
22+
pub const INVALID_SIGNAL_NUMBER: i32 = SignalNumber::MAX;
2123

2224
/////////////////////////////////////////////////////////////////////////////////////////////////////
2325

@@ -156,6 +158,7 @@ mod sb {
156158
pub mod sbtarget;
157159
pub mod sbthread;
158160
pub mod sbtype;
161+
pub mod sbunixsignals;
159162
pub mod sbvalue;
160163
pub mod sbvaluelist;
161164
pub mod sbwatchpoint;
@@ -198,6 +201,7 @@ pub use sb::sbsymbolcontextlist::*;
198201
pub use sb::sbtarget::*;
199202
pub use sb::sbthread::*;
200203
pub use sb::sbtype::*;
204+
pub use sb::sbunixsignals::*;
201205
pub use sb::sbvalue::*;
202206
pub use sb::sbvaluelist::*;
203207
pub use sb::sbwatchpoint::*;

adapter/lldb/src/sb/sbprocess.rs

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,9 @@ impl SBProcess {
7979
})
8080
.into_result()
8181
}
82-
pub fn detach(&self) -> Result<(), SBError> {
83-
cpp!(unsafe [self as "SBProcess*"] -> SBError as "SBError" {
84-
return self->Detach();
82+
pub fn detach(&self, keep_stopped: bool) -> Result<(), SBError> {
83+
cpp!(unsafe [self as "SBProcess*", keep_stopped as "bool"] -> SBError as "SBError" {
84+
return self->Detach(keep_stopped);
8585
})
8686
.into_result()
8787
}
@@ -157,6 +157,17 @@ impl SBProcess {
157157
Err(error)
158158
}
159159
}
160+
pub fn unix_signals(&self) -> SBUnixSignals {
161+
cpp!(unsafe [self as "SBProcess*"] -> SBUnixSignals as "SBUnixSignals" {
162+
return self->GetUnixSignals();
163+
})
164+
}
165+
pub fn signal(&self, signo: SignalNumber) -> Result<(), SBError> {
166+
cpp!(unsafe [self as "SBProcess*", signo as "int"] -> SBError as "SBError" {
167+
return self->Signal(signo);
168+
})
169+
.into_result()
170+
}
160171
}
161172

162173
impl IsValid for SBProcess {
Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
use super::*;
2+
3+
cpp_class!(pub unsafe struct SBUnixSignals as "SBUnixSignals");
4+
5+
unsafe impl Send for SBUnixSignals {}
6+
7+
impl SBUnixSignals {
8+
pub fn clear(&mut self) {
9+
cpp!(unsafe [self as "SBUnixSignals*"] {
10+
self->Clear();
11+
})
12+
}
13+
pub fn num_signals(&self) -> u32 {
14+
cpp!(unsafe [self as "SBUnixSignals*"] -> u32 as "uint32_t" {
15+
return self->GetNumSignals();
16+
})
17+
}
18+
pub fn signal_at_index(&self, index: u32) -> SignalNumber {
19+
cpp!(unsafe [self as "SBUnixSignals*", index as "uint32_t"] -> SignalNumber as "int" {
20+
return self->GetSignalAtIndex(index);
21+
})
22+
}
23+
pub fn signal_number_from_name(&self, name: &str) -> Option<SignalNumber> {
24+
let signo = with_cstr(name, |name| {
25+
cpp!(unsafe [self as "SBUnixSignals*", name as "const char*"] -> i32 as "int" {
26+
return self->GetSignalNumberFromName(name);
27+
})
28+
});
29+
if signo == INVALID_SIGNAL_NUMBER {
30+
None
31+
} else {
32+
Some(signo)
33+
}
34+
}
35+
pub fn signal_name(&self, signo: SignalNumber) -> Option<&CStr> {
36+
let ptr = cpp!(unsafe [self as "SBUnixSignals*", signo as "int"] -> *const c_char as "const char*" {
37+
return self->GetSignalAsCString(signo);
38+
});
39+
if ptr.is_null() {
40+
None
41+
} else {
42+
unsafe { Some(CStr::from_ptr(ptr)) }
43+
}
44+
}
45+
pub fn should_stop(&self, signo: SignalNumber) -> bool {
46+
cpp!(unsafe [self as "SBUnixSignals*", signo as "int"] -> bool as "bool" {
47+
return self->GetShouldStop(signo);
48+
})
49+
}
50+
pub fn set_should_stop(&self, signo: SignalNumber, value: bool) -> bool {
51+
cpp!(unsafe [self as "SBUnixSignals*", signo as "int", value as "bool"] -> bool as "bool" {
52+
return self->SetShouldStop(signo, value);
53+
})
54+
}
55+
pub fn should_suppress(&self, signo: SignalNumber) -> bool {
56+
cpp!(unsafe [self as "SBUnixSignals*", signo as "int"] -> bool as "bool" {
57+
return self->GetShouldSuppress(signo);
58+
})
59+
}
60+
pub fn set_should_suppress(&self, signo: SignalNumber, value: bool) -> bool {
61+
cpp!(unsafe [self as "SBUnixSignals*", signo as "int", value as "bool"] -> bool as "bool" {
62+
return self->SetShouldSuppress(signo, value);
63+
})
64+
}
65+
pub fn should_notify(&self, signo: SignalNumber) -> bool {
66+
cpp!(unsafe [self as "SBUnixSignals*", signo as "int"] -> bool as "bool" {
67+
return self->GetShouldNotify(signo);
68+
})
69+
}
70+
pub fn set_should_notify(&self, signo: SignalNumber, value: bool) -> bool {
71+
cpp!(unsafe [self as "SBUnixSignals*", signo as "int", value as "bool"] -> bool as "bool" {
72+
return self->SetShouldNotify(signo, value);
73+
})
74+
}
75+
}
76+
77+
impl IsValid for SBUnixSignals {
78+
fn is_valid(&self) -> bool {
79+
cpp!(unsafe [self as "SBUnixSignals*"] -> bool as "bool" {
80+
return self->IsValid();
81+
})
82+
}
83+
}

0 commit comments

Comments
 (0)