[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
This commit is contained in:
Raphael Isemann 2020-09-03 09:17:03 +02:00
parent 2878ecc90f
commit f0699d9109
3 changed files with 10 additions and 1 deletions

View File

@ -0,0 +1,3 @@
#include <stdlib.h>
int main(int argc, char **argv) { abort(); }

View File

@ -0,0 +1,6 @@
UNSUPPORTED: system-windows
RUN: %clang_host %p/Inputs/abort.c -o %t
RUN: %lldb %t -o run -o continue | FileCheck %s
CHECK: status = 6 (0x00000006) Terminated due to signal 6

View File

@ -3066,7 +3066,7 @@ rnb_err_t RNBRemote::HandlePacket_last_signal(const char *unused) {
WEXITSTATUS(pid_status));
else if (WIFSIGNALED(pid_status))
snprintf(pid_exited_packet, sizeof(pid_exited_packet), "X%02x",
WEXITSTATUS(pid_status));
WTERMSIG(pid_status));
else if (WIFSTOPPED(pid_status))
snprintf(pid_exited_packet, sizeof(pid_exited_packet), "S%02x",
WSTOPSIG(pid_status));