armgdb

GDB: 'set substitute-path' command does not work


The gdb command set substitute-path does not work as expected. I have a .elf arm file and I want to substitute source path for the debug:

C:\Users\user\Desktop\project\src/main.c:

to

./src/main.c:

I tried the following commands without any success:

>>> set substitute-path C:\\Users\\user\\Desktop\\project\\ \.//
>>> show substitute-path
List of all source path substitution rules:
  `C:\Users\user\Desktop\project\' -> `./'.

>>> list main
40      C:\Users\user\Desktop\project\src/main.c: No such file or directory.

I also tried a lot of different substitute path without success:

set substitute-path C:\Users\user\Desktop\project\ ./
...
set substitute-path C:\\Users\\user\\Desktop\\project\\ ./
...
...

I'm wondering if I correctly use the set substitute-path command.


Solution

  • As I have pointed out in a comment, ensure to use double backslashes without file names, like:

    set substitute-path C:\\Users\\user\\Desktop\\project .\\src

    or based in the author's test, it seems that this version also works:

    set substitute-path C:\\Users\\user\\Desktop\\project\\src ./src