Skip to content

Commit 6713545

Browse files
committed
Use async/await in getStackVariables
1 parent 907fbd5 commit 6713545

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed

src/backend/mi2/mi2.ts

Lines changed: 17 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -617,27 +617,25 @@ export class MI2 extends EventEmitter implements IBackend {
617617
});
618618
}
619619

620-
getStackVariables(thread: number, frame: number): Thenable<Variable[]> {
620+
async getStackVariables(thread: number, frame: number): Promise<Variable[]> {
621621
if (trace)
622622
this.log("stderr", "getStackVariables");
623-
return new Promise((resolve, reject) => {
624-
this.sendCommand("stack-list-variables --thread " + thread + " --frame " + frame + " --simple-values").then((result) => {
625-
let variables = result.result("variables");
626-
let ret: Variable[] = [];
627-
variables.forEach(element => {
628-
const key = MINode.valueOf(element, "name");
629-
const value = MINode.valueOf(element, "value");
630-
const type = MINode.valueOf(element, "type");
631-
ret.push({
632-
name: key,
633-
valueStr: value,
634-
type: type,
635-
raw: element
636-
});
637-
});
638-
resolve(ret);
639-
}, reject);
640-
});
623+
624+
const result = await this.sendCommand(`stack-list-variables --thread ${thread} --frame ${frame} --simple-values`);
625+
const variables = result.result("variables");
626+
let ret: Variable[] = [];
627+
for (const element of variables) {
628+
const key = MINode.valueOf(element, "name");
629+
const value = MINode.valueOf(element, "value");
630+
const type = MINode.valueOf(element, "type");
631+
ret.push({
632+
name: key,
633+
valueStr: value,
634+
type: type,
635+
raw: element
636+
});
637+
}
638+
return ret;
641639
}
642640

643641
examineMemory(from: number, length: number): Thenable<any> {

0 commit comments

Comments
 (0)