delve: g command fails on most recent version of debugserver on darwin/arm64

Please answer the following before submitting your issue:

Note: Please include any substantial examples (debug session output, stacktraces, etc) as linked gists.

  1. What version of Delve are you using (dlv version)? Version 1.6.0
  2. What version of Go are you using? (go version)? Go1.16.2
  3. What operating system and processor architecture are you using? Macmini m1 chip
  4. What did you do?
  • cd /Documents && mkdir test && cd test && touch main.go

  • use vscode set main.go like

` package main import “fmt”

func main() { a := 1 fmt.Print(“123”) fmt.Println(a) } `

  • add break point at line 6 and line 8
  • go mod init test
  • go mod tidy
  • create default debug config ./vscode/launch.json { "version": "0.2.0", "configurations": [ { "name": "Launch Package", "type": "go", "request": "launch", "mode": "debug", "program": "${workspaceFolder}" } ] }
  • click Launch Package
  1. What did you expect to see? run debug success and go to breakpoint
  2. What did you see instead? image

无法加载源“”。means can not load source

what should i do?

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Reactions: 3
  • Comments: 27 (6 by maintainers)

Most upvoted comments

I am now experiencing the same problem after upgrading to macOS 11.3… system:

% uname -a
Darwin hsot.domain 20.4.0 Darwin Kernel Version 20.4.0: Fri Mar  5 01:14:02 PST 2021; root:xnu-7195.101.1~3/RELEASE_ARM64_T8101 arm64

go:

% go version
go version go1.16.3 darwin/arm64

dlv :

% dlv version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

xcode version:

% xcodebuild -version
Xcode 12.5
Build version 12E262

debug console:

API server listening at: 127.0.0.1:28107
Failed to continue - protocol error E74 during registers read for packet $g;thread:fb41;
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

Failed to get list local variables - unable to find function context
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

1619574846745 I was caused by upgrading 11.3. After adding the code as shown in the figure to the dlv source code, dlv continued to work for me

  • I add this code to delve and rebuild, copy dlv to a temp path, I am using /Users/myName/go/bin.

  • Open goland and run the Edit Custom Properties action (Help | Edit Custom Properties), add the path to Delve on a new line: dlv.path=/path/to/delve/macarm (e.g. dlv.path=/Users/myName/go/bin/dlv). Flowing this step Goland Edit Custom Properties.

image

  • And then debug normaly. 🥰🥰🥰

Had this problem as well. Installed via go install github.com/go-delve/delve/cmd/dlv@latest

It installed 1.6.0

It seems this was fixed, just isn’t released yet. So when I installed it this way, the debugger is working.

$ git clone https://github.com/go-delve/delve
$ cd delve
$ go install github.com/go-delve/delve/cmd/dlv

Ok so I figured what happened on my end. I had installed xcode via the App Store on Mac. I had set the app store to update my apps automatically (big mistake). Yesterday, xcode was automatically updated to 12.5 as you can see from the More Downloads for Apple Developers page. What I did to solve the issue was:

  1. Uninstall xcode following this tutorial.

  2. Reboot.

  3. Install xcode version 12.4 from the More Downloads for Apple Developers page. image

  4. Reboot.

  5. Make sure automatic updates are turned off on the app store AND on System Preferences as well.

After this, everything is working correctly. I would presume something is fishy about xcode 12.5. Hope this helps

No need to clone the repo, just install with

go install github.com/go-delve/delve/cmd/dlv@master

Once the fix is released, switch back to latest:

go install github.com/go-delve/delve/cmd/dlv@latest

I am now experiencing the same problem after upgrading to macOS 11.3…

system:

% uname -a
Darwin hsot.domain 20.4.0 Darwin Kernel Version 20.4.0: Fri Mar  5 01:14:02 PST 2021; root:xnu-7195.101.1~3/RELEASE_ARM64_T8101 arm64

go:

% go version
go version go1.16.3 darwin/arm64

dlv :

% dlv version
Delve Debugger
Version: 1.6.0
Build: $Id: 8cc9751909843dd55a46e8ea2a561544f70db34d $

xcode version:

% xcodebuild -version
Xcode 12.5
Build version 12E262

debug console:

API server listening at: 127.0.0.1:28107
Failed to continue - protocol error E74 during registers read for packet $g;thread:fb41;
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

Failed to get list local variables - unable to find function context
Last known immediate stacktrace (goroutine id 0):
	?:-1
		<unknown>
	:0
		<unknown>

1619574846745 I was caused by upgrading 11.3. After adding the code as shown in the figure to the dlv source code, dlv continued to work for me

Thank you @mensurm, @ormissia

These are the steps that I took that worked for me with GoLand 2021.1 on Mac 11.2.3

I first took @mensurm’s advice (can be done in any directory)

git clone https://github.com/go-delve/delve
cd delve
go install github.com/go-delve/delve/cmd/dlv

This makes the new dlv available in your $GOPATH/bin. One can get the path with:

ls $GOPATH/bin/dlv

image

If no errors appear, then that’s the path you can use when you follow @ormissia 's advice, and paste the value in the idea.properties file.

image

I’ve changed a local delve to have the option

				if v[len("version:"):] == "1205" && p.bi.Arch.Name == "arm64" {
					p.gcmdok = false
				}

and can confirm this works on the latest xcode Perhaps when you do a dlv version , then also show this version v[len(“version:”):] So people don’t need to change their source. (or perhaps make it >= 1200, instead of exact?)

just update my xcode to 12.5 and encounter the same issue

You should report this problem to apple/llvm, after all that’s what betas are for.

I did by going back to an older version of the xcode developers tools

Anyone experiencing this issue should:

  1. post the output produced by delve when using the options --log --log-output=gdbwire.
  2. try the workaround in https://github.com/go-delve/delve/issues/2436#issuecomment-821809170
  3. post the output produced by delve when using the options --log --log-output=gdbwire after applying the workaround

in this order.

@jimcroft you could see if the same thing happens using lldb with a compiled binary. Also in pkg/proc/gdbserial/gdbserver.go there’s a version check that sets p.gcmdok = false, you could try to enable it always, it could be that they broke the g command again.