aboutsummaryrefslogtreecommitdiff
path: root/cortex-m-rt
diff options
context:
space:
mode:
authorGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-10-23 08:08:36 +0000
committerGravatar bors[bot] <bors[bot]@users.noreply.github.com> 2018-10-23 08:08:36 +0000
commit28d9f89d871bde5fee98cb8773f18da103df3218 (patch)
tree122ca17f880dfc33fd800fe44fd42ed85f57c7b5 /cortex-m-rt
parent777d73402600ebb6498255493cc04bc2fad4c864 (diff)
parent6f437d9d03f8f7f5438cffe0e227ec12339d07f8 (diff)
downloadcortex-m-28d9f89d871bde5fee98cb8773f18da103df3218.tar.gz
cortex-m-28d9f89d871bde5fee98cb8773f18da103df3218.tar.zst
cortex-m-28d9f89d871bde5fee98cb8773f18da103df3218.zip
Merge #131
131: Allow GDB to unwind HardFault callstacks r=therealprof a=adamgreen When I currently request GDB to dump a hard fault stack, I see something like this: ``` (gdb) bt #0 UserHardFault_ (ef=0x10001fb8) at /depots/cortex-m-rt/src/lib.rs:537 #1 0x08003fe6 in HardFault () Backtrace stopped: previous frame identical to this frame (corrupt stack?) ``` GDB can't unwind past HardFault since the current implementation of this function overwrites the Link Register (LR) value. This change pushes LR and R0 (to maintain 8-byte stack alignment) to the stack before transferring execution to UserHardFault(). After this change, I see a callstack like this from GDB: ``` (gdb) bt #0 UserHardFault_ (ef=0x10001fb0) at /depots/cortex-m-rt/src/lib.rs:537 #1 0x08003fe8 in HardFault () #2 <signal handler called> #3 0x08002820 in core::ptr::read_volatile (src=0x48001800) at libcore/ptr.rs:472 #4 0x080001a2 in main () at src/07-registers/src/main.rs:14 ``` Notes: * This code uses 8 more stack bytes. * Increases the size of the HardFault handler by 2 narrow instructions or 4 bytes. This could be decreased to 2 bytes by removing the pop since UserHardFault() doesn't currently return but it just looks too odd for me to do as an initial attempt. Co-authored-by: Adam Green <adamgreen@users.noreply.github.com>
Diffstat (limited to 'cortex-m-rt')
-rw-r--r--cortex-m-rt/asm.s2
-rw-r--r--cortex-m-rt/bin/thumbv6m-none-eabi.abin886 -> 920 bytes
-rw-r--r--cortex-m-rt/bin/thumbv7em-none-eabi.abin886 -> 920 bytes
-rw-r--r--cortex-m-rt/bin/thumbv7em-none-eabihf.abin886 -> 920 bytes
-rw-r--r--cortex-m-rt/bin/thumbv7m-none-eabi.abin886 -> 920 bytes
5 files changed, 2 insertions, 0 deletions
diff --git a/cortex-m-rt/asm.s b/cortex-m-rt/asm.s
index c7133c0..f5ace26 100644
--- a/cortex-m-rt/asm.s
+++ b/cortex-m-rt/asm.s
@@ -2,5 +2,7 @@
.global HardFault
.thumb_func
HardFault:
+ push {r0, lr}
mrs r0, MSP
bl UserHardFault
+ pop {r0, pc}
diff --git a/cortex-m-rt/bin/thumbv6m-none-eabi.a b/cortex-m-rt/bin/thumbv6m-none-eabi.a
index 62ac317..e002080 100644
--- a/cortex-m-rt/bin/thumbv6m-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv6m-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv7em-none-eabi.a b/cortex-m-rt/bin/thumbv7em-none-eabi.a
index ef9042f..230b866 100644
--- a/cortex-m-rt/bin/thumbv7em-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv7em-none-eabi.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv7em-none-eabihf.a b/cortex-m-rt/bin/thumbv7em-none-eabihf.a
index ef9042f..230b866 100644
--- a/cortex-m-rt/bin/thumbv7em-none-eabihf.a
+++ b/cortex-m-rt/bin/thumbv7em-none-eabihf.a
Binary files differ
diff --git a/cortex-m-rt/bin/thumbv7m-none-eabi.a b/cortex-m-rt/bin/thumbv7m-none-eabi.a
index b93dae7..cb086a0 100644
--- a/cortex-m-rt/bin/thumbv7m-none-eabi.a
+++ b/cortex-m-rt/bin/thumbv7m-none-eabi.a
Binary files differ