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
  1. instagibbs commented at 2:09 PM on June 27, 2017: member

    Saved me many hours. h/t to @jnewbery for the new guide efforts

  2. 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 .pid file in the data directory. Find the data directory:

    2017-06-27 14:13:56.686000 TestFramework (INFO): Initializing test directory /tmp/user/1000/testo9vsdjo3
    

    Then cat the .pid file:

    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!)

  3. jnewbery commented at 2:24 PM on June 27, 2017: member

    ACK

    One suggested change for finding the wanted bitcoind pid more easily.

  4. instagibbs force-pushed on Jun 27, 2017
  5. instagibbs force-pushed on Jun 27, 2017
  6. instagibbs force-pushed on Jun 27, 2017
  7. instagibbs commented at 2:50 PM on June 27, 2017: member

    updated with simpler steps

  8. 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.

  9. jnewbery commented at 4:14 PM on June 27, 2017: member

    reACK

  10. add gdb attach process to test README 7ec3343df2
  11. instagibbs force-pushed on Jun 27, 2017
  12. instagibbs commented at 5:04 PM on June 27, 2017: member

    squashed last commit, same text

  13. laanwj added the label Docs and Output on Jun 28, 2017
  14. jonasschnelli commented at 7:55 PM on June 28, 2017: contributor

    ACK.

    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
  15. fanquake commented at 12:40 AM on July 6, 2017: member

    utACK 7ec3343

  16. jnewbery commented at 3:27 PM on July 19, 2017: member

    Can merge please? Simple docs change with 3 ACKs.

  17. MarcoFalke commented at 8:43 PM on July 19, 2017: member

    utACK 7ec3343df21aae30bf782f77171f5e4d9a1d5e65

  18. MarcoFalke merged this on Jul 19, 2017
  19. MarcoFalke closed this on Jul 19, 2017

  20. MarcoFalke referenced this in commit df0793f324 on Jul 19, 2017
  21. PastaPastaPasta referenced this in commit 737d36e7cf on Jul 17, 2019
  22. PastaPastaPasta referenced this in commit 219f470042 on Jul 17, 2019
  23. PastaPastaPasta referenced this in commit bc5d6ae2c1 on Jul 23, 2019
  24. PastaPastaPasta referenced this in commit d587fe3f0e on Jul 24, 2019
  25. barrystyle referenced this in commit fcdff1d92b on Jan 22, 2020
  26. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

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

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me