RFC strace via gdbserver

Josh Stone jistone at redhat.com
Wed Jan 20 20:10:25 UTC 2016


Hi,

I've been experimenting with using strace via gdbserver, through the gdb
remote protocol.  It's now in good enough state that I'd like to get
some feedback.

First, syscall support in gdbserver is very new.  There was a patch
posted a few years ago by Philippe Waroquiers, but I only just finished
getting that merged last week.  This will be in GDB 7.11:
https://sourceware.org/git/?p=binutils-gdb.git;a=commit;h=82075af2c14b1f8a54fa5796fb63f7ef23f98d9d

You can find my strace hacking at github.com/cuviper/strace/.  It adds a
"-G host:port" option to point to a listening gdbserver.  However I've
mostly just tested this on localhost so far, and surely cross-arch stuff
won't work.

I'm not necessarily looking for a code review though, as I definitely
took some prototyping shortcuts and this is not in merge-able state.
Even the branch point from strace master is pretty old now -- I'm now
working on rebasing that.  As RFCs go, I'm more looking for feedback on
the concept.

Why would one want this?  At a first glance, I hope even just "remote
strace" is interesting.  That isn't just over TCP as implemented now,
but eventually any way that gdbserver can be reached, like serial
debugging as it was originally started.  GDBserver is smaller than the
strace binary too, so you could add just gdbserver on your remote hosts,
containers, etc. to support both gdb and strace.

My colleague Stan Cox is also working on letting gdbserver work with
multiple clients, even allowing them to independently attach to the same
process.  So you can basically use this like a ptrace multiplexer,
letting you use strace and gdb on the same process!
https://sourceware.org/git/?p=archer.git;a=shortlog;h=refs/heads/scox/globalstate

He also has a dyninst branch, which means you could strace a process
that's also being instrumented at the same time.
https://sourceware.org/git/?p=archer.git;a=shortlog;h=refs/heads/scox/dyninst


All feedback is welcome.  If you think this might be interesting enough
to properly merge into strace, I'd especially appreciate guidance on how
to best approach that.

Thanks!

Josh




More information about the Strace-devel mailing list