Skip to content

probe-web / @probe-web/client / testing / FakeDebugger

Class: FakeDebugger ​

Defined in: testing/fake-debugger.ts:39

A scripted stand-in for index!Debugger with the same methods and events, so it can be passed wherever a debugger is expected. It models a tiny program — main → step_a → step_b with locals, statics and registers — and run/pause/step transitions and breakpoints, starting halted at a breakpoint. Every mutating call is recorded in FakeDebugger.calls.

Extends ​

  • EventTarget

Constructors ​

Constructor ​

ts
new FakeDebugger(): FakeDebugger;

Defined in: testing/fake-debugger.ts:61

A fake core halted at a breakpoint in step_b.

Returns ​

FakeDebugger

Overrides ​

ts
EventTarget.constructor

Properties ​

PropertyModifierTypeDefault valueDescriptionDefined in
statepublicRunState'halted'As index!Debugger.state; starts halted.testing/fake-debugger.ts:41
lastStoppublicStoppedDetail | nullundefinedAs index!Debugger.lastStop.testing/fake-debugger.ts:43
epochpublicnumber0As index!Debugger.epoch; bumped whenever the fake core moves.testing/fake-debugger.ts:45
callsreadonlystring[][]Every mutating call, in order, e.g. continue, step over, writeRegister R0=2a.testing/fake-debugger.ts:47
npublicnumber2The program's n local (in main), which FakeDebugger.hit increments.testing/fake-debugger.ts:49
counterpublicnumber1The program's COUNTER static, which FakeDebugger.hit increments.testing/fake-debugger.ts:51
linepublicnumber40The source line the innermost frame is on.testing/fake-debugger.ts:53
registerspublicMap<number, bigint>undefinedRegister values by register id.testing/fake-debugger.ts:55
svdLoadedpublicbooleanfalseWhether FakeDebugger.loadSvd was called, which adds a Peripherals scope.testing/fake-debugger.ts:152

Methods ​

start() ​

ts
start(): void;

Defined in: testing/fake-debugger.ts:94

As index!Debugger.start; does nothing (events fire synchronously).

Returns ​

void


dispose() ​

ts
dispose(): void;

Defined in: testing/fake-debugger.ts:96

As index!Debugger.dispose; does nothing.

Returns ​

void


refresh() ​

ts
refresh(): Promise<RunState>;

Defined in: testing/fake-debugger.ts:98

As index!Debugger.refresh.

Returns ​

Promise<RunState>


continue() ​

ts
continue(): Promise<void>;

Defined in: testing/fake-debugger.ts:100

As index!Debugger.continue: the fake core runs until FakeDebugger.hit.

Returns ​

Promise<void>


pause() ​

ts
pause(): Promise<StoppedDetail>;

Defined in: testing/fake-debugger.ts:102

As index!Debugger.pause.

Returns ​

Promise<StoppedDetail>


step() ​

ts
step(mode): Promise<{
  pc: bigint;
  warning: null;
}>;

Defined in: testing/fake-debugger.ts:104

As index!Debugger.step: every mode moves one line down.

Parameters ​

ParameterType
modeSteppingMode

Returns ​

Promise<{ pc: bigint; warning: null; }>


reset() ​

ts
reset(): Promise<void>;

Defined in: testing/fake-debugger.ts:115

As index!Debugger.reset.

Returns ​

Promise<void>


resetAndHalt() ​

ts
resetAndHalt(): Promise<StoppedDetail>;

Defined in: testing/fake-debugger.ts:117

As index!Debugger.resetAndHalt.

Returns ​

Promise<StoppedDetail>


enableVectorCatch() ​

ts
enableVectorCatch(c): Promise<void>;

Defined in: testing/fake-debugger.ts:119

As index!Debugger.enableVectorCatch; only recorded.

Parameters ​

ParameterType
cWireVectorCatchCondition

Returns ​

Promise<void>


hit() ​

ts
hit(pc?): void;

Defined in: testing/fake-debugger.ts:122

Simulate the firmware hitting a breakpoint (or any halt) while running.

Parameters ​

ParameterTypeDefault value
pcbigint0x978n

Returns ​

void


registerTable() ​

ts
registerTable(): Promise<RegisterInfo[]>;

Defined in: testing/fake-debugger.ts:130

As index!Debugger.registerTable: R0–R15, XPSR and S0 of a Cortex-M.

Returns ​

Promise<RegisterInfo[]>


readRegisters() ​

ts
readRegisters(): Promise<RegisterValue[]>;

Defined in: testing/fake-debugger.ts:132

As index!Debugger.readRegisters.

Returns ​

Promise<RegisterValue[]>


writeRegister() ​

ts
writeRegister(register, value): Promise<void>;

Defined in: testing/fake-debugger.ts:137

As index!Debugger.writeRegister, by exact name or id.

Parameters ​

ParameterType
registerstring | number
valuebigint

Returns ​

Promise<void>


