Use var-assign to set variables values

This commit is contained in:
gentoo90 2017-05-26 11:14:42 +03:00
commit d498b381bf
2 changed files with 19 additions and 5 deletions

View file

@ -690,6 +690,12 @@ export class MI2 extends EventEmitter implements IBackend {
return this.sendCommand(`var-update --all-values ${name}`) return this.sendCommand(`var-update --all-values ${name}`)
} }
async varAssign(name: string, rawValue: string): Promise<MINode> {
if (trace)
this.log("stderr", "varAssign");
return this.sendCommand(`var-assign ${name} ${rawValue}`);
}
logNoNewLine(type: string, msg: string) { logNoNewLine(type: string, msg: string) {
this.emit("msg", type, msg); this.emit("msg", type, msg);
} }

View file

@ -130,15 +130,23 @@ export class MI2DebugSession extends DebugSession {
this.sendResponse(response); this.sendResponse(response);
} }
protected setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): void { protected async setVariableRequest(response: DebugProtocol.SetVariableResponse, args: DebugProtocol.SetVariableArguments): Promise<void> {
this.miDebugger.changeVariable(args.name, args.value).then(() => { try {
let name = args.name;
if (args.variablesReference >= VAR_HANDLES_START) {
const parent = this.variableHandles.get(args.variablesReference) as VariableObject;
name = `${parent.name}.${name}`;
}
let res = await this.miDebugger.varAssign(name, args.value);
response.body = { response.body = {
value: args.value value: res.result("value")
}; };
this.sendResponse(response); this.sendResponse(response);
}, err => { }
catch (err) {
this.sendErrorResponse(response, 11, `Could not continue: ${err}`); this.sendErrorResponse(response, 11, `Could not continue: ${err}`);
}); };
} }
protected setFunctionBreakPointsRequest(response: DebugProtocol.SetFunctionBreakpointsResponse, args: DebugProtocol.SetFunctionBreakpointsArguments): void { protected setFunctionBreakPointsRequest(response: DebugProtocol.SetFunctionBreakpointsResponse, args: DebugProtocol.SetFunctionBreakpointsArguments): void {