delve
delve copied to clipboard
Feature request: simplify conditional breakpoint handling
@aarzilli and @derekparker Hi, I've just tried to implement an appropriate error handling for malformed conditions and right now the error handling leaves much to be desired.
I suppose it's mush easier for external developers to get the whole debugger state with the corresponding err field instead of getting an error for command request.
Right now I need to ask the state again:
OUT: {"method":"RPCServer.CreateBreakpoint","params":[{"Breakpoint":{"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"Cond":"b == nil"}}],"id":1}
OUT: {"method":"RPCServer.Command","params":[{"Name":"continue"}],"id":2}
IN: {"id":1,"result":{"Breakpoint":{"id":1,"name":"","addr":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"functionName":"main.main","Cond":"b == nil","continue":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"hitCount":{},"totalHitCount":0}},"error":null}
IN: {"id":2,"result":null,"error":"error evaluating expression: can not compare string to nil"}
OUT: {"method":"RPCServer.State","params":[{}],"id":3}
IN: {"id":3,"result":{"State":{"currentThread":{"id":11011,"pc":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"function":{"name":"main.main","value":8256,"type":84,"goType":0},"goroutineID":1,"breakPoint":{"id":1,"name":"","addr":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"functionName":"main.main","Cond":"b == nil","continue":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"hitCount":{"1":1},"totalHitCount":1},"breakPointInfo":null},"currentGoroutine":{"id":1,"currentLoc":{"pc":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"function":{"name":"main.main","value":8256,"type":84,"goType":0}},"userCurrentLoc":{"pc":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"function":{"name":"main.main","value":8256,"type":84,"goType":0}},"goStatementLoc":{"pc":322366,"file":"/usr/local/Cellar/go/1.7.1/libexec/src/runtime/asm_amd64.s","line":152,"function":{"name":"runtime.rt0_go","value":322016,"type":84,"goType":0}},"threadID":11011},"Threads":[{"id":11011,"pc":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"function":{"name":"main.main","value":8256,"type":84,"goType":0},"goroutineID":1,"breakPoint":{"id":1,"name":"","addr":8336,"file":"/Users/ignatov/IdeaProjects/untitled17/run-to-cursor.go","line":8,"functionName":"main.main","Cond":"b == nil","continue":false,"goroutine":false,"stacktrace":0,"LoadArgs":null,"LoadLocals":null,"hitCount":{"1":1},"totalHitCount":1},"breakPointInfo":null},{"id":13575,"pc":337606,"file":"/usr/local/Cellar/go/1.7.1/libexec/src/runtime/sys_darwin_amd64.s","line":296,"function":{"name":"runtime.usleep","value":337552,"type":84,"goType":0},"goroutineID":0,"breakPointInfo":null},{"id":13827,"pc":337899,"file":"/usr/local/Cellar/go/1.7.1/libexec/src/runtime/sys_darwin_amd64.s","line":418,"function":{"name":"runtime.mach_semaphore_wait","value":337888,"type":84,"goType":0},"goroutineID":0,"breakPointInfo":null},{"id":14083,"pc":337899,"file":"/usr/local/Cellar/go/1.7.1/libexec/src/runtime/sys_darwin_amd64.s","line":418,"function":{"name":"runtime.mach_semaphore_wait","value":337888,"type":84,"goType":0},"goroutineID":0,"breakPointInfo":null},{"id":14339,"pc":337899,"file":"/usr/local/Cellar/go/1.7.1/libexec/src/runtime/sys_darwin_amd64.s","line":418,"function":{"name":"runtime.mach_semaphore_wait","value":337888,"type":84,"goType":0},"goroutineID":0,"breakPointInfo":null}],"NextInProgress":false,"exited":false,"exitStatus":0}},"error":null}
Turns out net/jsonrpc won't let us do this: https://golang.org/src/net/rpc/jsonrpc/server.go#L117 :(
But we can just send the message with the new state but fill the Err field.
That would not be backwards compatible
How many clients which support conditional breakpoints do you have?