其他项
重新映射调试对话的源文件路径
如果您的源文件不再位于与程序构建时相同的位置 (例如,如果程序是在另外一台计算机上构建的),您需要告诉调试器如何在本地文件路径中查找源文件,而不是构建系统的文件路径。
- gdb
- lldb
(gdb) set pathname-substitutions /buildbot/path /my/path
(lldb) settings set target.source-map /buildbot/path /my/path
在 gdb 中,可以提供文件目录来搜索源文件。
- gdb
- lldb
(gdb) directory /my/path
调试服务器设置
连接到远程调试服务器
- gdb
- lldb
(gdb) target remote eorgadd:8000
(lldb) gdb-remote eorgadd:8000
连接到本地调试服务器
- gdb
- lldb
(gdb) target remote localhost:8000
(lldb) gdb-remote 8000
临时变量和打印
创建临时变量并赋值
- gdb
- lldb
(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
# In lldb you evaluate a variable declaration expression as you would write it in C:
(lldb) expr unsigned int $foo = 5
在当前帧中的计算表达式
- gdb
- lldb
(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)
(lldb) expr (int) printf ("Print nine: %d.", 4 + 5)
# or using the print alias:
(lldb) print (int) printf ("Print nine: %d.", 4 + 5)
打印信息到屏幕
- gdb
- lldb
(gdb) echo Here is some text\n
(lldb) script print("Here is some text")