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/01/13 22:41:23 UTC

[GitHub] [incubator-nuttx] yamt commented on a change in pull request #2673: esp32: Add a gdb script to show backtrace

yamt commented on a change in pull request #2673:
URL: https://github.com/apache/incubator-nuttx/pull/2673#discussion_r556923243



##########
File path: tools/esp32/backtrace.gdbscript
##########
@@ -0,0 +1,85 @@
+############################################################################
+# tools/esp32/backtrace.gdbscript
+#
+# Licensed to the Apache Software Foundation (ASF) under one or more
+# contributor license agreements.  See the NOTICE file distributed with
+# this work for additional information regarding copyright ownership.  The
+# ASF licenses this file to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance with the
+# License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+# License for the specific language governing permissions and limitations
+# under the License.
+#
+############################################################################
+
+# Usage:
+#
+#   -------
+#       xtensa_registerdump:    PC: 400d5775    PS: 00060e33
+#       xtensa_registerdump:    A0: 800d504c    A1: 3ffd8080    A2: 3ffdfb28    A3: 00000001
+#   -------
+#       (gdb) esp32_bt 0x400d5775 0x800d504c 0x3ffd8080
+#   -------
+#
+# References:
+#
+#   Xtensa(R) Instruction Set Architecture (ISA) Reference Manual
+#   4.7.1.4 Call, Entry, and Return Mechanism
+#   4.7.1.5 Windowed Procedure-Call Protocol
+
+define esp32_bt
+    set $pc = $arg0
+    set $a0 = $arg1
+    set $a1 = $arg2
+    set $pc_topbits = (int)$pc & 0xc0000000
+    # The return address from xtensa_sig_deliver to _xtensa_sig_trampoline
+    set $sig_tramp_ra = (int)(_xtensa_sig_trampoline + 2 * 3)
+    print/a $pc
+    while (1)
+        # Note: "- 3" to workaround the case where "call" is
+        # the last instruction in the calling function.
+        set $next_pc = (($a0 & 0x3fffffff) | $pc_topbits) - 3
+        print/a $next_pc

Review comment:
       do you mean CONFIG_XTENSA_DUMPBT_ON_ASSERT?
   
   * CONFIG_XTENSA_DUMPBT_ON_ASSERT dumps the fault handler stack but not user's
   * this version deals with signal trampoline
   * ability to specify pc/a0/a1 is handy for me




----------------------------------------------------------------
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.

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