Bitcoin Stack Exchange is a question and answer site for Bitcoin crypto-currency enthusiasts. It only takes a minute to sign up.
Sign up to join this communityAnybody can ask a question
Anybody can answer
The best answers are voted up and rise to the top
How do you attach a gdb to a bitcoind daemon. I wish to step through the functions. Here is what i have tried.
gdb --args bitcoind -regtest -daemon
This however exists when the daemon starts. So i tried attaching via the pid after the fork.
gdb -p 841 (gdb) file /usr/local/bin/bitcoind Reading symbols from /usr/local/bin/bitcoind...done. (gdb) b sendtoaddress Breakpoint 1 at 0x4b4d34: file wallet/rpcwallet.cpp, line 379. r starting program...
This however does not work , when i invoke a transaction using the bitcoin-cli client. Is there anything i am missing. I have used --enable debug on configure.
Thanks.
As Nate Eldrige commented:
Try gdb /path/to/bitcoind and then attach 841. However, what OS are you on? Some don't allow normal users to attach debuggers to running processes; you would have to be root. Don't use r when attaching to a running process; that starts it over
Using attach (or -p) simply stops the process wherever it is and lets you inspect its state (e.g. where, print, ...), set breakpoints, modify its memory if you wish. When you want the process to do any further execution you have to issue an appropriate command (n,s,c).
If you are on MacOS this document might be useful from Fabian Jahr. He recommends using lldb rather than gdb if you are on MacOS.
You can get bonuses upto $100 FREE BONUS when you:
π° Install these recommended apps:
π² SocialGood - 100% Crypto Back on Everyday Shopping
π² xPortal - The DeFi For The Next Billion
π² CryptoTab Browser - Lightweight, fast, and ready to mine!
π° Register on these recommended exchanges:
π‘ Binanceπ‘ Bitfinexπ‘ Bitmartπ‘ Bittrexπ‘ Bitget
π‘ CoinExπ‘ Crypto.comπ‘ Gate.ioπ‘ Huobiπ‘ Kucoin.
Comments