Skip to content

couple fixes for POSTMORTEM_DEBUGGING - #26374

Merged
thinkyhead merged 3 commits into
MarlinFirmware:bugfix-2.1.xfrom
shadow578:fix-upstream/arm-postmortem
Nov 1, 2023
Merged

couple fixes for POSTMORTEM_DEBUGGING #26374
thinkyhead merged 3 commits into
MarlinFirmware:bugfix-2.1.xfrom
shadow578:fix-upstream/arm-postmortem

Conversation

@shadow578

Copy link
Copy Markdown
Contributor

Description

This PR fixes two issues i've noticed while working on POSTMORTEM_DEBUGGING for HC32. I believe that these issues affect other ARM Cortex Mx boards as well, thus this PR.

  1. In some circumstances, the UnwTabGetFunctionName would return a pointer pointing outside of the valid memory range, causing a fault when trying to print the function name in UnwReportOut. This PR adds a check to verify that the address calculated for the function name pointer is actually readable.

  2. While the common fault handler (CommonHandler_C) does capture the CFSR register, the captured value is cleared when not faulted_from_exception. I cannot see why this would be needed or useful, as all it does is hide details on the cause of the fault (e.g. divide by zero, ...).

Requirements

  • any ARM Cortex M Board
  • POSTMORTEM_DEBUGGING enabled

Benefits

  1. fixes a potential crash inside the fault handler
  2. adds additional information to fault logs emmitted by POSTMOTEM_DEBUGGING

Configurations

nothing special needed in configs

@thisiskeithb thisiskeithb added PR: Bug Fix T: Development Makefiles, PlatformIO, Python scripts, etc. labels Oct 28, 2023
@thinkyhead
thinkyhead force-pushed the fix-upstream/arm-postmortem branch from 742ed7f to e72a8a6 Compare November 1, 2023 00:07
@thinkyhead
thinkyhead force-pushed the fix-upstream/arm-postmortem branch from e72a8a6 to 29a0181 Compare November 1, 2023 00:07
@thinkyhead
thinkyhead merged commit 41a6f2b into MarlinFirmware:bugfix-2.1.x Nov 1, 2023
@thinkyhead

Copy link
Copy Markdown
Member

Thanks for the patch! It's hard to find complete examples of the "right" way to do this kind of thing.

eoyilmaz pushed a commit to eoyilmaz/Marlin that referenced this pull request Nov 21, 2023
Co-authored-by: Scott Lahteine <thinkyhead@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

PR: Bug Fix T: Development Makefiles, PlatformIO, Python scripts, etc.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants