Skip to content

Commit

Permalink
fixes: set "default" to "prettyPrinters",
Browse files Browse the repository at this point in the history
read thread names, fix variable creation
  • Loading branch information
oltolm committed Mar 7, 2024
1 parent a6f48d6 commit a4e1eb0
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@
"valuesFormatting": {
"type": "string",
"description": "Set the way of showing variable values. 'disabled' - show value as is, 'parseText' - parse debuggers output text into structure, 'prettyPrinters' - enable debuggers custom pretty-printers if there are any",
"default": "parseText",
"default": "prettyPrinters",
"enum": [
"disabled",
"parseText",
Expand Down
14 changes: 8 additions & 6 deletions src/backend/mi2/mi2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -678,12 +678,10 @@ export class MI2 extends EventEmitter implements IBackend {
return threads.map(element => {
const ret: Thread = {
id: parseInt(MINode.valueOf(element, "id")),
targetId: MINode.valueOf(element, "target-id")
targetId: MINode.valueOf(element, "target-id"),
name: MINode.valueOf(element, "name") || MINode.valueOf(element, "details")
};

ret.name = MINode.valueOf(element, "details")
|| undefined;

return ret;
});
}
Expand Down Expand Up @@ -832,10 +830,14 @@ export class MI2 extends EventEmitter implements IBackend {
return await this.sendCommand(command);
}

async varCreate(expression: string, name: string = "-", frame: string = "@"): Promise<VariableObject> {
async varCreate(threadId: number, frameLevel: number, expression: string, name: string = "-", frame: string = "@"): Promise<VariableObject> {
if (trace)
this.log("stderr", "varCreate");
const res = await this.sendCommand(`var-create ${this.quote(name)} ${frame} "${expression}"`);
let miCommand = "var-create ";
if (threadId != 0) {
miCommand += `--thread ${threadId} --frame ${frameLevel}`
}
const res = await this.sendCommand(`${miCommand} ${this.quote(name)} ${frame} "${expression}"`);
return new VariableObject(res.result(""));
}

Expand Down
8 changes: 6 additions & 2 deletions src/mibase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,11 @@ export class MI2DebugSession extends DebugSession {
response.body.threads.push(new Thread(thread.id, thread.id + ":" + threadName));
}
this.sendResponse(response);
}).catch(error => {
}).catch((error: MIError) => {
if (error.message === 'Selected thread is running.') {
console.error(error);
return;
}
this.sendErrorResponse(response, 17, `Could not get threads: ${error}`);
});
}
Expand Down Expand Up @@ -479,7 +483,7 @@ export class MI2DebugSession extends DebugSession {
varObj = this.variableHandles.get(varId) as any;
} catch (err) {
if (err instanceof MIError && err.message == "Variable object not found") {
varObj = await this.miDebugger.varCreate(variable.name, varObjName);
varObj = await this.miDebugger.varCreate(id.threadId, id.level, variable.name, varObjName);
const varId = findOrCreateVariable(varObj);
varObj.exp = variable.name;
varObj.id = varId;
Expand Down

0 comments on commit a4e1eb0

Please sign in to comment.