Skip to content

Commit faeef98

Browse files
committed
chore: fix and optimize HTAB safeToObserve check
1 parent 3260e10 commit faeef98

File tree

1 file changed

+24
-24
lines changed

1 file changed

+24
-24
lines changed

src/variables.ts

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -383,10 +383,14 @@ export class StepContext {
383383
currentFunctionName?: string;
384384

385385
/*
386-
* Whether is it safe for not get elements of Bitmapset.
387-
* Main concern are breakpoints in bitmapset.c
386+
* Whether is it safe to get elements of Bitmapset.
388387
*/
389388
isSafeToObserveBitmapset?: boolean;
389+
390+
/*
391+
* Whether is it safe to get elements of HTAB.
392+
*/
393+
isSafeToObserveHTAB?: boolean;
390394

391395
reset() {
392396
this.isSafeToAllocateMemory = undefined;
@@ -395,6 +399,7 @@ export class StepContext {
395399
this.rtable.exists = false;
396400
this.currentFunctionName = undefined;
397401
this.isSafeToObserveBitmapset = undefined;
402+
this.isSafeToObserveHTAB = undefined;
398403
}
399404
}
400405

@@ -4741,30 +4746,25 @@ class HTABSpecialMember extends RealVariable {
47414746
return info.type;
47424747
}
47434748

4744-
safeToObserve(): boolean {
4745-
for (const bp of vscode.debug.breakpoints) {
4746-
if (!bp.enabled) {
4747-
continue;
4748-
}
4749-
4750-
if (bp instanceof vscode.SourceBreakpoint) {
4751-
if (bp.location.uri.path.endsWith('bitmapset.c')) {
4752-
logger.info('found breakpoint at bitmapset.c - set elements not shown');
4753-
return false;
4754-
}
4755-
} else if (bp instanceof vscode.FunctionBreakpoint) {
4756-
/*
4757-
* Need to check functions that are called to get set elements
4758-
*/
4759-
if (HTABSpecialMember.evaluationUsedFunctions.indexOf(bp.functionName) !== -1) {
4760-
logger.info('found breakpoint at %s - bms elements not shown',
4761-
bp.functionName);
4762-
return false;
4763-
}
4764-
}
4749+
isDangerousBreakpoint(breakpoint: vscode.Breakpoint) {
4750+
if (!breakpoint.enabled) {
4751+
return false;
4752+
}
4753+
4754+
if (breakpoint instanceof vscode.SourceBreakpoint) {
4755+
return breakpoint.location.uri.fsPath.endsWith('dynahash.c');
4756+
}
4757+
4758+
if (breakpoint instanceof vscode.FunctionBreakpoint) {
4759+
return breakpoint.functionName.startsWith('hash_seq');
47654760
}
4761+
4762+
return false;
4763+
}
47664764

4767-
return true;
4765+
safeToObserve(): boolean {
4766+
return this.context.step.isSafeToObserveHTAB
4767+
??= !!vscode.debug.breakpoints.find(this.isDangerousBreakpoint);
47684768
}
47694769

47704770
async doGetChildren(): Promise<Variable[] | undefined> {

0 commit comments

Comments
 (0)