@@ -108,7 +108,7 @@ The autorun script broken down:
...
@@ -108,7 +108,7 @@ The autorun script broken down:
The `gdb` tool allows to program and debug the target, e.g., set breakpoints, inspect memory, etc. `gdb` can be highly automated through scripting. In the `DEBUG` console you can interact directly with `gdb`. The integration between the console and `vscode` is rudimentary. The `vscode``Native Debug` view is in general not notified/updated (by stepping/continuing through `vscode` icons/shortcuts the view gets in synch). Even so, manual interaction with `gdb` can be very useful, an example is to restart the program without reloading it (there is no shortcut/icon for this functionality in the `Native Debug` extension). Enter in the `DEBUG` console:
The `gdb` tool allows to program and debug the target, e.g., set breakpoints, inspect memory, etc. `gdb` can be highly automated through scripting. In the `DEBUG` console you can interact directly with `gdb`. The integration between the console and `vscode` is rudimentary. The `vscode``Native Debug` view is in general not notified/updated (by stepping/continuing through `vscode` icons/shortcuts the view gets in synch). Even so, manual interaction with `gdb` can be very useful, an example is to restart the program without reloading it (there is no shortcut/icon for this functionality in the `Native Debug` extension). Enter in the `DEBUG` console:
> source() r
> source r
or simply:
or simply:
...
@@ -132,6 +132,7 @@ In the `examples` folder you find:
...
@@ -132,6 +132,7 @@ In the `examples` folder you find:
## bare0.rs
## bare0.rs
This is a simple bare metal applicaiton:
This is a simple bare metal applicaiton:
``` rust
``` rust
//! bare0.rs
//! bare0.rs
//! Simple bare metal application
//! Simple bare metal application
...
@@ -190,7 +191,7 @@ MEMORY
...
@@ -190,7 +191,7 @@ MEMORY
}
}
```
```
## Compilng and Debugging
## Compilng and Inspecting the binary
First compile the example either through the `vscode` Tasks (Ctrl-Shift-B) or using the console:
First compile the example either through the `vscode` Tasks (Ctrl-Shift-B) or using the console:
...
@@ -361,6 +362,7 @@ We can compile the `bare0` application in -- release mode instead.
...
@@ -361,6 +362,7 @@ We can compile the `bare0` application in -- release mode instead.
So the Rust compiler is able to figure out that the assertion will be violated and merely calls the `panic` routine. So be aware, the Rust compiler is extremely aggressive in optimizing your code. On a side note the semantics of integer additions is slightly different between `dev` (normal/non-optimized) and `--release` (optimized) builds. In `dev` build the arithmics are checked and overflows result in a `panic`, in `--release`, arithmetics are unchecked (for performance reasons), and oveflows wrap (under two's complement semantics). To avoid ambiguity, you may use methods defined in the std/core library:
So the Rust compiler is able to figure out that the assertion will be violated and merely calls the `panic` routine. So be aware, the Rust compiler is extremely aggressive in optimizing your code.
On a side note: the semantics of integer additions is slightly different between `dev` (normal/non-optimized) and `--release` (optimized) builds. In `dev` build the arithmics are checked and overflows result in a `panic`, in `--release`, arithmetics are unchecked (for performance reasons), and oveflows wrap (under two's complement semantics). To avoid ambiguity, you may use methods defined in the std/core library:
- `wrapping_add`, `wrapping_sub`,returns the straight two’s complement result,
- `wrapping_add`, `wrapping_sub`,returns the straight two’s complement result,
- `saturating_add`, `saturating_sub`, returns the largest/smallest value (as appropriate) of the type when overflow occurs,
- `saturating_add`, `saturating_sub`, returns the largest/smallest value (as appropriate) of the type when overflow occurs,
...
@@ -407,9 +411,61 @@ So the Rust compiler is able to figure out that the assertion will be violated a
...
@@ -407,9 +411,61 @@ So the Rust compiler is able to figure out that the assertion will be violated a
Those methods never `panic`, but code might be verbose, e.g., expressing `x - y + z` under wrapping arithmetics equates to `x.wrapping_sub(y).wrapping_add(z)`. To this end you may choose to use the [Wrapping](https://doc.rust-lang.org/std/num/struct.Wrapping.html) type.
Those methods never `panic`, but code might be verbose, e.g., expressing `x - y + z` under wrapping arithmetics equates to `x.wrapping_sub(y).wrapping_add(z)`. To this end you may choose to use the [Wrapping](https://doc.rust-lang.org/std/num/struct.Wrapping.html) type.