Skip to content

Commit e637602

Browse files
committed
[lldb] [Process/FreeBSDRemote] Fix handling user-generated SIGTRAP
Update the SIGTRAP handler to account for the possibility of SIGTRAP being generated by the user, i.e. not having any specific debugging event associated with it, as well as receiving unknown SIGTRAPs. These instances of SIGTRAP are passed to the regular signal handler. Differential Revision: https://reviews.llvm.org/D91007
1 parent a56c795 commit e637602

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

lldb/source/Plugins/Process/FreeBSDRemote/NativeProcessFreeBSD.cpp

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,8 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
192192
}
193193
assert(info.pl_event == PL_EVENT_SIGNAL);
194194

195-
LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}", pid, info.pl_lwpid);
195+
LLDB_LOG(log, "got SIGTRAP, pid = {0}, lwpid = {1}, flags = {2:x}", pid,
196+
info.pl_lwpid, info.pl_flags);
196197
NativeThreadFreeBSD *thread = nullptr;
197198

198199
if (info.pl_flags & (PL_FLAG_BORN | PL_FLAG_EXITED)) {
@@ -240,6 +241,8 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
240241

241242
if (info.pl_flags & PL_FLAG_SI) {
242243
assert(info.pl_siginfo.si_signo == SIGTRAP);
244+
LLDB_LOG(log, "SIGTRAP siginfo: si_code = {0}, pid = {1}",
245+
info.pl_siginfo.si_code, info.pl_siginfo.si_pid);
243246

244247
switch (info.pl_siginfo.si_code) {
245248
case TRAP_BRKPT:
@@ -248,7 +251,7 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
248251
FixupBreakpointPCAsNeeded(*thread);
249252
}
250253
SetState(StateType::eStateStopped, true);
251-
break;
254+
return;
252255
case TRAP_TRACE:
253256
if (thread) {
254257
auto &regctx = static_cast<NativeRegisterContextFreeBSD &>(
@@ -272,9 +275,14 @@ void NativeProcessFreeBSD::MonitorSIGTRAP(lldb::pid_t pid) {
272275
}
273276

274277
SetState(StateType::eStateStopped, true);
275-
break;
278+
return;
276279
}
277280
}
281+
282+
// Either user-generated SIGTRAP or an unknown event that would
283+
// otherwise leave the debugger hanging.
284+
LLDB_LOG(log, "unknown SIGTRAP, passing to generic handler");
285+
MonitorSignal(pid, SIGTRAP);
278286
}
279287

280288
void NativeProcessFreeBSD::MonitorSignal(lldb::pid_t pid, int signal) {

lldb/test/API/functionalities/signal/raise/TestRaise.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ def test_sigsigrtmin(self):
3030
self.signal_test('SIGRTMIN', True)
3131

3232
@skipIfNetBSD # Hangs on NetBSD
33-
@skipIfFreeBSD # hangs
3433
def test_sigtrap(self):
3534
self.build()
3635
self.signal_test('SIGTRAP', True)

0 commit comments

Comments
 (0)