Skip to content

Commit d85505d

Browse files
committed
[debugserver] Fix that debugserver's stop reply packets always return signal code 0
If our process terminates due to an unhandled signal, we are supposed to get the signal code via WTERMSIG. However, we instead try to get the exit status via WEXITSTATUS which just ends up always calculating signal code 0 (at least on the macOS implementation where it just shifts the signal code bits away and we're left with only 0 bits). The exit status calculation on the LLDB side also seems a bit off as it claims an exit status that is just the signal code (instead of for example 128 + signal code), but that will be another patch. Reviewed By: jasonmolenda Differential Revision: https://reviews.llvm.org/D86336 (cherry picked from commit f0699d9)
1 parent d38d7b6 commit d85505d

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
#include <stdlib.h>
2+
3+
int main(int argc, char **argv) { abort(); }
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
UNSUPPORTED: system-windows
2+
3+
RUN: %clang_host %p/Inputs/abort.c -o %t
4+
RUN: %lldb %t -o run -o continue | FileCheck %s
5+
6+
CHECK: status = 6 (0x00000006) Terminated due to signal 6

lldb/tools/debugserver/source/RNBRemote.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3066,7 +3066,7 @@ rnb_err_t RNBRemote::HandlePacket_last_signal(const char *unused) {
30663066
WEXITSTATUS(pid_status));
30673067
else if (WIFSIGNALED(pid_status))
30683068
snprintf(pid_exited_packet, sizeof(pid_exited_packet), "X%02x",
3069-
WEXITSTATUS(pid_status));
3069+
WTERMSIG(pid_status));
30703070
else if (WIFSTOPPED(pid_status))
30713071
snprintf(pid_exited_packet, sizeof(pid_exited_packet), "S%02x",
30723072
WSTOPSIG(pid_status));

0 commit comments

Comments
 (0)