This is an archive of the discontinued LLVM Phabricator instance.

[lldb/crashlog] Add support for Application Specific Backtraces & Information
ClosedPublic

Authored by mib on May 23 2022, 5:25 PM.

Details

Summary

For an exception crashlog, the thread backtraces aren't usually very helpful
and instead, developpers look at the "Application Specific Backtrace" that
was generated by objc_exception_throw.

LLDB could already parse and symbolicate these Application Specific Backtraces
for regular textual-based crashlog, so this patch adds support to parse them
in JSON crashlogs, and materialize them a HistoryThread extending the
crashed ScriptedThread.

This patch also includes the Application Specific Information messages
as part of the process extended crash information log. To do so, the
ScriptedProcess Python interface has a new GetMetadata method that
returns an arbitrary dictionary with data related to the process.

rdar://93207586

Signed-off-by: Med Ismail Bennani <medismail.bennani@gmail.com>

Diff Detail

Event Timeline

mib created this revision.May 23 2022, 5:25 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 23 2022, 5:25 PM
mib requested review of this revision.May 23 2022, 5:25 PM

Test? :-)

lldb/examples/python/crashlog.py
567–570

Do we have an existing regex for this from the textual parser?

576

For consistency with the other errors

mib updated this revision to Diff 465232.Oct 4 2022, 5:19 PM
mib marked 2 inline comments as done.
mib retitled this revision from [lldb/crashlog] Add support for Application Specific Backtraces to [lldb/crashlog] Add support for Application Specific Backtraces & Information.
mib edited the summary of this revision. (Show Details)
mib added a reviewer: jingham.
  • Add test (wip)
  • Add Application Specific Information to process extended crash info
  • Add {,Scripted}Process::GetMetadata method

I'm not sure I understand how the test is exercising the application specific backtrace. I don't see any of the frames or the crash reason in there. What am I missing?

lldb/examples/python/crashlog.py
566–582

Can this be a top level function? It's hard to tell if this is capturing anything. We have other place where we have helper functions that are called from a loop.

lldb/examples/python/scripted_process/crashlog_scripted_process.py
142–145

nit

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
1000 ↗(On Diff #465232)

Should this check if the size == 1?

lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
491 ↗(On Diff #465232)

Is this ever populated?

mib marked 2 inline comments as done.Oct 10 2022, 2:49 PM
mib added inline comments.
lldb/examples/python/crashlog.py
566–582

This parses a single backtrace. I'm not sure what you mean by "We have other place where we have helper functions that are called from a loop."

lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
1000 ↗(On Diff #465232)

I don't think this should only work if the dictionary has only 1 item.

lldb/source/Plugins/Process/scripted/ScriptedProcess.cpp
491 ↗(On Diff #465232)

It is used below in ErrorWithMessage.

mib updated this revision to Diff 466636.Oct 10 2022, 2:59 PM
mib marked an inline comment as done.
mib edited the summary of this revision. (Show Details)
  • Address @JDevlieghere comments.
  • Change implementation to have the ASI in the process extended crash info and ASB as an extended HistoryThread of the actually crashed thread.
  • Fix test.
mib updated this revision to Diff 472756.Nov 2 2022, 2:06 PM

Update tests following changes in D135547

JDevlieghere accepted this revision.Nov 3 2022, 9:31 AM

A few nits but overall this LGTM.

lldb/examples/python/crashlog.py
566–582

ping

584–588

I don't think it's correct to treat the ASI as just another thread. IIUC it's the same as the crashing thread, just at another point in time (when the exception was thrown). To me that sounds like it should be its own thing.

lldb/examples/python/scripted_process/crashlog_scripted_process.py
44
lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
105 ↗(On Diff #472756)
lldb/include/lldb/Target/Process.h
2431 ↗(On Diff #472756)
lldb/source/Plugins/Platform/MacOSX/PlatformDarwin.cpp
985 ↗(On Diff #472756)
This revision is now accepted and ready to land.Nov 3 2022, 9:31 AM
mib marked 7 inline comments as done.Nov 3 2022, 2:23 PM
mib added inline comments.
lldb/examples/python/crashlog.py
584–588

This allows to show the Application Specific Backtrace with other threads when using the non-interactive crashlog command.

For interactive crashlogs, the Application Specific Backtrace is attached to the crashed thread as its extended backtrace and would only be show when doing thread backtrace --extended true

lldb/include/lldb/Interpreter/ScriptedProcessInterface.h
105 ↗(On Diff #472756)

ditto

lldb/include/lldb/Target/Process.h
2431 ↗(On Diff #472756)

I'll make a follow-up patch to update this. (D137359)

mib marked 2 inline comments as done.Nov 3 2022, 2:24 PM
mib updated this revision to Diff 473036.Nov 3 2022, 2:28 PM

Addressed @JDevlieghere feedbacks.