Skip to content

Commit

Permalink
debug: preserve the top of stack when stepping in or at BP (#214902)
Browse files Browse the repository at this point in the history
Refs  #214433
  • Loading branch information
connor4312 authored Jun 11, 2024
1 parent 48748f9 commit 611f9bf
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/vs/workbench/contrib/debug/common/debugModel.ts
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@ export class StackFrame implements IStackFrame {
}
}

const KEEP_SUBTLE_FRAME_AT_TOP_REASONS: readonly string[] = ['breakpoint', 'step', 'function breakpoint'];

export class Thread implements IThread {
private callStack: IStackFrame[];
private staleCallStack: IStackFrame[];
Expand Down Expand Up @@ -578,10 +580,11 @@ export class Thread implements IThread {

getTopStackFrame(): IStackFrame | undefined {
const callStack = this.getCallStack();
const stopReason = this.stoppedDetails?.reason;
// Allow stack frame without source and with instructionReferencePointer as top stack frame when using disassembly view.
const firstAvailableStackFrame = callStack.find(sf => !!(
((this.stoppedDetails?.reason === 'instruction breakpoint' || (this.stoppedDetails?.reason === 'step' && this.lastSteppingGranularity === 'instruction')) && sf.instructionPointerReference) ||
(sf.source && sf.source.available && !isFrameDeemphasized(sf))));
((stopReason === 'instruction breakpoint' || (stopReason === 'step' && this.lastSteppingGranularity === 'instruction')) && sf.instructionPointerReference) ||
(sf.source && sf.source.available && (KEEP_SUBTLE_FRAME_AT_TOP_REASONS.includes(stopReason!) || !isFrameDeemphasized(sf)))));
return firstAvailableStackFrame;
}

Expand Down

0 comments on commit 611f9bf

Please sign in to comment.