I often need to set a breakpoint at the end of a function which doesn't have return. What would be a good placeholder/no-op statement in golang?
评论:
opiniondevnull:
marksteve4:not sure what you mean, just use runtime.Breakpoint()
opiniondevnull:sorry. what i mean is i want to set a breakpoint at the end of a function, so I need a no-op statement to set the breakpoint at.
TheMerovius:Again, just use runtime.Breakpoint()
spiriualExplorer:Does
defer runtime.Breakpoint()
at the top of the function work? That should be the literal last thing a function executes (return or not). Though really, your debugger should also have a command for "continue running until the end of the function".
dlsniper:You can use runtime package, but I️ prefer using gdb. It works natively nowadays.
I️ don’t know which version of GO and which version of gdb started being compatible. But it works well.
Unless gdb received support for green threads recently, gdb is still not support. I recommend using delve instead.
