mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-05 03:27:48 +00:00
runtime: improve hardfault handler and stack reporting on Cortex-M
- Add reference to the current goroutine stack (PSP) when showing the hardfault info on Cortex-M.
This commit is contained in:
committed by
Ron Evans
parent
7cbbfd6fc5
commit
8e36d2758b
@@ -4,6 +4,7 @@ package runtime
|
||||
|
||||
import (
|
||||
"device/arm"
|
||||
"internal/task"
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
@@ -106,6 +107,20 @@ func HardFault_Handler() {
|
||||
print(" pc=", sp.PC)
|
||||
}
|
||||
}
|
||||
|
||||
// PSP holds the actual exception frame when the fault occurred in a
|
||||
// goroutine (thread mode, PSP active). The MSP-based sp above is the
|
||||
// scheduler's stack and its PC is garbage in that case.
|
||||
pspVal := task.GoroutineStack()
|
||||
|
||||
// heapEndSymbol is defined in baremetal.go; we also ensure that the goroutine exception frame is within addressable memory.
|
||||
if pspVal >= 0x20000000 && pspVal < (uintptr(unsafe.Pointer(&heapEndSymbol))-uintptr(unsafe.Sizeof(interruptStack{}))) {
|
||||
pspFrame := (*interruptStack)(unsafe.Pointer(pspVal))
|
||||
print(" psp=", pspFrame)
|
||||
print(" psp_pc=", pspFrame.PC)
|
||||
print(" psp_lr=", pspFrame.LR)
|
||||
}
|
||||
|
||||
println()
|
||||
abort()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user