Hello !
I have currently setup a .gdbinit and an openocd script to debug my embedded targets, but I have a few troubles making it work :
gdb is not able to see any symbols (even if debug=true is set in Cargo.toml) except static ones
breakpoints tend to behave strangely : I set up a breakpoint in a specific line, and gdb stops way after telling me that the breakpoint was at line 264 when I used the command br file.rs:160
debugging peripherals and hal is very tedious because you don't have a global peripheral view with all the registers
Is there a good working setup somewhere ?
Ho do you guys work ?
I disaggree with that. Everything you can do with C++ can be done with Rust as well (debugging wise).
When you can attach gdb to your target, you can step around, jump, print variables, registers, doing crazy stuff etc all from gdb/lldb.
It would be good if you explain what you are struggling with. Is it connecting to the target? Printing variables? Setting breakpoints?
What I mean by inconvenient is the points listed in the first post.
Maybe if you have a working setup for the stm32f103 target you could share it with me so that I can compare our configuration files and find the problem !
Okay, so I think I know why I have trouble debugging : using opt-level = 1 instead of opt-level = 3 in the release profile allow the debugger to have much more information about the code. Maybe the optimization from the compile are too aggressive for a proper debugging experience with opt-level = 3 ?
Yes, the opt level certainly affects the debugabilty. Pretty much everything becomes at opt level 3 but I need it turned on to fit in flash. I should try s or z though...
It will setup an OpenOCD server and run GDB for you, all within the context of VSCode.
You can run GDB/OpenOCD commands from within the integrated terminal too.
Breakpoints just work, and so does ITM (iprintln)
Registers and peripheral values are shown in the debug sidebar:
Ability to define JavaScript modules to decode complex data formats streamed over one or more ITM ports. Data can be printed to a output window, or sent to the graphing system.