This is an archive of the discontinued LLVM Phabricator instance.

[DWARF] Regularize dumping strings from line tables.
ClosedPublic

Authored by probinson on Feb 1 2018, 8:50 AM.

Details

Summary

The major visible difference here is that in line-table dumps,
directory and file names are wrapped in double-quotes; previously,
directory names got single quotes and file names were not quoted at
all.
(I know there have been changes lately to make dwarfdump more like Darwin's. I hope this change isn't an issue.)

The improvement in this patch is that when a DWARF v5 line table
header has indirect strings, in a verbose dump these will all have
their section[offset] printed as well as the name itself. This
matches the format used for dumping strings in the .debug_info
section.

Diff Detail

Repository
rL LLVM

Event Timeline

probinson created this revision.Feb 1 2018, 8:50 AM
JDevlieghere added inline comments.Feb 1 2018, 9:14 AM
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
443 ↗(On Diff #132407)

Maybe add a comment here that says that if we execute this path we know we're in verbose mode. Alternatively we could add the DumpOptions as an additional default argument but I don't think that's worth it here.

probinson added inline comments.Feb 1 2018, 10:34 AM
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
443 ↗(On Diff #132407)

There is a comment to that effect elsewhere, which is why I knew this call should use verbose mode. The line table dumping is weird that way. But a comment here as well would make sense.

dblaikie added inline comments.Feb 1 2018, 11:15 AM
llvm/lib/DebugInfo/DWARF/DWARFDebugLine.cpp
553 ↗(On Diff #132407)

Might be worth saving the CStr upfront/above, rather than having to go through the process of pulling it out of the DWARFFormValue 7 lines later down here?

927 ↗(On Diff #132407)

Should this remain as a StringRef & the 'if' clause following be changed to contain the 'getAsCString().getValue()' part?

llvm/test/DebugInfo/X86/dwarfdump-header.s
327–328 ↗(On Diff #132407)

Should this print as ".debug_line_str"?

probinson updated this revision to Diff 132489.Feb 1 2018, 3:36 PM
probinson marked 3 inline comments as done.

Address review comments.

@JDevlieghere are the quoted file/directory names compatible (enough) with Darwin's dwarfdump? I know you were working to make them compatible (although maybe it was mostly command-line compatible).

llvm/test/DebugInfo/X86/dwarfdump-header.s
327–328 ↗(On Diff #132407)

No, this is correct. The referenced string section depends on the form, not on the section where the reference is made.
This test uses FORM_strp in the directory table and FORM_line_strp in the file table, to verify correct printing for both cases. In practice I wouldn't expect a producer to mix-n-match like this, but for a test it seemed like a good idea.

@JDevlieghere are the quoted file/directory names compatible (enough) with Darwin's dwarfdump? I know you were working to make them compatible (although maybe it was mostly command-line compatible).

Indeed, I'm mainly concerned with command line interface and feature parity. Having similar output is nice, but it shouldn't hold us back from making improvements like this. Thanks for checking!

This revision is now accepted and ready to land.Feb 2 2018, 1:12 AM
This revision was automatically updated to reflect the committed changes.