Skip to content

doc: update .lldbinit configuration for cmake builds to see source code in debugger - #32205

Closed
pinheadmz wants to merge 1 commit into
bitcoin:masterfrom
pinheadmz:doc-lldbinit
Closed

pinheadmz wants to merge 1 commit into
bitcoin:masterfrom
pinheadmz:doc-lldbinit

Conversation

@pinheadmz

Copy link
Copy Markdown
Member

Closes #31204

To reproduce:

  1. build bitcoin with -DCMAKE_BUILD_TYPE=Debug
  2. run with lldb, add a breakpoint and trigger it (with a second local bitcoind peer, for example):
    • lldb buld/bin/bitcoind
    • (lldb) b ProcessMessage
    • (lldb) r -regtest
      Output will probably look like this:
Process 6764 stopped
* thread #34, name = 'b-msghand', stop reason = breakpoint 1.1
    frame #0: 0x00000001003380c0 bitcoind`(anonymous namespace)::PeerManagerImpl::ProcessMessages(this=0x000000013e80e400, pfrom=0x000000013c70a830, interruptMsgProc=0x000000013d009d40) at net_processing.cpp:4933:5

To fix (following the doc in this PR)
Create or append to ~/.lldbinit in your $HOME directory, using absolute paths. (My example)

settings set target.source-map /Users/matthewzipkin/Desktop/work/bitcoin/build/src /Users/matthewzipkin/Desktop/work/bitcoin/src

Improved output:

Process 6811 stopped
* thread #34, name = 'b-msghand', stop reason = breakpoint 1.1
    frame #0: 0x00000001003380c0 bitcoind`(anonymous namespace)::PeerManagerImpl::ProcessMessages(this=0x000000011c808800, pfrom=0x0000000104004080, interruptMsgProc=0x000000011d009140) at net_processing.cpp:4933:5
   4930
   4931 bool PeerManagerImpl::ProcessMessages(CNode* pfrom, std::atomic<bool>& interruptMsgProc)
   4932 {
-> 4933     AssertLockNotHeld(m_tx_download_mutex);
   4934     AssertLockHeld(g_msgproc_mutex);
   4935
   4936     PeerRef peer = GetPeerRef(pfrom->GetId());

@DrahtBot

DrahtBot commented Apr 2, 2025 •

Copy link
Copy Markdown
Contributor

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

Code Coverage & Benchmarks

For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32205.

Reviews

See the guideline for information on the review process.

Type Reviewers
ACK janb84

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

@janb84 janb84 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ACK 3a77f13

Before:

Process 52169 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
    frame #0: 0x000000010021547c bitcoind`AddLocal(addr=0x000000012600fe00, nScore=1) at net.cpp:307:30

After changes per instruction:

Process 52277 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 3.1
   frame #0: 0x00000001007f2d58 bitcoind`addnode() at net.cpp:307:23
  304 
  305  static RPCHelpMan addnode()
  306  {
-> 307      return RPCHelpMan{"addnode",
  308                  "\nAttempts to add or remove a node from the addnode list.\n"
  309                  "Or try a connection to a node once.\n"
  310                  "Nodes added using addnode (or -connect) are protected from DoS disconnection and are not required to be\n"

@mabu44 mabu44 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For me it works out of the box, without any lldbinit file. I am on Debian 12 with ccache installed.

cmake -B build_debug -DCMAKE_BUILD_TYPE=Debug
cmake --build build_debug -j 4 -t bitcoind
lldb-16 build_debug/bin/bitcoind
b ProcessInitCommands
r -regtest

Output:

Process 91637 launched: '/home/brown/bitcoin/build_debug/bin/bitcoind' (x86_64)
Process 91637 stopped
* thread #1, name = 'bitcoind', stop reason = breakpoint 1.1
    frame #0: 0x000055555558751f bitcoind`ProcessInitCommands(args=0x0000555556a77b80) at bitcoind.cpp:138:29
   135 	static bool ProcessInitCommands(ArgsManager& args)
   136 	{
   137 	    // Process help and version before taking care about datadir
-> 138 	    if (HelpRequested(args) || args.GetBoolArg("-version", false)) {
   139 	        std::string strUsage = CLIENT_NAME " daemon version " + FormatFullVersion() + "\n";
   140 	
   141 	        if (args.GetBoolArg("-version", false)) {

@ismaelsadeeq

Copy link
Copy Markdown
Member

@pinheadmz re #34081 (comment)

I also see the same output for test_bitcoin after updating the target.source-map based on the steps you provided here.

@pinheadmz

Copy link
Copy Markdown
Member Author

Closing, the approach in #34081 is way better

@pinheadmz pinheadmz closed this Dec 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Source code mapping for debugger has changed since cmake

5 participants