Re:Instant replay: Debugging C and C++ programs with rr
by tracnar on Tuesday May 04, 2021 @05:26PM
(#27043097)
AFAIK criu does something like what you describe, similarly to taking VM snapshots but for processes or containers: https://criu.org/Main_Page
Re:Instant replay: Debugging C and C++ programs with rr
by peter_d_sherman on Wednesday May 05, 2021 @03:42PM
(#27054692)
Excellent Link! Thanks!
PDS: An awesome set of ideas! A sorely lacking feature in most debuggers...
Actually, now that I think about it... there's this notion of "machine state" associated with any point in time of any given program run...
"Machine State" (of a program run, at a point in time) -- not only includes the set of processor registers at that point in time and the memory used by the program -- but also such things as OS entities, like files, sockets, critical sections, shared memory, etc., that are open and active (and their state!) -- at given point in time, during a program's run...
It may be somewhat infeasible for today's Operating Systems to do this, but in the future, it might be possible to take a "snapshot" of a program (CPU, registers, memory, open OS objects, eveything) at a given point in time -- then be able to reload that snapshot into a debugger and move forward in time from there...
On the one hand, OS'es have had for the longest time, the ability to write "Crash Dumps" of failed programs to disk, and debuggers can load them up and see machine state at the point of the crash -- but you typically can't reverse the program a series of steps from that point, nor can you re-create the now-closed OS objects that the program was holding on to -- nor reinstate their exact state at a given time, which would be necessary to run the point-in-time program snapshots as if nothing happened...
But future OS's -- will/should -- be able to (if requested) -- store state information about a program's open OS objects at a given point in time (perhaps that should be a series of new OS API calls? Like perhaps SnapshotAllOSObjectsUsedByThisProgramNow(); and RestoreAllOSObjectsUsedByThisProgramAtTime(Time);...?). But that's just speculative at this point...
Also -- wouldn't Plan 9 and other OS'es like it, ones that have the ability to move programs/processes from one physical machine to another while the program is running, have the preexisting infrastructure to snapshot a program's open OS objects at points in time, with very little code modification? It seems like they might...
Anyway, rr is a great and awesome step forward for debugging!