this commit refactors the code that prints the backtrace to be comprised of 3 smaller steps
unwind::target, talks to the probe and unwinds the target's program retrieving only a series of PC (program counters). This is fallible due to potential IO errors
symbolicate::frames, turns those raw PC values into function names and locations; it also expands inlined functions. This is infallible. When there's no debuginfo the PC address is used as the function "name".
pp::backtrace, pretty prints the processed frames preserving the current format. this is infallible API-wise (println! may still panic however)
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.
this commit refactors the code that prints the backtrace to be comprised of 3 smaller steps
unwind::target
, talks to the probe and unwinds the target's program retrieving only a series of PC (program counters). This is fallible due to potential IO errorssymbolicate::frames
, turns those raw PC values into function names and locations; it also expands inlined functions. This is infallible. When there's no debuginfo the PC address is used as the function "name".pp::backtrace
, pretty prints the processed frames preserving the current format. this is infallible API-wise (println!
may still panic however)there's more work that could have been done but has intentionally not been included in this commit, like making
unwind::target
and/orsymbolicate::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