目录
官网解析:
gdbserver-manhttps://man7.org/linux/man-pages/man1/gdbserver.1.html#:~:text=gdbserver%20is%20a%20program%20that,put%20onto%20the%20target%20system.gdbserver-wiki
https://en.wikipedia.org/wiki/Gdbserver
First, you need to have a copy of the program you want to debug put onto the target system. 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.
这段话是说:
远端gdbserver调试的程序可以是strip过的,gdnserver并不在乎(符号)symbols,
所有的符号处理只与host(主机)上的程序有关
gdbserver主要有三种用法:
一、调试指定的应用程序(可以通过tcp,也可以通过串口)
The general syntax is: target> gdbserver <comm> <program> [<args> ...]
gdbserver host:2345 emacs foo.txt
二、调试已经在运行的程序
This is accomplished via the --attach argument. The syntax is: target> gdbserver --attach <comm> <pid>
三、调试多个程序,一般用的少,在此暂时不写
应用:wiki上的例子
remote@~$ gdbserver :2159 hello_world Process hello_world created; pid = 2509 Listening on port 2159
local@~$ gdb -q hello_world Reading symbols from /home/user/hello_world...done. (gdb) target remote 192.168.0.11:2159 Remote debugging using 192.168.0.11:2159 0x002f3850 in ?? () from /lib/ld-linux.so.2 (gdb) continue Continuing. Program received signal SIGSEGV, Segmentation fault. 0x08048414 in main () at hello_world.c:10 10 printf("x[%d] = %g\n", i, x[i]); (gdb)
补充
1、gdbserver的使用,--attach的使用
2、set follow-fork-mode child 的使用,但是暂时不知道为什么一直调试的parent进程
3、编译某个平台host的gdb
4、了解gdb的编译的--target,--host的编译,了解各个编译工具链的的gdb是如何编译的
5、记录gdb在其他设备直接修改源码链接,可以直接找到源码的问题