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

张雨姗(ZHANG Yushan)-11310380 via llvm-dev llvm-dev at lists.llvm.org
Thu Jan 24 03:48:08 PST 2019


Hi Dean,




Thanks for your last reply. 



I compiled "tmux" with `CC=clang CXX=clang++ CXXFLAGS=-fxray-instrument CFLAGS=-fxray-instrument`, and it succeeded.


I installed the binary with `make install` to a local folder, and run it with XRAY_OPTIONS="patch_premain=true:xray_mode=xray-basic:verbosity=1" tmux'. 



But after it exited normally, I have no trace generated or any error. And I also used `llvm extract -symbolize` to make sure the binary is instrumented.



What is the cause for it? Does it depend on functions called during the execution? 



What environment variables I should use to guarantee there is always a trace log?




Thank you,
Yushan




 
------------------ Original ------------------
From:  "Dean Michael Berris"<dean.berris at gmail.com>;
Date:  Mon, Jan 21, 2019 01:26 PM
To:  ""张雨姗(ZHANG Yushan)-11310380""<zhangys3 at mail.sustc.edu.cn>; 
Cc:  "llvm-dev"<llvm-dev at lists.llvm.org>; 
Subject:  Re: [llvm-dev] [X-ray] How to check successful instrumentation and generate call trace?

 


> 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:

http://llvm.org/docs/XRay.html#xray-runtime-library

In the example at:

http://llvm.org/docs/XRayExample.html

You can set:

XRAY_OPTIONS="patch_premain=true:xray_mode=xray-basic:verbosity=1”

To get traces.

Cheers

-- Dean
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20190124/0c86fb37/attachment.html>


More information about the llvm-dev mailing list