mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-06 12:03:41 +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
@@ -42,3 +42,8 @@ func SystemStack() uintptr {
|
||||
runtimePanic("scheduler is disabled")
|
||||
return 0 // unreachable
|
||||
}
|
||||
|
||||
func GoroutineStack() uintptr {
|
||||
// No separate goroutine stack without a scheduler.
|
||||
return 0
|
||||
}
|
||||
|
||||
@@ -11,3 +11,14 @@ uintptr_t SystemStack() {
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
uintptr_t GoroutineStack() {
|
||||
uintptr_t sp;
|
||||
asm volatile(
|
||||
"mrs %0, PSP"
|
||||
: "=r"(sp)
|
||||
:
|
||||
: "memory"
|
||||
);
|
||||
return sp;
|
||||
}
|
||||
|
||||
@@ -70,3 +70,10 @@ func (s *state) pause() {
|
||||
//
|
||||
//export SystemStack
|
||||
func SystemStack() uintptr
|
||||
|
||||
// GoroutineStack returns the PSP (goroutine stack pointer). When a fault
|
||||
// occurs in goroutine context, the hardware saves the exception frame to PSP;
|
||||
// reading PSP+0x18 gives the actual faulting PC.
|
||||
//
|
||||
//export GoroutineStack
|
||||
func GoroutineStack() uintptr
|
||||
|
||||
Reference in New Issue
Block a user