configure: keep relative paths in debug info #22409

pull S3RK wants to merge 2 commits into bitcoin:master from S3RK:debug_keep_relative_path changing 2 files +32 −2
  1. S3RK commented at 7:22 am on July 6, 2021: member

    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.

  2. configure: keep relative paths in debug info
    Revert to the state prior to e507acbe and allow debugging
    from project root dir with `gdb src/bitcoind`.
    a8b515c317
  3. S3RK commented at 7:22 am on July 6, 2021: member
    Thanks @ajtowns for the idea and consultation
  4. fanquake added the label Build system on Jul 6, 2021
  5. in doc/developer-notes.md:256 in 4f19a84a9b outdated
    249@@ -249,6 +250,23 @@ Development tips and tricks
    250 Run configure with `--enable-debug` to add additional compiler flags that
    251 produce better debugging builds.
    252 
    253+### Show sources in debugging
    254+
    255+Absolute paths are stripped from debug information with -fdebug-prefix-map and
    256+-fmacro-prefix-map options. In case you move binaries after compilation or use
    


    ajtowns commented at 11:50 am on July 6, 2021:

    May be worth noting some or all of:

    • this is only when compiling with ccache enabled (and only if the compiler supports it)
    • that it breaks running “lldb ./bitcoind” (etc) when your cwd is the src/ directory, even if you don’t move the file around (gdb magically works fine, it seems) – and that this can be worked around by creating a “src -> .” symlink within the src/ directory.
    • the debugedit binary (available on debian/red hat based distros) can be used to edit the binaries to make the debug path absolute as well

    S3RK commented at 7:30 am on July 7, 2021:
    Updated. Please take another look
  6. laanwj commented at 1:44 pm on July 6, 2021: member
    Concept ACK
  7. ttloves2 changes_requested
  8. ttloves2 commented at 5:59 am on July 7, 2021: none
    Closed???
  9. S3RK force-pushed on Jul 7, 2021
  10. in doc/developer-notes.md:256 in 01d049e0eb outdated
    249@@ -249,6 +250,35 @@ Development tips and tricks
    250 Run configure with `--enable-debug` to add additional compiler flags that
    251 produce better debugging builds.
    252 
    253+### Show sources in debugging
    254+
    255+If you have ccache enabled absolute paths are stripped from debug information
    256+with -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the 
    


    MarcoFalke commented at 4:32 pm on July 7, 2021:
    0with -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the
    

    from the linter


    S3RK commented at 6:56 am on July 8, 2021:
    Thanks for extracting this out from the logs. Fixed
  11. S3RK force-pushed on Jul 8, 2021
  12. practicalswift commented at 8:08 pm on July 24, 2021: contributor
    Concept ACK
  13. tryphe commented at 3:41 am on August 1, 2021: contributor
    Concept ACK
  14. S3RK commented at 9:57 am on August 21, 2021: member
    @practicalswift @MarcoFalke @ajtowns Interested in doing a full review?
  15. Zero-1729 commented at 11:15 am on August 21, 2021: contributor
    Concept ACK
  16. in doc/developer-notes.md:255 in 6205f85d23 outdated
    249@@ -249,6 +250,35 @@ Development tips and tricks
    250 Run configure with `--enable-debug` to add additional compiler flags that
    251 produce better debugging builds.
    252 
    253+### Show sources in debugging
    254+
    255+If you have ccache enabled absolute paths are stripped from debug information
    


    Zero-1729 commented at 12:09 pm on August 21, 2021:

    minor grammar nits (cont’d below), feel free to ignore:

    0If you have ccache enabled, absolute paths are stripped from debug information
    
  17. in doc/developer-notes.md:256 in 6205f85d23 outdated
    249@@ -249,6 +250,35 @@ Development tips and tricks
    250 Run configure with `--enable-debug` to add additional compiler flags that
    251 produce better debugging builds.
    252 
    253+### Show sources in debugging
    254+
    255+If you have ccache enabled absolute paths are stripped from debug information
    256+with -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the
    


    Zero-1729 commented at 12:09 pm on August 21, 2021:
    0with the -fdebug-prefix-map and -fmacro-prefix-map options (if supported by the
    
  18. in doc/developer-notes.md:258 in 6205f85d23 outdated
    249@@ -249,6 +250,35 @@ Development tips and tricks
    250 Run configure with `--enable-debug` to add additional compiler flags that
    251 produce better debugging builds.
    252 
    253+### Show sources in debugging
    254+
    255+If you have ccache enabled absolute paths are stripped from debug information
    256+with -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 project root or use
    


    Zero-1729 commented at 12:09 pm on August 21, 2021:
    0after compilation, debug from the directory other than the project root or use
    
  19. jonatack commented at 3:59 pm on August 21, 2021: member
    Concept ACK
  20. doc: add info for debugging with relative paths 0bc666b053
  21. S3RK force-pushed on Aug 21, 2021
  22. S3RK commented at 6:44 pm on August 21, 2021: member
    Fixed grammar, thanks @Zero-1729
  23. Zero-1729 commented at 7:12 pm on August 21, 2021: contributor
    Light crACK 0bc666b053b8f4883c3f5de43959e2bbd91b95c5
  24. MarcoFalke commented at 11:29 am on August 25, 2021: member
    The commit id you reference in the commit message is wrong.
  25. MarcoFalke commented at 11:53 am on August 25, 2021: member

    I tested this in Clion and it didn’t change anything for me: Before and After the same error:

    Screenshot from 2021-08-25 13-12-46

    Reverting commit e507acb was a working workaround. Maybe #21885 (comment) also works.

  26. MarcoFalke commented at 11:55 am on August 25, 2021: member

    I tested this in Clion and it didn’t change anything for me: Before and After the same error:

    I guess I’ll still have to apply one of the workarounds you mention in the doc?

  27. S3RK commented at 8:02 pm on August 25, 2021: member

    I referenced merge commit as it has PR number for the expanded context, can change to the other commit once I get to my laptop.

    I tested this in Clion and it didn’t change anything for me: Before and After the same error:

    I guess I’ll still have to apply one of the workarounds you mention in the doc?

    Yes, unfortunately CLion uses absolute paths to set breakpoints, so you need one of the workarounds. Alternatively, you can use new “Relaxed breakpoints” feature starting from 2021.2 that uses file name only matching.

    This PR makes it again possible to debug from the project root dir with gdb arc/bitcoind

  28. kallewoof commented at 4:05 am on September 22, 2021: member

    Tested ACK 0bc666b053b8f4883c3f5de43959e2bbd91b95c5

    lldb src/bitcoind on master:

    0* thread [#13](/bitcoin-bitcoin/13/), name = 'b-httpworker.2', stop reason = step over
    1    frame [#0](/bitcoin-bitcoin/0/): 0x0000000100c87baf bitcoind`LegacyScriptPubKeyMan::IsMine(this=0x000000010cbdb1e0, script=0x0000000110190988) const at scriptpubkeyman.cpp:226:1
    2Target 0: (bitcoind) stopped.
    

    Using this PR:

    0* thread [#11](/bitcoin-bitcoin/11/), name = 'b-httpworker.0', stop reason = breakpoint 1.6
    1    frame [#0](/bitcoin-bitcoin/0/): 0x0000000100cfca46 bitcoind`CWallet::IsMine(this=0x000000010490e310, txout=0x00000001090052c0) const at wallet.cpp:1299:5
    2   1296
    3   1297	isminetype CWallet::IsMine(const CTxOut& txout) const
    4   1298	{
    5-> 1299	    AssertLockHeld(cs_wallet);
    6   1300	    return IsMine(txout.scriptPubKey);
    7   1301	}
    8   1302
    9Target 0: (bitcoind) stopped.
    

    (note lack of any line numbers in master)

  29. fanquake commented at 2:34 am on October 11, 2021: member
    Going to merge this now, as it’s an improvement for debugging (the current issue has tripped up a few people), without losing the behaviour from #20353.
  30. fanquake merged this on Oct 11, 2021
  31. fanquake closed this on Oct 11, 2021

  32. sidhujag referenced this in commit 553b7e7dfa on Oct 11, 2021
  33. PastaPastaPasta referenced this in commit 87caa91a99 on Apr 3, 2022
  34. gades referenced this in commit 3c7c32baf4 on May 9, 2022
  35. DrahtBot locked this on Oct 30, 2022

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-12-17 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me