Skip to content
This repository was archived by the owner on Jul 15, 2023. It is now read-only.

Debugger does not stop on breakpoints when debugging tests #1935

Closed
jadolg opened this issue Sep 21, 2018 · 22 comments
Closed

Debugger does not stop on breakpoints when debugging tests #1935

jadolg opened this issue Sep 21, 2018 · 22 comments
Labels
debug help wanted needs more info symlink Issues that occur when symlinks are used

Comments

@jadolg
Copy link

jadolg commented Sep 21, 2018

Hey there,
I'm writing an application and trying to debug one of my tests using the debug test option on top of the method
image
and I have set a breakpoint on this method. When the option is clicked my test runs but it won't stop on the breakpoint.
The breakpoint is listed on the breakpoints list and marked as a red dot in the IDE.
image

@ramya-rao-a
Copy link
Contributor

Can you write a simple test case and see if debugging works for that? Say

func TestSimple(t *testing.T) {
	a := 1
	t.Log(a)
}

@jadolg
Copy link
Author

jadolg commented Sep 27, 2018

Exactly the same behavior. Is there any other way to collect more information?

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Sep 27, 2018

Yes of course.

Instead of using the debug test codelens, use the debug configuration for debugging tests from the launch.json file.
See https://github.com/Microsoft/vscode-go/wiki/Debugging-Go-code-using-VS-Code#set-up-configurations-in-launchjson

Once you have the configuration set up, choose it from the drop down in the debug viewlet (View -> Debug), and press F5 to start debugging.

If you still dont see the breakpoint being hit, add the below to your debug configuration:
"showLog": true and "trace": "verbose" and try again. This will show the logs in the debug console (View -> Debug Console)

@jadolg
Copy link
Author

jadolg commented Sep 27, 2018

This is the output I'm getting when I set the flags. The file and line exist both.

SetBreakPointsRequest
All cleared
Creating on: /media/akiel/data/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go:6
Error on CreateBreakpoint: could not find /media/akiel/data/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go:6
All set:[null]

@ramya-rao-a
Copy link
Contributor

Are you using symlinks by any chance?

Can you try running dlv from the command line and see if you can successfully create and hit the breakpoints?

  • Run dlv test from the terminal (make sure you are in the directory where the test file lives)
  • Once dlv creates the binary and starts the debugging session type b filename:linumber. That will create the breakpoint
  • Then press c to continue. Your breakpoint should be hit

@jadolg
Copy link
Author

jadolg commented Sep 27, 2018

yes I'm using symlinks

@ramya-rao-a
Copy link
Contributor

😭 symlinks... they make me cry.

Were you able to run dlv test and get the breakpoints to work?

@jadolg
Copy link
Author

jadolg commented Sep 27, 2018

I don't have much space on my main harddrive so I have a lot of things symlinked 😊

$ dlv test
Type 'help' for list of commands.
(dlv) b other_test.go:6
Breakpoint 1 set at 0x8b4081 for gitlab.cu.aleph.engineering/aleph.engineering/hivedm.TestSimple() /home/akiel/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go:6
(dlv) c
2018/09/27 19:46:44 Downloading http://127.0.0.1:45779/testconfig.yml...
2018/09/27 19:46:44   200 OK
2018/09/27 19:46:44 Download saved to ./test_data/download/testconfig.yml
2018/09/27 19:46:44 Downloading http://127.0.0.1:45779/filenotfound...
2018/09/27 19:46:44   404 Not Found
2018/09/27 19:46:44 Download failed: server returned a non-2XX status code
2018/09/27 19:46:44 Downloading http://127.0.0.1:36503/test_photo.jpg...
2018/09/27 19:46:44   200 OK
2018/09/27 19:46:44 Download saved to ./test_data/download_compress_split/FILE
> gitlab.cu.aleph.engineering/aleph.engineering/hivedm.TestSimple() /home/akiel/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go:6 (hits goroutine(79):1 total:1)(PC: 0x8b4081)
     1: package hivedm
     2:
     3: import "testing"
     4:
     5: func TestSimple(t *testing.T) {
=>   6:         a := 1
     7:         t.Log(a)
     8: }
(dlv)

@ramya-rao-a
Copy link
Contributor

dlv created the breakpoint at /home/akiel/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go:6 where as vs code is trying to do so at /media/akiel/data/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go:6

  • Is the file physically under /home/akiel/GOLIBS/ or /media/akiel/data/GOLIBS?
  • What is the path of the folder opened in VS Code?
  • What is the path you get when you right click on the other_test.go file in the explorer and choose Copy Path? Is that the same you see when you hover on the editor tab where the file is open?

@jadolg
Copy link
Author

jadolg commented Sep 28, 2018

  • /home/akiel/GOLIBS/ is a symlink for /media/akiel/data/GOLIBS/
  • I always open my project @ /home/akiel/GOLIBS/
  • The path resulting from Copy Path is /media/akiel/data/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm/other_test.go

@ramya-rao-a
Copy link
Contributor

Sorry for my ignorance, so the real files are under /media/akiel/data/GOLIBS/ correct?

@jadolg
Copy link
Author

jadolg commented Sep 28, 2018

indeed

@ramya-rao-a
Copy link
Contributor

ramya-rao-a commented Sep 30, 2018

The last thing I need to know is the working directory from which dlv was launched by VS Code.

  • Install the beta-version of this extension
  • Add "trace": "verbose" back to your debug configuration and debug using this configuration. In the logs, you will now get statements like Using GOPATH, Current working directory:, &Running. Can you share the output of all these 3 statements?

@jadolg
Copy link
Author

jadolg commented Oct 1, 2018

Verbose logs are written to:
/tmp/vscode-go-debug.txt
10:23:11 AM, 10/1/2018
InitializeRequest
InitializeResponse
Using GOPATH: /home/akiel/GOLIBS
Current working directory: /media/akiel/data/GOLIBS/src/gitlab.cu.aleph.engineering/aleph.engineering/hivedm
Running: /home/akiel/GOLIBS/bin/dlv test --headless=true --listen=127.0.0.1:25998 --api-version=2 --log=true --
....

@madpipeline
Copy link

I'm also experiencing this issue while using a symlinked directory.
VS Code:

Version: 1.31.1
Commit: 1b8e8302e405050205e69b59abb3559592bb9e60
Date: 2019-02-12T02:19:29.629Z
Electron: 3.1.2
Chrome: 66.0.3359.181
Node.js: 10.2.0
V8: 6.6.346.32
OS: Linux x64 4.20.10-200.fc29.x86_64

Go extension version : 0.9.2

dlv version

Delve Debugger
Version: 1.2.0
Build: $Id: 068e2451004e95d0b042e5257e34f0f08ce01466 $

@tonywenoracle
Copy link

Yes, I experienced same issue. The symlink is the root cause. After changing to use physical path, everything works fine.

@suquant
Copy link

suquant commented Apr 12, 2019

Hi all,

I got same issues and I was tried finding issues...
My investigations reveal that the problem may be in cache system of dlv.

When do you using smart variables in your launch.json configuration file like in example below.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch server with smart var",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceFolder}/cmd/server/main.go",
            "args": ["server"],
            "trace": "verbose"
        },
        {
            "name": "Launch server with full path",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "/Users/user/go/src/xxx/xxx/project/cmd/server/main.go",
            "args": ["server"],
            "trace": "verbose"
        }
    ]
}

So in case "Launch server with full path" it will works fine if that break points did not used in "Launch server with smart var" but in case if used, that breakpoints will failed with error "Error on CreateBreakpoint: could not find" in both configs!

@jtackaberry
Copy link

I just got bit by this bug involving symlinks as well. In my case, /home is symlinked to an NFS volume mounted via autofs. My .code-workspace file is in my project root and sources . so the easy workaround was to open the workspace from the absolute path (/net/nas/home), rather than under /home.

This is also with Insiders and the remote development feature (which is pretty cool).

@ramya-rao-a ramya-rao-a added help wanted symlink Issues that occur when symlinks are used labels Oct 20, 2019
@ramya-rao-a
Copy link
Contributor

I am not able to replicate this issue locally, so if anyone seeing this issue is willing to set up a local dev setup of the extension, then I can help guide the process.

@vscodebot vscodebot bot closed this as completed Oct 27, 2019
@vscodebot
Copy link

vscodebot bot commented Oct 27, 2019

This issue has been closed automatically because it needs more information and has not had recent activity. Thank you for your contributions.

@robheerdink
Copy link

also experiencing this bug, debugger does not stop at symlinks under linux.
re-opening project through non symlink folder works

@ramya-rao-a
Copy link
Contributor

Thanks for reporting @robheerdink

While we have seen quite a few reports regarding debugging not working when using symlinks, we haven't been able to get a repro of it.

We would greatly appreciate it if you can set up a local dev environment of this extension and help in figuring out where exactly we are failing.

@vscodebot vscodebot bot locked and limited conversation to collaborators Dec 16, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
debug help wanted needs more info symlink Issues that occur when symlinks are used
Projects
None yet
Development

No branches or pull requests

7 participants