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

Unverified Breakpoint - With Remote Debug #941

Closed
pedrolvr opened this issue Apr 24, 2017 · 15 comments
Closed

Unverified Breakpoint - With Remote Debug #941

pedrolvr opened this issue Apr 24, 2017 · 15 comments
Assignees
Labels

Comments

@pedrolvr
Copy link

pedrolvr commented Apr 24, 2017

The breakpoint is gray in the editor.

Vs Code:
Version 1.11.2

Vs Code Go Plugin:
Version: 0.6.59

Delve:
Delve Debugger
Version: 0.12.2

Vs Code Config:

{
   "version": "0.2.0",
   "configurations": [
       {
           "name": "Launch Remote",
           "type": "go",
           "request": "launch",
           "mode": "remote",
           "remotePath": "/go/src/bitbucket.org/marked/markedProf1",
           "port": 2346,
           "host": "127.0.0.1",
           "program": "${workspaceRoot}",
           "env": {},
           "args": [],
           "showLog":true
       }
   ]
}

Docker compose:

ports:
      - 2346:2345
command:[
     "dlv debug --headless --listen=:2345 --log"
]
@pedrolvr
Copy link
Author

pedrolvr commented Apr 24, 2017

To resolve the problem I need to change the project folder name, and after launch the debug. If the folder name is equal for the docker folder path I have the problem.

If

"remotePath": "/go/src/bitbucket.org/marked/markedProf1",

is equal to

ADD. /go/src/bitbucket.org/marked/markedProf1 - Dockerfile

Someone can help me?

@ramya-rao-a
Copy link
Contributor

cc @roblourens

@willseward
Copy link

willseward commented May 4, 2017

I can repro this too, albeit without the fix.

I made a repo to demonstrate the problem: https://github.com/willseward/delve-crash

Just run docker-compose up --build, and try to use the remote debugging VS Code task.

@willseward
Copy link

willseward commented May 4, 2017

It works via the command line, but not with VS Code.

# Console
debugger_1  | Looking for myapp process...
debugger_1  | 2017/05/04 04:32:49 server.go:73: Using API v1
debugger_1  | 2017/05/04 04:32:49 debugger.go:69: attaching to pid 1
debugger_1  | API server listening at: [::]:2345
debugger_1  | 2017/05/04 04:33:08 debugger.go:327: created breakpoint: &api.Breakpoint{ID:1, Name:"", Addr:0x484c9d, File:"/go/src/myapp/main.go", Line:13, FunctionName:"main.main", Cond:"", Tracepoint:false, Goroutine:false, Stacktrace:0, Variables:[]string(nil), LoadArgs:(*api.LoadConfig)(nil), LoadLocals:(*api.LoadConfig)(nil), HitCount:map[string]uint64{}, TotalHitCount:0x0}
debugger_1  | 2017/05/04 04:33:09 debugger.go:482: continuing
debugger_1  | 2017/05/04 04:33:18 debugger.go:482: continuing
app_1       | Hello! I'm going to sleep for 1 second.
debugger_1  | 2017/05/04 04:33:20 debugger.go:482: continuing
app_1       | Hello! I'm going to sleep for 1 second.
debugger_1  | 2017/05/04 04:33:22 debugger.go:482: continuing
app_1       | Hello! I'm going to sleep for 1 second.
debugger_1  | 2017/05/04 04:33:24 debugger.go:482: continuing
app_1       | Hello! I'm going to sleep for 1 second.
debugger_1  | 2017/05/04 04:33:25 debugger.go:482: continuing
app_1       | Hello! I'm going to sleep for 1 second.
delvecrash_app_1 exited with code 2
delvecrash_debugger_1 exited with code 137
# VSCode

Verbose logs are written to:
/var/folders/_h/q7w4lltd1ln97vd302zn8kz40000gn/T/vscode-go-debug.txt
11:54:40 PM, 5/3/2017
InitializeRequest
InitializeResponse
InitializeEvent
SetBreakPointsRequest
All cleared
Creating on: /Users/willswward/delve-crash/app/main.go:13
Error on CreateBreakpoint
All set:[null]
SetBreakPointsResponse
ConfigurationDoneRequest
ContinueRequest
ContinueResponse
ThreadsRequest
SetBreakPointsRequest
All cleared
All set:[]
SetBreakPointsResponse
SetBreakPointsRequest
All cleared
Creating on: /Users/willswward/delve-crash/app/main.go:13
DisconnectRequest
DisconnectResponse

@roblourens
Copy link
Member

Thanks for the repo. This is from #742, which I don't think is quite right, and needs unit tests.

I don't use Docker often. @willseward what's the correct remote path to main.go? Is it /go/src/myapp/main.go (from the console log)? If so, where does "remotePath": "/app" come from?

@willseward
Copy link

willseward commented May 5, 2017

Thanks @roblourens

The correct remote path to the main.go should be /app/main.go. It lives in the debugger container via a volume. Now that you mention it, it is a little strange that the path shows up as /go/src/myapp/main.go in the console log.

I'll keep looking at it.

EDIT: I think the errant path may just be residual of the build process. Correct me if I'm wrong...

@roblourens
Copy link
Member

EDIT: I think the errant path may just be residual of the build process.

I'm not sure what you mean by that. Can you explain what the dockerfile is doing with that path?

@willseward
Copy link

@roblourens

The Dockerfile builds inside /go/src/myapp/ to create the binary, myapp, and then the second stage moves the binary from /go/src/myapp (with --from=builder) to /. /go/src/myapp simply doesn't exist in the docker image past the first stage of the build since it's built from the scratch image. Now, the since the debugger is in a separate container, I mount the source into /app/. This is where I derive the remotePath: "/app".

As for the path being part of the build process, I believe the build path is included in the symbols of the binary.

@willseward
Copy link

Got it!

If the original build path and the current path don't match, it won't work. The fix for me is:

diff --git a/.vscode/launch.json b/.vscode/launch.json
index 06da33b..d6366f5 100644
--- a/.vscode/launch.json
+++ b/.vscode/launch.json
@@ -5,7 +5,7 @@
         "type": "go",
         "request": "launch",
         "mode": "remote",
-        "remotePath": "/app",
+        "remotePath": "/go/src/myapp",
         "port": 2345,
         "host": "127.0.0.1",
         "program": "${fileDirname}",
diff --git a/docker-compose.yml b/docker-compose.yml
index 0884ba2..b1c7168 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -18,4 +18,4 @@ services:
       - "2345:2345"
     pid: "container:delvecrash_app_1"
     volumes:
-      - "./app:/app"
+      - "./app:/go/src/myapp"

A strange peculiarity.

@ramya-rao-a
Copy link
Contributor

@phenrigomes @willseward

Do you still have issues with remote debugging with the latest version of the Go extension?
If not, then can we close this issue?

@willseward
Copy link

The original problem still exists, but I don't think it's a bug---just some undocumented functionality.

@ramya-rao-a
Copy link
Contributor

And by original problem do you mean #941 (comment) or #941 (comment) ?

@willseward
Copy link

#941 (comment) is the work-around.

The repro in the github repo still works. The next-to-latest commit is the one with the failure.

@ramya-rao-a
Copy link
Contributor

@willseward

I am having trouble with the set up.

In the latest update to the Go extension, the errorError on CreateBreakpoint is accompanied by the error string from delve. Can you try again and share the logs?

If you are up for it, can you try and debug the issue by running the Go extension from source?

@ramya-rao-a
Copy link
Contributor

This issue has been closed automatically because it needs more information and has not had recent activity.

@microsoft microsoft locked as resolved and limited conversation to collaborators Mar 13, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants