Skip to content

Commit

Permalink
πŸ§‘β€πŸ’» Improve POSTMORTEM_DEBUGGING (MarlinFirmware#26374)
Browse files Browse the repository at this point in the history
Co-authored-by: Scott Lahteine <[email protected]>
  • Loading branch information
2 people authored and eoyilmaz committed Nov 21, 2023
1 parent 1e0694b commit 8320715
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 6 additions & 1 deletion Marlin/src/HAL/shared/backtrace/unwarmbytab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,12 @@ static const char *UnwTabGetFunctionName(const UnwindCallbacks *cb, uint32_t add
return nullptr;

if ((flag_word & 0xFF000000) == 0xFF000000) {
return (const char *)(address - 4 - (flag_word & 0x00FFFFFF));
const uint32_t fn_name_addr = address - 4 - (flag_word & 0x00FFFFFF);

// Ensure the address is readable to avoid returning a bogus pointer
uint8_t dummy = 0;
if (cb->readB(fn_name_addr, &dummy))
return (const char *)fn_name_addr;
}
return nullptr;
}
Expand Down
2 changes: 0 additions & 2 deletions Marlin/src/HAL/shared/cpu_exception/exception_arm.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -279,8 +279,6 @@ void CommonHandler_C(ContextStateFrame * frame, unsigned long lr, unsigned long
if (!faulted_from_exception) { // Not sure about the non_usage_fault, we want to try anyway, don't we ? && !non_usage_fault_occurred)
// Try to resume to our handler here
CFSR |= CFSR; // The ARM programmer manual says you must write to 1 all fault bits to clear them so this instruction is correct
// The frame will not be valid when returning anymore, let's clean it
savedFrame.CFSR = 0;

frame->pc = (uint32_t)resume_from_fault; // Patch where to return to
frame->lr = 0xDEADBEEF; // If our handler returns (it shouldn't), let's make it trigger an exception immediately
Expand Down

0 comments on commit 8320715

Please sign in to comment.