knurling-rs / probe-run

Run embedded programs just like native ones
Apache License 2.0
643 stars 75 forks source link

refactor "print backtrace" code #197

Closed japaric closed 3 years ago

japaric commented 3 years ago

this commit refactors the code that prints the backtrace to be comprised of 3 smaller steps

there's more work that could have been done but has intentionally not been included in this commit, like making unwind::target and/or symbolicate::frames lazy to only do as much work as required by the --max_backtrace_len flag.

this commit also fixes issue 196 by making --max_backtrace_len=1 print the right number of frames. The behavior of --max_backtrace_len=0 has been changed to never print a backtrace (--force-backtrace --max-backtrace-len=0 does not print a backtrace)

this commit also (non-exhaustively) groups Cortex-M constants and operations in a module to make them easier to spot (in case we ever add support for other architectures like RISC V). a qualified path, instead of an import, is used to access the items in that module.

we don't have automated tests for the backtrace but manual testing indicates that behavior is preserved. the warning message about the stack being corrupted now has less detail however.

fixes #196

jonas-schievink commented 3 years ago

bors r+

bors[bot] commented 3 years ago

Build succeeded: