This is an archive of the discontinued LLVM Phabricator instance.

[symbolizer] Treat invalid address as addr2line does
ClosedPublic

Authored by sepavloff on Mar 28 2023, 9:56 PM.

Details

Summary

llvm-symbolizer echoed input if it was not recognized as a valid address.
This behavior was extended to llvm-addr2line as well. GNU addr2line in
this case optputs "??:0". This difference prevents implementation of
symbol+offset lookup available in the recent versions of GNU binutils.
In that case a string that is not an address may be a symbol.

This change make reaction of llvm-addr2line on unrecognized input closer
to GNU addr2line.

Diff Detail

Event Timeline

sepavloff created this revision.Mar 28 2023, 9:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 9:56 PM
Herald added a subscriber: hiraditya. · View Herald Transcript
sepavloff requested review of this revision.Mar 28 2023, 9:56 PM
Herald added a project: Restricted Project. · View Herald TranscriptMar 28 2023, 9:56 PM
MaskRay accepted this revision.Mar 28 2023, 10:35 PM

Thanks. I have verified that GNU addr2line has the ??:0 behavior.

This revision is now accepted and ready to land.Mar 28 2023, 10:35 PM

Mostly looks good to me, but please see inline comments.

llvm/test/tools/llvm-symbolizer/input-base.test
29–32

These checks should be deleted, right?

llvm/test/tools/llvm-symbolizer/invalid-input-address.test
25

If I'm not mistaken, the different behaviour is controlled by the --output-style option and llvm-addr2line just happens to have the right default value for this to work. Is it worth explicitly testing llvm-symbolizer --output-style=GNU for this case?

sepavloff updated this revision to Diff 509275.Mar 29 2023, 2:52 AM

Add tests for llvm-symbolizer in GNU output mode

sepavloff added inline comments.Mar 29 2023, 2:57 AM
llvm/test/tools/llvm-symbolizer/input-base.test
29–32

These are used in test on line 11.

llvm/test/tools/llvm-symbolizer/invalid-input-address.test
25

Added such tests (lines 17-20).

Thanks for the new cases, but their output actually surprised me. I'd expect GNU output style to render invalid inputs as ??:0 (and equivalently, llvm-addr2line with non-GNU output to echo the input). I'm not too fussed by it, but I would have thought that this comes under "output style" really.

This revision was landed with ongoing or failed builds.Mar 29 2023, 11:30 PM
This revision was automatically updated to reflect the committed changes.