You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Aviron: Add breakpoint, set gas, detect infinite loop (#703)
* Update README
* Cleanup tests
* Add breakpoint and gas command line options
* tests: Make the expected value output hex
* aviron: Detect infinite loop used as halt
* Add check_exit method to IO to capture exit instead of killing the process
Copy file name to clipboardExpand all lines: sim/aviron/README.md
+32-20Lines changed: 32 additions & 20 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,16 +8,16 @@ AVR simulator in Zig.
8
8
9
9
```sh
10
10
.
11
-
├── doc # Documents for Aviron or AVR
11
+
├── doc # Documents for Aviron or AVR
12
12
├── samples # Source of examples that can be run on the simulator
13
13
├── src # Source code
14
14
│ ├── lib # - Aviron emulator
15
15
│ ├── libtestsuite # - Source code of the testsuite library
16
16
│ └── shared # - Shared code between the tools, generated code and simulator
17
17
├── testsuite # Contains the test suite of Aviron
18
18
│ ├── instructions # - Tests for single instructions
19
-
│ ├── lib # - Tests for the libtestsuie
20
-
│ ├── simulator # - Tests for the simulator per se
19
+
│ ├── lib # - Tests for the libtestsuite
20
+
│ ├── simulator # - Tests for the simulator per se
21
21
│ └── testrunner # - Tests for the test runner (conditions, checks, ...)
22
22
├── testsuite.avr-gcc # Contains code for the test suite that cannot be built with LLVM right now
23
23
│ └── instructions
@@ -29,8 +29,7 @@ AVR simulator in Zig.
29
29
Run the test suite by invoking
30
30
31
31
```sh-session
32
-
[~/projects/aviron]$ zig build test
33
-
[~/projects/aviron]$
32
+
$ zig build test
34
33
```
35
34
36
35
The `test` step will recursively scan the folder `testsuite` for files of the following types:
@@ -42,7 +41,9 @@ The `test` step will recursively scan the folder `testsuite` for files of the fo
42
41
-*load*`.bin`
43
42
-*load*`.elf`
44
43
45
-
File extensions marked *compile* will be compiled or assembled with the Zig compiler, then executed with the test runner. Those files allow embedding a JSON configuration via Zig file documentation comments:
44
+
File extensions marked *compile* will be compiled or assembled with the Zig compiler, then executed
45
+
with the test runner. Those files allow embedding a JSON configuration via Zig file documentation
For files marked as *load*, another companion file `.bin.json` or similar contains the configuration for this test.
62
+
For files marked as *load*, another companion file `.bin.json` or similar contains the configuration
63
+
for this test.
62
64
63
-
The [JSON schema](src/testconfig.zig) allows description of how the file is built and the test runner is executed. It also contains a set of pre- and postconditions that can be used to set up the CPU and validate it after the program exits.
65
+
The [JSON schema](src/testconfig.zig) allows description of how the file is built and the test
66
+
runner is executed. It also contains a set of pre- and postconditions that can be used to set up the
67
+
CPU and validate it after the program exits.
64
68
65
-
If you're not sure if your code compiled correctly, you can use the `debug-testsuite` build step to inspect the generated files:
69
+
If you're not sure if your code compiled correctly, you can use the `debug-testsuite` build step to
70
+
inspect the generated files:
66
71
67
72
```sh-session
68
-
[~/projects/aviron]$ zig build debug-testsuite
69
-
[~/projects/aviron]$ tree zig-out/
73
+
$ zig build debug-testsuite
74
+
$ tree zig-out/
70
75
zig-out/
71
76
├── bin
72
77
│ └── aviron-test-runner
@@ -90,7 +95,7 @@ zig-out/
90
95
You can then disassemble those files with either `llvm-objdump` or `avr-objdump`:
zig-out/testsuite/instructions/out-exit-0.elf: file format elf32-avr
106
111
@@ -110,23 +115,30 @@ Disassembly of section .text:
110
115
0: 00 27 eor r16, r16
111
116
2: 00 b9 out 0x00, r16 ; 0
112
117
113
-
[~/projects/aviron]$
118
+
$
114
119
```
115
120
116
-
The test runner is located at [src/testrunner.zig](src/testrunner.zig) and behaves similar to the main `aviron` executable, but introduces a good amount of checks we can use to inspect and validate the simulation.
121
+
The test runner is located at [src/testrunner.zig](src/testrunner.zig) and behaves similar to the
122
+
main `aviron` executable, but introduces a good amount of checks we can use to inspect and validate
123
+
the simulation.
117
124
118
125
### Updating AVR-GCC tests
119
126
120
-
To prevent a hard dependency on the `avr-gcc` toolchain, we vendor the binaries for all tests defined in the folder `testsuite.avr-gcc`. To update the files, you need to invoke the `update-testsuite` build step:
127
+
To prevent a hard dependency on the `avr-gcc` toolchain, we vendor the binaries for all tests
128
+
defined in the folder `testsuite.avr-gcc`. To update the files, you need to invoke the
129
+
`update-testsuite` build step:
121
130
122
131
```sh-session
123
-
[~/projects/aviron]$ zig build update-testsuite
124
-
[~/projects/aviron]$
132
+
$ zig build update-testsuite
133
+
$
125
134
```
126
135
127
136
After that, `zig build test` will run the regenerated tests.
128
137
129
-
**NOTE:** The build will not detect changed files, so you have no guarantee that running `zig build update-testsuite test` will actually do the right thing. If you're working on the test suite, just use `zig build update-testsuite && zig build test` for this.
138
+
> [!NOTE]
139
+
> The build will not detect changed files, so you have no guarantee that running `zig build
140
+
> update-testsuite test` will actually do the right thing. If you're working on the test suite, just
141
+
> use `zig build update-testsuite && zig build test` for this.
0 commit comments