set substitute-path /home/foo /tmp/debug/home/foo

http://sourceware.org/gdb/current/onlinedocs/gdb/Source-Path.html#index-set-substitute_002dpath

Answer from user184968 on Stack Overflow
🌐
GNU Project
sourceware.org › gdb › current › onlinedocs › gdb.html › Source-Path.html
Source Path (Debugging with GDB)
The source path will always include two special entries ‘$cdir’ and ‘$cwd’, these refer to the compilation directory (if one is recorded) and the current working directory respectively. ‘$cdir’ causes GDB to search within the compilation directory, if one is recorded in the debug information.
Discussions

Automatically append source directory to gdb when debugging
Hey, I have external source directories of my library that I want to add to gdb while debugging. In the command line I can do that by calling gdb via gdb --directory=/path/to/sources or by writing directory /path/to/sources while running gdb. More on forum.qt.io
🌐 forum.qt.io
7
1
July 4, 2023
compiling - (How) can I set source path (in debuginfo) when building debian package - Unix & Linux Stack Exchange
I need debuginfo for some libraries, ... packages. However it turns out that the source paths in the debug info is something like ../gst/gsttask.c that is relative to the build-dir. I could perhaps point out the build dir in gdb, but if I do this with a few libraries it becomes ... More on unix.stackexchange.com
🌐 unix.stackexchange.com
May 9, 2024
add `sourceFileMap` setting for conversion of paths between ide and gdb
I suggest to add a sourceFileMap setting. This would need to applied anywhere the client passes paths (breakpoints, "go to cursor") and when the client receives paths (I guess that's the stack only). ... People are using their own gdb-init scripts to [do path substitutions] - No help from extension ... More on github.com
🌐 github.com
7
March 9, 2022
Mapping source files during gdb remote debugging.
The application starts, gdbserver reports me that remote session from the host begins, but I'm not able to hit a breakpoint because gdb can't find source files - paths in docker and host are different and gdb searches in the wrong directory. Please notice in launch.json I added debugServerArgs ... More on github.com
🌐 github.com
3
April 13, 2017
🌐
Qt Forum
forum.qt.io › home › qt development › qt creator and other tools › automatically append source directory to gdb when debugging
Automatically append source directory to gdb when debugging | Qt Forum
July 4, 2023 - Hey, I have external source directories of my library that I want to add to gdb while debugging. In the command line I can do that by calling gdb via gdb --directory=/path/to/sources or by writing directory /path/to/sources while running gdb.
🌐
Dzyoba
alex.dzyoba.com › blog › gdb-source-path
How to point GDB to your sources | There is no magic here
April 30, 2017 - To find the sources GDB parses .debug_info section to find all DIEs with tag DW_TAG_compile_unit. The DIE with this tag has 2 main attributes DW_AT_comp_dir (compilation directory) and DW_AT_name - path to the source file.
🌐
Apple Developer
developer.apple.com › library › archive › documentation › DeveloperTools › gdb › gdb › gdb_8.html
Debugging with gdb - Examining Source Files
Each time GDB wants a source file, it tries all the directories in the list, in the order they are present in the list, until it finds a file with the desired name. For example, suppose an executable references the file `/usr/src/foo-1.0/lib/foo.c', and our source path is `/mnt/cross'.
🌐
Nsk
cmd.inp.nsk.su › old › cmd2 › manuals › programming › GNU › gdb › gdb_50.html
Debugging with GDB - Source Path
Executable programs sometimes do not record the directories of the source files from which they were compiled, just the names. Even when they do, the directories could be moved between the compilation and your debugging session. GDB has a list of directories to search for source files; this is ...
🌐
The Eclipse Foundation
eclipse.org › forums › index.php › t › 1082634
Eclipse Community Forums: C / C++ IDE (CDT) » What is the best/correct way to specify debugger source containers for an external makefile project | The Eclipse Foundation
November 21, 2016 - The Eclipse Foundation - home to a global community, the Eclipse IDE, Jakarta EE and over 350 open source projects, including runtimes, tools and frameworks.
🌐
UNAM
irya.unam.mx › computo › sites › manuales › fce12 › debugger › cl › commandref › gdb_mode › cmd_set_substitu.htm
set substitute-path (gdb mode only)
The set substitute-path command tells the debugger where to find the sources, so the list command displays the source code:
Find elsewhere
🌐
JetBrains
intellij-support.jetbrains.com › hc › en-us › community › posts › 205824249-Mapping-between-GDB-source-files-and-project-files-when-symbolic-link-in-path
Mapping between GDB source files and project files when symbolic link in path – IDEs Support (IntelliJ Platform) | JetBrains
January 13, 2015 - While debugging, clicking on a stack frame opens a source code file. Let's say the file is /apps/home/martin/my-project/my-file.cpp. CLion does not seem to recognize this as the project file because it tracks it as ~/my-project/my-file.cpp. We have a symbolic link as follows: ln -s /apps/home/martin /home/martin It seems the symbolic link on the path prevents the IDE to recognize that the files are the same.
🌐
VisualGDB
visualgdb.com › documentation › missingsources
Resolving Invalid Source Paths from GDB – VisualGDB Documentation
April 18, 2022 - The window displays the path of the currently debugged executable (1), and the exact path reported by gdb (2) and allows recursively searching an arbitrary directory (3) for the files with the matching name.
🌐
Stack Exchange
unix.stackexchange.com › questions › 783047 › how-can-i-set-source-path-in-debuginfo-when-building-debian-package
compiling - (How) can I set source path (in debuginfo) when building debian package - Unix & Linux Stack Exchange
May 9, 2024 - I need debuginfo for some libraries, for example gstreamer (which are not available in debian repo), but can be built using source packages. However it turns out that the source paths in the debug info is something like ../gst/gsttask.c that is relative to the build-dir. I could perhaps point out the build dir in gdb, but if I do this with a few libraries it becomes a bit unpractical.
🌐
GitHub
github.com › Marus › cortex-debug › issues › 611
add `sourceFileMap` setting for conversion of paths between ide and gdb · Issue #611 · Marus/cortex-debug
March 9, 2022 - I suggest to add a sourceFileMap setting. This would need to applied anywhere the client passes paths (breakpoints, "go to cursor") and when the client receives paths (I guess that's the stack only). ... People are using their own gdb-init scripts to [do path substitutions] - No help from extension needed.
Published   Mar 09, 2022
🌐
GitHub
github.com › Microsoft › vscode-cpptools › issues › 826
Mapping source files during gdb remote debugging. · Issue #826 · microsoft/vscode-cpptools
April 13, 2017 - { "version": "0.2.0", "configurations": [ { "name": "(gdb) remote debug", "type": "cppdbg", "request": "launch", "program": "${workspaceRoot}/build/bin/app", "debugServerArgs": "dir ${workspaceRoot}/src", "stopAtEntry": false, "cwd": "${workspaceRoot}", "environment": [], "externalConsole": true, "MIMode": "gdb", "miDebuggerServerAddress": "localhost:2222", "setupCommands": [ { "description": "Enable pretty-printing for gdb", "text": "-enable-pretty-printing", "ignoreFailures": true } ] } ] }
Published   Jun 14, 2017
🌐
University of Bristol
acrc.bris.ac.uk › acrc › RedHat › rhel-gdb-en-4 › source-path.html
Specifying source directories
Executable programs sometimes do not record the directories of the source files from which they were compiled, just the names. Even when they do, the directories could be moved between the compilation and your debugging session. gdb has a list of directories to search for source files; this is ...
🌐
Oracle
forums.oracle.com › ords › apexds › post › how-do-i-set-the-source-dir-path-for-gdb-1859
how do I set the source dir path for GDB
February 2, 2007 - When I debug my project with GDB I'm able to stop at breakpoints in the main program but not at ones set in the library its linked against. When using GDB from the command line I can supply the -d /ad...