Still unable to debug embedded Go?

113 views
Skip to first unread message

antZengger

unread,
Mar 23, 2021, 8:07:16 AM3/23/21
to delve-dev
Hi,

Recently I need to debug an embedded Go snippet. I compiled my Go code into .so file and loaded it in my C program. However, I found that dlv seems unable to debug to Go parts.

similar issues and talk:

the above links are opened in 2017 but seem still unresolved now. Is there any progress?

go source:

package main

import "C"
import (
    "sync"
    "time"
    "fmt"
)

func sum(a, b int) int {
        return a + b
}

func gof() {
    i := 0
    for {   
        fmt.Println(sum(i+1, i+2))
        i++
        time.Sleep(time.Second) 
    }
}

//export updateHeader
func updateHeader() {
    wg := sync.WaitGroup{}
    wg.Add(1)
    go func() {
        gof()
    } ()
    wg.Wait()
}

func main() {}

compile command:

go build -buildmode=c-shared -gcflags "all=-N -l" -o test.so test.go

C code:

#include"test.h"

int main() {
  updateHeader();
}

compiled command:

gcc -g -fno-asynchronous-unwind-tables -o main test.c test.so


After doing the above things, I tried both "dlv exec" and "dlv attach", both of them seems not work as expected, both cannot set breakpoint and list goroutines, etc.

Alessandro Arzilli

unread,
Mar 23, 2021, 1:42:16 PM3/23/21
to antZengger, delve-dev
I'm not aware of anyone having worked on this.
> --
> You received this message because you are subscribed to the Google Groups "delve-dev" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to delve-dev+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/delve-dev/b5b85b80-bae8-4053-8203-5dbf0334bf6cn%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages