diff options
author | Jason Molenda <jmolenda@apple.com> | 2018-11-10 00:14:14 +0000 |
---|---|---|
committer | Jason Molenda <jmolenda@apple.com> | 2018-11-10 00:14:14 +0000 |
commit | a9796ede3919f27a5b740b9006db94c6eb42d079 (patch) | |
tree | 1117933f216dd3223ebb483967d98569c96a1745 /lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp | |
parent | 936734b7775d0448dc0cfa12681413fdda67ef62 (diff) | |
download | bcm5719-llvm-a9796ede3919f27a5b740b9006db94c6eb42d079.tar.gz bcm5719-llvm-a9796ede3919f27a5b740b9006db94c6eb42d079.zip |
Enable listening for EXC_RESOURCE events, and format mach
event as a thread stop reason if we receive one, using
some macros to decode the payload.
Patch originally written by Fred Riss, with a few small changes
by myself.
Writing a test for this is a little tricky because the
mach exception data interpretation relies on header macros
or function calls - it may change over time and writing
a gdb_remote_client test for this would break as older
encoding interpretation is changed. I'll tak with Fred
about this more, but neither of us has been thrilled with
the kind of tests we could write for it.
<rdar://problem/13097323>, <rdar://problem/40144456>
llvm-svn: 346571
Diffstat (limited to 'lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp')
-rw-r--r-- | lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp index 3dbfe611e71..c215519a8e8 100644 --- a/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp +++ b/lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp @@ -10,6 +10,8 @@ #include "StopInfoMachException.h" // C Includes +#include <kern/exc_resource.h> + // C++ Includes // Other libraries and framework includes // Project includes @@ -41,6 +43,10 @@ const char *StopInfoMachException::GetDescription() { const char *code_desc = NULL; const char *subcode_label = "subcode"; const char *subcode_desc = NULL; + + char code_desc_buf[32]; + char subcode_desc_buf[32]; + switch (m_value) { case 1: // EXC_BAD_ACCESS exc_desc = "EXC_BAD_ACCESS"; @@ -275,6 +281,45 @@ const char *StopInfoMachException::GetDescription() { break; case 11: exc_desc = "EXC_RESOURCE"; + { + int resource_type = EXC_RESOURCE_DECODE_RESOURCE_TYPE(m_exc_code); + + code_label = "limit"; + code_desc = code_desc_buf; + subcode_label = "observed"; + subcode_desc = subcode_desc_buf; + + switch (resource_type) { + case RESOURCE_TYPE_CPU: + exc_desc = "EXC_RESOURCE RESOURCE_TYPE_CPU"; + snprintf(code_desc_buf, sizeof(code_desc_buf), "%d%%", + (int)EXC_RESOURCE_CPUMONITOR_DECODE_PERCENTAGE(m_exc_code)); + snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d%%", + (int)EXC_RESOURCE_CPUMONITOR_DECODE_PERCENTAGE_OBSERVED(m_exc_subcode)); + break; + case RESOURCE_TYPE_WAKEUPS: + exc_desc = "EXC_RESOURCE RESOURCE_TYPE_WAKEUPS"; + snprintf(code_desc_buf, sizeof(code_desc_buf), "%d w/s", + (int)EXC_RESOURCE_CPUMONITOR_DECODE_WAKEUPS_PERMITTED(m_exc_code)); + snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d w/s", + (int)EXC_RESOURCE_CPUMONITOR_DECODE_WAKEUPS_OBSERVED(m_exc_subcode)); + break; + case RESOURCE_TYPE_MEMORY: + exc_desc = "EXC_RESOURCE RESOURCE_TYPE_MEMORY"; + snprintf(code_desc_buf, sizeof(code_desc_buf), "%d MB", + (int)EXC_RESOURCE_HWM_DECODE_LIMIT(m_exc_code)); + subcode_desc = nullptr; + subcode_label = "unused"; + break; + case RESOURCE_TYPE_IO: + exc_desc = "EXC_RESOURCE RESOURCE_TYPE_IO"; + snprintf(code_desc_buf, sizeof(code_desc_buf), "%d MB", + (int)EXC_RESOURCE_IO_DECODE_LIMIT(m_exc_code)); + snprintf(subcode_desc_buf, sizeof(subcode_desc_buf), "%d MB", + (int)EXC_RESOURCE_IO_OBSERVED(m_exc_subcode));; + break; + } + } break; case 12: exc_desc = "EXC_GUARD"; |