[Lldb-commits] [PATCH] D131130: [lldb] Improve EXC_RESOURCE exception reason
Jonas Devlieghere via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Wed Aug 3 17:10:42 PDT 2022
JDevlieghere created this revision.
JDevlieghere added reviewers: jasonmolenda, jingham.
Herald added a project: All.
JDevlieghere requested review of this revision.
Jason noted that the stop message we print for a memory high water mark notification (EXC_RESOURCE) could be clearer. Currently, the stop message looks like this:
* thread #3, queue = 'com.apple.CFNetwork.LoaderQ', stop reason = EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=14 MB, unused=0x0)
frame #0: 0x00000001f6a8c09c dyld`dyld4::APIs::dyld_shared_cache_some_image_overridden()
dyld`dyld4::APIs::dyld_shared_cache_some_image_overridden:
-> 0x1f6a8c09c <+0>: pacibsp
0x1f6a8c0a0 <+4>: sub sp, sp, #0x30
0x1f6a8c0a4 <+8>: stp x20, x19, [sp, #0x10]
0x1f6a8c0a8 <+12>: stp x29, x30, [sp, #0x20]
It's hard to read the message because the exception and the types (EXC_RESOURCE RESOURCE_TYPE_MEMORY) blend together. Additionally, the "observed=0x0" should not be printed for memory limit exceptions.
I wanted to continue to include the resource type from `<kern/exc_resource.h>` while also explaining what it actually is. With this path, the stop reason now looks like this:
* thread #5, stop reason = EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded) (limit=14 MB)
frame #0: 0x000000022500bb90 libsystem_pthread.dylib`start_wqthread
libsystem_pthread.dylib`start_wqthread:
-> 0x22500bb90 <+0>: stp xzr, xzr, [sp, #-0x10]!
0x22500bb94 <+4>: bl 0x22500bcd8 ; _pthread_wqthread
0x22500bb98 <+8>: brk #0x1
rdar://40466897
https://reviews.llvm.org/D131130
Files:
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
Index: lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
===================================================================
--- lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
+++ lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp
@@ -410,7 +410,7 @@
switch (resource_type) {
case RESOURCE_TYPE_CPU:
- exc_desc = "EXC_RESOURCE RESOURCE_TYPE_CPU";
+ exc_desc = "EXC_RESOURCE (RESOURCE_TYPE_CPU: CPU usage monitor tripped)";
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%%",
@@ -418,7 +418,7 @@
m_exc_subcode));
break;
case RESOURCE_TYPE_WAKEUPS:
- exc_desc = "EXC_RESOURCE RESOURCE_TYPE_WAKEUPS";
+ exc_desc = "EXC_RESOURCE (RESOURCE_TYPE_WAKEUPS: idle wakeups monitor tripped)";
snprintf(
code_desc_buf, sizeof(code_desc_buf), "%d w/s",
(int)EXC_RESOURCE_CPUMONITOR_DECODE_WAKEUPS_PERMITTED(m_exc_code));
@@ -427,11 +427,11 @@
m_exc_subcode));
break;
case RESOURCE_TYPE_MEMORY:
- exc_desc = "EXC_RESOURCE RESOURCE_TYPE_MEMORY";
+ exc_desc = "EXC_RESOURCE (RESOURCE_TYPE_MEMORY: high watermark memory limit exceeded)";
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";
+ subcode_label = nullptr;
break;
#if defined(RESOURCE_TYPE_IO)
// RESOURCE_TYPE_IO is introduced in macOS SDK 10.12.
@@ -470,7 +470,7 @@
if (m_exc_data_count >= 2) {
if (subcode_desc)
strm.Printf(", %s=%s", subcode_label, subcode_desc);
- else
+ else if (subcode_label)
strm.Printf(", %s=0x%" PRIx64, subcode_label, m_exc_subcode);
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D131130.449835.patch
Type: text/x-patch
Size: 1980 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20220804/f595e217/attachment-0001.bin>
More information about the lldb-commits
mailing list