cstraceltrace

Line Number Info in ltrace and strace tools


Is it possible that I can view the line number and file name (for my program running with ltrace/strace) along with the library call/system call information.

Eg:

code section :: ptr = malloc(sizeof(int)*5); (file:code.c, line:21)

ltrace or any other tool: malloc(20) :: code.c::21

I have tried all the options of ltrace/strace but cannot figure out a way to get this info.

If not possible through ltrace/strace, do we have any parallel tool option for GNU/Linux?


Solution

  • You may be able to use the -i option (to output the instruction pointer at the time of the call) in strace and ltrace, combined with addr2line to resolve the calls to lines of code.