code-debug icon indicating copy to clipboard operation
code-debug copied to clipboard

honor debugger created/modified breakpoints (possibly also watchpoints)

Open GitMensch opened this issue 3 years ago • 1 comments

So far we delete every breakpoint, then explicit create the ones that come from the debugging frontent.

It would be nice to automatically adjust the frontend list when done on the debugger side.

Easiest way to reproduce: start debugging of a program that has a breakpoint in line 10 and stop there, then enter "b 11". The MI return is

=breakpoint-created,bkpt={number="2",type="breakpoint",disp="keep",enabled="y",addr="0x00007fffe747af6b",func="main",file="/tmp/testme_symlinked.c",fullname="/tmp/testme.c",line="11",thread-groups=["i1"],times="0",original-location="/tmp/testme.c:11"} 

Expectation: also visible in the frontend (and therefore also adjustable on the frontend).

Similar: when breakpoints are disabled, their condition changed or even the breakpoint is deleted on the debugging console (the first two return a breakpoint-modified and the last a breakpoint-deleted event as noted below) - should also be done in the UI.

=breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="n",addr="0x00007fffe747af6b",func="main",file="/tmp/testme_symlinked.c",fullname="/tmp/testme.c",line="11",thread-groups=["i1"],times="0",original-location="/tmp/testme.c:11"} 
=breakpoint-modified,bkpt={number="2",type="breakpoint",disp="keep",enabled="n",addr="0x00007fffe747af6b",func="main",file="/tmp/testme_symlinked.c",fullname="/tmp/testme.c",line="11",thread-groups=["i1"],cond="1 == 2",times="0",original-location="/tmp/testme.c:11"} 
=breakpoint-deleted,id="2" 

Watchpoints are similar but additional include a "what" field, for example ,what="*(char(*)[10])(0x7fffe783c090)" and a type field as follows: ,type="hw watchpoint" (depending on the type also as read watchpoint, acc watchpoint or (plain software watchpoint) watchpoint) ; they commonly have no addr, func, file or fullname.

All kinds of breakpoints may have a script field (containing the commands, adjusting those would also be a breakpoint-modified event).

GitMensch avatar Mar 03 '22 14:03 GitMensch

The frontend code would be along:

import * as vscode from "vscode";
if (record.asyncClass == "breakpoint-added"
|| record.asyncClass == "breakpoint-modified"
|| "breakpoint-deleted") {
	var file = parsed.record("fullname");
	var line = parsed.record("line");
	var loc = new vscode.Location(vscode.Uri.file(file), new vscode.Position(line,0));
	var bp = new vscode.SourceBreakpoint(loc);
	if (record.asyncClass == "breakpoint-modified"
	|| record.asyncClass == "breakpoint-deleted") {
		vscode.debug.removeBreakpoints([bp]);
	}
	if (record.asyncClass == "breakpoint-added"
	|| record.asyncClass == "breakpoint-modified") {
		vscode.debug.addBreakpoints([bp]);
	}
}

GitMensch avatar Mar 07 '22 14:03 GitMensch