-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Capturing stack fails, calculating stack_size too big. #32
Comments
Panic handler #[defmt::panic_handler]
fn panic() -> ! {
cortex_m::interrupt::free(|_cs| {
unsafe {
stackdump_capture::cortex_m::capture(
&mut *STACK_CAPTURE.as_mut_ptr(),
&mut *CORE_REGISTERS_CAPTURE.as_mut_ptr(),
&mut *FPU_REGISTERS_CAPTURE.as_mut_ptr(),
);
// If you want to capture the heap or the static data, then do that here too yourself
}
set_capture_made();
});
cortex_m::peripheral::SCB::sys_reset(); //panic_reset
//cortex_m::asm::udf() //panic_probe
} Cargo tree
|
Yes, the stack_start is 0x20040000. In my case, the application does not crash, but I can not print the STACK_CAPTURE through defmt. The issue I encountered was that when this code is ran when a capture was made: if is_capture_made() {
reset_capture_made();
info!("STACKCAPTURE {=[u8]:x}", unsafe {
STACK_CAPTURE
.assume_init_ref()
.bytes()
.collect::<Vec<u8, 0x4000>>()
});
info!("CORECAPTURE {=[u8]:x}", unsafe {
CORE_REGISTERS_CAPTURE
.assume_init_ref()
.bytes()
.collect::<Vec<u8, 128>>()
});
info!("FPUCAPTURE {=[u8]:x}", unsafe {
FPU_REGISTERS_CAPTURE
.assume_init_ref()
.bytes()
.collect::<Vec<u8, 256>>()
}); The output is this:
I never get the first info!, not even an empty array or similiar. |
Well, it seems that defmt might sometimes now show messages that overwhelm its resources. |
Summary
When stack capture is created, the stack_size is calculated. Debugging our project I see that this is calculated to be 536875968, which is rather large, and seems to rather be a memory address, 0x200013c0.
![Screenshot 2023-08-03 at 17 27 37](https://private-user-images.githubusercontent.com/551129/258161556-cd24ad5c-d19d-4298-aa15-f225f8d74b86.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjUxNzA0NzAsIm5iZiI6MTcyNTE3MDE3MCwicGF0aCI6Ii81NTExMjkvMjU4MTYxNTU2LWNkMjRhZDVjLWQxOWQtNDI5OC1hYTE1LWYyMjVmOGQ3NGI4Ni5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwOTAxJTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDkwMVQwNTU2MTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT1hYmRkYjE2MTM4ZDEyODliYmU5OGNhMjg5OTk3ODZiMjE2YThmMzNkNmVjMmM3YjBjZDU3OWY1OGI5ZGM0MDdmJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.INQI-eMAOR5aYSUIM9HBeWIHjp3oaFXRHj66lpUEcgc)
Story
So I realized that I cannot print the stack capture on start, but fpu and core registers are fine with this:
Then I tried to debug the issue, (but debug itself became the issue, then we solved that) and saw that stack_size value turns out to be something resembling a memory address.
The issue is that I still can't debug in opt = 0 , therefore cannot follow what is going wrong there.
Some data (will provide)
The text was updated successfully, but these errors were encountered: