1. 首先安装gdbserver
apt-get install gdbserver
2. 编译-g 程序
gcc -g test_gdb.c -o test_gdb
源码如下:
#include "Util.h" void p1()
{
int j = ;
char *p; *p = ''; printf("%p %c",p,*p);
do
{
j++;
}while(j < ); } void p2()
{
int j = ; while(j < )
{
j = j + j*j;
} } int main(int argc,char **argv)
{ CreateGerneralThread(p1); CreateGerneralThread(p2); while()
{
sleep();
}
return ;
}
3. 在server端执行下面语句:
gdbserver 192.168.110.138:9002 ./test_gdb
会出现下面这句话
tiger@ubuntu:/mnt/hgfs/e/Lessons/MyExercise/UtilLibs/THREAD$ gdbserver 192.168.115.250:9002 ./test_gdb
Process ./test_gdb created; pid = 23562
Listening on port 9002
在client端执行下面几句话:
1. gdb
出现下面这些东西:
[root@localhost ~]# gdb
GNU gdb (GDB) Fedora (7.3.50.20110722-.fc16)
Copyright (C) Free Software Foundation, Inc.
License GPLv3+: GNU GPL version or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law. Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-redhat-linux-gnu".
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
(gdb) target remote 192.168.115.250:
Remote debugging using 192.168.115.250:
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0xb7fdf1d0 in ?? ()
2. 执行:
target remote:192.168.115.250:9002
3. 执行:
symbol-file remote:192.168.115.250:9002
4. 可以调用类似continue , break 等命令了
参考:http://*.com/questions/14014288/gdb-remote-debugging-cant-seem-to-find-symbols