This is an archive of the discontinued LLVM Phabricator instance.

[dwarfdump] Add verbose output for .debug-line section
ClosedPublic

Authored by JDevlieghere on Sep 18 2017, 6:21 AM.

Details

Summary

This patch adds dumping of line table instructions as well as the final
state at each specified pc value in verbose mode. This is essentially
the same as the default in Darwin's dwarfdump. Dumping the actual line
table opcodes can be particularly useful for something like debugging a
bad .debug_line section.

Diff Detail

Repository
rL LLVM

Event Timeline

JDevlieghere created this revision.Sep 18 2017, 6:21 AM
aprantl edited edge metadata.Sep 18 2017, 7:59 AM

Doing this during parsing doesn't seem too intrusive and looks like it is the right trade-off.
Do you have a test case, too?

Doing this during parsing doesn't seem too intrusive and looks like it is the right trade-off.
Do you have a test case, too?

Jup, I put up the code before/while fixing the tests. I've added a verbose.test to check the printing of the opcodes. The existing tests that use verbose mode essentially verify that the resulting rows are still identical. As a verification I also ran a diff against Darwin's dwarfdump and the printed opcodes are identical.

dblaikie added inline comments.Sep 18 2017, 8:51 AM
lib/DebugInfo/DWARF/DWARFDebugLine.cpp
445 ↗(On Diff #115662)

If we don't have one already, should probably have a DW_LNE enum stringification function generated from Dwarf.def - and use that to print the DW_LNE_* first, outside the switch, then use the switch to dump the specific parameters, if any, etc.

462 ↗(On Diff #115662)

There's some inconsistency in whitespace (some of the printing "DW_LNE_foo (" and some without the space) - pick one for consistency.

test/DebugInfo/MIR/X86/empty-inline.mir
14–16 ↗(On Diff #115662)

Perhaps it's worth un-verbosifying test cases when they need to be touched manually like this anyway?

Added a couple more inline comments.

Since you aren't checking for the verbose details in many of the modified tests, perhaps it would be better to replace the RUN command with a --debug-line (non-verbose) invocation?
This is not super important, so feel free to decide what to do on a case-by-case basis.

lib/DebugInfo/DWARF/DWARFContext.cpp
340 ↗(On Diff #115662)

Add: // Verbose dumping is done during parsing and not on the intermediate representation.

lib/DebugInfo/DWARF/DWARFDebugLine.cpp
445 ↗(On Diff #115662)

To avoid typos and make the binary smaller, I'd prefer:
dwarf::LNExtendedString(DW_LNE_end_sequence)
here and below...

Looks like I just typed up everything that David said :-)

JDevlieghere marked 2 inline comments as done.

Thanks Dave, I've updated the diff with your feedback.

test/DebugInfo/MIR/X86/empty-inline.mir
14–16 ↗(On Diff #115662)

That's how I got started before switching to this approach. I wasn't confident enough about the content of the verbose output not being part of the test. I definitely don't want to reduce the test quality for this kind of change. If there are tests that stick out where it would obviously not matter, I'd be more than happy to change it!

dblaikie added inline comments.Sep 18 2017, 11:51 AM
lib/DebugInfo/DWARF/DWARFDebugLine.cpp
444–445 ↗(On Diff #115666)

Could this go outside the switch? So it's written once rather than in every case in the switch? Or are there some cases that need to avoid it or otherwise do something different? (& if possible, the newline printing could also go after the switch to avoid that being repeated in every case)

test/DebugInfo/MIR/X86/empty-inline.mir
14–16 ↗(On Diff #115662)

Seems like the opposite, though - by removing the CHECK-NEXTs you've reduced the quality of the test by allowing other line entries to be present, etc, potentially.

So it's probably better here, for instance, to unverbosify the test to keep it closer to the original intent. (possibly similarly on other tests)

JDevlieghere set the repository for this revision to rL LLVM.
  • Moved printing outside switch.
  • Un-verbosed test cases.
JDevlieghere marked 4 inline comments as done.Sep 19 2017, 2:26 AM
JDevlieghere added inline comments.
test/DebugInfo/MIR/X86/empty-inline.mir
14–16 ↗(On Diff #115662)

Fair enough, I agree that this is probably better. Thanks!

Did you accidentally upload the wrong patch?

JDevlieghere marked an inline comment as done.
  • Upload the correct patch (Thanks Adrian!)
dblaikie added inline comments.Sep 20 2017, 9:46 AM
test/DebugInfo/MIR/X86/empty-inline.mir
7 ↗(On Diff #115847)

I don't think the {{.*}} is needed? Maybe - not sure how whitespace-ignorant FileCheck is by default.

test/MC/ARM/dwarf-asm-multiple-sections.s
55–58 ↗(On Diff #115847)

Why did these line numbers change?

JDevlieghere added inline comments.Sep 20 2017, 9:54 AM
test/DebugInfo/MIR/X86/empty-inline.mir
7 ↗(On Diff #115847)

AFAIK only leading and trailing whitespace is ignored. An additional benefit is that most of the lines won't have to be changed if we ever want to make the test verbose again.

test/MC/ARM/dwarf-asm-multiple-sections.s
55–58 ↗(On Diff #115847)

That's because added the 3 run lines at the top of the file, before the code.

probinson added inline comments.
test/DebugInfo/MIR/X86/empty-inline.mir
7 ↗(On Diff #115847)

I am pretty sure that FileCheck treats all whitespace as variable length, unless you tell it to be strict.

  • Remove regex for whitespace
JDevlieghere marked 4 inline comments as done.Sep 21 2017, 2:21 AM
JDevlieghere added inline comments.
test/DebugInfo/MIR/X86/empty-inline.mir
7 ↗(On Diff #115847)

Seems like you were both right! I've updated the tests.

dblaikie accepted this revision.Sep 21 2017, 7:48 AM

Seems good

This revision is now accepted and ready to land.Sep 21 2017, 7:48 AM
This revision was automatically updated to reflect the committed changes.
JDevlieghere marked an inline comment as done.