Page MenuHomePhabricator

[llvm-symbolizer] Improve compatibility of llvm-symbolizer --functions with GNU addr2line

Authored by jhenderson on Jan 22 2019, 4:57 AM.



This fixes

GNU addr2line's --functions switch is off by default, has a short alias of -f, and does not take an argument. This patch changes llvm-symbolizer to allow the second and third point (changing the default behaviour may have negative impacts on users). If the option is missing a value, it now treats it as "linkage".

This change does cause one previously valid command-line to behave differently. Before --functions <value> was accepted, but now only --functions=<value> is allowed (as well as --functions). The old behaviour will result in the value being treated as a positional argument.

The previous testing for --functions=short has been pulled out into a new test that also tests the other accepted values and option formats.

Diff Detail


Event Timeline

jhenderson created this revision.Jan 22 2019, 4:57 AM

Add cl::Grouping to short alias (see also and D57046).

ruiu added inline comments.Jan 22 2019, 6:02 PM
3 ↗(On Diff #182896)

Can't tests for llvm-symbolizer depend on llvm-mc? If it can, can you represent functions.o in assembly and assemble it at test-time so that you can avoid checking in a binary file?

jhenderson marked an inline comment as done.Jan 23 2019, 1:41 AM
jhenderson added inline comments.
3 ↗(On Diff #182896)

I tried that first using llvm-mc -g but that produces ?? for the function name of --functions=short. I could be persuaded that that's fine, because it shows a difference in behaviour between them, but it doesn't really test short function names.

Another alternative would be to create manually-written .debug* data. I'll have a look and see if that's practical, but I think that would make the test somewhat harder to read.

Use llvm-mc and assembly as test input instead of a pre-built object.

ruiu accepted this revision.Jan 23 2019, 9:07 AM


This revision is now accepted and ready to land.Jan 23 2019, 9:07 AM
This revision was automatically updated to reflect the committed changes.