Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GDB remote debugging, can't seem to find symbols

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?

like image 729
fred basset Avatar asked Dec 23 '12 20:12

fred basset


People also ask

How do I add debug symbols in GDB?

To add additional symbols you might use add-symbol-file . The add-symbol-file command reads additional symbol table information from the file filename. You would use this command when filename has been dynamically loaded (by some other means) into the program that is running.

What does no debugging symbols mean?

The most frequent cause of "no debugging symbols found" when -g is present is that there is some "stray" -s or -S argument somewhere on the link line. From man ld : -s --strip-all Omit all symbol information from the output file.

What are debugging symbols in GDB?

A Debugging Symbol Table maps instructions in the compiled binary program to their corresponding variable, function, or line in the source code. This mapping could be something like: Program instruction ⇒ item name, item type, original file, line number defined.

How will you do remote debugging using GDB?

To start remote debugging, run GDB on the host machine, and specify as an executable file the program that is running in the remote machine. This tells GDB how to find your program's symbols and the contents of its pure text. Start GDB on the host, and connect to the target (see section Connecting to a remote target).


2 Answers

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
like image 181
Employed Russian Avatar answered Sep 20 '22 17:09

Employed Russian


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.

like image 20
highsciguy Avatar answered Sep 22 '22 17:09

highsciguy