This is an archive of the discontinued LLVM Phabricator instance.

have crashlog.py insert a stack frame with $lr when stack frame 0 is address 0
ClosedPublic

Authored by jasonmolenda on May 5 2022, 2:11 PM.

Details

Summary

A common crash is calling through a null function pointer and trying to execute an instruction at address 0. lldb's backtracer special cases this, but the macOS crash tracer algorithm does not; crash reports will have a stack frame at 0 and then skip the calling stack frame, assuming a stack frame was set up. On arm64, the caller function is likely available in $lr, so let's insert a stack frame with that return pc value.

Also fix a little bug where register names without a "prefix" would get "None" prepended, so "Nonepc", "Nonelr" etc.

rdar://92631787

Diff Detail

Event Timeline

jasonmolenda created this revision.May 5 2022, 2:11 PM
Herald added a project: Restricted Project. · View Herald TranscriptMay 5 2022, 2:11 PM
jasonmolenda requested review of this revision.May 5 2022, 2:11 PM

Does that mean that the interactive crashlogs (crashlog -i) do this correctly?

Does that mean that the interactive crashlogs (crashlog -i) do this correctly?

I didn't look at that when I wrote the patch; asked @mib and it sounded like he was going to do that separately.

mib added a comment.May 5 2022, 5:11 PM

Does that mean that the interactive crashlogs (crashlog -i) do this correctly?

I didn't look at that when I wrote the patch; asked @mib and it sounded like he was going to do that separately.

Interactive crashlogs use the same crashlog parser to fetch the register context, so I think they should work out of the box with this patch applied.

kastiglione accepted this revision.May 5 2022, 5:28 PM

thanks for fixing these, especially the lr technique!

lldb/examples/python/crashlog.py
520

(minor) I think a word is missing between "if" and "jump".

533

What do you think of adding a break here? Not that it would change the outcome, but it might make the intention of the loop slightly better.

This revision is now accepted and ready to land.May 5 2022, 5:28 PM
mib added a comment.May 5 2022, 5:30 PM

Does that mean that the interactive crashlogs (crashlog -i) do this correctly?

I didn't look at that when I wrote the patch; asked @mib and it sounded like he was going to do that separately.

Interactive crashlogs use the same crashlog parser to fetch the register context, so I think they should work out of the box with this patch applied.

I applied @jasonmolenda's patch to test it with interactive crashlog and I can see the added stack frame as expected.

mib accepted this revision.May 5 2022, 5:31 PM

LGTM! Thanks J!

jasonmolenda added inline comments.May 5 2022, 5:34 PM
lldb/examples/python/crashlog.py
520

yep good catch.

533

ok.

update to incorporate dave's suggestions.

This revision was landed with ongoing or failed builds.May 5 2022, 5:55 PM
This revision was automatically updated to reflect the committed changes.