Open PieterJanVdb opened 1 year ago
Having this same issue on iMac.
Same issue here on M1 Mac. The lines in the range 13-15 seem to be absent, you can verify this by executing next
several times. You will see that gdb jumps from line 12 straight to line 16. Also, I tried disabling optimizations explicitly by specifying "-C", "opt-level=0"
in .cargo/config
, but it didn't help.
I got it to work by downgrading rust to 1.66 and half
crate to 2.2.1 (since 2.3.1 requires rust 1.70+). It seems that there was a change in 1.69 that is causing this weird optimization because 1.68.2 was the last version where I couldn't reproduce it. I wonder if this is the case for other platforms.
UPD. This also happens on Linux x86_64
This is also currently happening on Arch Linux for me. For now I'll move forward with the chapter and "take his word for it".
Immediate discoveries: the lines in question aren't actually being compiled away. By manually next
ing, while it does jump over the _y = x
, doing a info locals
afterwards does show that _y = 42
, so the setting did indeed happen.
I have the same issue on Linux Mint 20.04, Ubuntu 20.04. I.e. jumping from line 12 to 15 whilst single stepping. I also have another problem with the code on section 5.4 'The led and delay abstractions'. When using 'next' to step over the call to let (mut delay, mut leds): (Delay, LedArray) = aux5::init() it jumps straight to the loop, as if I'd typed 'continue'. When using the assembler view and 'si' to step into the aux5::init() function, it again steps over it. Anyone else experiencing this?
Not entirely sure what is happening here, I'm guessing it's some compiler optimization, but I can't seem to put a breakpoint on line 13 as shown in the chapter. Instead it only allows me to break on line 12 and line 16 (the loop).
The asm TUI looks like this:
While the disassembly looks like this:
At first glance it seems like the statement on line 13 has been optimized away, but I'm pretty sure the binary was built without optimizations:
For the record, I'm running this on Mac M1, with arm-none-eabi-gdb as the debugger