Skip to content

Commit 8320715

Browse files
shadow578thinkyhead
authored andcommitted
πŸ§‘β€πŸ’» Improve POSTMORTEM_DEBUGGING (MarlinFirmware#26374)
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
1 parent 1e0694b commit 8320715

File tree

2 files changed

+6
-3
lines changed

2 files changed

+6
-3
lines changed

β€ŽMarlin/src/HAL/shared/backtrace/unwarmbytab.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,12 @@ static const char *UnwTabGetFunctionName(const UnwindCallbacks *cb, uint32_t add
5555
return nullptr;
5656

5757
if ((flag_word & 0xFF000000) == 0xFF000000) {
58-
return (const char *)(address - 4 - (flag_word & 0x00FFFFFF));
58+
const uint32_t fn_name_addr = address - 4 - (flag_word & 0x00FFFFFF);
59+
60+
// Ensure the address is readable to avoid returning a bogus pointer
61+
uint8_t dummy = 0;
62+
if (cb->readB(fn_name_addr, &dummy))
63+
return (const char *)fn_name_addr;
5964
}
6065
return nullptr;
6166
}

β€ŽMarlin/src/HAL/shared/cpu_exception/exception_arm.cpp

-2
Original file line numberDiff line numberDiff line change
@@ -279,8 +279,6 @@ void CommonHandler_C(ContextStateFrame * frame, unsigned long lr, unsigned long
279279
if (!faulted_from_exception) { // Not sure about the non_usage_fault, we want to try anyway, don't we ? && !non_usage_fault_occurred)
280280
// Try to resume to our handler here
281281
CFSR |= CFSR; // The ARM programmer manual says you must write to 1 all fault bits to clear them so this instruction is correct
282-
// The frame will not be valid when returning anymore, let's clean it
283-
savedFrame.CFSR = 0;
284282

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

0 commit comments

Comments
Β (0)