3
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.
Try
gdb /path/to/bitcoindand thenattach 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 userwhen attaching to a running process; that starts it over. – Nate Eldredge – 2017-02-18T22:59:32.057@NateEldredge : Cheers, it worked when i was root. Strangely ,i had to hit n on the console for the trace to begin. Apologies for ninja, trying a few things. – Bobo – 2017-02-18T23:07:20.107
It isn't strange. 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). – Nate Eldredge – 2017-02-18T23:09:40.567