Crate for tracing stack dumps

10 releases

0.3.0 May 19, 2023
0.2.4 Apr 7, 2023
0.2.3 Jul 26, 2022
0.2.0 Jun 28, 2022
0.1.1 Feb 24, 2022

#468 in Embedded development

Download history 46/week @ 2023-02-04 21/week @ 2023-02-11 37/week @ 2023-02-18 6/week @ 2023-02-25 5/week @ 2023-03-04 2/week @ 2023-03-11 3/week @ 2023-03-18 1/week @ 2023-03-25 25/week @ 2023-04-01 24/week @ 2023-04-08 15/week @ 2023-04-15 3/week @ 2023-04-22 9/week @ 2023-04-29 20/week @ 2023-05-06 20/week @ 2023-05-13 25/week @ 2023-05-20

74 downloads per month
Used in stackdump-cli



Stackdump Trace

crates.io Documentation

This crate implement stack tracing from the memory that was captured using the stackdump-capture crate.

Also see the main repo readme.

The aim is to extract as much information from the captured memory as possible. As such, not only the stack frames are given, but also the variables that are present in each frame. The value of these variables can only be read if their memory is captured.

The minimum this crate needs is a stack & registers capture. But if any variable is found that points outside the stack, like a String, then you´ll need to have captured the heap memory as well. Otherwise it will just show the pointer value.

Right now, only the cortex m target is supported. A lot of the code could be refactored to work cross-platform.

If you want to add a target, then please discuss and create an issue or PR.


In this case we have a cortex m target with FPU. A dump has been made with the two register captures first and then the stack capture.

# use stackdump_core::device_memory::DeviceMemory;
# use stackdump_core::register_data::VecRegisterData;
# use stackdump_core::memory_region::VecMemoryRegion;
# use stackdump_trace::platform::cortex_m::CortexMPlatform;
# use stackdump_trace::render_colors::Theme;

let dump: Vec<u8> = todo!(); // Get your dump from somewhere
let elf: Vec<u8> = todo!(); // Read your elf file

let mut dump_iter = dump.iter().copied();

let mut device_memory = DeviceMemory::new();

device_memory.add_register_data(VecRegisterData::from_iter(&mut dump_iter));
device_memory.add_register_data(VecRegisterData::from_iter(&mut dump_iter));
device_memory.add_memory_region(VecMemoryRegion::from_iter(&mut dump_iter));

let frames = stackdump_trace::platform::trace::<CortexMPlatform>(device_memory, &elf).unwrap();

for (i, frame) in frames.iter().enumerate() {
    println!("{}: {}", i, frame.display(true, false, false, Theme::Dark));

Reading live from the device

In principle, if you have a way of reading the memory of the device directly (e.g. via probe-rs), then it is possible to create types that implement RegisterData and MemoryRegion so that you can insert those into the DeviceMemory instance.


~128K SLoC