Go Remote debugging: the editor does not open the source file
Problem
A Go Remote run/debug configuration connects to Delve on a remote machine or in a container. The debugger stops on a panic or on a breakpoint and the stack frames appear, but the editor does not open the matching source file. Breakpoints render as a circle with a slash instead of a red dot.
Cause
GoLand maps remote source paths to local files automatically, which is why the configuration has no mapping table. The build directory does not have to exist locally: a binary built in a directory that was deleted afterwards still resolves its frames to the project.
The mapping is built one file at a time. A frame resolves to a local file only when a breakpoint was set in that file before the stop, so a panic can produce a complete stack and no editor.
GoLand sends no substitution rules to Delve, so Delve's own substitute-path option has no effect on a GoLand session.
Resolution
- Set a line breakpoint in each file the editor needs to open, before reproducing the problem. Any line in the file works.
- Open the sources that produced the binary in the local project.
The full remote setup, including the build flags Delve needs, is documented in Attach to running Go processes with the debugger.
Bazel projects
Bazel records source paths relative to the execution root, for example greet/greet.go, so a binary built in a container carries the same strings as one built locally. These relative paths resolve without the Bazel plugin installed.
With the Bazel plugin installed, a failed match writes a warning to idea.log:
Server could not resolve remote path '<path>' to local path.
The line names the path recorded in the binary. Comparing it against the project layout shows which prefix does not match.
If the file still does not open
GoLand can match a file to a different file with the same name, for example one in the Go SDK, which leaves the breakpoint disabled. That defect is open and tracked in GO-19917.
- Reproduce the session once with the Go Remote configuration.
- Select Help | Collect Logs and Diagnostic Data from the main menu.
- Upload the resulting ZIP file to
uploads.jetbrains.comand send the Upload ID to support.
Please sign in to leave a comment.