GDB and LD_PRELOAD library-call interception

Jan Kratochvil jan.kratochvil@redhat.com
Thu Mar 31 12:16:00 GMT 2011


On Thu, 31 Mar 2011 11:46:56 +0200, Kevin Pouget wrote:
> I was wondering if there could be a way to hack this exec-wrapper to
> launch for instance the executable in an xterm window?

It is not such straightforward, GDB expects the PID it has spawned will be
debugged while with xterm the process being debugged is its child.

I guess you can write a small C helper which will:
 * create new pty
 * change its fds 0/1/2 to the slave of this pty
 * fork xterm -e own-helper-part pty-unique-id
In own-helper-part interconnect the pty master part and its fds 0/1/2.

Another way is to make fork-child.c more flexible/configurable.


> but it it possible to follow easily (two) forks?

Yes, `set detach-on-fork off', so-called multi-inferior mode, it has some
issues on native GNU/Linux system.


Regards,
Jan



More information about the Gdb mailing list