Skip to content

Commit d498b38

Browse files
committed
Use var-assign to set variables values
1 parent 2551dba commit d498b38

File tree

2 files changed

+19
-5
lines changed

2 files changed

+19
-5
lines changed

src/backend/mi2/mi2.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -690,6 +690,12 @@ export class MI2 extends EventEmitter implements IBackend {
690690
return this.sendCommand(`var-update --all-values ${name}`)
691691
}
692692

693+
async varAssign(name: string, rawValue: string): Promise<MINode> {
694+
if (trace)
695+
this.log("stderr", "varAssign");
696+
return this.sendCommand(`var-assign ${name} ${rawValue}`);
697+
}
698+
693699
logNoNewLine(type: string, msg: string) {
694700
this.emit("msg", type, msg);
695701
}

src/mibase.ts

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -130,15 +130,23 @@ export class MI2DebugSession extends DebugSession {
130130
this.sendResponse(response);
131131
}
132132

133-
protected setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): void {
134-
this.miDebugger.changeVariable(args.name, args.value).then(() => {
133+
protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): Promise<void> {
134+
try {
135+
let name = args.name;
136+
if (args.variablesReference >= VAR_HANDLES_START) {
137+
const parent = this.variableHandles.get(args.variablesReference) as VariableObject;
138+
name = `${parent.name}.${name}`;
139+
}
140+
141+
let res = await this.miDebugger.varAssign(name, args.value);
135142
response.body = {
136-
value: args.value
143+
value: res.result("value")
137144
};
138145
this.sendResponse(response);
139-
}, err => {
146+
}
147+
catch (err) {
140148
this.sendErrorResponse(response, 11, `Could not continue: ${err}`);
141-
});
149+
};
142150
}
143151

144152
protected setFunctionBreakPointsRequest(response: DebugProtocol.SetFunctionBreakpointsResponse, args: DebugProtocol.SetFunctionBreakpointsArguments): void {

0 commit comments

Comments
 (0)