-
Notifications
You must be signed in to change notification settings - Fork 197
Description
The embedded rust book in section 2.2 discusses the following example code:
#[entry]
fn main() -> ! {
hprintln!("Hello, world!").unwrap();
// exit QEMU
// NOTE do not run this on hardware; it can corrupt OpenOCD state
// debug::exit(debug::EXIT_SUCCESS);
loop {}
}
But when we reach the Debugging
part of the section, we do see this text:
Breakpoint 1, main () at examples/hello.rs:15
15 let mut stdout = hio::hstdout().unwrap();
This does not correspond to the example code given earlier. I looked a bit in the history of the example code (https://github.com/rust-embedded/cortex-m-quickstart) and the example code was modified in 2018 already to use the hprintln!
macro (commit #9c6b290
, "use hprint macros", "japaric committed on Nov 10, 2018").
The second deviation between the book and what I see happening is when setting the break point on fn main()
:
(gdb) break main
The text suggests the break point is placed on the first line of the main
function:
Breakpoint 1, main () at examples/hello.rs:15
15 let mut stdout = hio::hstdout().unwrap();
This is not the same as I see happening in my setup (rustc 1.49.0 (e1884a8e3 2020-12-29)
):
Breakpoint 1, hello::__cortex_m_rt_main_trampoline () at examples/hello.rs:11
11 #[entry]
Thus just before the fn main()
. When issuing a next
gdb command (as the book suggests), gdb will simply step over the fn main()
function and then basically hangs because of the endless loop ()
inside fn main()
.
When using the step
gdb command it's possible to step inside fn main()' and then execute the
hprintln!` command on its own as intended by the text.
I guess the above deviations might be due more recent Rust
implementations?