3

I have an M1 mac and cannot invoke functions via DLV in VSCode.

Unable to evaluate expression: backend does not support function calls

Delve Debugger
Version: 1.8.2
❯ go version                                                                                                                                              ─╯
go version go1.18 darwin/arm64

What am I missing?

Launch.JSON file

{
  "version": "0.2.0",
  "configurations": [
    {
      "name": "Launch file",
      "type": "go",
      "request": "launch",
      "mode": "auto",
      "program": "${file}",
      "env": {
        "PATH": "/usr/local/go/bin:${fileDirname}"
      },
      "args": []
    }
  ]
}
Ryan
  • 1,102
  • 1
  • 15
  • 30
  • https://github.com/golang/go/issues/50614 Go runtime doesn't support function call for arm64 yet. – Hana Apr 17 '22 at 18:25

3 Answers3

4

From Delve (May 2022):

Support for calling functions on ARM64 has landed! https://github.com/go-delve/delve/pull/2996

Requires Go & Delve built from source with the latest changes.

Call functions from a debug session on ARM64 CPUs, including the Apple M1!

Note: Support function call injection on arm64 with Go 1.19 (CL 395754, as noted in issue 2277), so you will need to wait for Q4 2022.

VonC
  • 1,262,500
  • 529
  • 4,410
  • 5,250
  • Wow, thanks! I am sooooo stoked for this addition. Can you maybe tell me what function call injection means? – Ryan May 06 '22 at 23:35
  • 1
    @Ryan That would enable Changing the value of a variable during a debug session: it requires an allocation, which can only be done by injecting a function call and function call injection is not supported on arm64 because the go runtime doesn't have an implementation for it. Not before Go 1.19 – VonC Jun 02 '22 at 21:03
1

The following json works for me-

 {
        "version": "0.2.0",
        "configurations": [
            {
                "name": "DEV",
                "type": "go",
                "request": "launch",
                "mode": "auto",
                "program": "${workspaceFolder}",
                "env": {
                    "ENV_SERVERADDRESS": "0.0.0.0:7171",
                }
            }
        ] 
 }
saqsham
  • 61
  • 5
0

On an M1:

{
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Debug normal",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceRoot}",
            "env": {},
            "args": []
        },
        {
            "name": "Debug arg=migrate",
            "type": "go",
            "request": "launch",
            "mode": "auto",
            "program": "${workspaceRoot}",
            "env": {},
            "args": [
                "migrate"
            ]
        }
    ]
}

Which Go version?

Did you install delve with that version?

Marcelloh
  • 82
  • 1
  • 5
  • Are you actually able to invoke functions in the debugger or just evaluate variables, etc? – Ryan Apr 11 '22 at 21:35
  • Will, you can give it arguments, and if your program react to those args given... But Delve it only about the current state at any given point in the program. Do you still have the problem? – Marcelloh Apr 13 '22 at 07:22
  • When I develop on the JVM, for instance, I can invoke a function preemptively while debugging. This is very helpful when developing while debugging. I can evaluate variables in golang, but I cannot invoke functions, which is hindering my experience. Does that make sense? – Ryan Apr 14 '22 at 00:10
  • That's not doable in Go because Go doesn't make a runtime but a real executable. If you need to test something, write a small test for it which you can debug. so I think your delve actually works, but you did expect something else :-) – Marcelloh Apr 15 '22 at 07:48