Skip to content

Commit 6fc2a05

Browse files
authored
Add enum for Inspect 0x09 payload (#18)
* Add enum for `Inspect 0x09` payload * Fix exports
1 parent 48feb11 commit 6fc2a05

File tree

4 files changed

+55
-14
lines changed

4 files changed

+55
-14
lines changed

src/debug/WARDuino.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,20 @@ export namespace WARDuino {
1212
tableIndexes: number[]
1313
}
1414

15+
export enum Inspect {
16+
counter = '01',
17+
breakpoints = '02',
18+
callstack = '03',
19+
globals = '04',
20+
table = '05',
21+
memory = '06',
22+
branching = '07',
23+
stack = '08',
24+
callbacks = '09',
25+
events = '0a',
26+
io = '0b'
27+
}
28+
1529
export enum Interrupt {
1630
run = '01',
1731
halt = '02',
@@ -72,5 +86,6 @@ export namespace WARDuino {
7286
br_table?: BRTable;
7387
callbacks?: CallbackMapping[];
7488
events?: InterruptEvent[];
89+
io?: string[];
7590
}
7691
}

src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,6 @@ export * from './framework/scenario/Invoker';
1616
export * from './testbeds/TestbedSpecification';
1717
export * from './debug/Breakpoint';
1818
export * from './reporter/index';
19+
export * from './debug/WARDuino';
1920

2021
export const latch = Framework.getImplementation();

src/messaging/Message.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ export interface Request<R> {
3030

3131
export namespace Message {
3232
import Float = WASM.Float;
33+
import Inspect = WARDuino.Inspect;
3334
export const run: Request<Ack> = {
3435
type: Interrupt.run,
3536
parser: (line: string) => {
@@ -85,10 +86,11 @@ export namespace Message {
8586
};
8687
}
8788

88-
export function inspect(payload: string): Request<State> {
89+
export function inspect(fields: Inspect[]): Request<State> {
8990
return {
9091
type: Interrupt.inspect,
91-
payload: () => payload,
92+
payload: () => fields.length.toString(16).padStart(4, '0') + fields.join('')
93+
,
9294
parser: stateParser
9395
}
9496
}

tests/examples/example.ts

Lines changed: 35 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,13 @@ import {
88
Message,
99
Step,
1010
Verbosity,
11-
WASM
11+
WASM,
12+
WARDuino
1213
} from '../../src/index';
1314
import dump = Message.dump;
1415
import stepOver = Message.stepOver;
16+
import Inspect = WARDuino.Inspect;
17+
import State = WARDuino.State;
1518

1619
const framework = Framework.getImplementation();
1720

@@ -74,16 +77,16 @@ const DUMP: Step = {
7477
title: 'Send DUMP command',
7578
instruction: {kind: Kind.Request, value: Message.dump},
7679
expected: [
77-
{'pc': {kind: 'description', value: Description.defined} as Expected<string>},
78-
{
79-
'breakpoints': {
80-
kind: 'comparison', value: (state: Object, value: Array<any>) => {
81-
return value.length === 0;
82-
}, message: 'list of breakpoints should be empty'
83-
} as Expected<Array<any>>
84-
},
85-
{'callstack[0].sp': {kind: 'primitive', value: -1} as Expected<number>},
86-
{'callstack[0].fp': {kind: 'primitive', value: -1} as Expected<number>}]
80+
{'pc': {kind: 'description', value: Description.defined} as Expected<string>},
81+
{
82+
'breakpoints': {
83+
kind: 'comparison', value: (state: Object, value: Array<any>) => {
84+
return value.length === 0;
85+
}, message: 'list of breakpoints should be empty'
86+
} as Expected<Array<any>>
87+
},
88+
{'callstack[0].sp': {kind: 'primitive', value: -1} as Expected<number>},
89+
{'callstack[0].fp': {kind: 'primitive', value: -1} as Expected<number>}]
8790
};
8891

8992
debug.test({
@@ -92,5 +95,25 @@ debug.test({
9295
steps: [DUMP]
9396
});
9497

98+
const reverse = framework.suite('Test Reverse interface');
99+
reverse.testee('emulator[:8530]', new EmulatorSpecification(8530));
100+
101+
reverse.test({
102+
title: 'Test snapshot',
103+
program: 'tests/examples/blink.wast',
104+
steps: [{
105+
title: 'Test IO snapshot',
106+
instruction: {kind: Kind.Request, value: Message.inspect([Inspect.io])},
107+
expected: [{
108+
'io': {
109+
kind: 'comparison', value: (state: State) => state.io?.length === 0
110+
}
111+
}],
112+
},
113+
new Invoker('read', [WASM.i32(BigInt(15))], WASM.i32(BigInt(0))),
114+
new Invoker('write', [WASM.i32(BigInt(15)), WASM.i32(BigInt(1))], undefined),
115+
new Invoker('read', [WASM.i32(BigInt(15))], WASM.i32(BigInt(1)))]
116+
})
117+
95118
framework.reporter.verbosity(Verbosity.debug);
96-
framework.analyse([spec, debug]);
119+
framework.analyse([spec, debug, reverse]);

0 commit comments

Comments
 (0)