Condensed stack trace
The stack trace in a test looks like this:
#0 calendar::render::find_free_lane<calendar::render::atasco::ShortEvent> (new_event_begin=250, atasco=0x7ffff7c82da8,
compute_end=0x55555559f480 <calendar::render::Rectangle::compute_bottom_edge>) at crates/calendar/src/render.rs:480
#1 0x000055555559fc75 in calendar::render::short_event_rectangles (short_events=&[calendar::Event](size=5) = {...}, first_date=0x7ffff7c833fc, arguments=0x7ffff7c833ec)
at crates/calendar/src/render.rs:563
#2 0x0000555555597c40 in calendar::render::tests::atasco::test_collision () at crates/calendar/src/render.rs:797
#3 0x0000555555599087 in calendar::render::tests::atasco::test_collision::{closure#0} () at crates/calendar/src/render.rs:764
#4 0x00005555555999e6 in core::ops::function::FnOnce::call_once<calendar::render::tests::atasco::test_collision::{closure_env#0}, ()> ()
at /home/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250
#5 0x00005555555debab in core::ops::function::FnOnce::call_once<fn() -> core::result::Result<(), alloc::string::String>, ()> () at library/core/src/ops/function.rs:250
#6 test::__rust_begin_short_backtrace<core::result::Result<(), alloc::string::String>, fn() -> core::result::Result<(), alloc::string::String>> () at library/test/src/lib.rs:648
#7 0x00005555555dde2e in test::run_test_in_process::{closure#0} () at library/test/src/lib.rs:671
#8 core::panic::unwind_safe::{impl#23}::call_once<core::result::Result<(), alloc::string::String>, test::run_test_in_process::{closure_env#0}> ()
at library/core/src/panic/unwind_safe.rs:272
#9 std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> ()
at library/std/src/panicking.rs:589
#10 std::panicking::catch_unwind<core::result::Result<(), alloc::string::String>, core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>> ()
at library/std/src/panicking.rs:552
#11 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<test::run_test_in_process::{closure_env#0}>, core::result::Result<(), alloc::string::String>> ()
at library/std/src/panic.rs:359
#12 test::run_test_in_process () at library/test/src/lib.rs:671
#13 test::run_test::{closure#0} () at library/test/src/lib.rs:592
#14 0x00005555555a19c4 in test::run_test::{closure#1} () at library/test/src/lib.rs:622
#15 std::sys::backtrace::__rust_begin_short_backtrace<test::run_test::{closure_env#1}, ()> () at library/std/src/sys/backtrace.rs:152
#16 0x00005555555a532a in std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure#0}<test::run_test::{closure_env#1}, ()> () at library/std/src/thread/mod.rs:559
#17 core::panic::unwind_safe::{impl#23}::call_once<(), std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>> ()
at library/core/src/panic/unwind_safe.rs:272
#18 std::panicking::catch_unwind::do_call<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> () at library/std/src/panicking.rs:589
#19 std::panicking::catch_unwind<(), core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>> () at library/std/src/panicking.rs:552
#20 std::panic::catch_unwind<core::panic::unwind_safe::AssertUnwindSafe<std::thread::{impl#0}::spawn_unchecked_::{closure#1}::{closure_env#0}<test::run_test::{closure_env#1}, ()>>, ()> () at library/std/src/panic.rs:359
#21 std::thread::{impl#0}::spawn_unchecked_::{closure#1}<test::run_test::{closure_env#1}, ()> () at library/std/src/thread/mod.rs:557
#22 core::ops::function::FnOnce::call_once<std::thread::{impl#0}::spawn_unchecked_::{closure_env#1}<test::run_test::{closure_env#1}, ()>, ()> ()
at library/core/src/ops/function.rs:250
#23 0x000055555561b7ff in alloc::boxed::{impl#28}::call_once<(), dyn core::ops::function::FnOnce<(), Output=()>, alloc::alloc::Global> () at library/alloc/src/boxed.rs:1966
#24 std::sys::pal::unix::thread::{impl#2}::new::thread_start () at library/std/src/sys/pal/unix/thread.rs:107
#25 0x00007ffff7cf8724 in start_thread (arg=<optimized out>) at pthread_create.c:448
#26 0x00007ffff7d7c80c in __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
Only top 3 entries are from my application, the rest are from the standard library. In addition, there are the addresses of the functions which are needed only in certain cases. The information is useful as long as you work on the layer beyond your application. If this ceases to be the case, the information is redundant. The extension provides a frame filter which removes the addresses and the frames from the standard library. With this filter the stack trace looks like this:
#0 calendar::render::find_free_lane<calendar::render::atasco::ShortEvent>
(new_event_begin=250, atasco=0x7ffff7c82da8, compute_end=0x55555559f480 <calendar::render::Rectangle::compute_bottom_edge>) at crates/calendar/src/render.rs:480
#1 calendar::render::short_event_rectangles (short_events=&[calendar::Event](size=5) = {...}, first_date=0x7ffff7c833fc, arguments=0x7ffff7c833ec)
at crates/calendar/src/render.rs:563
#2 calendar::render::tests::atasco::test_collision () at crates/calendar/src/render.rs:797
#3 calendar::render::tests::atasco::test_collision::{closure#0} () at crates/calendar/src/render.rs:764
#4 core::ops::function::FnOnce::call_once<calendar::render::tests::atasco::test_collision::{closure_env#0}, ()> ()
at /home/laladrik/.rustup/toolchains/stable-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/core/src/ops/function.rs:250
#25 start_thread (arg=<optimized out>) at pthread_create.c:448
#26 __GI___clone3 () at ../sysdeps/unix/sysv/linux/x86_64/clone3.S:78
To disable the frame filter, use the following command:
disable frame-filter global RustToolsGDB.FrameFilter
Commands
Stop at panic!
The macro invokes the function ::core::panicking::panic_fmt. The command breakpanic makes a breakpoint at the function. Example:
(gdb) breakpanic
Breakpoint 1 at 0x55555563c7a8: file library/core/src/panicking.rs, line 145.
Print an element of a Vec
Given the index, returns an element at that index from the Vec:
(gdb) rust_get events 0
$2 = calendar::Event {title: "Desayuno", start_date: calendar::Date {year: 2025, month: 9, day: 29}, start_time: calendar::Time {hour: 0, minute: 0}, end_date: calendar::Date {year: 2025, month: 9, day: 29}, end_time: calendar::Time {hour: 1, minute: 0}, all_day: "False"}
Invoking the command does not allow a field of the element to be accessed. The underlying convenience function addresses the limitation:
(gdb) p $rust_get(events, 0).title
$3 = "Desayuno"
Convenience functions
String comparison
Returns true if the strings are the same, otherwise returs false:
(gdb) print $rust_streq(event.title, "expected string")
$1 = false
Searching for a substring in a string
Searches for the value of the second argument in the value of the first argument, returning its index. It returns -1 if nothing is found. Examples:
(gdb) p $rust_strpos("haystack", "needle")
$3 = -1
(gdb) p $rust_strpos("needlestack", "needle")
$4 = 0
(gdb) p $rust_strpos("stackneedle", "needle")
$5 = 5
Get the length of a collection
Returns the number of elements in the passed collection. It supports String, Vec and &str. Arrays are not supported. To see the size of an array you can use ptype.
Examples:
(gdb) p $rust_len(events[0].title)
$2 = 4
(gdb) p $rust_len(events[0].title.as_str())
$3 = 4
(gdb) p $rust_len(events[0].title.vec)
$4 = 4