gdb over irc

Python scripting in gdb 7.0 kicks total ass. Today I played around with one cool usecase for it: Remote debugging.

I don’t know how many times I have tried to help someone debug over irc, with the person cutting and pasteing gdb commands and results into xchat. Well, no more! Today I hacked up a gdb python script and an xchat python script that lets you export a gdb session over irc:

From gdb:

(gdb) source 
gdb irc server, Waiting for connection on /tmp/gdb-socket-500

In xchat:

> /load ~/
Loaded xchat-gdb
> /join #test
> /gdb connect
connecting to gdb...

Loggin in as another user on irc:

> /join #test
> alex: gdb print "yey"
<alex> $6 = "yey"
> alex: gdb bt 2
<alex> #0  0x00000035010d50d3 in *__GI___poll (fds=<value optimized out>, nfds=<value optimized out>, timeout=-1) at ..
<alex> #1  0x00007ffff52f96cc in g_main_context_poll (n_fds=<value optimized out>, fds=<value optimized out>,
+priority=<value optimized out>, timeout=<value optimized out>, context=<value optimized out>) at gmain.c:2904

Obviously this is kinda unsafe as you can do all sorts of things via gdb. It needs to be able to limit who can control your gdb instance, and you should only give such permissions to people you trust.

Git repo here, have fun with it.

14 Responses to “gdb over irc”

  1. otte says:

    Yay, most useful hack of the week!

    Also, get a freedesktop account and store your repos there please. Freedesktop has cgit.

  2. Danni says:

    This could also be implementing using telepathy-python. For some awesome peer-to-peer debugging.

  3. […] This post was mentioned on Twitter by mr. u. mr. u said: #cool #hack: !gdb over !irc with #xchat […]

  4. website says:

    gdb shell cat /etc/passwd

  5. alexl says:

    website: Thats relatively benign, why not “rm -rf ~/”?

    As I said, there are clear security issues with this.

  6. Chris S. says:

    Oh that is too cool!

  7. datakid says:

    Why don’t people just use one of the free pastebins? That’s how I’ve _always_ done my questions/support in irc.

  8. Olivier Le Thanh says:

    @datakid, that’s what all the people use but it doesn’t allow to send commands directly to the DGB of the person you are trying to help which is why his solution is so nice.

  9. alexl says:

    In fact, it might be a cool idea if xchat-gdb auto-used a pastebin for replies longer than say two lines.

  10. […] de Python dentro del mismo, las posibilidades de depuración se han ampliado enormemente. En este post podemos ver un ejemplo de como depurar una aplicación a través de xchat usando un pequeño script […]