This is an archive of the discontinued LLVM Phabricator instance.

[llvm-symbolizer] -print-source-context-lines option to print source code around the line.
ClosedPublic

Authored by aizatsky on Jan 5 2016, 4:21 PM.

Diff Detail

Event Timeline

aizatsky updated this revision to Diff 44068.Jan 5 2016, 4:21 PM
aizatsky retitled this revision from to [llvm-symbolizer] -print-source-context-lines option to print source code around the line..
aizatsky updated this object.
aizatsky added a project: Restricted Project.
aizatsky added a subscriber: llvm-commits.
samsonov added inline comments.Jan 6 2016, 10:42 AM
tools/llvm-symbolizer/llvm-symbolizer.cpp
218

This will be confusing: first you will print several blocks with function/file/lineno, and then several blocks with source code. Shouldn't they be interchanged? Probably source code printing can be implemented in DIPrinter.

aizatsky updated this revision to Diff 44276.Jan 7 2016, 3:39 PM
aizatsky marked an inline comment as done.

review

samsonov added inline comments.Jan 7 2016, 4:37 PM
tools/llvm-symbolizer/llvm-symbolizer.cpp
218

So, what are the drawbacks of printing source file contents from DIPrinter? We changed llvm-symbolizer to be agnostic of the way DILineInfo / DIInliningInfo is represented: and pass it directly from producer to printer, and now we return to manually writing all these loops.

Keeping that in DIPrinter would also let you write unit tests for that functionality, if needed.

aizatsky updated this revision to Diff 44345.Jan 8 2016, 11:17 AM

moved context functionality into printer.

samsonov accepted this revision.Jan 8 2016, 3:06 PM
samsonov edited edge metadata.

LGTM (but switch to line_iterator if it's convenient).

lib/DebugInfo/Symbolize/DIPrinter.cpp
46 ↗(On Diff #44348)

Can you use include/llvm/Support/LineIterator.h instead of splitting file manually?

This revision is now accepted and ready to land.Jan 8 2016, 3:06 PM
aizatsky updated this revision to Diff 44384.Jan 8 2016, 3:27 PM
aizatsky edited edge metadata.

using line iterator.

This revision was automatically updated to reflect the committed changes.