Skip to content

Commit

Permalink
Issue Marus#306, support more than 20 stack frames
Browse files Browse the repository at this point in the history
  • Loading branch information
haneefdm committed Jun 19, 2020
1 parent e54a3a0 commit 05d3717
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Minor bug fix release
2. Issues Fixed
* Fixed Issue [#273](https://github.com/Marus/cortex-debug/issues/273). Handle peripherals blocks with no addressBlocks. Also fix issue with multiple address blocks where only the first one was being used
* Fixed Issue [#284](https://github.com/Marus/cortex-debug/issues/284). Implement/support 'derivedFrom' at register level.
* Fixed Issue [#306](https://github.com/Marus/cortex-debug/issues/306). Support displaying more than 20 stack frames
* When runToMain was enabled there were 1-2 harmless popups when the program stopped in main. They were very frequent on Windows, less frequent on Linux and very rare if any on a Mac.

# V0.3.6
Expand Down
13 changes: 13 additions & 0 deletions src/backend/mi2/mi2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -456,6 +456,19 @@ export class MI2 extends EventEmitter implements IBackend {
});
}

public getStackDepth(threadId: number): Thenable<number> {
if (trace) {
this.log('stderr', 'getStackDepth');
}
return new Promise((resolve, reject) => {
this.sendCommand(`stack-info-depth --thread ${threadId} 10000`).then((result) => {
const depth = result.result('depth');
const ret = parseInt(depth);
resolve(ret);
}, reject);
});
}

public getStack(threadId: number, startLevel: number, maxLevels: number): Thenable<Stack[]> {
if (trace) {
this.log('stderr', 'getStack');
Expand Down
7 changes: 5 additions & 2 deletions src/gdb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,9 @@ export class GDBDebugSession extends DebugSession {

protected async stackTraceRequest(response: DebugProtocol.StackTraceResponse, args: DebugProtocol.StackTraceArguments): Promise<void> {
try {
const stack = await this.miDebugger.getStack(args.threadId, args.startFrame, args.levels);
const maxDepth = await this.miDebugger.getStackDepth(args.threadId);
const highFrame = Math.min(maxDepth, args.startFrame + args.levels) - 1;
const stack = await this.miDebugger.getStack(args.threadId, args.startFrame, highFrame);
const ret: StackFrame[] = [];
for (const element of stack) {
const stackId = GDBDebugSession.encodeReference(args.threadId, element.level);
Expand Down Expand Up @@ -1359,7 +1361,8 @@ export class GDBDebugSession extends DebugSession {
}

response.body = {
stackFrames: ret
stackFrames: ret,
totalFrames: maxDepth
};
this.sendResponse(response);
}
Expand Down

0 comments on commit 05d3717

Please sign in to comment.