문제

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.

도움이 되었습니까?

해결책

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().

다른 팁

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.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top