delve icon indicating copy to clipboard operation
delve copied to clipboard

Feature request: simplify conditional breakpoint handling

Open ignatov opened this issue 8 years ago • 4 comments
trafficstars

@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} 

ignatov avatar Mar 01 '17 01:03 ignatov

Turns out net/jsonrpc won't let us do this: https://golang.org/src/net/rpc/jsonrpc/server.go#L117 :(

aarzilli avatar Mar 02 '17 16:03 aarzilli

But we can just send the message with the new state but fill the Err field.

ignatov avatar Mar 05 '17 11:03 ignatov

That would not be backwards compatible

aarzilli avatar Mar 05 '17 12:03 aarzilli

How many clients which support conditional breakpoints do you have?

ignatov avatar Mar 05 '17 12:03 ignatov