From 2c80d6387b44bb19fdbf386ef90c2982113a53fe Mon Sep 17 00:00:00 2001 From: Xinyu Sui Date: Thu, 29 Jul 2021 11:34:39 -0700 Subject: [PATCH 1/2] Add a special entry when disassembly is unavailable --- .../contrib/debug/browser/disassemblyView.ts | 37 +++++++++++++------ 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/disassemblyView.ts b/src/vs/workbench/contrib/debug/browser/disassemblyView.ts index 6f3468ae5ec..807c091894d 100644 --- a/src/vs/workbench/contrib/debug/browser/disassemblyView.ts +++ b/src/vs/workbench/contrib/debug/browser/disassemblyView.ts @@ -37,6 +37,17 @@ interface IDisassembledInstructionEntry { instructionAddress?: bigint; } +// Special entry as a placeholer when disassembly is not available +const disassemblyNotAvailable: IDisassembledInstructionEntry = { + allowBreakpoint: false, + isBreakpointSet: false, + instruction: { + address: '-1', + instruction: localize('instructionNotAvailable', "Disassembly not available.") + }, + instructionAddress: BigInt(-1) +}; + export class DisassemblyView extends EditorPane { private static readonly NUM_INSTRUCTIONS_TO_LOAD = 50; @@ -189,7 +200,7 @@ export class DisassemblyView extends EditorPane { if ((e === State.Running || e === State.Stopped) && (this._previousDebuggingState !== State.Running && this._previousDebuggingState !== State.Stopped)) { // Just started debugging, clear the view - this._disassembledInstructions?.splice(0, this._disassembledInstructions.length); + this._disassembledInstructions?.splice(0, this._disassembledInstructions.length, [disassemblyNotAvailable]); } this._previousDebuggingState = e; })); @@ -283,11 +294,13 @@ export class DisassemblyView extends EditorPane { newEntries.push({ allowBreakpoint: true, isBreakpointSet: found !== undefined, instruction: resultEntries[i] }); } + const specialEntriesToRemove = this._disassembledInstructions.length === 1 ? 1 : 0; + // request is either at the start or end if (instructionOffset >= 0) { - this._disassembledInstructions.splice(this._disassembledInstructions.length, 0, newEntries); + this._disassembledInstructions.splice(this._disassembledInstructions.length, specialEntriesToRemove, newEntries); } else { - this._disassembledInstructions.splice(0, 0, newEntries); + this._disassembledInstructions.splice(0, specialEntriesToRemove, newEntries); } return true; @@ -350,7 +363,7 @@ export class DisassemblyView extends EditorPane { */ private reloadDisassembly(targetAddress?: string) { if (this._disassembledInstructions) { - this._disassembledInstructions.splice(0, this._disassembledInstructions.length); + this._disassembledInstructions.splice(0, this._disassembledInstructions.length, [disassemblyNotAvailable]); this._instructionBpList = this._debugService.getModel().getInstructionBreakpoints(); this.loadDisassembledInstructions(targetAddress, -DisassemblyView.NUM_INSTRUCTIONS_TO_LOAD * 4, DisassemblyView.NUM_INSTRUCTIONS_TO_LOAD * 8).then(() => { // on load, set the target instruction in the middle of the page. @@ -497,14 +510,16 @@ class InstructionRenderer extends Disposable implements ITableRenderer Date: Thu, 29 Jul 2021 12:05:30 -0700 Subject: [PATCH 2/2] Prevent loading at -1 --- src/vs/workbench/contrib/debug/browser/disassemblyView.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/vs/workbench/contrib/debug/browser/disassemblyView.ts b/src/vs/workbench/contrib/debug/browser/disassemblyView.ts index 807c091894d..83b6488eaa5 100644 --- a/src/vs/workbench/contrib/debug/browser/disassemblyView.ts +++ b/src/vs/workbench/contrib/debug/browser/disassemblyView.ts @@ -275,8 +275,8 @@ export class DisassemblyView extends EditorPane { } private async loadDisassembledInstructions(address: string | undefined, instructionOffset: number, instructionCount: number): Promise { - // if address is null, then use current stack frame. - if (!address) { + // if address is null or a special address, then try to use current stack frame. + if (!address || address === '-1') { address = this.currentInstructionAddress; } if (!address) {