This is an automated email from the ASF dual-hosted git repository.

xiaoxiang pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/incubator-nuttx.git

commit f130d8c1432c8347e96f25094709aaf23df515b1
Author: Abdelatif Guettouche <[email protected]>
AuthorDate: Fri Apr 22 15:42:59 2022 +0200

    xtensa_user_handler.S: Fix backtrace.
    
    Signed-off-by: Abdelatif Guettouche <[email protected]>
---
 arch/xtensa/src/common/xtensa_user_handler.S | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/xtensa/src/common/xtensa_user_handler.S 
b/arch/xtensa/src/common/xtensa_user_handler.S
index f7a8114db2..432c18ce06 100644
--- a/arch/xtensa/src/common/xtensa_user_handler.S
+++ b/arch/xtensa/src/common/xtensa_user_handler.S
@@ -220,6 +220,10 @@ _xtensa_user_handler:
        s32i    a0, sp, (4 * REG_A0)
        s32i    a2, sp, (4 * REG_A2)
 
+#ifdef CONFIG_XTENSA_INTBACKTRACE
+       wsr sp, EXCSAVE_1
+#endif
+
        /* Save EXCCAUSE and EXCVADDR into the user frame */
 
        rsr             a0, EXCCAUSE
@@ -252,10 +256,12 @@ _xtensa_user_handler:
    */
 
 #ifdef CONFIG_XTENSA_INTBACKTRACE
-  l32i    a3, sp, (4 * REG_A0)     /* Copy pre-exception a0 (return address) */
+  rsr     a0, EXCSAVE_1            /* Get exception frame pointer stored in 
EXCSAVE_1 */
+  l32i    a3, a0, (4 * REG_A0)     /* Copy pre-exception a0 (return address) */
   s32e    a3, sp, -16
-  l32i    a3, sp, (4 * REG_A1)     /* Copy pre-exception a1 (stack pointer) */
+  l32i    a3, a0, (4 * REG_A1)     /* Copy pre-exception a1 (stack pointer) */
   s32e    a3, sp, -12
+
   rsr     a0, EPC_1                /* return address for debug backtrace */
   movi    a4, 0xc0000000           /* constant with top 2 bits set (call size) 
*/
   or      a0, a0, a4               /* set top 2 bits */

Reply via email to