Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Show cdir values

Tags:

gdb

When I tried to see what are the directories gdb try to search for source files, I used show directories, it output a variable:

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

But how can I show value of the two variables: cdir and cwd? Tried show or p didn't work.

like image 912
fluter Avatar asked Jan 01 '23 12:01

fluter


1 Answers

how can I show value of the two variables: cdir and cwd

The $cdir stands for compilation directory (if one is recorded) and is specific to the current source file.

The command info source should show you info for current source file, including the compilation directory:

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.

The $cwd stands for current working directory, which you can examine with the pwd command:

(gdb) pwd
Working directory /tmp.
like image 200
Employed Russian Avatar answered Jan 31 '23 10:01

Employed Russian