This is an archive of the discontinued LLVM Phabricator instance.

[lldb/crashlog] Add CrashLogScriptedProcess & remove interactive mode
ClosedPublic

Authored by mib on Feb 10 2022, 4:19 PM.

Details

Summary

This patch introduces a new type of ScriptedProcess: CrashLogScriptedProcess.
It takes advantage of lldb's crashlog parsers and Scripted Processes to
reconstruct a static debugging session with symbolicated stackframes, instead
of just dumping out everything in the user's terminal.

The crashlog command also has an interactive mode that only provide a
very limited experience. This is why this patch removes all the logic
for this interactive mode and creates CrashLogScriptedProcess instead.

This will fetch and load all the libraries that were used by the crashed
thread and re-create all the frames artificially.

rdar://88721117

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

Diff Detail

Event Timeline

mib requested review of this revision.Feb 10 2022, 4:19 PM
mib created this revision.
JDevlieghere added inline comments.Feb 10 2022, 10:02 PM
lldb/examples/python/crashlog.py
1153–1157

If options.interactive is set explicitly we should honor it. In the future we'll want to use ci.IsInteractive() to decide what to do if nothing is specified. At the same time we should create another option (--non-interactive?) and also honor it, so that this logic would look something like:

if options.interactive:
 // Interactive
else if options.noninteractive:
 // Classic
else if ci and ci.IsInteractive():
 // Interactive
else 
 // Classic
mib added a subscriber: clayborg.Feb 11 2022, 9:32 AM
This comment was removed by mib.
mib added a comment.Feb 11 2022, 9:34 AM

@clayborg I heard from Jim that you might be interested by this patch

I used this back when I worked at Apple to load thousands of crash logs and get information about the versions of a library that were all involved in the crash. From the Apple crash reporter site, download the zip file with all crash logs, load them all into, use interactive mode to say "image LLDB" and I could see if any of the crashes were in current versions of LLDB after we submitted a fix for something. I am no longer at Apple, so find to remove this feature if no one uses it.

I used this back when I worked at Apple to load thousands of crash logs and get information about the versions of a library that were all involved in the crash. From the Apple crash reporter site, download the zip file with all crash logs, load them all into, use interactive mode to say "image LLDB" and I could see if any of the crashes were in current versions of LLDB after we submitted a fix for something. I am no longer at Apple, so find to remove this feature if no one uses it.

We're not really removing it, we're replacing it with a (imho much better) implementation backed by the scripted processes. This gives a "native" way to interactive inspect the crashlog with bt and frame select etc.

mib updated this revision to Diff 408081.Feb 11 2022, 3:29 PM
mib marked an inline comment as done.
mib retitled this revision from [lldb/crashlog] Replace interactive mode by CrashLogScriptedProcess to [lldb/crashlog] Add CrashLogScriptedProcess to replace interactive mode.
mib edited the summary of this revision. (Show Details)

Merge D119389 into this and address @JDevlieghere comments.

Test?

lldb/examples/python/crashlog.py
988

Do we need to have LLDB import it? Can we import it here straight from python?

1153–1162

I'd extract a helper to compute if we need the interactive or batch crashlog to avoid the duplication across the clauses.

1158–1159

Let's hold off on making the interactive one the default for now.

mib marked an inline comment as done.Feb 11 2022, 4:36 PM
mib added inline comments.
lldb/examples/python/crashlog.py
988

crashlog.py can be imported outside of the debugger, so in my understanding, if we're importing it here directly, lldb's script interpreter might not find the module and class used to create the ScriptedProcess object.

mib updated this revision to Diff 408107.Feb 11 2022, 4:38 PM
mib marked an inline comment as done.
mib retitled this revision from [lldb/crashlog] Add CrashLogScriptedProcess to replace interactive mode to [lldb/crashlog] Add CrashLogScriptedProcess & remove interactive mode.

Address @JDevlieghere comments. Still working the test.

JDevlieghere added inline comments.Feb 11 2022, 5:59 PM
lldb/examples/python/crashlog.py
988

But that's not relevant for the (new) interactive mode? If you run crashlog on the command line it should behave like it does today.

mib marked 3 inline comments as done.Feb 11 2022, 6:05 PM
mib added inline comments.
lldb/examples/python/crashlog.py
988

It's actually only relevant for the new interactive mode, since this will import the crashlog scripted process blueprint. Otherwise, launching the process won't work (see line 999) because lldb won't find the managing class module.

mib updated this revision to Diff 409325.Feb 16 2022, 10:43 AM
mib marked an inline comment as done.

Add test

mib updated this revision to Diff 409335.Feb 16 2022, 10:56 AM
This revision is now accepted and ready to land.Feb 16 2022, 11:08 AM
This revision was landed with ongoing or failed builds.Feb 16 2022, 11:45 AM
This revision was automatically updated to reflect the committed changes.