This is an archive of the discontinued LLVM Phabricator instance.

[lldb] Display MachO seg,sec of memory region
AbandonedPublic

Authored by kastiglione on Dec 30 2021, 10:10 AM.

Details

Summary

memory region displays the top-level section name, which for MachO is the segment name. The segment name alone is not much use, it's very coarse grained. This changes memory region to display the segment and section names for MachO images. For example, display __DATA,__const instead of only __DATA.

Diff Detail

Event Timeline

kastiglione requested review of this revision.Dec 30 2021, 10:10 AM
kastiglione created this revision.
Herald added a project: Restricted Project. · View Herald TranscriptDec 30 2021, 10:10 AM
kastiglione edited the summary of this revision. (Show Details)Dec 30 2021, 12:08 PM

I see now this isn't valid as written. The address range and rwx permissions printed by memory region are for the segment not the section. I think it would be helpful to print the section too, but as this change is written now, it could appear that all the info is for the section, when it's really for the segment. Maybe a better change would be to print a second line with an address range for the section, and the section's name.

aprantl added inline comments.Jan 7 2022, 1:03 PM
lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
76

Doesn't lldbutil.run_break_set_by_symbol() do the "file" and "run" already and this run command runs it a second time?

aprantl added inline comments.Jan 7 2022, 1:05 PM
lldb/source/Commands/CommandObjectMemory.cpp
1695

Why did section_sp->GetName(); return the Segment name in the original code? Is that a bug?

kastiglione added inline comments.Jan 10 2022, 9:24 AM
lldb/source/Commands/CommandObjectMemory.cpp
1695

The original code is traversing the parent chain of sections, which for mach-o ends up on the segment. Now that I have learned the address range printed is for the segment, then it makes sense why the segment name alone is printed.

lldb/test/API/functionalities/memory-region/TestMemoryRegion.py
76

I will learn more to find out.

kastiglione abandoned this revision.Jan 28 2022, 11:43 AM