gdb-source-file

Define a source path substitution rule

set substitute-path from to Define a source path substitution rule, and add it at the end of the current list of existing substitution rules. If a rule with the same from was already defined, then the old rule is also deleted.

For example, if the file /foo/bar/baz.c was moved to /mnt/cross/baz.c, then the command

1
(gdb) set substitute-path /foo/bar /mnt/cross

will tell GDB to replace /foo/bar with /mnt/cross, which will allow GDB to find the file baz.c even though it was moved.

In the case when more than one substitution rule have been defined, the rules are evaluated one by one in the order where they have been defined. The first one matching, if any, is selected to perform the substitution.

For instance, if we had entered the following commands:

1
2
(gdb) set substitute-path /usr/src/include /mnt/include
(gdb) set substitute-path /usr/src /mnt/src

GDB would then rewrite /usr/src/include/defs.h into /mnt/include/defs.h by using the first rule. However, it would use the second rule to rewrite /usr/src/lib/foo.c into /mnt/src/lib/foo.c.

1
2
3
4
5
(gdb) bt
#0 main () at ./calc/vecadd.cpp:10

(gdb) set substitute-path . /mnt/hgfs/YANG/Desktop/cmake-test/

1
2
3
4
5
6
7
8
9
10
11
12
(gdb) list
5 void foo() {
6 mul(5 , 6);
7 add(3, 4);
8 }
9
10 int main() {
11 std::cout << "main function: " << "\n";
12 foo();
13 return 0;
14 }
(gdb)

Source-Path

Share