Skip to content

Commit

Permalink
Array optimisation for variablesRequest (#343)
Browse files Browse the repository at this point in the history
  • Loading branch information
asimgunes authored Dec 5, 2024
1 parent 3204f5d commit b3a5eb6
Showing 1 changed file with 1 addition and 47 deletions.
48 changes: 1 addition & 47 deletions src/gdb/GDBDebugSessionBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2008,56 +2008,10 @@ export abstract class GDBDebugSessionBase extends LoggingDebugSession {
// update the display name for array elements to have square brackets
name = `[${child.exp}]`;
}
if (isArrayParent || isArrayChild) {
// can't use a relative varname (eg. var1.a.b.c) to create/update a new var so fetch and track these
// vars by evaluating their path expression from GDB
const fullPath = await this.getFullPathExpression(
child.name
);
// create or update the var in GDB
let arrobj = this.gdb.varManager.getVar(
frame.frameId,
frame.threadId,
depth,
fullPath
);
if (!arrobj) {
const varCreateResponse = await mi.sendVarCreate(
this.gdb,
{
expression: fullPath,
frameId: frame.frameId,
threadId: frame.threadId,
}
);
arrobj = this.gdb.varManager.addVar(
frame.frameId,
frame.threadId,
depth,
fullPath,
true,
false,
varCreateResponse
);
} else {
arrobj = await this.gdb.varManager.updateVar(
frame.frameId,
frame.threadId,
depth,
arrobj
);
}
// if we have an array parent entry, we need to display the address.
if (isArrayParent) {
value = await this.getAddr(arrobj);
}
arrobj.isChild = true;
varobjName = arrobj.varname;
}
const variableName = isArrayChild ? name : child.exp;
const evaluateName =
isArrayParent || isArrayChild
? await this.getFullPathExpression(child.name)
? `${topLevelPathExpression}[${child.exp}]`
: `${topLevelPathExpression}.${child.exp}`;
variables.push({
name: variableName,
Expand Down

0 comments on commit b3a5eb6

Please sign in to comment.