readMemory() ​

ts
readMemory(address, count): Promise<Uint8Array<ArrayBuffer>>;

Defined in: testing/fake-debugger.ts:145

As index!Debugger.readMemory: each byte is the low byte of its address.

Parameters ​

ParameterType
addressnumber | bigint
countnumber

Returns ​

Promise<Uint8Array<ArrayBuffer>>


writeMemory() ​

ts
writeMemory(address, data): Promise<void>;

Defined in: testing/fake-debugger.ts:147

As index!Debugger.writeMemory; only recorded.

Parameters ​

ParameterType
addressnumber | bigint
dataUint8Array

Returns ​

Promise<void>


loadDebugInfo() ​

ts
loadDebugInfo(): Promise<void>;

Defined in: testing/fake-debugger.ts:150

As index!Debugger.loadDebugInfo; only recorded (the fake always has debug info).

Returns ​

Promise<void>


loadSvd() ​

ts
loadSvd(): Promise<void>;

Defined in: testing/fake-debugger.ts:154

As index!Debugger.loadSvd.

Returns ​

Promise<void>


clearSvd() ​

ts
clearSvd(): Promise<void>;

Defined in: testing/fake-debugger.ts:156

As index!Debugger.clearSvd; does nothing.

Returns ​

Promise<void>


stackTrace() ​

ts
stackTrace(): Promise<Frame[]>;

Defined in: testing/fake-debugger.ts:159

As index!Debugger.stackTrace: an inlined frame, then step_b, step_a and main.

Returns ​

Promise<Frame[]>


scopes() ​

ts
scopes(frameId): Promise<Scope[]>;

Defined in: testing/fake-debugger.ts:181

As index!Debugger.scopes.

Parameters ​

ParameterType
frameIdnumber

Returns ​

Promise<Scope[]>


variables() ​

ts
variables(reference): Promise<Variable[]>;

Defined in: testing/fake-debugger.ts:216

As index!Debugger.variables; references from before the last resume are rejected.

Parameters ​

ParameterType
referencenumber

Returns ​

Promise<Variable[]>


evaluate() ​

ts
evaluate(expression): Promise<Evaluation>;

Defined in: testing/fake-debugger.ts:224

As index!Debugger.evaluate: knows COUNTER and register names.

Parameters ​

ParameterType
expressionstring

Returns ​

Promise<Evaluation>


setVariable() ​

ts
setVariable(variable, value): Promise<Evaluation>;

Defined in: testing/fake-debugger.ts:233

As index!Debugger.setVariable: writing COUNTER or n changes the program state.

Parameters ​

ParameterType
variablePick<Variable, "name" | "parent">
valuestring

Returns ​

Promise<Evaluation>


breakpoints() ​

ts
breakpoints(): Breakpoint[];

Defined in: testing/fake-debugger.ts:243

As index!Debugger.breakpoints.

Returns ​

Breakpoint[]


setSourceBreakpoints() ​

ts
setSourceBreakpoints(path, specs): Promise<Breakpoint[]>;

Defined in: testing/fake-debugger.ts:245

As index!Debugger.setSourceBreakpoints: line 1 has no code, so it stays unverified.

Parameters ​

ParameterType
pathstring
specs{ line: number; column?: number; }[]

Returns ​

Promise<Breakpoint[]>


setInstructionBreakpoints() ​

ts
setInstructionBreakpoints(addresses): Promise<Breakpoint[]>;

Defined in: testing/fake-debugger.ts:258

As index!Debugger.setInstructionBreakpoints.

Parameters ​

ParameterType
addresses(number | bigint)[]

Returns ​

Promise<Breakpoint[]>


clearBreakpoints() ​

ts
clearBreakpoints(): Promise<void>;

Defined in: testing/fake-debugger.ts:267

As index!Debugger.clearBreakpoints.

Returns ​

Promise<void>


reapplyBreakpoints() ​

ts
reapplyBreakpoints(): Promise<Breakpoint[]>;

Defined in: testing/fake-debugger.ts:269

As index!Debugger.reapplyBreakpoints.

Returns ​

Promise<Breakpoint[]>


resolveSourceLocations() ​

ts
resolveSourceLocations(addresses): Promise<{
  path: string;
  line: number;
  column: number;
}[]>;

Defined in: testing/fake-debugger.ts:271

As index!Debugger.resolveSourceLocations.

Parameters ​

ParameterType
addresses(number | bigint)[]

Returns ​

Promise<{ path: string; line: number; column: number; }[]>


disassemble() ​

ts
disassemble(
   address, 
   count, 
   instructionOffset?
): Promise<Instruction[]>;

Defined in: testing/fake-debugger.ts:273

As index!Debugger.disassemble: alternating Thumb instructions, 2 bytes apart.

Parameters ​

ParameterTypeDefault value
addressnumber | bigintundefined
countnumberundefined
instructionOffsetnumber0

Returns ​

Promise<Instruction[]>