本文介绍了远程调试 - 未验证断点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

希望我能解释清楚.

更新:我可以确认 dlv debug -l 127.0.0.1:2345 确实有效.因此我必须在 VsCode launch.json

Update: I can confirm that dlv debug -l 127.0.0.1:2345 does work.Therefore I must be in VsCode launch.json

更新:消除恐慌.Go 版本有所不同.现在 VsCode 中的调试器无法正常工作,它显示未验证断点".但是,如果我在终端中使用 dlv,如果我在带有代码的文件夹中,它就可以正常工作.

Update: removed the panic. There was a different in go versions.Now the debugger in VsCode is just not working, it says "Unverified breakpoint". But it works fine if I use dlv from terminal, if I am in the folder with the code.

我正在尝试使用示例代码进行远程调试.

I am trying to remote debug with this sample code.

它适用于这个 改变.

你知道该怎么做吗?我试图将 launch.json 更改为 "program": "${workspaceRoot}", 以包含类似 "program": "${workspaceRoot}/src/app",.

Do you know what to do? I have tried to change the launch.json to "program": "${workspaceRoot}", to include the path like "program": "${workspaceRoot}/src/app",.

Launch.json

Launch.json

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch",
            "type": "go",
            "request": "launch",
            "mode": "debug",
            "program": "${workspaceRoot}",
            "env": {},
            "args": []
        },
        {
            // To remote debug in Docker, run the following before debugging:
            // # docker build -t webapp-go .
            // # docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 webapp-go
            // # docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 -v "${PWD%/*}/src/app/":/go/src/app webapp-go
            // And then each time you want to restart debugging:
            // # docker restart
            "name": "Remote debug in Docker",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "program": "${workspaceRoot}",
            "env": {},
            "args": [],
            "remotePath": "/go/src/app",
            "port": 2345, // Port 
            "host": "127.0.0.1" // Docker IP
/*            "preLaunchTask": "docker" */ 
        }
    ]
}

Dockerfile:

Dockerfile:

FROM golang:1.6
RUN go get -u -v github.com/derekparker/delve/cmd/dlv
EXPOSE 2345

# RUN mkdir -p /go/src/app
# WORKDIR /go/src/app
# VOLUME ["src/app2"]

VOLUME ["/go/src/app"]
RUN mkdir -p /go/src/app
WORKDIR /go/src/app
COPY src/app /go/src/app

RUN go-wrapper download
RUN go-wrapper install

EXPOSE 8080
CMD ["dlv", "debug", "--headless", "--listen=:2345", "--log"]

推荐答案

我通过向 launch.json(在 VS Code 中)添加trace"选项解决了我的问题

I figured out my problem by adding the "trace" option to the launch.json (in VS Code)

    {
        "name": "Attach remote ",
        "type": "go",
        "request": "attach",
        "mode": "remote",
        "remotePath": "/home/me/goprojects/src/github.com/owner/project/package",
        "port": 2345,
        "host": "xxxx.xyz",
        "trace":"log",

    }

这样做会在调试控制台中显示它正在寻找路径错误的源文件.我意识到 launch.json 中的 remotePath 应该(至少对于我的设置)只是 /home/me/goprojects/src/github.com/owner/project

Doing that revealed in the Debug Console that it was looking for the source file with the wrong path. I realised that remotePath in the launch.json should be (for my setup at least) just /home/me/goprojects/src/github.com/owner/project

因此,尝试添加跟踪并仔细检查调试控制台

So, try adding trace and scrutinize the Debug Console

这篇关于远程调试 - 未验证断点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-22 18:29