Reputation: 8401
I have:
I can connect to running stripped binary (gdp -p PID
). How can I give symbols from unstripped binary to gdb connected to running process?
Upvotes: 3
Views: 2290
Reputation: 22539
There are two main ways to do this.
One way is to start gdb on the unstripped executable, and then attach:
$ gdb unstripped
(gdb) attach 12345
This way is easy! However it has a hidden danger, which is that you might accidentally mismatch the stripped and unstripped programs, leading to a very confusing debugging session.
Another way is to take the time to properly split the debug information into a separate file when stripping. There are some instructions in the gdb manual.
With this approach, be sure to use the build-id feature. If you do this properly, then you can simply point gdb at your archive of separate debug info, and gdb will pick up the proper information automatically.
The main advantage of this approach is that it avoids the possibility of debuginfo mismatch. FWIW this is what the distros use to build their debuginfo archives.
Upvotes: 2