go-delve / delve

Delve is a debugger for the Go programming language.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Delve is incompatible with musl system loader

x-yuri opened this issue · comments

I don't think it's the substitute-path issue because list main.main succeeds
and the preconditions doesn't seem to match.

  1. What version of Delve are you using (dlv version)?

    Delve Debugger
    Version: 1.21.2
    Build: $Id: 98f8ab2662d926245917ade2f2bb38277315c7fc $
    
  2. What version of Go are you using? (go version)?

    go version go1.21.5 linux/amd64
    
  3. What operating system and processor architecture are you using?

    Arch Linux + Alpine Linux, x86_64

  4. What did you do?

    a.sh:

    set -eu
    docker run --rm -itv "$PWD:/app" -w /app alpine:3.19 sh -euc '
        apk add go delve
        exec sh
    '

    a/a.go:

    package main
    import "fmt"
    func main() {
        fmt.Println("hello world")
    }
    $ sh a.sh
    ...
    /app # dlv debug ./cmd/dlv -- debug ./a
    Type 'help' for list of commands.
    (dlv) b cmds.execute
    Breakpoint 1 set at 0xdc4dd6 for github.com/go-delve/delve/cmd/dlv/cmds.execute() ./cmd/dlv/cmds/commands.go:943
    (dlv) c main.main
    Breakpoint 2 set at 0xe0d916 for main.main() ./cmd/dlv/main.go:14
    > main.main() ./cmd/dlv/main.go:14 (hits goroutine(1):1 total:1) (PC: 0xe0d916)
         9: )
        10:
        11: // Build is the git sha of this binaries build.
        12: var Build string
        13:
    =>  14: func main() {
        15:         if Build != "" {
        16:                 version.DelveVersion.Build = Build
        17:         }
        18:
        19:         const cgoCflagsEnv = "CGO_CFLAGS"
    (dlv) b debugCmd
    Command failed: Breakpoint exists at /app/cmd/dlv/cmds/commands.go:578 at dbf8ca
    (dlv) c
    WARN[0018] CGO_CFLAGS already set, Cgo code could be optimized.  layer=dlv
    > github.com/go-delve/delve/cmd/dlv/cmds.debugCmd() ./cmd/dlv/cmds/commands.go:578 (hits goroutine(1):1 total:1) (PC: 0xdbf8ca)
       573:                 return "", false
       574:         }
       575:         return debugname, true
       576: }
       577:
    => 578: func debugCmd(cmd *cobra.Command, args []string) {
       579:         status := func() int {
       580:                 dlvArgs, targetArgs := splitArgs(cmd, args)
       581:                 debugname, ok := buildBinary(cmd, dlvArgs, false)
       582:                 if !ok {
       583:                         return 1
    (dlv) exit
    

    So maybe I don't need to set the breakpoint?

    /app # dlv debug ./cmd/dlv -- debug ./a
    Type 'help' for list of commands.
    (dlv) b cmds.execute
    Breakpoint 1 set at 0xdc4dd6 for github.com/go-delve/delve/cmd/dlv/cmds.execute() ./cmd/dlv/cmds/commands.go:943
    (dlv) c main.main
    Breakpoint 2 set at 0xe0d916 for main.main() ./cmd/dlv/main.go:14
    > main.main() ./cmd/dlv/main.go:14 (hits goroutine(1):1 total:1) (PC: 0xe0d916)
         9: )
        10:
        11: // Build is the git sha of this binaries build.
        12: var Build string
        13:
    =>  14: func main() {
        15:         if Build != "" {
        16:                 version.DelveVersion.Build = Build
        17:         }
        18:
        19:         const cgoCflagsEnv = "CGO_CFLAGS"
    (dlv) c
    WARN[0001] CGO_CFLAGS already set, Cgo code could be optimized.  layer=dlv
    > github.com/go-delve/delve/cmd/dlv/cmds.execute() ./cmd/dlv/cmds/commands.go:943 (hits goroutine(1):1 total:1) (PC: 0xdc4dd6)
       938:                 fmt.Println(err)
       939:         }
       940:         return status
       941: }
       942:
    => 943: func execute(attachPid int, processArgs []string, conf *config.Config, coreFile string, kind debugger.ExecuteKind, dlvArgs []string, buildFlags string) int {
       944:         if err := logflags.Setup(log, logOutput, logDest); err != nil {
       945:                 fmt.Fprintf(os.Stderr, "%v\n", err)
       946:                 return 1
       947:         }
       948:         defer logflags.Close()
    (dlv) exit
    

    I need. And if I set the breakpoint before c main.main?

    /app # dlv debug ./cmd/dlv -- debug ./a
    Type 'help' for list of commands.
    (dlv) b debugCmd
    Breakpoint 1 set at 0xdbf8ca for github.com/go-delve/delve/cmd/dlv/cmds.debugCmd() ./cmd/dlv/cmds/commands.go:578
    (dlv) c main.main
    Breakpoint 2 set at 0xe0d916 for main.main() ./cmd/dlv/main.go:14
    > main.main() ./cmd/dlv/main.go:14 (hits goroutine(1):1 total:1) (PC: 0xe0d916)
         9: )
        10:
        11: // Build is the git sha of this binaries build.
        12: var Build string
        13:
    =>  14: func main() {
        15:         if Build != "" {
        16:                 version.DelveVersion.Build = Build
        17:         }
        18:
        19:         const cgoCflagsEnv = "CGO_CFLAGS"
    (dlv) c
    WARN[0001] CGO_CFLAGS already set, Cgo code could be optimized.  layer=dlv
    > github.com/go-delve/delve/cmd/dlv/cmds.debugCmd() ./cmd/dlv/cmds/commands.go:578 (hits goroutine(1):1 total:1) (PC: 0xdbf8ca)
       573:                 return "", false
       574:         }
       575:         return debugname, true
       576: }
       577:
    => 578: func debugCmd(cmd *cobra.Command, args []string) {
       579:         status := func() int {
       580:                 dlvArgs, targetArgs := splitArgs(cmd, args)
       581:                 debugname, ok := buildBinary(cmd, dlvArgs, false)
       582:                 if !ok {
       583:                         return 1
    (dlv) exit
    
  5. What did you expect to see?

    I expected it to not produce errors when it succeeded.

  6. What did you see instead?

    I saw the "Breakpoint exists" error.

logs with --log --log-output=rpc,dap