跳到主要内容

其他项

重新映射调试对话的源文件路径

如果您的源文件不再位于与程序构建时相同的位置 (例如,如果程序是在另外一台计算机上构建的),您需要告诉调试器如何在本地文件路径中查找源文件,而不是构建系统的文件路径。

(gdb) set pathname-substitutions /buildbot/path /my/path

在 gdb 中,可以提供文件目录来搜索源文件。

(gdb) directory /my/path

调试服务器设置

连接到远程调试服务器

(gdb) target remote eorgadd:8000

连接到本地调试服务器

(gdb) target remote localhost:8000

临时变量和打印

创建临时变量并赋值

(gdb) set $foo = 5
(gdb) set variable $foo = 5

# or using the print command

(gdb) print $foo = 5

# or using the call command

(gdb) call $foo = 5

# and if you want to specify the type of the variable:

(gdb) set $foo = (unsigned int) 5

在当前帧中的计算表达式

(gdb) print (int) printf ("Print nine: %d.", 4 + 5)

# or if you don’t want to see void returns:

(gdb) call (int) printf ("Print nine: %d.", 4 + 5)

打印信息到屏幕

(gdb) echo Here is some text\n