With the build workflow change from Autotools to CMake, the debug information became incorrect due to outdated file path remapping (#31204). This issue comes from a workaround that was needed in the previous build system (#21885 problem, which was addressed in #20353 and later again on #22409. ).
This PR attempts to resolve the problem by correcting the file path remapping for the new out-of-source build.
I have tested the fix both in the terminal using GDB and in VS Code using LLDB
After my changes, I tested by running gdb:
0cmake -DCMAKE_BUILD_TYPE=Debug -B build
1cmake --build build -j "$(($(nproc)/2+1))"
2
3gdb build/bin/bitcoind
4break init.cpp:1848
5run -regtest
6 Thread 1 "bitcoind" hit Breakpoint 1, AppInitMain (node=..., tip_info=0x0) at ./init.cpp:1848
7 1848 if (args.GetBoolArg("-txindex", DEFAULT_TXINDEX)) {
And also with lldb and vscode using the following .vscode/launch.json:
0{
1"version": "0.2.0",
2"configurations": [
3 {
4 "type": "lldb",
5 "request": "launch",
6 "name": "Debug",
7 "program": "${workspaceFolder}/build/bin/bitcoind",
8 "args": [
9 "-regtest"
10 ],
11 "cwd": "${workspaceFolder}",
12 }
13]
14}
Alternatives
If this PR is not considered, I have two alternative proposals:
- Update the doc to remove the text indicating the user must debug from the root of the project
- PR #https://github.com/bitcoin/bitcoin/pull/32205 Update the doc indicating they must use
set substitute-path path/to/build/src /path/to/project/root/src