Reputation: 10072
I'm trying to remote debug an application running on a machine with address 192.168.98.64. On that machine I run:
gdbserver serveripaddr:4444 progname
then from the server I run "gdb", then at the gdb prompt run:
(gdb) target remote 192.168.98.64:4444 Remote debugging using 192.168.98.64:4444 [New Thread 28432] warning: Could not load vsyscall page because no executable was specified try using the "file" command first. 0xb775e810 in ?? () (gdb) break internal[TAB]
I was expecting a press of the TAB key when trying to set my breakpoint to bring up a list of corresponding functions starting with internal, but it doesn't bring up anything. The code has been compiled with debugging turned on with -g. What am I doing wrong?
Upvotes: 18
Views: 32188
Reputation: 2933
When debugging remote, gdb client does not know where to load symbols from. You have two options:
specify executable when starting gdb
gdb <executable>
(gdb) target remote <IP>:<port>
(gdb) load <executable>
gdb should know symbols now
(gdb) b main
(gdb) mon reset
(gdb) continue
it should break at main
(gdb) bt
use file command to tell about the symbols.
gdb
(gdb) target remote <IP>:<port>
(gdb) load <executable>
(gdb) file <executable>
gdb should know symbols now
(gdb) b main
(gdb) mon reset
(gdb) continue
it should break at main
(gdb) bt
PS: Make sure you have compiled executable with debug symbols -g -O0
Upvotes: 7
Reputation: 2637
I just encountered this problem myself when I used a cross-compiled gdb (you will in general need this if your remote host has a different architecture). In this case the symbols need to be read from the binary compiled on the remote host. I figured out that the following works for me (also if the architectures on the hosts are the same):
On the remote host:
gdbserver [host]:[port] [remote-path-to-binary-from-gdbserver-workdir]
and then on the local host in (cross-compiled) gdb:
shell sleep 5
target remote [host]:[port]
symbol-file remote:[remote-path-to-binary-from-gdbserver-workdir]
directory [local-root-directory-for-source-files]
continue
Replace the [*]
with your data. You can use it as a gdb script (hence the sleep
in the first line) or enter it on your gdb command line. The optional directory line tells it to add the local source directory to the search path for sources. This can be useful if you use a frontend which points you to the source code.
Upvotes: 5
Reputation: 213375
I run "gdb"
You are supposed to give GDB the executable you are debugging (preferably a non-stripped version of it):
gdb /path/to/progname
(gdb) target remote 192.168.98.64:4444
Upvotes: 16