Reputation: 11
Say I have a C program called aa, and another C program called bb. bb can only run on top of aa (passed in as an argument) and can't run by itself. So maybe think aa as an OS and bb is an app if it helps. Now I want to debug bb, but in GDB I need to do gdb ./aa, then issue command r -- ./bb. So in this case, is it possible to setup breakpoints directly in bb without running? Thanks!
Upvotes: 1
Views: 75
Reputation: 1030
Assuming you have debugging symbols, and the name of the function you want to break on doesn't exist in the aa
binary, you can do:
set follow-fork-mode child
b <function>
and then answer yes when prompted on whether to break on a future shared library load. When the first program forks, gdb will follow the child and set a breakpoint on the desired function.
Upvotes: 2