Saved me many hours. h/t to @jnewbery for the new guide efforts
add gdb attach process to test README #10681
pull instagibbs wants to merge 1 commits into bitcoin:master from instagibbs:gdbattach changing 1 files +20 −0-
instagibbs commented at 2:09 PM on June 27, 2017: member
-
in test/README.md:163 in 6ff9d427b1 outdated
154 | @@ -155,6 +155,26 @@ import pdb; pdb.set_trace() 155 | anywhere in the test. You will then be able to inspect variables, as well as 156 | call methods that interact with the bitcoind nodes-under-test. 157 | 158 | +If further introspection of the bitcoind instances themselves becomes 159 | +necessary, this can be accomplished by first setting a pdb breakpoint 160 | +at an appropriate location, running the test to that point, then using 161 | +`gdb` to attach to the process and debug: 162 | + 163 | +```bash
jnewbery commented at 2:24 PM on June 27, 2017:I think this can be more easily achieved by
cating the.pidfile in the data directory. Find the data directory:2017-06-27 14:13:56.686000 TestFramework (INFO): Initializing test directory /tmp/user/1000/testo9vsdjo3Then
catthe.pidfile:cat /tmp/user/1000/testo9vsdjo3/node0/regtest/bitcoind.pid gdb /home/example/bitcoind !$(or if you really have to show off):
gdb /home/example/bitcoind $(cat /tmp/user/1000/testo9vsdjo3/node0/regtest/bitcoind.pid)
jnewbery commented at 2:33 PM on June 27, 2017:perhaps also mention that this may require superuser privileges, so may need
sudo gdb ...
instagibbs commented at 2:43 PM on June 27, 2017:I assume most will get "permission denied" and sudo but maybe it's best to say
jnewbery commented at 3:13 PM on June 27, 2017:Yeah - if gdb can't attach to a specific PID, the error message is actually buried in the middle of the gdb text so it's not immediately obvious what the problem is. I think including the warning is helpful here.
Also, my above invocation was wrong:
cat /tmp/user/1000/testo9vsdjo3/node0/regtest/bitcoind.pid gdb /home/example/bitcoind !$it should be:
cat /tmp/user/1000/testo9vsdjo3/node0/regtest/bitcoind.pid gdb /home/example/bitcoind <pid>(sorry - trying to be too clever!)
jnewbery commented at 2:24 PM on June 27, 2017: memberACK
One suggested change for finding the wanted bitcoind pid more easily.
instagibbs force-pushed on Jun 27, 2017instagibbs force-pushed on Jun 27, 2017instagibbs force-pushed on Jun 27, 2017instagibbs commented at 2:50 PM on June 27, 2017: memberupdated with simpler steps
in test/README.md:176 in 81fe0d4cfc outdated
171 | +```bash 172 | +cat /tmp/user/1000/testo9vsdjo3/node1/regtest/bitcoind.pid 173 | +gdb /home/example/bitcoind <pid> 174 | +``` 175 | + 176 | +Note: gdb attach step may require `sudo`
laanwj commented at 4:00 PM on June 27, 2017:I usually prefer
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope(on development machines) to running gdb itself as root.
jnewbery commented at 4:14 PM on June 27, 2017: memberreACK
add gdb attach process to test README 7ec3343df2instagibbs force-pushed on Jun 27, 2017instagibbs commented at 5:04 PM on June 27, 2017: membersquashed last commit, same text
laanwj added the label Docs and Output on Jun 28, 2017jonasschnelli commented at 7:55 PM on June 28, 2017: contributorACK.
I personally use a different approach (I guess it's more complicated, though will not need to attach and works with IDE's)
- replace a self.node object in the test with a custom added AuthProxy (to localhost and a fix port with a given rpcusername/pw)
- Start (via IDE, gdb) a such localhost regtest peer (make sure it has an empty datadir)
- run test
fanquake commented at 12:40 AM on July 6, 2017: memberutACK 7ec3343
jnewbery commented at 3:27 PM on July 19, 2017: memberCan merge please? Simple docs change with 3 ACKs.
MarcoFalke commented at 8:43 PM on July 19, 2017: memberutACK 7ec3343df21aae30bf782f77171f5e4d9a1d5e65
MarcoFalke merged this on Jul 19, 2017MarcoFalke closed this on Jul 19, 2017MarcoFalke referenced this in commit df0793f324 on Jul 19, 2017PastaPastaPasta referenced this in commit 737d36e7cf on Jul 17, 2019PastaPastaPasta referenced this in commit 219f470042 on Jul 17, 2019PastaPastaPasta referenced this in commit bc5d6ae2c1 on Jul 23, 2019PastaPastaPasta referenced this in commit d587fe3f0e on Jul 24, 2019barrystyle referenced this in commit fcdff1d92b on Jan 22, 2020DrahtBot locked this on Sep 8, 2021Labels
This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-22 18:15 UTC
More mirrored repositories can be found on mirror.b10c.me