-
Notifications
You must be signed in to change notification settings - Fork 645
Breakpoints set in VS Code not hit (docker remote debugging) #2010
Comments
👍 The same thing is happening when debugging without docker, the debugger does not seem to hit API handlers or endpoints. Everything in the call stack looks like trace:
|
This ticket is related to the already open ticket here: #1987 |
Perhaps, but in my issue the execution never pauses (if you run the above go code the program runs and finishes execution with no pause whatsoever). You can't interrogate any call stack nor does VS Code visually pause. #1987 looks like it manages to successfully set the breakpoint but then has issues once you hit the breakpoint, I can't even get it to set any breakpoints to begin with. Also, the log outputs seem quite different (I'd guess that's because the breakpoints get set). |
@peteat, @jinmatt, @jpopadak Can you try the latest Insiders? |
@ramya-rao-a This half works in the Insiders Edition. When I am debugging a test, I am at least getting an error message in the When I debug a running program, it hits the breakpoints correctly and shows the variables correctly. However, it jumps to the |
Hi @ramya-rao-a apologies for the delay. I've just tested it on the latest insiders and, I'm afraid, it's no different for me. I still get the |
@peteat, @jinmatt, @jpopadak Can you try the latest beta-version of this extension? |
Hi @ramya-rao-a unfortunately it's the same for me with that latest beta (on VS Code and latest insiders) - |
Hi, all and @ramya-rao-a, I just ran into this issue myself, developing on Windows but running the app/delve in a docker container. Windows 10 version: 10.0.17134 Debugging with Goland works just fine, but when I try with vscode, the debug log in vscode shows me the below, the breakpoints become "unverified" and are never hit. Manually debugging with delve works. Goland works. I also suspect it may be a file path issue between Windows and Unix path conventions. I have posted a StackOverflow question on this (with a lot more info) before I found this bug report: I have also created a clean, simple GitHub repo to demonstrate the issue (this causes the exact same behaviour for me):
Btw, vscode allows me to CTRL-click on the "C:/Users/joe/go/src/github.com/joe15000/vscode_go_debug/package1/package1.go:17" shown in the "Error ... could not find" line - and it opens the file in vscode. Also leaving this here - not sure if it helps but they look more closely into how the path is passed from vscode to delve: As the last answer was from over half a year ago - is this still being investigated / addressed? I really love vscode but if docker debugging is not possible, I unfortunately cannot use it. |
I can confirm this happening for me as well - I can debug AWS lambdas via sam local in Goland but not VSCode
Setup commands /batch script
My launch.json file in the same folder as the batch script is
|
I also tried with API version 1 and it still occured - attached is the debug logs |
Even I too confirm , this happening for me as well - I can debug AWS lambdas via sam local in Goland but not VSCode I tried with new simple go lang program sam local start-api -d 5989 --debugger-path . --debug-args="-delveAPI=2" , i can see upto the below lines in terminal My launch.json |
I've been investigating this further including why VSCode does not debug and Goland down and it seems to be down to the fact that VSCode sends delve JSON-RPC commands specifying the location of the file and the line to breakpoint, and Goland sends the memory address to breakpoint at. For the former,when debugging remotely, Delve requires access to a copy of the source code so it knows where to set the breakpoint. However in AWS SAM, the Delve debugger, and the binary to be debuggged is run inside a temporary docker container, so Delve cannot locate the source file, fails to set the breakpoint, and the program completes. I tried to fix this by waiting until AWS SAM / delve halted for a debugger to attach, and then copying the source files into the docker instance via the AWS SAM file share, and using vscodes remotePath: to pick it up, but unfortunately Delve did not pick up the files. This might be solved by having AWS SAM mount the source code, and pointing Delve towards these files so vscode can work. I have also commented on issu for AWS SAM However this might be more easily resolved on the AWS SAM end by mounting source code |
@KarthickEmis After further investigation into the Delve debugger , I've discovered the following:
Breakpoints fail when the compiled path is different then the composite path of remotePath, and the relative path to the file for the VSCode - it is not needed for source code on the remote machine, as this line info is built into the binary. Where my code was failing was because I built in WSL linux, but my vscode remote path did not have a linux style path to my code directory. Unfortunately, if I choose the option of compiling in Windows with GOOS=linux, then the paths compiled into the binary look like:
The nature of the slashes are different, and so the breakpoints are not hit. This would require either a change to Go build to change the compiled files on a window system with GOOS=linux, or more easily, to change VSCode so it send paths inP OSIX format when remote connecting to a linux machine. A third option is for delve to rewrite paths passed in so they are in POSIX format |
Great detective work @jdwalker-emis! I would like to inspect what file path osx produces using linux build, as I suspect it’ll probably be similar to the ones above, I would say for now it’s an ELI5ing in AWS docs on how to structure remote path for vscode as this is configurable However I guess raising the issue with delve or go build, Is the way to go as the build process isn’t explicitly handled by vs code |
cc @quoctruong and @jhendrixMSFT for any additional insights here |
I think this seems similar to this issue: #2931. The work around was to build with |
@quoctruong I tried the workaround, and checked the debug information - unfortunately setting the trimpath only removed it for the immediate packages and not any of the referenced packages so I would be unable to set breakpoints for those packages. In addition Vscode go is pre fixing my remote path with a forward slash e.g. "/Git/code" vs compiled "Git/code" so this approach is not working. |
I just ran into this same problem with Typescript in a remote container. I can set breakpoints, but they are never hit. |
@BryanHunt For typescript, I think you have to specify |
Im having the same issue with OS X, have tried all solutions proposed but none have worked to stop the breakpoint, is this still happening for you? |
Sync @ 7da5077 * master: Address mismatch on path separators in debug config (microsoft#2010) (microsoft#3108) Include the link to release note/package overview in the update prompt, and update gopls default version (microsoft#3041) bug_report.md: Fix "architecture" typo. (microsoft#3095) telemetry.ts: send telemetry only if aiKey is not an empty string(microsoft#3091)
Merge 'microsoft/vscode-go/master' into 'golang/vscode-go/master' Sync @ 7da5077 * master: Address mismatch on path separators in debug config (#2010) (#3108) Include the link to release note/package overview in the update prompt, and update gopls default version (#3041) bug_report.md: Fix "architecture" typo. (#3095) telemetry.ts: send telemetry only if aiKey is not an empty string(#3091) Change-Id: I727ef0ed3b8d1ad926e26831534c153b06070e64 GitHub-Last-Rev: d11e342 GitHub-Pull-Request: #11 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/224239 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
* master: goLanguageServer: set completion follow up command from middleware (microsoft#3084) Add stacktrace dump and better error messages on EXC_BAD_ACCESS panics (microsoft#2904) Address mismatch on path separators in debug config (microsoft#2010) (microsoft#3108) Include the link to release note/package overview in the update prompt, and update gopls default version (microsoft#3041) bug_report.md: Fix "architecture" typo. (microsoft#3095) telemetry.ts: send telemetry only if aiKey is not an empty string(microsoft#3091)
…sync microsoft/vscode-go@d53b1b3 * 'master' of https://github.com/microsoft/vscode-go: goLanguageServer: set completion follow up command from middleware (microsoft#3084) Add stacktrace dump and better error messages on EXC_BAD_ACCESS panics (microsoft#2904) Address mismatch on path separators in debug config (microsoft#2010) (microsoft#3108)
Merge branch 'master' of https://github.com/microsoft/vscode-go@d53b1b3 * 'master' of https://github.com/microsoft/vscode-go: goLanguageServer: set completion follow up command from middleware (microsoft#3084) Add stacktrace dump and better error messages on EXC_BAD_ACCESS panics (microsoft#2904) Address mismatch on path separators in debug config (microsoft#2010) (microsoft#3108) Created by `git pull --no-ff --log upstream master` Change-Id: Id38768f3ec1bd01fa81325978f51f314fc1c08cb GitHub-Last-Rev: 3a8de3f GitHub-Pull-Request: #17 Reviewed-on: https://go-review.googlesource.com/c/vscode-go/+/224240 Reviewed-by: Rebecca Stambler <rstambler@golang.org>
The fix from #3108 is available in the latest beta version of this extension. Please do try and share feedback |
I can confirm that I am able to hit breakpoints now using AWS SAM to launch a linux container with delve and go binaries compiled from Windows. For anyone still having this problem (like I was before I edited this comment), take care that the "remotePath" element of your launch.json is the absolute path to the source files as compiled on your local system (not the container). As implied above - it's the absolute local path that is added to the DWARF compilation unit file table when you compile the binary. |
Thanks @anthonybgale The latest version of the extension now has the fix to this issue |
I can't seem to hit breakpoints set in VS Code when remotely debugging my go app (which is running in Docker).
I've set up my launch.json:
This is my
go.delveConfig
(user settings in VS Code):It attaches fine, and even hits breakpoints set via
runtime.Breakpoint()
but will not hit any breakpoints set via VS Code. Debugging the same project in GoLand works fine, I can set and hit breakpoints with no issue.I have done a lot of googling, and checking documentation, playing with configurations (launch.json, dockerfile, dlv etc) but can't seem to find a fix. Not sure what's wrong, but I have noticed a difference in the VS Code CreateBreakpoint request compared to the GoLand one by looking at the dlv log output (by adding
--log --log-output=rpc
).Here's the dlv log (via docker) when debugging via GoLand:
But here's the dlv log (via docker) when debugging via VS Code:
Notice all the extra escapes in the file path for the VS Code call?
They aren't there for the GoLand equivalent call. Are those escapes the problem? Are they preventing dlv from finding the file?
Steps to Reproduce:
e.g.
./build.sh && docker-compose -f docker-compose.yml up --build
main.go:
build.sh:
docker-compose.yml:
Dockerfile_dev:
VS Code debug console output:
Bash console output:
Note: all output and config has been slightly santised (with
<username>
)System info:
VS Code 1.28.1 (user setup)
Windows 10 Enterprise 1803
Docker 18.06.1-ce-win73
Edit: added system info
The text was updated successfully, but these errors were encountered: