go-delve / delve

Delve is a debugger for the Go programming language.
MIT License
22.38k stars 2.13k forks source link

In debug mode, the process does not stop at a breakpoint #3709

Closed petervalencic closed 2 months ago

petervalencic commented 2 months ago

Hi, have strange issue from a while. I'm unable to debug golang project using dlv and vscode.

  1. What version of Delve are you using (dlv version)? Delve Debugger Version: 1.22.1 Build: $Id: 0c3470054da6feac5f6dcf3e3e5144a64f7a9a48 $

  2. What version of Go are you using? (go version)? go version go1.21.4 linux/386

  3. What operating system and processor architecture are you using? WSL Ubuntu

  4. What did you do? Trying to debug a simple code (worked in past). The debugger won't to stop on the breakpoint

  5. What did you expect to see? To be able to debug the code

  6. What did you see instead? I see the same result as if the run command were used..

This is my launch.json file:

 "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch Package",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "program": "${fileDirname}",
    }
  ]
}

When trying to debug the code I get: image

Don't know what is wrong or how to make the debugger to stop at the breakpoint in the code..

aarzilli commented 2 months ago

Do you have a way for us to reproduce this?

aarzilli commented 2 months ago

Is this WSL 1 or WSL 2?

petervalencic commented 2 months ago

Hi, I'm using WSL2: image

The strange thing is that some time ago I was able to debug the Go app. I mainly use vscode for Go, Java, node and Python development (switching projects depending on work).. The last week was debugging Python project and then switched back to Go and the debugger just ran over the code without considering breakpoints. At the same time, the toolbar with the debug buttons did not appear on the vscode screen.

debug

aarzilli commented 2 months ago

Do you have a way for us to reproduce this? Can you reproduce the problem using the command line client? Can you add "logOutput": "dap" to launch.json and post the output?

petervalencic commented 2 months ago

The output is:

image

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch main.go",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}/test.go",
            "env": {},
            "args": [],
            "logOutput": "dap",
        }
    ]
}

If I run the DLV in terminal: image

aarzilli commented 2 months ago

You also need to add "showLog": true apparently. The way to run the command line client is dlv debug not dlv debug ./test. Once it's running type help for how to set breakpoints and run the program. Also please post text not screenshots or videos.

petervalencic commented 2 months ago

What I have done is that I have removed Go from my system.. reinstalled the latest version of Go and installed Delve ...

peterv@SILFC857M3:/home/ec2-user/scripts/gotest$ go version
go version go1.22.2 linux/amd64
peterv@SILFC857M3:/home/ec2-user/scripts/gotest$ dlv version
Delve Debugger
Version: 1.22.1
Build: $Id: 0c3470054da6feac5f6dcf3e3e5144a64f7a9a48 $

Now the debug is working well: image

petervalencic commented 2 months ago

I didn't have time to investigate more on what was wrong, but I'm able to debug it now. That solved my problem. You can close the ticket. Thank you for your help and time!