当我尝试查看gdb尝试搜索源文件的目录时,我使用了show directories
,它输出了一个变量:
(gdb) show directories
Source directories searched: $cdir:$cwd
但是如何显示两个变量的值:cdir
和cwd
?尝试过show
或p
无效。
答案 0 :(得分:2)
如何显示两个变量的值:
cdir
和cwd
$cdir
stands for编译目录(如果已记录),并且特定于当前源文件。
命令info source
应该向您显示当前源文件的信息,包括编译目录:
Starting program: /tmp/a.out
Temporary breakpoint 1, main (argc=1, argv=0x7fffffffdcb8) at t.c:3
3 return 0;
(gdb) info source
Current source file is t.c
Compilation directory is /tmp <<<=== this is $cdir
Located in /tmp/t.c
Contains 4 lines.
Source language is c.
Producer is GNU C11 7.3.0 -mtune=generic -march=x86-64 -g.
Compiled with DWARF 2 debugging format.
Does not include preprocessor macro info.
$cwd
代表当前的工作目录,您可以使用pwd
命令进行检查:
(gdb) pwd
Working directory /tmp.