I'm on section 5.4 of the Embedded Rust Discovery book. I've gotten the code to compile and load into the discovery board. When I get to 'break main', gdb breaks at line 7, #[entry]', not line 9, like the example in the book.
Typing continue works, but again it breaks at line 7 not 9. But when I type 'next', GDB hangs.
If I hit control-c, I get the following:
(gdb) next
^C
Program received signal SIGINT, Interrupt.
0x080039ac in HardFault_ (ef=0x10001d88) at /Users/jprain/.cargo/registry/src/github.com-1ecc6299db9ec823/cortex-m-rt-0.6.12/src/lib.rs:555
555 atomic::compiler_fence(Ordering::SeqCst);
I'm using a Mac running 10.15.6.
The code I'm trying to use is the same as the book, but it's here:
So I've now set this up on both Ubuntu and MacOS and I'm getting the same problem on both.
I've found a work around though. Instead of typing 'break main' into gdb. I just type break and the line number. So in this case it would be 'break 9'. Then I can keep going with step and next the way the examples show.
I would still like to know why break main doesn't break on the main function the way it shows in the examples. Do I have something setup wrong? Has GDB changed and break main no longer works for embedded?
Glancing at the source, it looks like the #[entry] macro rewrites your main function into a modified version with a name like __cortex_m_rt_main, and then emits its own separate entry point function.
Perhaps the behavior of the macro changed and the book hasn't been updated to reflect it, yet. It looks like the problem has been reported by other readers, too: