#How to debug go compiler in VSCode

4 messages · Page 1 of 1 (latest)

old vector
#

The OS is linux(ubuntu 22.04). go version 1.24.0

Under go/src directory, we can use dlv exec ../pkg/tool/linux_amd64/compile testing/testing.go to debug compiler for go. And the dlv can show the source code of cmd/compile/main.go as shown in the following image in the attached figure.

But in VSCode, after using the following launch.json, setting the breakpoints as shown in the 2nd attached figure, invoking the debug session under go/src directory, it can't stop at the breakpoint such as main.main of cmd/compile package.

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Launch Package",
            "type": "go",
            "request": "launch",
            "mode": "exec",
            "program": "../pkg/tool/linux_arm64/compile",
            "args": [
                "testing/testing.go"
            ],
        }
    ]
}

How to debug go compiler in VSCode? I want to set up the debug environment and avoid printing, which is annoying.

How to solve the problem? Thanks!

By the way, use GOROOT_BOOTSTRAP=<path to go1.24.0 root> GO_GCFLAGS="-N -l" ./make.bash under src directory to make a new go without inline optimization, if I'm correct, which may help debugging compiler.

#

How to debug go compiler in VSCode

#