Skip to content

Commit 6af7922

Browse files
committed
auto continue after breakpoint group change
1 parent e36c2e7 commit 6af7922

File tree

1 file changed

+14
-6
lines changed

1 file changed

+14
-6
lines changed

code-debug/src/mibase.ts

+14-6
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ export class BreakpointGroups {
166166
//功能和disableCurrentBreakpointGroupBreakpoints有重合。
167167
//断点被触发时会调用该函数。如果空间发生变化(如kernel=>'src/bin/initproc.rs')
168168
//缓存旧空间的断点,令GDB清除旧断点组的断点,卸载旧断点组的符号表文件,加载新断点组的符号表文件,加载新断点组的断点
169-
public updateCurrentBreakpointGroup(updateTo: string) {
169+
public updateCurrentBreakpointGroup(updateTo: string, continueAfterUpdate: boolean = false) {
170170
let newIndex = -1;
171171
for (let i = 0; i < this.groups.length; i++) {
172172
if (this.groups[i].name === updateTo) {
@@ -201,8 +201,8 @@ export class BreakpointGroups {
201201
this.debugSession.miDebugger.addSymbolFile(f);
202202
}
203203

204-
this.groups[newIndex].setBreakpointsArguments.forEach((args) => {
205-
this.debugSession.miDebugger.clearBreakPoints(args.source.path).then(
204+
const breakpointPromises = this.groups[newIndex].setBreakpointsArguments.map((args) => {
205+
return this.debugSession.miDebugger.clearBreakPoints(args.source.path).then(
206206
() => {
207207
let path = args.source.path;
208208
if (this.debugSession.isSSH) {
@@ -218,12 +218,20 @@ export class BreakpointGroups {
218218
logMessage: brk.logMessage
219219
});
220220
});
221+
return Promise.all(all);
221222
},
222223
(msg) => {
223224
//TODO
224225
}
225226
);
226227
});
228+
229+
Promise.all(breakpointPromises).then(() => {
230+
if (continueAfterUpdate) {
231+
this.debugSession.miDebugger.continue();
232+
}
233+
});
234+
227235
this.currentBreakpointGroupName = this.groups[newIndex].name;
228236
this.debugSession.showInformationMessage("breakpoint group changed to " + updateTo);
229237
}
@@ -1370,7 +1378,7 @@ example: {"token":43,"outOfBandRecord":[],"resultRecords":{"resultClass":"done",
13701378
}
13711379

13721380
public async getStringVariable(name:string):Promise<string>{
1373-
const node = await this.miDebugger.sendCliCommand('x /s ' + name );
1381+
const node = await this.miDebugger.sendCliCommand('print ' + name ); // x /s may work
13741382
const resultstring = this.miDebugger.getOriginallyNoTokenMINodes(node.token)[0].outOfBandRecord[0].content;
13751383
this.showInformationMessage("`getStringVariable` got string: " + resultstring);
13761384
return /"(.*?)"/.exec(resultstring)[1];// we want things INSIDE double quotes so it's [1], the first captured group.
@@ -1490,13 +1498,13 @@ example: {"token":43,"outOfBandRecord":[],"resultRecords":{"resultClass":"done",
14901498
}
14911499
else if(action.type === DebuggerActions.high_level_switch_breakpoint_group_to_low_level){//for example, user to kernel
14921500
const high_level_breakpoint_group_name = this.breakpointGroups.getCurrentBreakpointGroupName();
1493-
this.breakpointGroups.updateCurrentBreakpointGroup(this.breakpointGroups.getNextBreakpointGroup());
1501+
this.breakpointGroups.updateCurrentBreakpointGroup(this.breakpointGroups.getNextBreakpointGroup(),true);
14941502
this.breakpointGroups.setNextBreakpointGroup(high_level_breakpoint_group_name);// if a hook is triggered during low level execution, NextBreakpointGroup will be set to the return value of hook behavior function.
14951503
}
14961504
else if(action.type === DebuggerActions.low_level_switch_breakpoint_group_to_high_level){//for example, kernel to user
14971505
const low_level_breakpoint_group_name = this.breakpointGroups.getCurrentBreakpointGroupName();
14981506
const high_level_breakpoint_group_name = this.breakpointGroups.getNextBreakpointGroup();
1499-
this.breakpointGroups.updateCurrentBreakpointGroup(high_level_breakpoint_group_name);
1507+
this.breakpointGroups.updateCurrentBreakpointGroup(high_level_breakpoint_group_name,true);
15001508
this.breakpointGroups.setNextBreakpointGroup(low_level_breakpoint_group_name);
15011509
}
15021510

0 commit comments

Comments
 (0)