diff options
author | Greg Clayton <gclayton@apple.com> | 2014-04-30 20:24:10 +0000 |
---|---|---|
committer | Greg Clayton <gclayton@apple.com> | 2014-04-30 20:24:10 +0000 |
commit | 040c560f2c93b4cb85136737981946b390fd2897 (patch) | |
tree | 93fb83c7540d31f9510b240fd4b8eeee5c1409b2 /lldb/tools/debugserver/source/DNB.cpp | |
parent | 3ef43692b4c7d1b80c28cf69b0fe990c7a6065b2 (diff) | |
download | bcm5719-llvm-040c560f2c93b4cb85136737981946b390fd2897.tar.gz bcm5719-llvm-040c560f2c93b4cb85136737981946b390fd2897.zip |
Report the result of waitpid() a little more clearly as well as clearly logging the process status.
llvm-svn: 207698
Diffstat (limited to 'lldb/tools/debugserver/source/DNB.cpp')
-rw-r--r-- | lldb/tools/debugserver/source/DNB.cpp | 68 |
1 files changed, 55 insertions, 13 deletions
diff --git a/lldb/tools/debugserver/source/DNB.cpp b/lldb/tools/debugserver/source/DNB.cpp index 49122cc3bf3..49670214ae9 100644 --- a/lldb/tools/debugserver/source/DNB.cpp +++ b/lldb/tools/debugserver/source/DNB.cpp @@ -165,24 +165,66 @@ kqueue_thread (void *arg) else { int status; - pid_t child_pid = waitpid ((pid_t) death_event.ident, &status, 0); - if (death_event.data & NOTE_EXIT_MEMORY) + const pid_t pid = (pid_t)death_event.ident; + const pid_t child_pid = waitpid (pid, &status, 0); + + + bool exited = false; + int signal = 0; + int exit_status = 0; + const char *status_cstr = NULL; + if (WIFSTOPPED(status)) { - if (death_event.data & NOTE_VM_PRESSURE) - DNBProcessSetExitInfo (child_pid, "Terminated due to Memory Pressure"); - else if (death_event.data & NOTE_VM_ERROR) - DNBProcessSetExitInfo (child_pid, "Terminated due to Memory Error"); + signal = WSTOPSIG(status); + status_cstr = "STOPPED"; + DNBLogThreadedIf(LOG_PROCESS, "waitpid (%i) -> STOPPED (signal = %i)", child_pid, signal); + } + else if (WIFEXITED(status)) + { + exit_status = WEXITSTATUS(status); + status_cstr = "EXITED"; + exited = true; + DNBLogThreadedIf(LOG_PROCESS, "waitpid (%i) -> EXITED (status = %i)", child_pid, exit_status); + } + else if (WIFSIGNALED(status)) + { + signal = WTERMSIG(status); + status_cstr = "SIGNALED"; + if (child_pid == abs(pid)) + { + DNBLogThreadedIf(LOG_PROCESS, "waitpid (%i) -> SIGNALED and EXITED (signal = %i)", child_pid, signal); + char exit_info[64]; + ::snprintf (exit_info, sizeof(exit_info), "Terminated due to signal %i", signal); + DNBProcessSetExitInfo (child_pid, exit_info); + exited = true; + exit_status = INT8_MAX; + } else - DNBProcessSetExitInfo (child_pid, "Terminated due to unknown Memory condition"); + { + DNBLogThreadedIf(LOG_PROCESS, "waitpid (%i) -> SIGNALED (signal = %i)", child_pid, signal); + } } - else if (death_event.data & NOTE_EXIT_DECRYPTFAIL) + + if (exited) + { + if (death_event.data & NOTE_EXIT_MEMORY) + { + if (death_event.data & NOTE_VM_PRESSURE) + DNBProcessSetExitInfo (child_pid, "Terminated due to Memory Pressure"); + else if (death_event.data & NOTE_VM_ERROR) + DNBProcessSetExitInfo (child_pid, "Terminated due to Memory Error"); + else + DNBProcessSetExitInfo (child_pid, "Terminated due to unknown Memory condition"); + } + else if (death_event.data & NOTE_EXIT_DECRYPTFAIL) DNBProcessSetExitInfo (child_pid, "Terminated due to decrypt failure"); - else if (death_event.data & NOTE_EXIT_CSERROR) + else if (death_event.data & NOTE_EXIT_CSERROR) DNBProcessSetExitInfo (child_pid, "Terminated due to code signing error"); - - DNBLogThreadedIf(LOG_PROCESS, "waitpid_process_thread (): setting exit status for pid = %i to %i", child_pid, status); - DNBProcessSetExitStatus (child_pid, status); - return NULL; + + DNBLogThreadedIf(LOG_PROCESS, "waitpid_process_thread (): setting exit status for pid = %i to %i", child_pid, exit_status); + DNBProcessSetExitStatus (child_pid, status); + return NULL; + } } } } |