This is an archive of the discontinued LLVM Phabricator instance.

[lldb/crashlog] Create interactive crashlog with no binary
ClosedPublic

Authored by mib on May 31 2023, 3:47 PM.

Details

Summary

This patch changes the way we load a crash report into a scripted
process by creating a empty target.

To do so, it parses the architecture information from the report (for
both the legacy and json format) and uses that to create a target that
doesn't have any executable, like what we do when attaching to a process.

For the legacy format, we mostly rely on the Code Type line, since the
architure is an optional field on the Binary Images sections.

However for the json format, we first try to get the architecture while
parsing the image dictionary if we couldn't find it, we try to infer it
using the "flavor" key when parsing the frame's registers.

If the architecture is still not set after parsing the report, we use
the host architecture, as a fallback.

rdar://107850263

Signed-off-by: Med Ismail Bennani <ismail@bennani.ma>

Diff Detail

Event Timeline

mib created this revision.May 31 2023, 3:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 31 2023, 3:47 PM
mib requested review of this revision.May 31 2023, 3:47 PM
bulbazord accepted this revision.May 31 2023, 4:04 PM
bulbazord added inline comments.
lldb/examples/python/crashlog.py
493

Any reason you moved this?

552–555

I assume "pid" and "procName" are not optional right? Maybe not in this one but in a follow-up we can add some error handling here.

1373–1374

The fallback of "use the host platform's architecture" seems like it could lead to some issues no? I'm not sure we can do better if the crashlog doesn't have any info about a process architecture though...

This revision is now accepted and ready to land.May 31 2023, 4:04 PM
mib marked an inline comment as done.May 31 2023, 4:39 PM
mib added inline comments.
lldb/examples/python/crashlog.py
493

It makes more sense to me to initialize the crashlog object last.

1373–1374

Do you think we shouldn't fallback to the host architecture in this case and raise an exception instead ?

bulbazord added inline comments.May 31 2023, 5:00 PM
lldb/examples/python/crashlog.py
1373–1374

That might be a better idea. For example, if you're debugging a crashlog for a different platform, lldb would make this assumption silently which can lead to strange problems that are difficult to reason about.

mib updated this revision to Diff 527575.Jun 1 2023, 12:51 PM
mib marked an inline comment as done.
mib added a subscriber: jingham.

Address @bulbazord & @jingham's comments:

  • Rename name -> label
  • Add test
  • Add sanity check to avoid having integer only labels
  • Add target index when label already exist for another target
mib updated this revision to Diff 527576.Jun 1 2023, 12:53 PM

Reload the previous version of this diff

mib updated this revision to Diff 527672.Jun 1 2023, 5:08 PM
mib marked 2 inline comments as done.

Address @bulbazord last comments

This revision was landed with ongoing or failed builds.Jun 1 2023, 5:11 PM
This revision was automatically updated to reflect the committed changes.

LGTM modulo typo

lldb/examples/python/crashlog.py
1374

Typo