From 50969458c3157396b4b8eab18e24e1f891b207c0 Mon Sep 17 00:00:00 2001 From: tolauwae Date: Tue, 27 Aug 2024 00:12:49 +0200 Subject: [PATCH 1/2] Add enum for `Inspect 0x09` payload --- src/debug/WARDuino.ts | 15 +++++++++++++++ src/messaging/Message.ts | 6 ++++-- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/debug/WARDuino.ts b/src/debug/WARDuino.ts index c4dec9f..fd1f89f 100644 --- a/src/debug/WARDuino.ts +++ b/src/debug/WARDuino.ts @@ -12,6 +12,20 @@ export namespace WARDuino { tableIndexes: number[] } + export enum Inspect { + counter = '01', + breakpoints = '02', + callstack = '03', + globals = '04', + table = '05', + memory = '06', + branching = '07', + stack = '08', + callbacks = '09', + events = '0a', + io = '0b' + } + export enum Interrupt { run = '01', halt = '02', @@ -72,5 +86,6 @@ export namespace WARDuino { br_table?: BRTable; callbacks?: CallbackMapping[]; events?: InterruptEvent[]; + io?: string[]; } } \ No newline at end of file diff --git a/src/messaging/Message.ts b/src/messaging/Message.ts index 0288571..23e684a 100644 --- a/src/messaging/Message.ts +++ b/src/messaging/Message.ts @@ -30,6 +30,7 @@ export interface Request { export namespace Message { import Float = WASM.Float; + import Inspect = WARDuino.Inspect; export const run: Request = { type: Interrupt.run, parser: (line: string) => { @@ -85,10 +86,11 @@ export namespace Message { }; } - export function inspect(payload: string): Request { + export function inspect(fields: Inspect[]): Request { return { type: Interrupt.inspect, - payload: () => payload, + payload: () => fields.length.toString(16).padStart(4, '0') + fields.join('') + , parser: stateParser } } From 03bb865ecff6d695ffb364571f5f92b91d1f95e0 Mon Sep 17 00:00:00 2001 From: Tom Lauwaerts Date: Thu, 22 Jan 2026 08:26:16 +0100 Subject: [PATCH 2/2] Fix exports --- src/index.ts | 1 + tests/examples/example.ts | 47 +++++++++++++++++++++++++++++---------- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/index.ts b/src/index.ts index b30a277..49e7049 100644 --- a/src/index.ts +++ b/src/index.ts @@ -16,5 +16,6 @@ export * from './framework/scenario/Invoker'; export * from './testbeds/TestbedSpecification'; export * from './debug/Breakpoint'; export * from './reporter/index'; +export * from './debug/WARDuino'; export const latch = Framework.getImplementation(); diff --git a/tests/examples/example.ts b/tests/examples/example.ts index 6210ad7..6698adc 100644 --- a/tests/examples/example.ts +++ b/tests/examples/example.ts @@ -8,10 +8,13 @@ import { Message, Step, Verbosity, - WASM + WASM, + WARDuino } from '../../src/index'; import dump = Message.dump; import stepOver = Message.stepOver; +import Inspect = WARDuino.Inspect; +import State = WARDuino.State; const framework = Framework.getImplementation(); @@ -74,16 +77,16 @@ const DUMP: Step = { title: 'Send DUMP command', instruction: {kind: Kind.Request, value: Message.dump}, expected: [ - {'pc': {kind: 'description', value: Description.defined} as Expected}, - { - 'breakpoints': { - kind: 'comparison', value: (state: Object, value: Array) => { - return value.length === 0; - }, message: 'list of breakpoints should be empty' - } as Expected> - }, - {'callstack[0].sp': {kind: 'primitive', value: -1} as Expected}, - {'callstack[0].fp': {kind: 'primitive', value: -1} as Expected}] + {'pc': {kind: 'description', value: Description.defined} as Expected}, + { + 'breakpoints': { + kind: 'comparison', value: (state: Object, value: Array) => { + return value.length === 0; + }, message: 'list of breakpoints should be empty' + } as Expected> + }, + {'callstack[0].sp': {kind: 'primitive', value: -1} as Expected}, + {'callstack[0].fp': {kind: 'primitive', value: -1} as Expected}] }; debug.test({ @@ -92,5 +95,25 @@ debug.test({ steps: [DUMP] }); +const reverse = framework.suite('Test Reverse interface'); +reverse.testee('emulator[:8530]', new EmulatorSpecification(8530)); + +reverse.test({ + title: 'Test snapshot', + program: 'tests/examples/blink.wast', + steps: [{ + title: 'Test IO snapshot', + instruction: {kind: Kind.Request, value: Message.inspect([Inspect.io])}, + expected: [{ + 'io': { + kind: 'comparison', value: (state: State) => state.io?.length === 0 + } + }], + }, + new Invoker('read', [WASM.i32(BigInt(15))], WASM.i32(BigInt(0))), + new Invoker('write', [WASM.i32(BigInt(15)), WASM.i32(BigInt(1))], undefined), + new Invoker('read', [WASM.i32(BigInt(15))], WASM.i32(BigInt(1)))] +}) + framework.reporter.verbosity(Verbosity.debug); -framework.analyse([spec, debug]); +framework.analyse([spec, debug, reverse]);