Merge bitcoin/bitcoin#22409: configure: keep relative paths in debug info

0bc666b053b8f4883c3f5de43959e2bbd91b95c5 doc: add info for debugging with relative paths (S3RK)
a8b515c317f0b5560f62c72a8f4eb6560d8f1c75 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 0bc666b053b8f4883c3f5de43959e2bbd91b95c5
  Zero-1729:
    Light crACK 0bc666b053b8f4883c3f5de43959e2bbd91b95c5

Tree-SHA512: d4b75183c3d3a0f59fe786841fb230581de87f6fe04cf7224e4b89c520d45513ba729d4ad8c0e62dd1dbaaa7a25741f04d036bc047f92842e76c9cc31ea47fb2
This commit is contained in:
fanquake 2021-10-11 09:55:05 +08:00 committed by pasta
parent bcb9cb546c
commit 87caa91a99
2 changed files with 32 additions and 2 deletions

View File

@ -1622,8 +1622,8 @@ if test "x$use_ccache" != "xno"; then
fi
AC_MSG_RESULT($use_ccache)
if test "x$use_ccache" = "xyes"; then
AX_CHECK_COMPILE_FLAG([-fdebug-prefix-map=A=B],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -fdebug-prefix-map=\$(abs_srcdir)=."],,[[$CXXFLAG_WERROR]])
AX_CHECK_PREPROC_FLAG([-fmacro-prefix-map=A=B],[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -fmacro-prefix-map=\$(abs_srcdir)=."],,[[$CXXFLAG_WERROR]])
AX_CHECK_COMPILE_FLAG([-fdebug-prefix-map=A=B],[DEBUG_CXXFLAGS="$DEBUG_CXXFLAGS -fdebug-prefix-map=\$(abs_top_srcdir)=."],,[[$CXXFLAG_WERROR]])
AX_CHECK_PREPROC_FLAG([-fmacro-prefix-map=A=B],[DEBUG_CPPFLAGS="$DEBUG_CPPFLAGS -fmacro-prefix-map=\$(abs_top_srcdir)=."],,[[$CXXFLAG_WERROR]])
fi
fi

View File

@ -11,6 +11,7 @@ Developer Notes
- [Coding Style (Doxygen-compatible comments)](#coding-style-doxygen-compatible-comments)
- [Development tips and tricks](#development-tips-and-tricks)
- [Compiling for debugging](#compiling-for-debugging)
- [Show sources in debugging](#show-sources-in-debugging)
- [Compiling for gprof profiling](#compiling-for-gprof-profiling)
- [`debug.log`](#debuglog)
- [Testnet and Regtest modes](#testnet-and-regtest-modes)
@ -215,6 +216,35 @@ Development tips and tricks
Run configure with `--enable-debug` to add additional compiler flags that
produce better debugging builds.
### Show sources in debugging
If you have ccache enabled, absolute paths are stripped from debug information
with the -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the
compiler). This might break source file detection in case you move binaries
after compilation, debug from the directory other than the project root or use
an IDE that only supports absolute paths for debugging.
There are a few possible fixes:
1. Configure source file mapping.
For `gdb` create or append to `.gdbinit` file:
```
set substitute-path ./src /path/to/project/root/src
```
For `lldb` create or append to `.lldbinit` file:
```
settings set target.source-map ./src /path/to/project/root/src
```
2. Add a symlink to the `./src` directory:
```
ln -s /path/to/project/root/src src
```
3. Use `debugedit` to modify debug information in the binary.
### Compiling for gprof profiling
Run configure with the `--enable-gprof` option, then make.