显示cdir值

时间:2018-12-12 04:30:21

标签: gdb

当我尝试查看gdb尝试搜索源文件的目录时,我使用了show directories,它输出了一个变量:

(gdb) show directories
Source directories searched: $cdir:$cwd

但是如何显示两个变量的值:cdircwd?尝试过showp无效。

1 个答案:

答案 0 :(得分:2)

  

如何显示两个变量的值:cdircwd

$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.