[RFC,0/7] gdb: replay diversion support

Message ID v_ns5mbr17x_mbagxbzcmt8-2qrh-xm2o5n7-94jd.6afy5d0/r7@mail.bob131.so
Headers show
  • gdb: replay diversion support
Related show


Tom de Vries via Gdb-patches June 1, 2021, 7:10 p.m.
This patch series makes the GDB core aware of temporary diversions of
execution in a replay target and adds a remote protocol extension for
manipulating such diversions.

* Background

rr[1] is a deterministic process record and replay system for
Linux. Recording works by trapping on sources of non-deterministic
inputs (such as system calls, `rdtsc', signals, etc) during execution
and saving the inputs in a trace; replay executes the program,
intercepting these same sources and writing the previously-recorded
results to the process state. A GDB remote target is implemented for
interactive debugging of the replay. This enables space-efficient
whole-program record and replay with nifty features like reverse
debugging (if you've not already done so, definitely check it out!).

One of the cool features enabled by this approach is support for
inferior calls, since replay involves an actual live inferior
executing code; however, maintaining determinism means any state
changes must not impact replay and are necessarily limited in scope
and duration. rr solves this by attempting to detect when GDB is about
to start an inferior call and creating a 'diversion session' (a clone
of the process and rr state); this diversion session becomes the
inferior on which GDB operates until the next continue, at which point
the diversion is destroyed and the original replay session takes
over. This is usually transparent to both GDB and the user, but doing
this under GDB's nose has been a continuing source of bugs.

* Purpose

The goal of this series is to move the diversion session logic out of
rr and into GDB: rather than rr using heuristics and hacks to try and
guess what GDB wants and trying to manipulate state under it, GDB is
aware of diversions and is responsible for telling rr when to start
and end diversions. Obviously this work has been done with rr in mind,
but since the basic concept behind rr is fairly general I've tried to
design an interface that should be equally applicable to other rr-like

The proposed changes to rr can be found here.[2]

[1]: https://rr-project.org/
[2]: https://github.com/rr-debugger/rr/pull/2877

George Barrett (7):
  gdb: add replay diversion interface to target_ops
  gdb: handle early replay diversion exits
  gdb/remote: add vReplayDiversion packet
  gdb/inferior: add replay diversion state
  gdb/infcall: enter replay diversion before call
  gdb/infrun: solo thread resume in replay diversion
  gdb/infcmd: add replay diversion commands

 gdb/doc/gdb.texinfo     |  40 ++++++++++++++
 gdb/infcall.c           |   6 +++
 gdb/infcmd.c            |  59 +++++++++++++++++++-
 gdb/inferior.c          |  23 ++++++++
 gdb/inferior.h          |  21 ++++++++
 gdb/infrun.c            |  41 ++++++++++++--
 gdb/remote.c            | 116 ++++++++++++++++++++++++++++++++++++++--
 gdb/target-delegates.c  | 100 ++++++++++++++++++++++++++++++++++
 gdb/target.c            |  32 +++++++++++
 gdb/target.h            |  31 +++++++++++
 gdb/target/waitstatus.c |   2 +
 gdb/target/waitstatus.h |   4 ++
 12 files changed, 466 insertions(+), 9 deletions(-)