1

Here is the code fragment:

debugger problem

The debugger first stops at line 64. Then I press F10 to "step over" and then it jumps to line 75. There is a breakpoint at line 74, but it simply ignores that.

wsconn is a simple struct with a handleCall method defined on it:

/*
This private method simply selects and calls the right handler for
a given "call", sent by the client.
*/
func (wsconn InternalWsConn) handleCall(method string) error {
    handler, ok := api.CallHandlers[method]
    if !ok {
        // Read arguments, even if we cannot find the method.
        // The client sends the arguments unconditionally anyway.
        _, _, err := wsutil.ReadClientData(wsconn.conn)
        if err != nil {
            return err
        }
        return fmt.Errorf("call error: invalid method: %v", method)
    }
    return handler(wsconn)
}

If I place a breakpoint inside the handleCall method, then the debugger stops there. It just refuses to stop on line 74. So I can debug the code if I want to.

But I'm a bit frightened, because it seems that vs code allows to put breakpoints at places and then it does not work. I can possibly face the same problem again and again, and spend hours with this before I realize that a problem is not where I'm looking for it.

So the real question is this: why it is happening? Is it a problem with vscode? Or is it a problem with go itself? (Tested with go1.19.1 linux/amd64.) How can I avoid this? If I can't avoid, then is there a way to at least predict the places where I should not place breakpoints, because they are probably not going to work?

nagylzs
  • 3,954
  • 6
  • 39
  • 70
  • I have had this problem in the past on Windows but not Linux. I believe it was a problem with Delv (Go debugger) as it occurred with both VSCode and GoLand. However, I have not had this problem for some time now. I recommend making sure you have the latest version of dlv.exe and vscode. If that does not help maybe use an earlier version of Go (such as 1.17 unless you are using generics). – Andrew W. Phillips Oct 02 '22 at 11:30
  • continue vs step over?? https://stackoverflow.com/a/52368238/12341099 – Yadu Oct 02 '22 at 14:20
  • continue also jumps to the third breakpoint – nagylzs Oct 02 '22 at 17:17

0 Answers0