-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
need to debug embedded Go #873
Comments
What @alexbrainman told you is 100% correct, what you want to debug is not a go program and delve does not work if the program isn't a go program. It is possible, in theory, to get delve there but it's a huge change. |
I added a simple goroutine call in sayhello(), and it seems it's running properly. I'm not sure about Go runtime initialization, but gdb shows a number of threads starting, I assumed it was related to Go's runtime. Starting program: C:\Users\amellan\src\ngm\examples\sharedlib\dload.exe Goodbye I assume the issue is exactly the same with a .so on Linux? go build -buidmode=c-shared is supposed to work on Linux, not sure if it would really change the problem. |
Probably not, I don't know. |
Based on the documentation from
|
still unable to debug embedded Go? or are there any solutions? |
Looks like debugging embedded Go is still not possible. Every Go main package can be built as a C shared library. The runtime initialization works and is done at DLL load time. Thereafter, things like goroutines can be used. I think what's needed is some way to trigger Delve from the Go code. Something like a break into debugger function. The other option that comes to mind is, to call a function that gets the DLL into a state that gops can detect it. But I don't have any idea how gops works. |
Hi,
I need to debug a Go application that has to reside in a DLL. In order to have the DLL loading work properly, I had to write a small C layer on top of Go.
How can I get dlv to attach to the Go code? Example code to reproduce my steps is at https://groups.google.com/d/msg/golang-nuts/ywzTYaalWLE/kn4GoobJAAAJ.
The text was updated successfully, but these errors were encountered: