This is an archive of the discontinued LLVM Phabricator instance.

Add verbose printing of line info in LLVM Symbolizer
ClosedPublic

Authored by sque on Jan 24 2017, 12:54 PM.

Details

Summary

The verbose mode prints out all the fields of DILineInfo in human-readable form.

Verbose mode is enabled by a command-line switch "-verbose" that is off by default. Example:

With verbose flag:

sque@sque3:~/code/llvm-build$ bin/llvm-symbolizer -obj bin/llvm-symbolizer -verbose
0x414edf
isWhitespace(char)
  Filename: /usr/local/google/home/sque/code/llvm/lib/Support/CommandLine.cpp
  Line: 702
  Column: 0
  Discriminator: 0

Without verbose flag:

sque@sque3:~/code/llvm-build$ bin/llvm-symbolizer -obj bin/llvm-symbolizer
0x414edf
isWhitespace(char)
/usr/local/google/home/sque/code/llvm/lib/Support/CommandLine.cpp:702:0

Diff Detail

Repository
rL LLVM

Event Timeline

sque created this revision.Jan 24 2017, 12:54 PM
sque edited the summary of this revision. (Show Details)Jan 24 2017, 12:59 PM
sque added inline comments.
lib/DebugInfo/Symbolize/DIPrinter.cpp
85 ↗(On Diff #85623)

Should this be marked as DWARF-only, or placed in a DWARF-only section?

sque edited the summary of this revision. (Show Details)Jan 24 2017, 1:01 PM
dblaikie edited edge metadata.Jan 26 2017, 2:07 PM

Needs test coverage

lib/DebugInfo/Symbolize/DIPrinter.cpp
85 ↗(On Diff #85623)

I'm /guessing/ (though you can probably reproduce this by running -verbose on a checked in COFF/CodeView file - I assume/imagine we have some of those in the dumper testing) that the Discriminator is 0 when not provided?

Perhaps it'd be easy enough to not print it when it's zero? If that works/you can confirm CodeView is doing what I assume it is - add a test? (for either CV, or a case a zero or not present discriminator in ELF).

sque added inline comments.Jan 26 2017, 2:08 PM
lib/DebugInfo/Symbolize/DIPrinter.cpp
85 ↗(On Diff #85623)

I am not familiar with possible values of the discriminator. Does discriminator == 0 mean it's invalid? Could it have a valid value of 0?

sque updated this revision to Diff 86237.Jan 29 2017, 6:11 PM

Print discriminator only if nonzero; Add regression test

dblaikie accepted this revision.Jan 29 2017, 6:17 PM

Looks good - thanks!

If the test case be reduced any before committing, that'd be great.

lib/DebugInfo/Symbolize/DIPrinter.cpp
81–91 ↗(On Diff #86237)

To reduce indentation, invert the condition and return early:

if (!Verbose) {
  OS << ...
  printContext(...);
  return;
}
OS << ...

Maybe that doesn't help - anyway, an idea if you like it (LLVM tends towards finding ways to reduce indentation like that, but it doesn't necessarily improve readability in all cases)

test/tools/llvm-symbolizer/Inputs/discrim.inp
2–8 ↗(On Diff #86237)

Are these all interesting addresses to test - I'd have expected one zero discriminator and one non-zero would suffice?

This revision is now accepted and ready to land.Jan 29 2017, 6:17 PM
sque updated this revision to Diff 86238.Jan 29 2017, 6:21 PM
sque marked 2 inline comments as done.

Adjusted logic for indentation; Reduced number of addresses to test

sque added a comment.Jan 31 2017, 1:43 PM

I don't have commit access. I need someone to commit this for me.

This revision was automatically updated to reflect the committed changes.
sque added a comment.Jan 31 2017, 8:55 PM

The new files didn't get committed.