google / bloaty

Bloaty: a size profiler for binaries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Error when multiple `--debug-file` arguments specified

jchl opened this issue · comments

When running bloaty against multiple libraries with multiple --debug-file arguments, I get an error, for example:

$ bloaty /usr/lib/libStrataAgent.so.0.0.0 --debug-file /usr/lib/debug/usr/lib/libStrataAgent.so.0.0.0.debug /usr/lib/libStrataAgentBase.so.0.0.0 --debug-file /usr/lib/debug/usr/lib/libStrataAgentBase.so.0.0.0.debug
bloaty: Debug file(s) did not match any input file:
678381284140c49336f6a28d3c2e44b6ba538f6b   /usr/lib/debug/usr/lib/libStrataAgent.so.0.0.0.debug

Input Files:
678381284140c49336f6a28d3c2e44b6ba538f6b   /usr/lib/libStrataAgent.so.0.0.0
917d423f220d0a39c840a53a95b1d11123a224d8   /usr/lib/libStrataAgentBase.so.0.0.0

I know that the debug files are correct, because bloaty is happy if I run it against these libraries one at a time:

$ bloaty /usr/lib/libStrataAgent.so.0.0.0 --debug-file /usr/lib/debug/usr/lib/libStrataAgent.so.0.0.0.debug 
     VM SIZE                         FILE SIZE
 --------------                   --------------
  56.5%  5.94Mi .text              5.94Mi  55.9%
  11.1%  1.16Mi .dynstr            1.16Mi  11.0%
...
$ bloaty /usr/lib/libStrataAgentBase.so.0.0.0 --debug-file /usr/lib/debug/usr/lib/libStrataAgentBase.so.0.0.0.debug 
     VM SIZE                         FILE SIZE
 --------------                   --------------
  34.2%  67.9Ki .text              67.9Ki  32.6%
  19.2%  38.1Ki .dynstr            38.1Ki  18.3%
...

Weirdly, if I add -d symbols to the above command line, I do not get the error, and the output correctly includes symbols from both debug libraries.

This looks like a relatively straightforward bug. The code is assuming that each thread will only scan one file/build-id, which is incorrect. The fix should be relatively simple; this needs to be a vector instead of a single string:

std::string build_id;

Feel free to send me a PR to fix this, otherwise I will fix it when I am able.

Thanks for the pointer. Working on a fix now.

This was fixed in #193 (thanks!)