GoLand

GoLand is a Go IDE from JetBrains, available from the JetBrains website.

GoLand uses the Delve debugger internally to support Time Travel Debugging. Programs can either be recorded and replayed directly within GoLand or recordings from LiveRecorder can be loaded.

Enabling UDB within GoLand

At present there is no built in configuration in GoLand to allow selection of UDB. To use UDB in GoLand:

  1. Fetch and install the version of Delve with Undo support

    This needs to replace the dlv binary in your GoLand tree. The UDB release ships with a script to do this, called patch-goland-delve. This must be called as:

    patch-goland-delve <goland-base-path>

    <goland-base-path> should be the path to your GoLand installation. It will save the original version of Delve to dlv.orig. Running patch-goland-delve -u <goland-base-path> will restore this original binary.

  2. Launch GoLand with an additional environment variable

    To allow GoLand to select the UDB backend for recording and replaying, the environment variable DLV_RECORD_REPLAY_BACKEND must be set to undo. Depending on how you launch GoLand this can be achieved in various ways. If launching from a shell in the GoLand base path, run:

    DLV_RECORD_REPLAY_BACKEND=undo bin/goland.sh

Using UDB within GoLand

GoLand integrates with UDB in two ways:

  • replaying existing saved recordings, with Debug Saved Trace.
  • recording and immediately replaying, with Record and Debug.

Note that in both modes of operation playback will start immediately. If there are no breakpoints execution will need to be paused manually.

GoLand’s Time Travel Debugging functionality is currently limited to a “reverse continue” operation, which will run backwards until a breakpoint of some sort is hit, or we reach the beginning of the recording. To access this, use the Run -> Rewind menu option or the goland-rewind button.

To load an existing recording, use the menu option Run -> Debug Saved Trace…. In the current version of GoLand the user interface prompts for the Trace directory. This should not in fact be a directory, but a LiveRecorder recording file.

To run in Record and Debug mode use the Run -> Record and Debug menu option or the goland-record button.