GDB远程调试,似乎找不到符号

时间:2012-12-23 20:04:30

标签: gdb remote-debugging

我正在尝试远程调试在地址为192.168.98.64的计算机上运行的应用程序。在那台机器上我运行:

gdbserver serveripaddr:4444 progname

然后从服务器运行“gdb”,然后在gdb提示符下运行:

(gdb)  target remote 192.168.98.64:4444
Remote debugging using 192.168.98.64:4444
[New Thread 28432]
warning: Could not load vsyscall page because no executable was specified
try using the "file" command first.
0xb775e810 in ?? ()
(gdb) break internal[TAB]

当我尝试设置断点以显示从内部开始的相应函数列表时,我期待按下TAB键,但它没有显示任何内容。编译代码时使用-g打开调试。我做错了什么?

3 个答案:

答案 0 :(得分:11)

  

我跑“gdb”

你应该给GDB你正在调试的可执行文件(最好是它的非剥离版本):

gdb /path/to/progname
(gdb) target remote 192.168.98.64:4444

答案 1 :(得分:6)

当我使用交叉编译的gdb时,我自己就遇到了这个问题(如果你的远程主机有不同的架构,你通常需要这个)。在这种情况下,需要从远程主机上编译的二进制文件中读取符号。我发现以下内容适用于我(如果主机上的体系结构相同):

在远程主机上:

gdbserver [host]:[port] [remote-path-to-binary-from-gdbserver-workdir]

然后在本地主机上(交叉编译)gdb:

shell sleep 5
target remote [host]:[port]
symbol-file remote:[remote-path-to-binary-from-gdbserver-workdir]
directory [local-root-directory-for-source-files]
continue

[*]替换为您的数据。您可以将它用作gdb脚本(因此在第一行中为sleep)或在gdb命令行中输入它。可选目录行告诉它将本地源目录添加到源的搜索路径。如果您使用指向源代码的前端,这将非常有用。

答案 2 :(得分:4)

调试远程时,gdb客户端不知道从哪里加载符号。您有两种选择:

class Polygon {
    constructor(height, width) {
        this.height = height;
        this.width = width;
    }
    getArea() {
        return this.height * this.width;
    }
}

PS:确保已使用调试符号1. specify executable when starting gdb gdb <executable> (gdb) target remote <IP>:<port> (gdb) load <executable> gdb should know symbols now (gdb) b main (gdb) mon reset (gdb) contnue it should break at main (gdb) bt 2. use file command to tell about the symbols. gdb (gdb) target remote <IP>:<port> (gdb) load <executable> (gdb) file <executable> gdb should know symbols now (gdb) b main (gdb) mon reset (gdb) contnue it should break at main (gdb) bt

编译可执行文件