Skip to content
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

Consult a technical question: how to debug golang code #11

Closed
Code2Life opened this issue Feb 27, 2022 · 3 comments
Closed

Consult a technical question: how to debug golang code #11

Code2Life opened this issue Feb 27, 2022 · 3 comments

Comments

@Code2Life
Copy link

Hi, I'm using this lib to developing a tool, but I encountered an error, then I tried copy codes to my golang project and then tried to set breakpoints into golang codes.

But breakpoints doesn't work, how could I implement this ? or, If I want to contribute to this lib, how to debug this lib locally with VSCode (because it could not be launched when this settings are put into .vscode/settings.json)

"go.toolsEnvVars": {
"GOARCH": "wasm",
"GOOS": "js",
},

Thanks a lot.

The error was:

panic: syscall/js: call of Value.Invoke on undefined

goroutine 1 [running]:
syscall/js.Value.Invoke(0x0, 0x0, 0x42ac80, 0x1, 0x1, 0x10, 0x10)
syscall/js/js.go:417 +0xa
yam.plus/example-go-plugin/wasm.toJSFunc(0x14060, 0x333f8, 0x13, 0x0, 0x0)
yam.plus/example-go-plugin/wasm/function.go:30 +0xf
yam.plus/example-go-plugin/wasm.ToJSValue(0x14060, 0x333f8, 0x98, 0x1)
yam.plus/example-go-plugin/wasm/reflect_to.go:64 +0x2d
yam.plus/example-go-plugin/wasm.mapToJSObject(0x153e0, 0x424210, 0x15, 0x0, 0x0)
yam.plus/example-go-plugin/wasm/reflect_to.go:129 +0x54
yam.plus/example-go-plugin/wasm.ToJSValue(0x153e0, 0x424210, 0x0, 0x0)
yam.plus/example-go-plugin/wasm/reflect_to.go:66 +0x34
yam.plus/example-go-plugin/wasm.Object.Set(0x7ff800010000000d, 0x410040, 0x2f03b, 0x1a, 0x153e0, 0x424210)
yam.plus/example-go-plugin/wasm/object.go:121 +0x2
yam.plus/example-go-plugin/wasm.Expose(...)
yam.plus/example-go-plugin/wasm/wasm.go:42
main.main()
command-line-arguments/main.go:40 +0x7

@hhhapz
Copy link
Member

hhhapz commented Feb 27, 2022

It's a bit difficult to debug and find the source to the problem without any code. Can you please share both what you have in JS and in Go?

@hhhapz
Copy link
Member

hhhapz commented Feb 27, 2022

Looks like I misunderstood your initial post. There exist some web assembly debugging tools in chrome devtools. Apart from that, there's an issue in golang/go (golang/go#33503) which mentions source map support, and there might be more related to this if tinygo fits the bill for you. Otherwise, I'm not sure if there's realistically much can be done with this library specifically, as it's goal is mainly to be the bridge/glue between the 'Go' land and the 'JS' land.

@Code2Life
Copy link
Author

yeah, if DWARF implemented then debugging could be possible with Chrome devtools, currently I'm switching compile target and mock input from JS to debug breakpoints. Thanks a lot !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants