This is an archive of the discontinued LLVM Phabricator instance.

[llvm-symbolizer] Make --relative-address work with DWARF contexts
ClosedPublic

Authored by rnk on Sep 15 2015, 11:13 AM.

Details

Summary

Previously the relative address flag only affected PDB debug info. Now
both DIContext implementations always expect to be passed virtual
addresses. llvm-symbolizer is now responsible for adding ImageBase to
module offsets when --relative-offset is passed.

Diff Detail

Repository
rL LLVM

Event Timeline

rnk updated this revision to Diff 34815.Sep 15 2015, 11:13 AM
rnk retitled this revision from to [llvm-symbolizer] Make --relative-address work with DWARF contexts.
rnk updated this object.
rnk added a reviewer: zturner.
rnk added a subscriber: llvm-commits.

Originally the plan was to remove --relative-address and update the callers to always use absolute addresses. Enhancing the functionality of --relative-address seems contrary to this goal. +samsonov in case he has some thoughts on this direction.

rnk added a comment.Sep 15 2015, 11:19 AM

I want to go the other direction now. Producing absolute virtual addresses from a stack dumper is tricky, but it is very easy to produce object offsets. See the code in compiler-rt / sanitizer_common that takes a runtime virtual address and turns it into an "virtual" address. I didn't want to have to rewrite this code in LLVM's stack dumper.

rnk added a comment.Sep 15 2015, 11:21 AM

Given that it's more convenient for both known clients of llvm-symbolizer to produce module offsets, the next logical step is to make --relative-offsets the default, and put in a --virtual-addresses flag.

samsonov edited edge metadata.Sep 17 2015, 6:02 PM

I agree with the direction of the patch - it's indeed tricky to figure out virtual addresses when we use llvm-symbolizer as an online tool (bleh, parsing PECOFF headers :(), so we might stick with passing --relative-address in this case. However, per our offline discussion, this flag should still be off by default, so that we will expect the same PCs as those stored in the debug info, or those printed in objdump output.

lib/Object/COFFObjectFile.cpp
177 ↗(On Diff #34815)

See another comments. Also, this can go in as a separate change.

274 ↗(On Diff #34815)

What should you do if getImageBase() failed? Maybe, just add 0 in this case? Do we want to crash/assert in this case?

431 ↗(On Diff #34815)

Do you need to propagate object_error::parse_failed if getImageBase() returned it?

test/tools/llvm-symbolizer/coff-dwarf.test
2 ↗(On Diff #34815)

Is there no way to create the input file on the fly with "echo" commands on Windows, instead of storing the input in a separate file?

test/tools/llvm-symbolizer/pdb/pdb.test
3 ↗(On Diff #34815)

Why do you need this copy here?

rnk updated this revision to Diff 36904.Oct 8 2015, 4:29 PM
rnk edited edge metadata.
  • Address review comments, remove error case and return 0 instead as required by tests
lib/Object/COFFObjectFile.cpp
274 ↗(On Diff #34815)

Hm, the test case says I need to return 0. =/ Awkward. I guess I'll preserve the existing behavior then.

test/tools/llvm-symbolizer/coff-dwarf.test
2 ↗(On Diff #34815)

I don't think \n works in strings in lit's shell. I can use grep and sed though to cut down on files.

test/tools/llvm-symbolizer/pdb/pdb.test
3 ↗(On Diff #34815)

gone

This revision was automatically updated to reflect the committed changes.
rnk added a comment.Oct 8 2015, 6:03 PM

Woops, I accidentally committed this. Let me know if there are issues.

LGTM. Thank you!