mirror of
https://github.com/ferrous-systems/embedded-trainings-2020.git
synced 2024-10-31 22:28:49 +00:00
Merge pull request #177 from ferrous-systems/update-probe-run-output
Update probe-run output to newer versions
This commit is contained in:
commit
8b15469bd3
4 changed files with 33 additions and 33 deletions
|
@ -321,8 +321,7 @@ fn RTC0() {
|
||||||
unsafe { core::mem::transmute::<_, RTC0>(()).events_ovrflw.reset() }
|
unsafe { core::mem::transmute::<_, RTC0>(()).events_ovrflw.reset() }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Exits the application and prints a backtrace when the program is executed through the `probe-run`
|
/// Exits the application when the program is executed through the `probe-run` Cargo runner
|
||||||
/// Cargo runner
|
|
||||||
pub fn exit() -> ! {
|
pub fn exit() -> ! {
|
||||||
log::info!("`dk::exit() called; exiting ...`");
|
log::info!("`dk::exit() called; exiting ...`");
|
||||||
// force any pending memory operation to complete before the BKPT instruction that follows
|
// force any pending memory operation to complete before the BKPT instruction that follows
|
||||||
|
|
|
@ -5,17 +5,25 @@
|
||||||
This program attempts to index an array beyond its length and this results in a panic.
|
This program attempts to index an array beyond its length and this results in a panic.
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
|
(HOST) INFO flashing program (34.79 KiB)
|
||||||
|
(HOST) INFO success!
|
||||||
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
ERROR:panic_log -- panicked at 'index out of bounds: the len is 3 but the index is 3', src/bin/panic.rs:29:13
|
ERROR:panic_log -- panicked at 'index out of bounds: the len is 3 but the index is 3', src/bin/panic.rs:29:13
|
||||||
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
stack backtrace:
|
stack backtrace:
|
||||||
0: 0x000022f0 - __bkpt
|
0: HardFaultTrampoline
|
||||||
1: 0x00002010 - rust_begin_unwind
|
<exception entry>
|
||||||
2: 0x00000338 - core::panicking::panic_fmt
|
[...]
|
||||||
3: 0x00000216 - core::panicking::panic_bounds_check
|
7: panic::bar
|
||||||
4: 0x0000016a - panic::bar
|
at src/bin/panic.rs:29:13
|
||||||
5: 0x00000158 - panic::foo
|
8: panic::foo
|
||||||
6: 0x00000192 - panic::__cortex_m_rt_main
|
at src/bin/panic.rs:22:5
|
||||||
7: 0x00000178 - main
|
9: panic::__cortex_m_rt_main
|
||||||
8: 0x0000199e - Reset
|
at src/bin/panic.rs:12:5
|
||||||
|
10: main
|
||||||
|
at src/bin/panic.rs:8:1
|
||||||
|
[...]
|
||||||
|
(HOST) ERROR the program panicked
|
||||||
```
|
```
|
||||||
|
|
||||||
In `no_std` programs the behavior of panic is defined using the `#[panic_handler]` attribute. In the example, the *panic handler* is defined in the `panic_log` crate but we can also implement it manually:
|
In `no_std` programs the behavior of panic is defined using the `#[panic_handler]` attribute. In the example, the *panic handler* is defined in the `panic_log` crate but we can also implement it manually:
|
||||||
|
|
|
@ -14,20 +14,13 @@ Expected output:
|
||||||
``` console
|
``` console
|
||||||
$ cargo run --bin hello
|
$ cargo run --bin hello
|
||||||
Running `probe-run --chip nRF52840_xxAA target/thumbv7em-none-eabihf/debug/hello`
|
Running `probe-run --chip nRF52840_xxAA target/thumbv7em-none-eabihf/debug/hello`
|
||||||
(HOST) INFO flashing program (30.09 KiB)
|
(HOST) INFO flashing program (34.79 KiB)
|
||||||
(HOST) INFO success!
|
(HOST) INFO success!
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
INFO:hello -- Hello, world!
|
INFO:hello -- Hello, world!
|
||||||
stack backtrace:
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
0: __bkpt
|
(HOST) INFO device halted without error
|
||||||
1: hello::__cortex_m_rt_main
|
|
||||||
at src/bin/hello.rs:15
|
|
||||||
2: main
|
|
||||||
at src/bin/hello.rs:8
|
|
||||||
3: ResetTrampoline
|
|
||||||
at $REGISTRY/cortex-m-rt-0.6.13/src/lib.rs:547
|
|
||||||
4: Reset
|
|
||||||
at $REGISTRY/cortex-m-rt-0.6.13/src/lib.rs:550
|
|
||||||
```
|
```
|
||||||
|
|
||||||
`cargo run` will compile the application and then invoke the `probe-run` tool with its argument set to the path of the output ELF file.
|
`cargo run` will compile the application and then invoke the `probe-run` tool with its argument set to the path of the output ELF file.
|
||||||
|
|
|
@ -16,24 +16,24 @@ The `spam()` function allocates data on the stack until the stack boundaries are
|
||||||
|
|
||||||
✅ Run `stack_overflow.rs`
|
✅ Run `stack_overflow.rs`
|
||||||
|
|
||||||
You should see output similar to this:
|
You should see output similar to this (the program output between the horizontal bars might be missing):
|
||||||
|
|
||||||
``` console
|
``` console
|
||||||
(...)
|
(HOST) INFO flashing program (35.25 KiB)
|
||||||
(HOST) INFO flashing program (32.68 KiB)
|
(HOST) INFO success!
|
||||||
(HOST) INFO success!
|
|
||||||
────────────────────────────────────────────────────────────────────────────────
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
INFO:stack_overflow -- provoking stack overflow...
|
INFO:stack_overflow -- provoking stack overflow...
|
||||||
INFO:stack_overflow -- address of current `use_stack` at recursion depth 0: 0x2003aec0
|
INFO:stack_overflow -- address of current `use_stack` at recursion depth 0: 0x2003aec0
|
||||||
INFO:stack_overflow -- address of current `use_stack` at recursion depth 1: 0x20039e50
|
INFO:stack_overflow -- address of current `use_stack` at recursion depth 1: 0x20039e50
|
||||||
(...)
|
(...)
|
||||||
INFO:stack_overflow -- address of current `use_stack` at recursion depth 10: 0x20030a60
|
INFO:stack_overflow -- address of current `use_stack` at recursion depth 10: 0x20030a60
|
||||||
INFO:stack_overflow -- address of current `use_stack` at recursionstack backtrace:
|
INFO:stack_overflow -- address of current `use_stack` at recursion
|
||||||
|
────────────────────────────────────────────────────────────────────────────────
|
||||||
|
stack backtrace:
|
||||||
0: HardFaultTrampoline
|
0: HardFaultTrampoline
|
||||||
<exception entry>
|
<exception entry>
|
||||||
1: ???
|
(HOST) WARN call stack was corrupted; unwinding could not be completed
|
||||||
error: the stack appears to be corrupted beyond this point
|
(HOST) ERROR the program has overflowed its stack
|
||||||
(HOST) ERROR the program has overflowed its stack
|
|
||||||
```
|
```
|
||||||
|
|
||||||
❗️ `flip-link` is a third-party tool, so make sure you've installed it through `cargo install flip-link`
|
❗️ `flip-link` is a third-party tool, so make sure you've installed it through `cargo install flip-link`
|
||||||
|
|
Loading…
Reference in a new issue