You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Source code mapping for debugger has changed since cmake #31204
Here's an example of lldb's confused guess of source location:
(lldb) image lookup -vn ProcessMessages
1 match found in /Users/matthewzipkin/Desktop/work/bitcoin/build/src/bitcoind:
...
LineEntry: [0x00000001003302f4-0x000000010033032c): build/src/src/net_processing.cpp:5373
Could just be fixed by updating developer-notes.md -- would we ever include a .lldbinit file in the repo itself? Or am I missing something else.
Add this to ~/.lldbinit to make it load a local .lldbinit file: settings set target.load-cwd-lldbinit true. This is a convenience so that I can keep everything related to Bitcoin Core in its repo.
In the Bitcoin Core repo folder, add a .lldbinit file with (mine is located at /Users/jose.edil/2-development/bitcoin/bitcoin-core-dev, adjust to your path):
settings set target.source-map /Users/jose.edil/2-development/bitcoin/bitcoin-core-dev/build/src/ /Users/jose.edil/2-development/bitcoin/bitcoin-core-dev/src/
In particular, I suspect that -fdebug-prefix-map is not doing it's thing:
(lldb) set list target.source-map
target.source-map -- Source path remappings apply substitutions to the paths of source files, typically
needed to debug from a different host than the one that built the target. The
source-map property consists of an array of pairs, the first element is a path prefix,
and the second is its replacement. The syntax is `prefix1 replacement1 prefix2
replacement2...`. The pairs are checked in order, the first prefix that matches is
used, and that prefix is substituted with the replacement. A common pattern is to use
source-map in conjunction with the clang -fdebug-prefix-map flag. In the build, use
`-fdebug-prefix-map=/path/to/build_dir=.` to rewrite the host specific build directory
to `.`. Then for debugging, use `settings set target.source-map . /path/to/local_dir`
to convert `.` to a valid local path.
But I found I needed to create a .lldbinit file with these lines:
@pinheadmz Has this fixed the mapping in your system permanently? I have not tried this yet and I observe that the source file detection fails because it seems to be generated in a new location everytime I build again like in the below errors.
Breakpoint at /Users/rkrux/projects/bitcoin/src/script/descriptor.cpp:1512 could not be resolved, but a valid location was found at /Users/rkrux/projects/bitcoin/build/src/script/descriptor.cpp:1512
Breakpoint at /Users/rkrux/projects/bitcoin/src/wallet/wallet.cpp:1326 could not be resolved, but a valid location was found at /Users/rkrux/projects/bitcoin/build/src/wallet/wallet/wallet.cpp:1326
I'm still tweaking the .lldbinit file actually -- sometimes I'll be debugging with lldb and end up in a new directory I hadn't linked yet like /fuzz or something and it'll break again. So I suspect there is a simple catch all solution I just haven't figured it out yet
It's not clear if this is something that needs to be fixed, (is a regression), or if it's a behaviour change that needs to be documented in some way, (in the developer notes), or something else? cc @hebasto
With the steps to reproduce there, it is a cmake regression. I am not sure if callgrind_annotate allows mapping, so it may be best to fix this inside the build system itself.
Fixed in #34281. Tested on a fresh install of Ubuntu 26.04 LTS:
Master:
# lldb
(lldb) version
lldb version 21.1.7
(lldb) target create ./bld-c/bin/bitcoind
Current executable set to '/b-c/bld-c/bin/bitcoind' (x86_64).
(lldb) settings show target.source-map
target.source-map (path-map) =
(lldb) breakpoint set --name AppInitSanityChecks
Breakpoint 1: where = bitcoind`AppInitSanityChecks(kernel::Context const&) at init.cpp:1161:1, address = 0x00000000001981c0
(lldb) run
error: Cannot launch '/b-c/bld-c/bin/bitcoind': personality set failed: Function not implemented
(lldb) settings set target.disable-aslr false
(lldb) run
Process 20302 launched: '/b-c/bld-c/bin/bitcoind' (x86_64)
Process 20302 stopped
* thread #1, name = 'bitcoind', stop reason = breakpoint 1.1
frame #0: 0x0000563485dce1c0 bitcoind`AppInitSanityChecks(kernel=0x00005634923d71d0) at init.cpp:1161:1
(lldb)
My fix:
# lldb
(lldb) version
lldb version 21.1.7
(lldb) target create ./bld-c/bin/bitcoind
Current executable set to '/b-c-pull-34281/bld-c/bin/bitcoind' (x86_64).
(lldb) settings show target.source-map
target.source-map (path-map) =
(lldb) breakpoint set --name AppInitSanityChecks
Breakpoint 1: where = bitcoind`AppInitSanityChecks(kernel::Context const&) at init.cpp:1161:1, address = 0x00000000001981c0
(lldb) run
error: Cannot launch '/b-c-pull-34281/bld-c/bin/bitcoind': personality set failed: Function not implemented
(lldb) settings set target.disable-aslr false
(lldb) run
Process 20308 launched: '/b-c-pull-34281/bld-c/bin/bitcoind' (x86_64)
Process 20308 stopped
* thread #1, name = 'bitcoind', stop reason = breakpoint 1.1
frame #0: 0x0000564415caf1c0 bitcoind`AppInitSanityChecks(kernel=0x000056443ed4d1d0) at init.cpp:1161:1
1158 }
1159
1160 bool AppInitSanityChecks(const kernel::Context& kernel)
-> 1161 {
1162 // ********************************************************* Step 4: sanity checks
1163 auto result{kernel::SanityChecks(kernel)};
1164 if (!result) {
(lldb)
Activity
edilmedeiros commentedon Jan 2, 2025
After many hours, I could make it work.
Add this to ~/.lldbinit to make it load a local .lldbinit file:
settings set target.load-cwd-lldbinit true. This is a convenience so that I can keep everything related to Bitcoin Core in its repo.In the Bitcoin Core repo folder, add a .lldbinit file with (mine is located at
/Users/jose.edil/2-development/bitcoin/bitcoin-core-dev, adjust to your path):Compiled with:
$ cmake -B build -DBoost_INCLUDE_DIR=/opt/local/libexec/boost/1.87/include -DCMAKE_C_COMPILER=clang-mp-18 -DCMAKE_CXX_COMPILER=clang++-mp-18 -DCMAKE_BUILD_TYPE=Debug -DWITH_CCACHE=OFFIn particular, I suspect that
-fdebug-prefix-mapis not doing it's thing:I would expect it to use paths like
./<file>for debugging symbols, but it's not the case (note theLineEntryfield below):rkrux commentedon Feb 25, 2025
@pinheadmz Has this fixed the mapping in your system permanently? I have not tried this yet and I observe that the source file detection fails because it seems to be generated in a new location everytime I build again like in the below errors.
I will try this solution.
pinheadmz commentedon Feb 25, 2025
I'm still tweaking the .lldbinit file actually -- sometimes I'll be debugging with lldb and end up in a new directory I hadn't linked yet like
/fuzzor something and it'll break again. So I suspect there is a simple catch all solution I just haven't figured it out yetfanquake commentedon Mar 5, 2025
It's not clear if this is something that needs to be fixed, (is a regression), or if it's a behaviour change that needs to be documented in some way, (in the developer notes), or something else? cc @hebasto
hodlinator commentedon Mar 5, 2025
I find it okay to have to set a mapping for the root directory, but I currently need things like:
Note how the subdirectory needs to be repeated for it to work:
test/util/test/util/Same thing happened for rkrux above:
hebasto commentedon Mar 5, 2025
@hodlinator
Mind submitting a PR?
hodlinator commentedon Mar 5, 2025
Any idea where to start looking for the duplicate subdirectory issue? Where do we get the virtual build/src/ paths to begin with?
willcl-ark commentedon Mar 20, 2025
This seems to work for me on Linux without any
.lldbinitfile:Perhaps #31161 affected this, or is it a macOS-specific issue? Is it still an issue on current master?
configure log
maflcko commentedon Mar 21, 2025
I am also seeing non-existent folders in #31957:
With the steps to reproduce there, it is a cmake regression. I am not sure if
callgrind_annotateallows mapping, so it may be best to fix this inside the build system itself.hebasto commentedon Mar 26, 2025
#31204 (comment):
I tested v28.1 on Ubuntu 24.04 with GCC 13.3:
So the guideline for lldb does not work in my build environment, even for the pre-CMake branch.
maflcko commentedon Apr 1, 2025
Is this a blocker for 29.0? Seems fine to backport to 29.1, if it is ready later, no?
pinheadmz commentedon Apr 2, 2025
definitely not a blocker but I think I figured it out: #32205
maflcko commentedon Nov 18, 2025
For reference, inside GDB, the following worked for me:
Not using the (outdated?) gdbinit advice:
As an alternative, i could use debugedit:
hebasto commentedon Nov 23, 2025
@pinheadmz
Does the approach proposed in both #31957 (comment) and #31957 (comment) make any difference to this issue?
Fix GitHub Issue bitcoin#31204: Source code mapping for d...
arejula27 commentedon Dec 16, 2025
Hi, I proposed an alternative to #32205, instead of modifying the doc making each user configure the path, do it dynamically on cmake: #34081
maflcko commentedon Jan 14, 2026
Fixed in #34281. Tested on a fresh install of Ubuntu 26.04 LTS:
Merge bitcoin/bitcoin#34281: build: Temporarily remove confusing and …
Merge bitcoin/bitcoin#34281: build: Temporarily remove confusing and …
Merge bitcoin/bitcoin#34281: build: Temporarily remove confusing and …
Merge bitcoin/bitcoin#34281: build: Temporarily remove confusing and …
Merge bitcoin#34281: build: Temporarily remove confusing and brittle …