This is an archive of the discontinued LLVM Phabricator instance.

[llvm-symbolizer] Add support for specifying input addresses on the command-line
ClosedPublic

Authored by jhenderson on Jan 3 2019, 8:11 AM.

Details

Summary

See https://bugs.llvm.org/show_bug.cgi?id=40070.

GNU addr2line accepts input addresses both on the command-line and via stdin. llvm-symbolizer previously only supported the latter. This change adds support for the former. As with addr2line, the new behaviour is to only look for addresses on stdin if no positional arguments were provided to llvm-symbolizer.

Diff Detail

Repository
rL LLVM

Event Timeline

jhenderson created this revision.Jan 3 2019, 8:11 AM
ruiu added inline comments.Jan 9 2019, 9:01 AM
test/tools/llvm-symbolizer/basic.s
12–14

Why don't you do

echo "0xa 0xb" | llvm-symbolizer ...

?

tools/llvm-symbolizer/llvm-symbolizer.cpp
205–207

Now it is more straightforward to move fgets inside the while condition?

jhenderson updated this revision to Diff 180866.Jan 9 2019, 9:39 AM
jhenderson marked 4 inline comments as done.

Move fgets inside loop termination condition.

Thanks @ruiu!

test/tools/llvm-symbolizer/basic.s
12–14

When fed in via stdin, each input needs to be on a new line. I'm not sure I know a way to do this with a single echo command.

tools/llvm-symbolizer/llvm-symbolizer.cpp
205–207

I'm actually not sure why this couldn't have been done before.

ruiu accepted this revision.Jan 9 2019, 9:47 AM

LGTM

test/tools/llvm-symbolizer/basic.s
12–14

In lld we do like this:

echo -e "0xa\n0xb\n" | ...
This revision is now accepted and ready to land.Jan 9 2019, 9:47 AM

Use -e to simplify the echo commands in the test.

I'll commit this tomorrow if there are no objections before then, as I'm just leaving the office.

jhenderson marked an inline comment as done.Jan 9 2019, 10:00 AM
ruiu added inline comments.Jan 9 2019, 10:04 AM
test/tools/llvm-symbolizer/basic.s
12

Not sure if it is safe without "". Perhaps you should add ""to be on the safe side.

13

Remove %t2.input.

jhenderson marked 4 inline comments as done.

Add quotes and remove spurious redirection.

This revision was automatically updated to reflect the committed changes.
jhenderson added inline comments.Jan 10 2019, 6:14 AM
test/tools/llvm-symbolizer/basic.s
12

I think it probably is safe, but I'll add them anyway.

13

Oops, thanks.