[lldb] Improve EXC_RESOURCE exception reason
authorJonas Devlieghere <jonas@devlieghere.com>
Fri, 5 Aug 2022 18:17:18 +0000 (11:17 -0700)
committerJonas Devlieghere <jonas@devlieghere.com>
Fri, 5 Aug 2022 18:19:46 +0000 (11:19 -0700)
commit9c81b743e31a7dca288b37b6cf6cca3213bfd923
tree8fa636fe28862aefa44adb7829c8451e793a5d06
parentf493b21e1695ac08ea3cd54dc2c2b87c36f52a95
[lldb] Improve EXC_RESOURCE exception reason

Jason noted that the stop message we print for a memory high water mark
notification (EXC_RESOURCE) could be clearer. Currently, the stop
reason looks like this:

  * thread #3, queue = 'com.apple.CFNetwork.LoaderQ', stop reason =
    EXC_RESOURCE RESOURCE_TYPE_MEMORY (limit=14 MB, unused=0x0)

It's hard to read the message because the exception and the type
(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)

rdar://40466897

Differential revision: https://reviews.llvm.org/D131130
lldb/source/Plugins/Process/Utility/StopInfoMachException.cpp