diff options
author | Pavel Labath <labath@google.com> | 2017-06-19 12:47:50 +0000 |
---|---|---|
committer | Pavel Labath <labath@google.com> | 2017-06-19 12:47:50 +0000 |
commit | 3508fc8cc518f2f62d38c351c90f7815f835c3e4 (patch) | |
tree | b5f3493c3e24f3739b2e1d3a4da707e0c0405f72 /lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | |
parent | cc1c112806556e75453e0c9a1dc0f4038aecb4ef (diff) | |
download | bcm5719-llvm-3508fc8cc518f2f62d38c351c90f7815f835c3e4.tar.gz bcm5719-llvm-3508fc8cc518f2f62d38c351c90f7815f835c3e4.zip |
Add pretty-printer for wait(2) statuses and modernize the code handling them
Summary:
A number of places were trying to decode the result of wait(). Add a simple
utility function that does that and a struct that encapsulates the
decoded result. Then also provide a pretty-printer for that class.
Reviewers: zturner, krytarowski, eugene
Subscribers: lldb-commits, mgorny
Differential Revision: https://reviews.llvm.org/D33998
llvm-svn: 305689
Diffstat (limited to 'lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp | 50 |
1 files changed, 10 insertions, 40 deletions
diff --git a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp index d318c35366f..d34a79453fe 100644 --- a/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp +++ b/lldb/source/Plugins/Process/gdb-remote/GDBRemoteCommunicationServerLLGS.cpp @@ -370,53 +370,23 @@ GDBRemoteCommunicationServerLLGS::SendWResponse( Log *log(GetLogIfAnyCategoriesSet(LIBLLDB_LOG_PROCESS)); // send W notification - ExitType exit_type = ExitType::eExitTypeInvalid; - int return_code = 0; - std::string exit_description; - - const bool got_exit_info = - process->GetExitStatus(&exit_type, &return_code, exit_description); - if (!got_exit_info) { - if (log) - log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 - ", failed to retrieve process exit status", - __FUNCTION__, process->GetID()); + auto wait_status = process->GetExitStatus(); + if (!wait_status) { + LLDB_LOG(log, "pid = {0}, failed to retrieve process exit status", + process->GetID()); StreamGDBRemote response; response.PutChar('E'); response.PutHex8(GDBRemoteServerError::eErrorExitStatus); return SendPacketNoLock(response.GetString()); - } else { - if (log) - log->Printf("GDBRemoteCommunicationServerLLGS::%s pid %" PRIu64 - ", returning exit type %d, return code %d [%s]", - __FUNCTION__, process->GetID(), exit_type, return_code, - exit_description.c_str()); - - StreamGDBRemote response; - - char return_type_code; - switch (exit_type) { - case ExitType::eExitTypeExit: - return_type_code = 'W'; - break; - case ExitType::eExitTypeSignal: - return_type_code = 'X'; - break; - case ExitType::eExitTypeStop: - return_type_code = 'S'; - break; - case ExitType::eExitTypeInvalid: - return_type_code = 'E'; - break; - } - response.PutChar(return_type_code); + } - // POSIX exit status limited to unsigned 8 bits. - response.PutHex8(return_code); + LLDB_LOG(log, "pid = {0}, returning exit type {1}", process->GetID(), + *wait_status); - return SendPacketNoLock(response.GetString()); - } + StreamGDBRemote response; + response.Format("{0:g}", *wait_status); + return SendPacketNoLock(response.GetString()); } static void AppendHexValue(StreamString &response, const uint8_t *buf, |