Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gdbserver loading symbol table from remote file

Tags:

gdb

gdbserver

I am trying to use gdbserver...
I have an application with binary path /user/bin/foo running with pid 19767.

Started the gdbserver on remote:

gdbserver  --remote-debug --multi 0:12347 

Started gdb on client and connected it to remove server

target extended-remote 192.168.1.84:12347

Attached gdb on pid

attach 19767

It shows:

warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0x00007f207550043c in ?? ()

Also, current thread information it is showing is incorrect. Like info threads shows 1 thread , but my app has 10 threads-

(gdb) info threads
* 1 Thread 19767.19767  0x00007f207550043c in ?? ()

How can I ask gdb to load symbol from remote file /user/bin/foo? How to make it show correct info?

like image 612
Vivek Goel Avatar asked Mar 21 '13 14:03

Vivek Goel


People also ask

What is gdbserver and how does it work?

] gdbserver is a control program for Unix-like systems, which allows you to connect your program with a remote GDB via target remote ---but without linking in the usual debugging stub. gdbserver is not a complete replacement for the debugging stubs, because it requires essentially the same operating-system facilities that GDB itself does.

How do I use GDB server?

The program can be stripped to save space if needed, as GDBserver doesn’t care about symbols. All symbol handling is taken care of by the GDB running on the host system. To use the server, you log on to the target system, and run the ‘gdbserver’ program.

How do I implement a remote stub in gdb?

Implementing a remote stub The stub files provided with GDB implement the target side of the communication protocol, and the GDB side is implemented in the GDB source file `remote.c'. Normally, you can simply allow these subroutines to communicate, and ignore the details.

How to debug a remote program in gdb?

Go to the first, previous, next, lastsection, table of contents. Debugging remote programs Connecting to a remote target On the GDB host machine, you will need an unstripped copy of your program, since GDB needs symobl and debugging information. Start up GDB as usual, using the name of the local copy of your program as the first argument.


2 Answers

How can I ask gdb to load symbol from remote file /user/bin/foo

You can't. Copy remote /usr/bin/foo locally (or mount the filesystem it's on), and then invoke gdb like this: gdb /path/to/copy/of/foo, or just use the file command.

like image 93
Employed Russian Avatar answered Sep 28 '22 19:09

Employed Russian


As of gdb 7.10, you can use

set sysroot target:

to make gdb retrieve files from the remote filesystem. See https://sourceware.org/gdb/onlinedocs/gdb/Files.html#Files

like image 21
HexMachina Avatar answered Sep 28 '22 20:09

HexMachina