-
Notifications
You must be signed in to change notification settings - Fork 0
Step through a stack trace
The VEX V5 frameworks PROS and vexide provide users with stack traces to aid in debugging during a crash. These help the savvy developer figure out exactly what caused a crash. For example, in the following Rust program, the program will crash because the function foo
is given a number bigger than 5:
fn foo(num: i32) {
if num > 5 {
panic!("num was bigger than 5");
}
}
fn main() {
foo(10);
}
If this code ran in a desktop environment, the crash message would include the name of the function which ran foo
as well as its file and line number:
thread 'main' panicked at src/main.rs:3:9:
num was bigger than 5
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: playground::foo
at ./src/main.rs:3:9
3: playground::main
at ./src/main.rs:8:5
However, code running on the VEX V5 doesn't give specific line numbers or file names in stack traces; instead, it provides hexadecimal address numbers describing each line's location in the robot's memory. You can then use Symbolizer for VEX V5 to turn these numbers into something more useful for humans and jump to each line in your stack trace.
Install Symbolizer for VEX V5 from the VS Code extension marketplace:
https://marketplace.visualstudio.com/items?itemName=vexide.symbolizer-for-vex-v5
Stack traces are sent over the robot's USB serial connection, so connect the V5 brain to your computer using a USB cable before running the buggy program.
Start the V5 brain terminal by selecting PROS icon > V5 Brain > Brain Terminal.
The next time the buggy program crashes, its stack trace will appear in the newly opened brain terminal.
Start the V5 brain terminal by opening a new terminal and running cargo v5 terminal
.
Hold Ctrl (Windows, Linux) or Command (macOS) while clicking on each address to jump to reveal what code was running during the crash. More recent function calls will appear at the top of the stack trace.
If the code you open is part of an external framework like PROS, Symbolizer for VEX V5 may need to give you a link to the relevant code online instead of opening it directly in your editor.