Skip to content

Conversation

@mark-undoio
Copy link
Contributor

This PR reworks the way we've layered code in our fork, without changing functionality.

Goals:

  • Concentrate Undo-specific logic, as far as reasonably possible, into undo.go.
  • Represent things at logically sensible layers in Delve, though with a bias towards our code living in undo.go as part of maintaining the ongoing fork.
  • Simplify code where possible.

Notable changes:

  • isUndoServer boolean is removed from the gdbConn structure.
  • *undoSession pointer is moved from the gdbProcess structure down into the gdbConn level.
  • undoCmd is moved from gdbserver_conn.go into undo.go
  • Progress indicator / volatile mode handling for ContinueOnce and Restart is moved as far as possible into undo.go.
  • A number of smaller cleanups and simplifications are applied.

Follow-on plans:

  • Revisit the grouping of functions in undo.go - I think they could be in a better order.
  • Squish our patches down to make it easier to forward-port them to the new Delve v1.21.0 release.

gareth-rees and others added 23 commits May 4, 2023 16:06
In Undo, debuggee state is immutable during replay, so reading the G
pointer via code injection won't work; and in any case, this approach
is simpler.
* Update the documentation to mention UDB or LiveRecorder alongside rr.
* Add makefile support for testing the Undo backend.
* Add DLV_RECORD_REPLAY_BACKEND environment variable which overrides
  the record-replay backend, for use in GoLand.
* Implement checkpoints as a map from checkpoint number to time.
* Suppress resume call after restart.
* Implement "when" command using "get_time" serial command.
* Implement call injection using "set_debuggee_volatile".
* Implement "restart" using "goto_time".
* Enable or disable Undo backend appropriately in test cases.
This changeset fixes a bug in which, after continuing to the end of a loaded
LiveRecorder recording, it became impossible to reverse into the debug session.

By using the same technique already implemented for rr support it is now
possible to reach the end of time and then continue debugging. In addition, the
exit code (where available) be reported correctly - although it will be reported
as zero at the end of time if no exit was recorded.

A workaround for apparent SIGCHILD handling (actually SIGSTOP, due to how the
gdbserial protocol encodes signals) is removed as it is not required with this
new implementation.
This fixes a bug in which it was not possible to reverse debug after a stepping
operation e.g. next encountered the end of recorded history.
This ensures that the Undo backend can always find the server when `udb` is on
the `PATH`.  System-wide installs of UDB don't put the server on `PATH` by
default, so this simplifies Delve setup in those cases.
The error handling here was a bit painful but only needs doing in these two
places (for now).
This makes it possible to apply a standard formatting to Undo times from
anywhere in the code that requires it - this will later be used to display
checkpoint times.
This is for readability and for consistency with the existing UDB convention.
Allow fast navigation to extremes of history.
This changeset adds validation for the `start` / `end` magic arguments to the
`restart` command, plus adds parsing for directly-specified bbcounts or
bbcount:pc times.

Doing the validation early allows us to bail out before the function makes any
changes to global state.  Parsing time specifications directly allows the user
to jump to a time without it having a pre-existing checkpoint.
This is made compatible with UDB's bookmarks by using the UDB bookmark name as
the "Note" field in Delve. To save Delve checkpoints, the "Note" must be made
unique, so as to be a valid bookmark name in UDB.
This is in line with the actual use of this variable.
Previously we were trying to interpret an empty command as a time, which was not
correct.
During inferior calls we are in volatile mode and should not attempt to use
progress indicators. By tracking volatile mode we are able to correctly skip
progress indicator commands.
This layer doesn't need to concern itself with gdbProcess structures for now.
@mark-undoio mark-undoio force-pushed the undo-v1.20.2-4-refactor-layers branch from a58829f to b4fea42 Compare August 2, 2023 21:26
Move undoSession struct down to the gdbConn level.
The current implementation of `restart()` is trying to fit us into the model
used by `rr` but it's not a very natural fit.

It's also convenient to concentrate our code in `undo.go` where possible, since
we're still maintaining a fork.
If we were a fully integrated backend then the undoCmd probably should live with
the gdbConn code - but, for now, we're maintaining a fork and this should be
easier to handle.
The exact details of when we'll activate them and how we do so are not relevant
to the `gdbserver.go` code.
@mark-undoio mark-undoio force-pushed the undo-v1.20.2-4-refactor-layers branch from b4fea42 to 3678774 Compare August 2, 2023 21:30
@mark-undoio mark-undoio requested a review from gareth-rees August 3, 2023 10:55
@mark-undoio
Copy link
Contributor Author

I've moved on with this - I'll be rebasing and squashing these changes on top of v1.21.0 as a foundation for our next release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants