This is an archive of the discontinued LLVM Phabricator instance.

Update ProcessMachCore::DoLoadCore to handle binary hints with and without addresses
ClosedPublic

Authored by jasonmolenda on Mar 30 2021, 3:10 AM.

Details

Summary

ProcessMachCore::DoLoadCore was implemented to handle the two LC_NOTEs "kern ver str" and "main bin spec" with only certain combinations of UUID and address and type present. Other groups are starting to adopt these corefile hints and there are combinations that lldb wouldn't handle correctly.

This patch cleans up the handling of these hints in DoLoadCore a lot -- I've been wanting to clean this up for over a year now -- and adds tests for all of the combinations.

I did make one change to DynamicLoaderStatic to only set load addresses of Sections to their file addresses (slide==0) if an address hasn't already been set. This gives me the ability to set the load address in ProcessMachCore and have it not get re-set back to the original file address later by the dynamic loader plugin.

The rest of this patch is is code that's my little playground of ProcessMachCore, so I don't know if others will have any comments, but I wanted to open it to the floor if anyone has suggestions or questions.

Diff Detail

Event Timeline

jasonmolenda created this revision.Mar 30 2021, 3:10 AM
jasonmolenda requested review of this revision.Mar 30 2021, 3:10 AM
shafik added a subscriber: shafik.Mar 30 2021, 9:53 AM
shafik added inline comments.
lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
214

We can use make_shared here instead.

lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
142

0x70000000000 feels like it should be a variable with a name since we are using in multiple places.

lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp
90

snprintf we should also collect the return value and assert on the result.

Thanks for the feedback Shafik, updated the patch and landing in a sec.

lldb/source/Plugins/Process/mach-core/ProcessMachCore.cpp
214

Sounds good.

lldb/test/API/macosx/lc-note/firmware-corefile/TestFirmwareCorefiles.py
142

Good suggestion, done.

lldb/test/API/macosx/lc-note/firmware-corefile/create-empty-corefile.cpp
90

Thanks, I switched to using a PRIx64 formatter to make it explicit how large the formatter's output will be.

This revision was not accepted when it landed; it landed in state Needs Review.Apr 1 2021, 7:03 PM
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.