Skip to content

Commit be19c27

Browse files
oltolmWebFreak001
authored andcommitted
fixes: set "default" to "prettyPrinters",
read thread names, fix variable creation
1 parent a6f48d6 commit be19c27

3 files changed

Lines changed: 15 additions & 9 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
"valuesFormatting": {
188188
"type": "string",
189189
"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",
190-
"default": "parseText",
190+
"default": "prettyPrinters",
191191
"enum": [
192192
"disabled",
193193
"parseText",

src/backend/mi2/mi2.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -678,12 +678,10 @@ export class MI2 extends EventEmitter implements IBackend {
678678
return threads.map(element => {
679679
const ret: Thread = {
680680
id: parseInt(MINode.valueOf(element, "id")),
681-
targetId: MINode.valueOf(element, "target-id")
681+
targetId: MINode.valueOf(element, "target-id"),
682+
name: MINode.valueOf(element, "name") || MINode.valueOf(element, "details")
682683
};
683684

684-
ret.name = MINode.valueOf(element, "details")
685-
|| undefined;
686-
687685
return ret;
688686
});
689687
}
@@ -832,10 +830,14 @@ export class MI2 extends EventEmitter implements IBackend {
832830
return await this.sendCommand(command);
833831
}
834832

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

src/mibase.ts

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ export class MI2DebugSession extends DebugSession {
283283
response.body.threads.push(new Thread(thread.id, thread.id + ":" + threadName));
284284
}
285285
this.sendResponse(response);
286-
}).catch(error => {
286+
}).catch((error: MIError) => {
287+
if (error.message === 'Selected thread is running.') {
288+
console.error(error);
289+
return;
290+
}
287291
this.sendErrorResponse(response, 17, `Could not get threads: ${error}`);
288292
});
289293
}
@@ -479,7 +483,7 @@ export class MI2DebugSession extends DebugSession {
479483
varObj = this.variableHandles.get(varId) as any;
480484
} catch (err) {
481485
if (err instanceof MIError && err.message == "Variable object not found") {
482-
varObj = await this.miDebugger.varCreate(variable.name, varObjName);
486+
varObj = await this.miDebugger.varCreate(id.threadId, id.level, variable.name, varObjName);
483487
const varId = findOrCreateVariable(varObj);
484488
varObj.exp = variable.name;
485489
varObj.id = varId;

0 commit comments

Comments
 (0)