Manuel
Manuel

Reputation: 675

ltrace and gdb attach to same process

Is it somehow possible to use ltrace and gdb at the same time? I have a small stripped binary program, where I would like to see the variable contents, of some library calls I can see with ltrace.

Is it somehow possible to attach gdb and ltrace to the same process?

Upvotes: 2

Views: 1590

Answers (1)

osgx
osgx

Reputation: 94225

No, both gdb and ltrace use ptrace to debug and trace process, and tracee (target) process may be attached only to single ptrace tracer.

You may try implement some call tracing inside gdb with breakpoint function_name or b function_addr, getting breakpoint id and adding gdb commands to execute at this breakpoint, for example for breakpoint with number 1:

  commands 1
  bt 2
  p/x $rax
  continue 

gdb will print backtrace (bt), and rax register value, then it will continue execution (more examples and disabling of pagination is at What are the best ways to automate a GDB debugging session?).

Or you can try in-kernel tracing solution like sysdig.

Upvotes: 2

Related Questions