(startFrame: number, maxLevels: number, thread: number)
| 689 | } |
| 690 | |
| 691 | async getStack(startFrame: number, maxLevels: number, thread: number): Promise<Stack[]> { |
| 692 | if (trace) this.log("stderr", "getStack"); |
| 693 | |
| 694 | const options: string[] = []; |
| 695 | |
| 696 | if (thread != 0) |
| 697 | options.push("--thread " + thread); |
| 698 | |
| 699 | const depth: number = (await this.sendCommand(["stack-info-depth"].concat(options).join(" "))).result("depth").valueOf(); |
| 700 | const lowFrame: number = startFrame ? startFrame : 0; |
| 701 | const highFrame: number = (maxLevels ? Math.min(depth, lowFrame + maxLevels) : depth) - 1; |
| 702 | |
| 703 | if (highFrame < lowFrame) |
| 704 | return []; |
| 705 | |
| 706 | options.push(lowFrame.toString()); |
| 707 | options.push(highFrame.toString()); |
| 708 | |
| 709 | const result = await this.sendCommand(["stack-list-frames"].concat(options).join(" ")); |
| 710 | const stack = result.result("stack"); |
| 711 | return stack.map(element => { |
| 712 | const level = MINode.valueOf(element, "@frame.level"); |
| 713 | const addr = MINode.valueOf(element, "@frame.addr"); |
| 714 | const func = MINode.valueOf(element, "@frame.func"); |
| 715 | const filename = MINode.valueOf(element, "@frame.file"); |
| 716 | let file: string = MINode.valueOf(element, "@frame.fullname"); |
| 717 | if (file) { |
| 718 | if (this.isSSH) |
| 719 | file = path.posix.normalize(file); |
| 720 | else |
| 721 | file = path.normalize(file); |
| 722 | } |
| 723 | |
| 724 | let line = 0; |
| 725 | const lnstr = MINode.valueOf(element, "@frame.line"); |
| 726 | if (lnstr) |
| 727 | line = parseInt(lnstr); |
| 728 | const from = parseInt(MINode.valueOf(element, "@frame.from")); |
| 729 | return { |
| 730 | address: addr, |
| 731 | fileName: filename, |
| 732 | file: file, |
| 733 | function: func || from, |
| 734 | level: level, |
| 735 | line: line |
| 736 | }; |
| 737 | }); |
| 738 | } |
| 739 | |
| 740 | async getStackVariables(thread: number, frame: number): Promise<Variable[]> { |
| 741 | if (trace) |
nothing calls this directly
no test coverage detected