Merge pull request #129797 from xisui-MSFT/dev/xisui/fix_129526
Add a special entry when disassembly is unavailable
This commit is contained in:
commit
5489d1ba16
|
@ -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;
|
||||
|
@ -202,7 +213,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;
|
||||
}));
|
||||
|
@ -278,7 +289,7 @@ export class DisassemblyView extends EditorPane {
|
|||
|
||||
private async loadDisassembledInstructions(address: string | undefined, instructionOffset: number, instructionCount: number): Promise<boolean> {
|
||||
// if address is null, then use current stack frame.
|
||||
if (!address) {
|
||||
if (!address || address === '-1') {
|
||||
address = this.focusedInstructionAddress;
|
||||
}
|
||||
if (!address) {
|
||||
|
@ -296,11 +307,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;
|
||||
|
@ -363,7 +376,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.
|
||||
|
@ -526,14 +539,16 @@ class InstructionRenderer extends Disposable implements ITableRenderer<IDisassem
|
|||
|
||||
const instruction = element.instruction;
|
||||
const sb = createStringBuilder(10000);
|
||||
|
||||
sb.appendASCIIString(instruction.address);
|
||||
let spacesToAppend = 10;
|
||||
if (instruction.address.length < InstructionRenderer.INSTRUCTION_ADDR_MIN_LENGTH) {
|
||||
spacesToAppend = InstructionRenderer.INSTRUCTION_ADDR_MIN_LENGTH - instruction.address.length;
|
||||
}
|
||||
for (let i = 0; i < spacesToAppend; i++) {
|
||||
sb.appendASCII(0x00A0);
|
||||
|
||||
if (instruction.address !== '-1') {
|
||||
sb.appendASCIIString(instruction.address);
|
||||
if (instruction.address.length < InstructionRenderer.INSTRUCTION_ADDR_MIN_LENGTH) {
|
||||
spacesToAppend = InstructionRenderer.INSTRUCTION_ADDR_MIN_LENGTH - instruction.address.length;
|
||||
}
|
||||
for (let i = 0; i < spacesToAppend; i++) {
|
||||
sb.appendASCII(0x00A0);
|
||||
}
|
||||
}
|
||||
|
||||
if (instruction.instructionBytes) {
|
||||
|
@ -591,7 +606,9 @@ class AccessibilityProvider implements IListAccessibilityProvider<IDisassembledI
|
|||
let label = '';
|
||||
|
||||
const instruction = element.instruction;
|
||||
label += `${localize('instructionAddress', "Address")}: ${instruction.address}`;
|
||||
if (instruction.address !== '-1') {
|
||||
label += `${localize('instructionAddress', "Address")}: ${instruction.address}`;
|
||||
}
|
||||
if (instruction.instructionBytes) {
|
||||
label += `, ${localize('instructionBytes', "Bytes")}: ${instruction.instructionBytes}`;
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue