This is an archive of the discontinued LLVM Phabricator instance.

[lldb/crashlog] Adapt raw text crashlog exception to json format
ClosedPublic

Authored by mib on Aug 11 2022, 1:47 PM.

Details

Summary

This patch parses CrashLog exception data from the raw
text format and adapts it to the new JSON format.

This is necessary for feature parity between the 2 formats.

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

Diff Detail

Event Timeline

mib created this revision.Aug 11 2022, 1:47 PM
Herald added a project: Restricted Project. · View Herald TranscriptAug 11 2022, 1:47 PM
mib requested review of this revision.Aug 11 2022, 1:47 PM
mib updated this revision to Diff 451998.Aug 11 2022, 3:06 PM

Change regex to support actual hex addresses

kastiglione added inline comments.Aug 11 2022, 3:17 PM
lldb/examples/python/crashlog.py
628

consider using EXC_[A-Z_]+ or EXC_.*? to not over match.

\s* (a space followed by \s*) could be replaced with \s+

kastiglione added inline comments.Aug 11 2022, 3:22 PM
lldb/examples/python/crashlog.py
708–709

is this meaning to check that the key 'type' exists, and that it is false-y? Or, should it be checking whether the key 'type' is in the dictionary (if key is not in dict)

also, this check could be hoisted out, and avoid performing the regex search if the result isn't going to be used. As it is now, the regex search happens, and the result is ignored if this condition is met.

mib added inline comments.Aug 11 2022, 3:22 PM
lldb/examples/python/crashlog.py
628

Yeah, that's better! Also, I suspect the second group to be optional, so I need to change this regex anyway

mib added inline comments.Aug 11 2022, 3:30 PM
lldb/examples/python/crashlog.py
708–709

+1

mib marked 2 inline comments as done.Aug 11 2022, 3:44 PM
mib updated this revision to Diff 452016.Aug 11 2022, 3:50 PM

Address @kastiglione comments

kastiglione added inline comments.Aug 11 2022, 4:18 PM
lldb/examples/python/crashlog.py
343

should this be initialized to {}?

684

if you would like to avoid the ignored group (_) then you can use non-capturing grouping (?:...) in the regex:

before:

r'^Exception Type:\s+(EXC_[A-Z_]+)(\s+\((.*)\))?'

after:

r'^Exception Type:\s+(EXC_[A-Z_]+)(?:\s+\((.*)\))?'
mib updated this revision to Diff 452032.Aug 11 2022, 4:32 PM
mib marked 2 inline comments as done.
  • Make CrashLog.exception a dictionary at initialization
  • Update exception_type regex to use a non-capture group
kastiglione accepted this revision.Aug 11 2022, 4:35 PM

one typo to fix, but otherwise looks good

lldb/examples/python/crashlog.py
690–691

should this also be if 'type' in self.crashlog.exception?

typo, should be = instead of :

This revision is now accepted and ready to land.Aug 11 2022, 4:35 PM
mib updated this revision to Diff 452042.Aug 11 2022, 5:25 PM
mib marked an inline comment as done.

Fixing typo

This revision was landed with ongoing or failed builds.Aug 11 2022, 10:29 PM
This revision was automatically updated to reflect the committed changes.