RFC: Debugging interface (gdb)

Chris Jones jones.chris.g at gmail.com
Wed May 22 19:22:39 PDT 2013

I've been investigating getting rr to act as a "gdbserver", so that
replayed programs can be debugged from within gdb.  The purpose of this
message is to ensure everyone is comfortable with the implementation

The higher-level planning is at


If tl;dr, the salient parts are
 - get the 80/90% use cases supported as quickly as possible in a "v1",
punt everything else
 - add a |--debug [trace]| command
 - don't bother much with abstraction, code for gdb (a la ptrace tracing)

There's a skeleton implementation up at


It can exchange some "small talk" with gdb, but doesn't do anything useful
yet.  The point of the current code is to show the implementation skeleton.
 Briefly, it looks like
 - when |rr --debug| starts up, binds to a debugging socket and waits for
the host (gdb) to connect
 - after that, the --debug code goes into an "event loop" that looks like
   1. poll for a new gdb request, blocking if necessary
      a. if request needs data immediately, find it and reply.  GOTO (1)
   2. continue execution per "resume request" (continue/step) as
appropriate, until done/interrupted
   3. notify gdb host, GOTO (1)

 - all the new code is in $rr/src/debugger; it's cloned from replayer/
 - debugger.c asks a function implemented in dbg_gdb.c for requests, and
then replies using the "public interface" of dbg_gdb.h.  That interface is
intended to be stateless (unlike the gdb protocol).
 - dbg_gdb.c handles all the details of talking to the gdb host, i.e.
implementing the low-level gdb protocol

When you read the debugger/ code, you'll see that the shared files are 99%
identical to replayer/, which is not coincidental since the debugger/
functionality is a superset of replayer/.  My plan is that once debugger/
is working, merge the two folders and turn the "--replay" command into a
"null debugger" that just always says "continue".  This is what
src/debugger/ code does right now, essentially.  That will eliminate the
code duplication.  (The "--replay" command is still useful on its own for
at least unit tests.)

Comments/questions are welcome, as always.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/rr-dev/attachments/20130522/297000bc/attachment.html>

More information about the rr-dev mailing list