[llvm-dev] [X-ray] How to check successful instrumentation and generate call trace?

Dean Michael Berris via llvm-dev llvm-dev at lists.llvm.org
Sun Jan 20 21:26:20 PST 2019

> On 21 Jan 2019, at 16:16, 张雨姗(ZHANG Yushan)-11310380 via llvm-dev <llvm-dev at lists.llvm.org> wrote:
> Hi all,
> I want to test X-ray performance and compare it with other research tools, so I use Clang 7.0.0 to compile and instrument GNU binutils-2.3.1 with the following commands:
> cd binutils-2.31/
> mkdir build
> cd build/
> CC=$local/clang CXX=$local/clang++ CFLAGS=-fxray-instrument CXXFLAGS=-fxray-instrument ../configure --prefix=/home/zhangysh1995/local
> make
> Then I extract instrumentation map with llvm-xray extract addr2line and it returns:
> ---
> - { id: 1, address: 0x000000000041CD70, function: 0x000000000041CD70, kind: function-enter, always-instrument: false, function-name: '' }
> - { id: 1, address: 0x000000000041D026, function: 0x000000000041CD70, kind: function-exit, always-instrument: false, function-name: '' }
> - { id: 2, address: 0x000000000041D4F0, function: 0x000000000041D4F0, kind: function-enter, always-instrument: false, function-name: '' }
> - { id: 2, address: 0x000000000041DAFA, function: 0x000000000041D4F0, kind: function-exit, always-instrument: false, function-name: '' }
> - { id: 3, address: 0x000000000041E570, function: 0x000000000041E570, kind: function-enter, always-in
> ......
> ......
> Does the map mean that no function is instrumented? Should I change my commands?

This means that the generated binary already has the instrumentation map. It looks like you also already have the function addresses, which if the binary is not stripped of symbols must have the function names. If you add the `-symbolize` flag to the invocation of `llvm-xray extract` then that should get the function names.

> BTW, after instrumentation could I run the binary and get trace directly?

You should be able to enable tracing of instrumented binaries using an environment variables.

> Here is the link to current documentation: https://llvm.org/docs/XRay.html

In that documentation, it shows the table of options you can set in the XRAY_OPTIONS environment variable:


In the example at:


You can set:


To get traces.


-- Dean

More information about the llvm-dev mailing list