Reputation:
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
Upvotes: 1
Views: 1919
Reputation: 1
Even if this question was asked a lot of time ago, I will answer by giving my context, it may be useful to someone else. Thanks to @user545199 for giving me the right way to solve this problem.
adb forward tcp:<port-A> tcp:<port-B>
gdb-server :<port-A> <exe-file> --multi
gdb-multiarch <same exe file in the Pixel>
gef-remote <127.0.0.1> <port-B>
(or equivalent)Upvotes: 0
Reputation:
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:
gdbserver --multi :port "path-to-executable"
gdb "path-to-executable" (gdb)> target remote "ip-of-the-remote-device:port"
Upvotes: 2