开发者

Trace all calls from a program?

开发者 https://www.devze.com 2023-03-01 08:06 出处:网络
A program is installed on 2 computers. A certain library is working correctly in one computer but not working at all 开发者_如何学JAVAin the other. I wonder if a library is missing.

A program is installed on 2 computers. A certain library is working correctly in one computer but not working at all 开发者_如何学JAVAin the other. I wonder if a library is missing.

I'm using strace so I can see which libraries are being called by the program at runtime. All libraries mentioned by strace are correct but does strace also detect if one library calls another library or file ? Any way to detect this scenario ?


Yes strace will detect calls from loaded libraries.

If you want to trace library calls (not system ones), use ltrace


It sounds like you want to view your app's function call graph, i.e. which functions call one another, which library they live in, etc. If so, you may want to check out the callgrind tool (which is part of valgrind).

Here is an example that uses callgrind to profile some code.

Once you've used callgrind to generate profile data for your app, load it into Kcachegrind to visualize it. It's simple point-and-click: highlight function, see callers/callees, view the call graph, and so on. I've found it quite useful in similar circumstances.


To check for libraries missing, run ldd /full/path/to/program


For programs using Clang to compile, try get call trace of the programs with Xray. It heuristically instruments part of a program and has very low runtime overhead.

0

精彩评论

暂无评论...
验证码 换一张
取 消