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.
gdb /path/to/bitcoind
and 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 user
when attaching to a running process; that starts it over. – Nate Eldredge Feb 18 '17 at 22:59attach
(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 Feb 18 '17 at 23:09