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:
Fetch and install the version of Delve with Undo support
This needs to replace the
dlv
binary in your GoLand tree. Undo’s Delve repository includes a script to do this calledpatch-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 todlv.orig
. Runningpatch-goland-delve -u <goland-base-path>
will restore this original binary.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 toundo
. 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 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 an Undo recording file.
To run in Record and Debug mode use the Run -> Record and Debug menu option or the button.