5

I'm trying to debug some functions in a dynamic shared library libexecHook.so. This library is preloaded setting LD_PRELOAD in order to intercept and rewrite some calls to execve() and friends. For debugging purposes I have built gmake with symbols. From what I read in other questions this should work:

gdb ~/tmp/make-dfsg-3.81/make
set exec-wrapper env LD_PRELOAD=/home/marko/execHook.C027/lib/libexecHook.so.0.0.0
start
break execve
break execvp
cont

I do see the breakpoints being set properly, e.g.

4       breakpoint     keep y   0x00007ffff7bd92e0 in execvp at execHook.c:128

but gdb never breaks at my preloaded exec..() functions. Watching the debug output during execution I see that the my library functions are being called.

Marko
  • 128
  • 1
  • 9

2 Answers2

3

The reason gdb did not break at my preloaded wrapper functions is that these are executed from a child process to which gdb was not attached. On Linux I can

set follow-fork-mode child

to make gdb attach to the child that gets created in a vfork().

Marko
  • 128
  • 1
  • 9
1

Try saying start before setting your breakpoints. This will begin running the program which will cause the library dependencies to be satisfied, hopefully using your LD_PRELOAD path. Then set the breakpoints after start, and then do continue.

John Zwinck
  • 239,568
  • 38
  • 324
  • 436
  • The exact same thing: I see the breakpoints: `4 breakpoint keep y 0x00007ffff7bd92e0 in execvp at execHook.c:128` and the program's debug output shows that it's using the functions, but the breakpoints are never triggered. – Marko Feb 10 '12 at 11:02