Skip to content

Commit 5b7210c

Browse files
committed
Merge bitcoin/bitcoin#22409: configure: keep relative paths in debug info
0bc666b doc: add info for debugging with relative paths (S3RK) a8b515c configure: keep relative paths in debug info (S3RK) Pull request description: This is a follow-up for #20353 that fixes #21885 It also adds a small section to assist debugging without absolute paths in debug info. ACKs for top commit: kallewoof: Tested ACK 0bc666b Zero-1729: Light crACK 0bc666b Tree-SHA512: d4b75183c3d3a0f59fe786841fb230581de87f6fe04cf7224e4b89c520d45513ba729d4ad8c0e62dd1dbaaa7a25741f04d036bc047f92842e76c9cc31ea47fb2
2 parents 829d3e0 + 0bc666b commit 5b7210c

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

configure.ac

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,8 +1661,8 @@ if test "x$use_ccache" != "xno"; then
16611661
fi
16621662
AC_MSG_RESULT($use_ccache)
16631663
if test "x$use_ccache" = "xyes"; then
1664-
AX_CHECK_COMPILE_FLAG([-fdebug-prefix-map=A=B],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -fdebug-prefix-map=\$(abs_srcdir)=."],,[[$CXXFLAG_WERROR]])
1665-
AX_CHECK_PREPROC_FLAG([-fmacro-prefix-map=A=B],[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -fmacro-prefix-map=\$(abs_srcdir)=."],,[[$CXXFLAG_WERROR]])
1664+
AX_CHECK_COMPILE_FLAG([-fdebug-prefix-map=A=B],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -fdebug-prefix-map=\$(abs_top_srcdir)=."],,[[$CXXFLAG_WERROR]])
1665+
AX_CHECK_PREPROC_FLAG([-fmacro-prefix-map=A=B],[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -fmacro-prefix-map=\$(abs_top_srcdir)=."],,[[$CXXFLAG_WERROR]])
16661666
fi
16671667
fi
16681668

doc/developer-notes.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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)
@@ -253,6 +254,35 @@ Development tips and tricks
253254
Run configure with `--enable-debug` to add additional compiler flags that
254255
produce better debugging builds.
255256

257+
### Show sources in debugging
258+
259+
If you have ccache enabled, absolute paths are stripped from debug information
260+
with the -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the
261+
compiler). This might break source file detection in case you move binaries
262+
after compilation, debug from the directory other than the project root or use
263+
an IDE that only supports absolute paths for debugging.
264+
265+
There are a few possible fixes:
266+
267+
1. Configure source file mapping.
268+
269+
For `gdb` create or append to `.gdbinit` file:
270+
```
271+
set substitute-path ./src /path/to/project/root/src
272+
```
273+
274+
For `lldb` create or append to `.lldbinit` file:
275+
```
276+
settings set target.source-map ./src /path/to/project/root/src
277+
```
278+
279+
2. Add a symlink to the `./src` directory:
280+
```
281+
ln -s /path/to/project/root/src src
282+
```
283+
284+
3. Use `debugedit` to modify debug information in the binary.
285+
256286
### Compiling for gprof profiling
257287

258288
Run configure with the `--enable-gprof` option, then make.

0 commit comments

Comments
 (0)