This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Improve EXC_RESOURCE exception reason
ClosedPublic

Authored by JDevlieghere on Aug 3 2022, 5:10 PM.

Details

Summary

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. I used the wording from the comments in the header. 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

Diff Detail

Event Timeline

JDevlieghere created this revision.Aug 3 2022, 5:10 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 3 2022, 5:10 PM
JDevlieghere requested review of this revision.Aug 3 2022, 5:10 PM
JDevlieghere edited the summary of this revision. (Show Details)
jingham accepted this revision.Aug 5 2022, 11:05 AM

LGTM

This revision is now accepted and ready to land.Aug 5 2022, 11:05 AM
This revision was automatically updated to reflect the committed changes.
Herald added a project: Restricted Project. · View Herald TranscriptAug 5 2022, 11:19 AM