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
question: how to put breakpoint to a Go method with gdb or delve #31013
Comments
(for gdb)
Try
Try In general, the symbol name of a method is |
@cherrymui , I tried your solution with delve and it works. Thank you very much for your response and the explanation of path of a symbol :) |
I'd actually like to re-open this as a feature request. Writing out the full symbol name is onerous. I often resort to running nm/objdump, grepping for the function name I want, and then using the address instead. It'd be nice if delve did some/all of these things:
|
Bonus: support the same features in gdb/lldb! Also cc @dr2chase @aclements (I'm not sure exactly who the debugger team is nowadays) |
Just |
Even if I didn’t realize the lldb script had been removed. Bummer. |
yes, and it does. |
You can also place a breakpoint using a line number, like "br fabsdk/context.go:NNN". I believe in gdb it will do some amount of disambiguation of the file name, so you don't have to type the full path to use this syntax. |
And just for the record, I don't think there's anything in the compiler/linker we can do to affect any of this. Maybe we could do something in runtime-gdb.py? But to me this seems like a Delve feature request, if anything. |
I agree with @heschik that this is more on the debugger side than the compiler side. Ideally maybe gdb/lldb should probably just hint symbols with partial matches. C++ function names are also quite long, in many cases. |
@josharian would you mind updating the title of this issue with what you'd like to accomplish? Should your feature requests be separate issues perhaps? |
Re-reading this thread, I think I'll just close it. |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Didnt check as this is a query related to debuggers with go rather than go itself
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
I want to debug a go code. I want to put breakpoint on a method (belonging to a named type) in a imported package. I went through a lot of online materials where they only put breakpoints on a line number in file (eg:breakpoint a.go:15).
I have done a lot of debugging in 'C' where I put breakpoints on functions. Is this kind of debugging possible in go??
I have the following code in my main package.
clientContext := sdk.Context(fabsdk.WithUser("Admin"), fabsdk.WithOrg("ordererorg"))
.I want to put breakpoints to
WithUser()
which belongs to packagefabsdk
in filegithub.com/hyperledger/fabric-sdk-go/pkg/fabsdk/context.go
.Context()
belonging to typeFabricSDK
in filegithub.com/hyperledger/fabric-sdk-go/pkg/fabsdk/fabsdk.go
in packagefabsdk
.Is it possible to put breakpoints to method
WithUser()
andcontext()
or Is breakpoints only allowed at a line number in a file?? I could use either gdb or delve or any other debugger as well.What did you expect to see?
need to put breakpoints on a method or function
What did you see instead?
(gdb) br sdk.Context
Function "sdk.Context" not defined.
Make breakpoint pending on future shared library load? (y or [n]) n
(gdb) br github.com/hyperledger/fabric-sdk-go/pkg/fabsdk.Context
Function "github.com/hyperledger/fabric-sdk-go/pkg/fabsdk.Context" not defined.
Make breakpoint pending on future shared library load? (y or [n]) y
Breakpoint 2 (github.com/hyperledger/fabric-sdk-go/pkg/fabsdk.Context) pending.
The text was updated successfully, but these errors were encountered: