0

I want to debug "decoderawtransaction" rpc call for learning.

I tried it with the following page as a reference but I could not find the way. Can you help me?

https://gist.github.com/gubatron/36784ee38e45cb4bf4c7a82ecc87b6a8

I think I need to add a break point in the rpc thread.

What I did:

$ cd /home/zono/bitcoinA/src

$ git branch
* v0.17.1

$ ./bitcoind -server -listen -port=17591 -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -datadir=$HOME/regtest/A/ -regtest -pid=$HOME/regtest/A/.pid -debug -listenonion=0 -rpcthreads=1 -daemon
Bitcoin server starting

$ ps -ef | grep bitcoind

$ sudo gdb ./bitcoind 31525

GNU gdb (Ubuntu 7.11.1-0ubuntu1~16.5) 7.11.1
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "x86_64-linux-gnu".
Type "show configuration" for configuration details.
For bug reporting instructions, please see:
<http://www.gnu.org/software/gdb/bugs/>.
Find the GDB manual and other documentation resources online at:
<http://www.gnu.org/software/gdb/documentation/>.
For help, type "help".
Type "apropos word" to search for commands related to "word"...
Reading symbols from ./bitcoind...done.
Attaching to program: /home/zono/bitcoinA/src/bitcoind, process 31525
[New LWP 31526]
[New LWP 31527]
[New LWP 31528]
[New LWP 31529]
[New LWP 31531]
[New LWP 31533]
[New LWP 31534]
[New LWP 31535]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
0x00007fde316b4c1d in nanosleep () at ../sysdeps/unix/syscall-template.S:84
84  ../sysdeps/unix/syscall-template.S: No such file or directory.

(gdb) b rawtransaction.cpp:68
Breakpoint 1 at 0x55eb1e09f6b2: file rpc/rawtransaction.cpp, line 68.

(gdb) info thread
  Id   Target Id         Frame
* 1    Thread 0x7fde326c1740 (LWP 31525) "bitcoind" 0x00007fde316b4c1d in nanosleep ()
    at ../sysdeps/unix/syscall-template.S:84
  2    Thread 0x7fde2d5ad700 (LWP 31526) "bitcoin-scriptc" pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
  3    Thread 0x7fde2cdac700 (LWP 31527) "bitcoin-schedul" pthread_cond_timedwait@@GLIBC_2.3.2 ()
    at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225
  4    Thread 0x7fde27fff700 (LWP 31528) "bitcoin-http" 0x00007fde3004ca13 in epoll_wait ()
    at ../sysdeps/unix/syscall-template.S:84
  5    Thread 0x7fde277fe700 (LWP 31529) "bitcoin-httpwor" pthread_cond_wait@@GLIBC_2.3.2 ()
    at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_wait.S:185
  6    Thread 0x7fde2627b700 (LWP 31531) "bitcoin-net" 0x00007fde300425d3 in select ()
    at ../sysdeps/unix/syscall-template.S:84
  7    Thread 0x7fde25279700 (LWP 31533) "bitcoin-addcon" pthread_cond_timedwait@@GLIBC_2.3.2 ()
    at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225
  8    Thread 0x7fde24a78700 (LWP 31534) "bitcoin-opencon" pthread_cond_timedwait@@GLIBC_2.3.2 ()
    at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225
  9    Thread 0x7fde13fff700 (LWP 31535) "bitcoin-msghand" pthread_cond_timedwait@@GLIBC_2.3.2 ()
    at ../sysdeps/unix/sysv/linux/x86_64/pthread_cond_timedwait.S:225

// from another console. but it does not stop as I expect.
$ ./bitcoinA/src/bitcoin-cli -rpcuser=bitcoinrpc -rpcpassword=bitcoinrpcpass -rpcport=16591 -regtest  decoderawtransaction 0200000001fdb0e05d8d3ecc04dad8513057410c7d827314c6ba732a3156368efb5cab36d10000000000ffffffff01606b042a010000001976a9141774241adc93f662e367fcd161aad90bf8ce320988ac00000000

Update 1

Oh. sorry I think I found the answer.

(gdb) b decoderawtransaction
Breakpoint 2 at 0x55eb1e09b870: file rpc/rawtransaction.cpp, line 508.
(gdb) n
[Switching to Thread 0x7fde277fe700 (LWP 31529)]

Thread 5 "bitcoin-httpwor" hit Breakpoint 2, decoderawtransaction (request=...) at rpc/rawtransaction.cpp:508
508 {
(gdb) n
509     if (request.fHelp || request.params.size() < 1 || request.params.size() > 2)
(gdb) n
565     LOCK(cs_main);
(gdb) n
566     RPCTypeCheck(request.params, {UniValue::VSTR, UniValue::VBOOL});
(gdb)

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.