diff --git a/package.json b/package.json index 23728b7f..70e6f0b4 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/src/backend/mi2/mi2.ts b/src/backend/mi2/mi2.ts index e6411609..7f2b81e7 100644 --- a/src/backend/mi2/mi2.ts +++ b/src/backend/mi2/mi2.ts @@ -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; }); } @@ -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 { + async varCreate(threadId: number, frameLevel: number, expression: string, name: string = "-", frame: string = "@"): Promise { 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("")); } diff --git a/src/mibase.ts b/src/mibase.ts index 152e7875..9a273e8a 100644 --- a/src/mibase.ts +++ b/src/mibase.ts @@ -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}`); }); } @@ -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;