This is an archive of the discontinued LLVM Phabricator instance.

[dwarfdump] Add -lookup option
ClosedPublic

Authored by JDevlieghere on Sep 29 2017, 9:55 AM.

Details

Summary

Add the option to lookup an address in the debug information and print
out the file, function, block and line table details, as well as the relevant
DIEs.

This mirrors the functionality from dwarfdump classic.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Sep 29 2017, 9:55 AM
aprantl added inline comments.Sep 29 2017, 10:17 AM
include/llvm/DebugInfo/DIContext.h
60 ↗(On Diff #117169)

return *this != DILineInfo(); ?

include/llvm/DebugInfo/DWARF/DWARFContext.h
263 ↗(On Diff #117169)

use a struct with named fields for better readability?

I assume this doesn't make sense as an optional because either of the fields may be not available and all are nullable. Yes, that seems ok.

include/llvm/DebugInfo/DWARF/DWARFUnit.h
332 ↗(On Diff #117169)

remove getSubroutineForAddress -.

lib/DebugInfo/DWARF/DWARFContext.cpp
749 ↗(On Diff #117169)

Worklist.insert(Worklist.end(), DIE.children_begin(), DIE.children_end())?

hmm... this maybe looks worse actually.

tools/llvm-dwarfdump/llvm-dwarfdump.cpp
247 ↗(On Diff #117169)

repeat the desc int the doxygen comment so it is more clear what the function is supposed to do?

263 ↗(On Diff #117169)

should this code live in a DILineInfo::dump() function?

284 ↗(On Diff #117169)

extra {}

  • CR comments Adrian
JDevlieghere marked 5 inline comments as done.Sep 29 2017, 11:14 AM
JDevlieghere added inline comments.
include/llvm/DebugInfo/DWARF/DWARFUnit.h
332 ↗(On Diff #117169)

Note to self: reflow comment

JDevlieghere marked an inline comment as done.Sep 29 2017, 11:16 AM
aprantl accepted this revision.Sep 29 2017, 11:46 AM

Thanks! (Minor nitpick + future work inside :-)

include/llvm/DebugInfo/DIContext.h
64 ↗(On Diff #117187)

optimization opportunity: this and the fact that we initialize the std::string with "<invalid>" seems kind of expensive. Perhaps switch to StringRef and handle the empty string in dump()?

lib/DebugInfo/DWARF/DWARFContext.cpp
748 ↗(On Diff #117187)

extra {}

tools/llvm-dwarfdump/llvm-dwarfdump.cpp
264 ↗(On Diff #117187)

extra {}

This revision is now accepted and ready to land.Sep 29 2017, 11:46 AM
JDevlieghere added inline comments.Oct 2 2017, 6:43 AM
include/llvm/DebugInfo/DIContext.h
64 ↗(On Diff #117187)

What exactly o you want to switch to StringRef? Do you mean storing an empty string and having a getter that returns it as a StringRef or "<invalid>" if it's empty?

Instead of storing a std::string containing a copy of filename and dir, we might be able to just use a StringRef and share the storage for the payload.

This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.
dblaikie added inline comments.Oct 9 2017, 11:28 AM
llvm/trunk/include/llvm/DebugInfo/DIContext.h
60

This should be explicit (implicit bool conversion operators are problematic - can easily convert to int, etc)

60

I probably wouldn't bother with the () around '*this'.

llvm/trunk/include/llvm/DebugInfo/DWARF/DWARFContext.h
265

explicit

llvm/trunk/tools/llvm-dwarfdump/llvm-dwarfdump.cpp
297–302

What if the subprogram DIE is nested within namespaces? (GCC doesn't do this (put subprogram definitions at nested namespace scope), but LLVM does) I'd expect dumping just the subprogram to dump the parent scopes in some way? (namespaces, classes, other functions, etc - maybe all abbreviated to just their name?)