1

I wanted to start using gdbserver for remote debugging and so I tested-out its functionality on my local machine with a simple test program that generates a segfault shown below:

segfault.c -- compiles to elf named "test"

#define NULL ((void*)0)
int main()
{
    int value = *((int*)NULL);
    return value;
}

Now when I run:

#gdb test

(gdb)run

I get:

Starting program: /home/awaibel/digiworkspace/test/Debug/test 

Program received signal SIGSEGV, Segmentation fault.
0x080483bf in main () at ../segfault.c:4
4       int value = *((int*)NULL);

however if I debug it with gdb server like so:

#gdbserver :65535 test

#gdb test

(gdb)target remote 127.0.0.1:65535

(gdb)continue

it gives me the debug info:

Program received signal SIGSEGV, Segmentation fault.
0x080483bf in ?? ()

it seems to give the same function address for the segfault, but the name and line number is omitted when debugging with the remote debugger. is it possible to have the remote debugger display this information, and if so, how?

I guess I should add that the program was compiled with GCC using the "-g" debug flag

  • 1
    When I repeat your steps, I get the expected result even with gdbserver (0x000000000040047b in main () at segfault.c:4). What platform (OS and architecture) and GDB version are you using? – simark Oct 30 '13 at 16:28
  • gdb --version gives `GNU gdb (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04` gdbserver --version gives `GNU gdbserver (Ubuntu/Linaro 7.4-2012.04-0ubuntu2.1) 7.4-2012.04` and the platform is Xubuntu 12.04 x86 –  Oct 30 '13 at 16:32
  • Looks like symbols aren't loaded – Paul Beusterien Oct 30 '13 at 16:35
  • do i have to add something to the gdbserver call to load the symbols? –  Oct 30 '13 at 16:36
  • 1
    It is gdb on the "client" side who does symbol resolution. gdbserver is only aware of addresses. When you launch gdb with "gdb test", you should see a line like "Reading symbols from test...done.". Do you see it? – simark Oct 30 '13 at 17:45
  • I do see a message on the client side: `Reading symbols from /lib/ld-linux.so.2...(no debugging symbols found)...done.` I didn't think that was an issue since it was on the client. how do I get it to load the symbols from the remote target? –  Oct 30 '13 at 18:04
  • Possible duplicate of [Source level debugging shared libraries remotely with gdb and gdbserver](https://stackoverflow.com/questions/25334285/source-level-debugging-shared-libraries-remotely-with-gdb-and-gdbserver) – Ciro Santilli OurBigBook.com Jul 22 '17 at 07:58

1 Answers1

2

Thanks to markys' comments I was able to figure out the problem. Since the gdb client is what parses the symbols and not the server, I had to make sure the client knew the full path to a copy of the executable. Since 'test' was not in the current directory for the command prompt that was used to run gdbtest it did not have a copy of the symbols to use. adding the the binary to PATH for the terminal running the client solved the problem. Thanks.

Summarizing:

  • server side:

gdbserver --multi :port "path-to-executable"

  • client side:

gdb "path-to-executable" (gdb)> target remote "ip-of-the-remote-device:port"

Community
  • 1
  • 1