This is an archive of the discontinued LLVM Phabricator instance.

[llvm-objdump/mac] Add new function starts print mode
ClosedPublic

Authored by keith on Feb 4 2022, 6:30 PM.

Details

Summary

This updates the --function-starts argument to now accept 3 different
modes, addrs for just printing the addresses of the function starts
(previous behavior), names for just printing the names of the function
starts, and both to print them both side by side.

In general if you're debugging function starts issues it's useful to see
the symbol name alongside the address. This also mirrors Apple's
dyldinfo -function_starts command which prints both.

Diff Detail

Event Timeline

keith created this revision.Feb 4 2022, 6:30 PM
keith requested review of this revision.Feb 4 2022, 6:30 PM
Herald added a project: Restricted Project. · View Herald TranscriptFeb 4 2022, 6:30 PM
keith updated this revision to Diff 406143.Feb 4 2022, 6:33 PM

Update docs

Herald added a project: Restricted Project. · View Herald TranscriptOct 5 2022, 11:32 AM
Herald added a subscriber: StephenFan. · View Herald Transcript

I'm not a Mach-O person, but I've got some nitpick comments on the general area.

llvm/docs/CommandGuide/llvm-objdump.rst
359

In other tools (I'm looking at llvm-symbolizer specifically at least), the format would be --function-starts [=<addrs|names|both>], to indicate a) the value is optional, and b) what the possible values are.

361–364

I'm not a Mach-O developer, and so am not particular familair with the object format. Is it obvious to someone who is familiar what the meaning of the addrs/names options actually is?

llvm/tools/llvm-objdump/llvm-objdump.h
16

I don't think you need the include. You can forward declare opt::Arg, I believe?

keith updated this revision to Diff 467288.Oct 12 2022, 3:59 PM
keith marked 3 inline comments as done.

Improve documentation, remove unnecessary import

Okay, no more comments from me. The rest will need reviewing by someone with more knowledge of the area.

Generally looks good to me. Adding Nico in case he has any feedback as well.

llvm/tools/llvm-objdump/MachODump.cpp
1109

So if we can't find the address associated with a symbol, we don't print anything for it? Does that match dyldinfo's behavior? Should we have a test for it?

llvm/tools/llvm-objdump/MachODump.h
37

Nit: I think an enum class would be nicer here.

keith updated this revision to Diff 467907.Oct 14 2022, 2:11 PM
keith marked 2 inline comments as done.

Add test for empty behavior

keith added a comment.Oct 14 2022, 2:12 PM
llvm/tools/llvm-objdump/MachODump.cpp
1109

So turns out that dyldinfo prints a ? beside the address in this case. I've mirrored that here and added a test, but in the case you only ask for names I stilled opted to print nothing since it doesn't seem like a ton of ?'s w/o any other info would be very useful output, and if you have _some_ symbols it might distract you from those. Interested to hear thoughts on this since names only not a mode dyldinfo has.

smeenai accepted this revision.Oct 14 2022, 2:19 PM

LGTM

llvm/tools/llvm-objdump/MachODump.cpp
1109

Yeah, that sounds reasonable to me.

llvm/tools/llvm-objdump/MachODump.h
37

Sorry for being nitty again, but you can remove the FS prefix now that it's an enum class (which was the motivation for my suggestion).

This revision is now accepted and ready to land.Oct 14 2022, 2:19 PM
keith updated this revision to Diff 467925.Oct 14 2022, 2:34 PM
keith marked an inline comment as done.

Remove unnecessary enum type prefix

llvm/tools/llvm-objdump/MachODump.h
37

good point, thanks!

This revision was landed with ongoing or failed builds.Oct 14 2022, 3:45 PM
This revision was automatically updated to reflect the committed changes.