Supported on windows
Supported on linux
Supported on embedded
Supported on android

set filename-display command

Switches between absolute and relative file names displayed by the backtrace and frame commands.

Syntax

set filename-display relative
set filename-display absolute
set filename-display basename
show filename-display

Modes

relative
GDB will show the paths to source files relative to the compilation directory. This mode is the default one.
absolute
GDB will show the full paths to all source files.
basename
GDB will show only the names of the files without any subdirectories.

Default value

The default value for the filename-display variable is relative.

Remarks

This command is supported by GDB 7.6 and later versions.

Examples

We will demonstrate the set filename-display command using a simple "Hello, World" program:

#include <stdio.h>

int main(int argc, char *argv[])
{
    printf("Hello, World\n");
    return 0;
}

We will start debugging, wait until our breakpoint in main() is hit and try different modes of filename-display:

(gdb) break main
Breakpoint 1 at 0x80483dd: file test.cpp, line 5.
(gdb) run
Starting program: /home/testuser/test

Breakpoint 1, main (argc=1, argv=0xbffff784) at test.cpp:5
5 printf("Hello, World\n");
(gdb) backtrace
#0 main (argc=1, argv=0xbffff784) at test.cpp:5
(gdb) show filename-display
Filenames are displayed as "relative".
(gdb) set filename-display absolute
(gdb) backtrace
#0 main (argc=1, argv=0xbffff784) at /home/testuser/test.cpp:5
(gdb) frame 0
#0 main (argc=1, argv=0xbffff784) at /home/testuser/test.cpp:5
5 printf("Hello, World\n");
(gdb)

Compatibility with VisualGDB

Do not use the set filename-display command with VisualGDB, as it will interfere with the way GDB reports the source file names to VisualGDB.

See also