@@ -12,6 +12,7 @@ Developer Notes
1212 - [ Generating Documentation] ( #generating-documentation )
1313 - [ Development tips and tricks] ( #development-tips-and-tricks )
1414 - [ Compiling for debugging] ( #compiling-for-debugging )
15+ - [ Show sources in debugging] ( #show-sources-in-debugging )
1516 - [ Compiling for gprof profiling] ( #compiling-for-gprof-profiling )
1617 - [ ` debug.log ` ] ( #debuglog )
1718 - [ Signet, testnet, and regtest modes] ( #signet-testnet-and-regtest-modes )
@@ -249,6 +250,35 @@ Development tips and tricks
249250Run configure with ` --enable-debug ` to add additional compiler flags that
250251produce better debugging builds.
251252
253+ ### Show sources in debugging
254+
255+ If you have ccache enabled, absolute paths are stripped from debug information
256+ with the -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the
257+ compiler). This might break source file detection in case you move binaries
258+ after compilation, debug from the directory other than the project root or use
259+ an IDE that only supports absolute paths for debugging.
260+
261+ There are a few possible fixes:
262+
263+ 1 . Configure source file mapping.
264+
265+ For ` gdb ` create or append to ` .gdbinit ` file:
266+ ```
267+ set substitute-path ./src /path/to/project/root/src
268+ ```
269+
270+ For ` lldb ` create or append to ` .lldbinit ` file:
271+ ```
272+ settings set target.source-map ./src /path/to/project/root/src
273+ ```
274+
275+ 2 . Add a symlink to the ` ./src ` directory:
276+ ```
277+ ln -s /path/to/project/root/src src
278+ ```
279+
280+ 3 . Use ` debugedit ` to modify debug information in the binary.
281+
252282### Compiling for gprof profiling
253283
254284Run configure with the ` --enable-gprof ` option, then make.
0 commit comments