Skip to content

Commit a55e03a

Browse files
authored
[linux] fix fatal error on user-invoked SIGTRAP
## Purpose A `SIGTRAP` in the inferior process originating from a user process other than ds2 is not an error. ## Overview * Treat `SIGTRAP` with a code <= 0 as non-fatal as long as it originates from a process other than ds2. * Leave the fatal error for unrecognized signal codes > 0 or if the signal originates from the ds2 process. * Re-enable the lldb test that was failing due to this issue. ## Problem Details `SIGTRAP` with a code <= 0 indicates it originates from a user process. It should not be treated as a fatal error if it comes from a process other than ds2. ## Validation The re-enabled lldb test now passes consistently locally on Android.
1 parent 3a08337 commit a55e03a

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

Sources/Target/Linux/Thread.cpp

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,6 @@ ErrorCode Thread::updateStopInfo(int waitStatus) {
9595
_stopInfo.reason = StopInfo::kReasonTrap;
9696
} else if (_stopInfo.signal == SIGTRAP) { // (5)
9797
switch (si.si_code) {
98-
case 0:
99-
_stopInfo.reason = StopInfo::kReasonTrap;
100-
break;
10198
case TRAP_HWBKPT:
10299
case TRAP_TRACE: {
103100
auto *hwBpm = process()->hardwareBreakpointManager();
@@ -111,7 +108,16 @@ ErrorCode Thread::updateStopInfo(int waitStatus) {
111108
_stopInfo.reason = StopInfo::kReasonBreakpoint;
112109
break;
113110
default:
114-
DS2BUG("unknown sigtrap code");
111+
if (si.si_code > 0 || si.si_pid == getpid())
112+
DS2BUG("unknown sigtrap code %d", si.si_code);
113+
114+
// If the value of si_code is <= 0, then the signal was generated by a
115+
// user process via kill(2), sigsend(2), abort(3C), raise(3C), etc. No
116+
// action is needed other than updating the thread's stop info.
117+
DS2LOG(Warning, "sigtrap code %d recieved from %" PRI_PID, si.si_code,
118+
si.si_pid);
119+
_stopInfo.reason = StopInfo::kReasonTrap;
120+
break;
115121
}
116122
} else {
117123
// This is not a signal that we originated. We can output a

Support/Testing/Excluded/ds2/android-x86_64.excluded

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,6 @@ TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_by_id_autocontinu
8989
TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_by_id_correct_executable_offset
9090
TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_by_name
9191
TestProcessAttach.ProcessAttachTestCase.test_attach_to_process_from_different_dir_by_id
92-
TestRaise.RaiseTestCase.test_sigtrap
9392
TestRegistersIterator.RegistersIteratorTestCase.test_iter_registers_dwarf
9493
TestRegistersIterator.RegistersIteratorTestCase.test_iter_registers_dwo
9594
TestRegisters.RegisterCommandsTestCase.test_convenience_registers_16bit_with_process_attach

0 commit comments

Comments
 (0)