You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by GitBox <gi...@apache.org> on 2021/09/15 08:06:52 UTC

[GitHub] [incubator-nuttx] zhuyanlinzyl opened a new pull request #4547: arch:xtensa: add full bactrace support

zhuyanlinzyl opened a new pull request #4547:
URL: https://github.com/apache/incubator-nuttx/pull/4547


   ## Summary
   
   Add for all tasks/interrupt backtrace support
   
   1 backtrace in other task, backtrace from stack.
   2 backtrace in current task, spill the register window, and backtrace from window and stack.
   Follow the linux backtrace step.
   https://github.com/jcmvbkbc/linux-xtensa/blob/master/arch/xtensa/kernel/stacktrace.c
   
   ## Impact
   
   No
   
   ## Testing
   
   **1. bactrace on the interrupt**
   
   ```
   diff --git a/examples/hello/hello_main.c b/examples/hello/hello_main.c
   index 2cd6cb400..9db692fdb 100644
   --- a/examples/hello/hello_main.c
   +++ b/examples/hello/hello_main.c
   @@ -36,5 +36,8 @@
    int main(int argc, FAR char *argv[])
    {
      printf("Hello, World!!\n");
   +
   +  *(unsigned int *)(0xffffaaaa) = 0x12345678;
   +
      return 0;
    }
   ```
   ```
   nsh> hello
   Hello, World!!
   xtensa_user_panic: User Exception: EXCCAUSE=0009 task: hello
   xtensa_registerdump:    PC: 202b32b8    PS: 00060030
   xtensa_registerdump:    A0: a02acb87    A1: 20998d10    A2: ffffaaaa    A3: 12345678
   xtensa_registerdump:    A4: a02ba26c    A5: 209949c0    A6: 20990994    A7: 00000258
   xtensa_registerdump:    A8: a02b32af    A9: 20998cb0   A10: 0000000f   A11: 209949a0
   xtensa_registerdump:   A12: a02be95c   A13: 20994980   A14: 00000003   A15: 209949d0
   xtensa_registerdump:   SAR: 00000000 CAUSE: 00000009 VADDR: ffffaaaa
   xtensa_registerdump:  LBEG: 00000000  LEND: 00000000  LCNT: 00000000
   xtensa_registerdump:  TMP0: 202b1512  TMP1: 20998af0
   sched_dumpstack: [BackTrace| 3|0]:  0x202acbae 0x202b232e 0x202b1912 0x202b19f5 0x202b24f1 0x202b152f    0x40023 0x202b32b0
   sched_dumpstack: [BackTrace| 3|1]:  0x202acb87 0x202a86a4
   xtensa_dumpstate: sp:         20998a20
   xtensa_dumpstate: stack base: 20994cf0
   xtensa_dumpstate: stack size: 000040b0
   xtensa_stackdump: 20998a20: 20994ce0 20998a10 0000000f 000040b0 20994cf0 20998a20 2098c7a0 20998a20
   xtensa_stackdump: 20998a40: 000040b0 20998a70 20998980 00000004 a02b24f1 20998a90 20998af0 202cee0c
   xtensa_stackdump: 20998a60: 5000b000 0000000a 2098c974 00000000 5000b000 0000000a 0000011e 00000000
   xtensa_stackdump: 20998a80: 602b152f 20998ac0 00000009 20998af0 a02af1bc 20998ae0 20998af0 00000009
   
   $ xt-addr2line -e nuttx/nuttx 0x202acbae 0x202b232e 0x202b1912 0x202b19f5 0x202b24f1 0x202b152f    0x40023 0x202b32b0 0x202acb87 0x202a86a4
   /home/zyl/bes2003/nuttx/libs/libc/sched/sched_dumpstack.c:63
   /home/zyl/bes2003/nuttx/arch/xtensa/src/common/xtensa_dumpstate.c:298
   /home/zyl/bes2003/nuttx/arch/xtensa/src/common/xtensa_assert.c:109
   /home/zyl/bes2003/nuttx/arch/xtensa/src/common/xtensa_assert.c:309
   ??:?
   /home/zyl/bes2003/nuttx/arch/xtensa/src/common/xtensa_user_handler.S:258
   ??:0
   /home/zyl/bes2003/apps/examples/hello/hello_main.c:40
   /home/zyl/bes2003/nuttx/libs/libc/sched/task_startup.c:151
   /home/zyl/bes2003/nuttx/sched/task/task_start.c:130
   ```
   
   
    **2 backtrace on current task**
   ```
   diff --git a/examples/hello/hello_main.c b/examples/hello/hello_main.c
   index 2cd6cb400..f4a0dafae 100644
   --- a/examples/hello/hello_main.c
   +++ b/examples/hello/hello_main.c
   @@ -24,6 +24,7 @@
    
    #include <nuttx/config.h>
    #include <stdio.h>
   +#include <execinfo.h>
    
    /****************************************************************************
     * Public Functions
   @@ -36,5 +37,7 @@
    int main(int argc, FAR char *argv[])
    {
      printf("Hello, World!!\n");
   +  dump_stack();
   +
      return 0;
    }
   ```
   ```
   nsh> hello
   Hello, World!!
   [BackTrace| 3|0]:  0x202acd6c 0x202b36b0 0x202acd4f 0x202a86cc
   up_exit: TCB=0x2098c820 exiting
   $ xt-addr2line -e nuttx/nuttx 0x202acd6c 0x202b36b0 0x202acd4f 0x202a86cc
   /home/zyl/bes2003/nuttx/libs/libc/sched/sched_dumpstack.c:60
   /home/zyl/bes2003/apps/examples/hello/hello_main.c:42
   /home/zyl/bes2003/nuttx/libs/libc/sched/task_startup.c:151
   /home/zyl/bes2003/nuttx/sched/task/task_start.c:130
   ```
   
   
   **3 backtrace  other task**
   ```
   nsh> ps
     PID PRI POLICY   TYPE    NPX STATE    EVENT     SIGMASK   STACK COMMAND
   - Ready              00000000 016352 Idle Task
       2 100 RR       Task    --- Running            00000000 016560 init
   
   nsh> dumpstack 2
   [BackTrace| 2|0]:  0x202b1ce4 0x202a6569 0x202a627b 0x202a62e4 0x202bed54 0x202ba664 0x202b9c26 0x202b983f
   [BackTrace| 2|1]:  0x202be814 0x202bf1be 0x202b3c4a 0x202acd4b 0x202a86c8
   up_exit: TCB=0x2098c810 exiting
   ```
   ```
   $ xt-addr2line -e nuttx/nuttx 0x202b1ce4 0x202a6569 0x202a627b 0x202a62e4 0x202bed54 0x202ba664 0x202b9c26 0x202b983f 0x202be814 0x202bf1be 0x202b3c4a 0x202acd4b 0x202a86c8
   /home/zyl/bes2003/nuttx/arch/xtensa/src/common/xtensa_blocktask.c:134
   /home/zyl/bes2003/nuttx/sched/semaphore/sem_wait.c:185
   /home/zyl/bes2003/nuttx/sched/sched/sched_waitpid.c:129
   /home/zyl/bes2003/nuttx/sched/sched/sched_waitpid.c:593
   /home/zyl/bes2003/apps/nshlib/nsh_builtin.c:160
   /home/zyl/bes2003/apps/nshlib/nsh_parse.c:528
   /home/zyl/bes2003/apps/nshlib/nsh_parse.c:2578
   /home/zyl/bes2003/apps/nshlib/nsh_parse.c:2662
   /home/zyl/bes2003/apps/nshlib/nsh_session.c:219
   /home/zyl/bes2003/apps/nshlib/nsh_consolemain.c:100
   /home/zyl/bes2003/apps/system/nsh/nsh_main.c:153
   /home/zyl/bes2003/nuttx/libs/libc/sched/task_startup.c:151
   /home/zyl/bes2003/nuttx/sched/task/task_start.c:130
   ```
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-nuttx] xiaoxiang781216 merged pull request #4547: arch:xtensa: add full bactrace support

Posted by GitBox <gi...@apache.org>.
xiaoxiang781216 merged pull request #4547:
URL: https://github.com/apache/incubator-nuttx/pull/4547


   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org