Q
Q
qvlad2016-06-28 09:54:10
linux
qvlad, 2016-06-28 09:54:10

Is it possible to connect to a running program without debug information using gdb and attach debug information to it?

Is it possible to connect to a running program without debug information using gdb and attach debug information to it having a binary with debug information without interrupting the program execution.
objcopy --only-keep-debug was not made beforehand to the running program.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
C
Cool Admin, 2016-06-28
@ifaustrue

No.

J
jcmvbkbc, 2016-06-28
@jcmvbkbc

Can. Run gdb like this:
gdb program-image-with-debug-symbols and run gdb attach pid
from the command line where pid is the number of the process to attach to. Well, of course, for this to work correctly, program-image-with-debug-symbols must differ from the running program only by the presence of debug information.

Q
qvlad, 2016-06-29
@qvlad

Can. Run gdb like this:
gdb program-image-with-debug-symbols and run gdb attach pid
from the command line where pid is the number of the process to attach to. Well, of course, for this to work correctly, program-image-with-debug-symbols must differ from the running program only by the presence of debug information.
gdb /tmp/telemetry 
GNU gdb (GDB) 7.5.1
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-buildroot-linux-gnueabi".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>...
Reading symbols from /tmp/telemetry...done.
(gdb) attach 6986
Attaching to program: /tmp/telemetry, process 6986
Reading symbols from /lib/ld-linux-armhf.so.3...(no debugging symbols found)...done.
Loaded symbols for /lib/ld-linux-armhf.so.3
0x403eb276 in ?? ()
(gdb) bt
#0  0x403eb276 in ?? ()
#1  0x4045a488 in ?? ()
#2  0x4045a488 in ?? ()
gdb /tmp/telemetry
b InfoListener::saveValue
Breakpoint 1 at 0x241e8: file InfoListener.cpp, line 949.
(gdb) c
Continuing.

After starting, I see the corresponding log from the function, but the program does not stop at the set breakpoint.
If you immediately run the binary with debug symbols under gdb and put the same breakpoint, then everything works correctly. If you connect to a process running with a binary with debug symbols, then everything also works correctly.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question