wes3 commented on a change in pull request #2408:
URL: https://github.com/apache/mynewt-core/pull/2408#discussion_r520964039



##########
File path: compiler/gdbmacros/cmac_core_dump.gdb
##########
@@ -0,0 +1,97 @@
+# 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.
+
+#
+# Source this script to gdb that has loaded DA1469x core file
+#
+# It will produce cmac_core.elf file that will have RAM data from CMAC 
Cortex-M0
+# then use this cmac_core.elf along with cmac elf file produced during build 
to analyze core dump
+#
+
+define cmac_core_dump
+
+    set $_rom_size = ((struct cmac_image_info 
*)(_binary_cmac_rom_bin_start+0x80))->offset_data
+    set $_cmac_ram_start = ((struct cmac_image_info 
*)(_binary_cmac_rom_bin_start+0x80))->offset_data + _binary_cmac_ram_bin_start
+    set $_cmac_ram_end = $_cmac_ram_start + ((struct cmac_image_info 
*)(_binary_cmac_rom_bin_start+0x80))->size_ram - ((struct cmac_image_info 
*)(_binary_cmac_rom_bin_start+0x80))->offset_data
+
+    set $_regs_size = 0xA8
+    set $_ram_size =  $_cmac_ram_end - $_cmac_ram_start
+
+    set $_mem = $_cmac_ram_start + 0x100
+
+    set $_lr = g_cmac_shared_data->coredump.lr
+    set $_pc = g_cmac_shared_data->coredump.pc
+    set $_tp = 0
+
+    # Find exception frame by LR nad PC pair
+    # NOTE: this could be avoided if Trap Frame pointer was also stored in 
shared data.
+    find /w /1 $_cmac_ram_start, +$_ram_size, $_lr, $_pc
+    # exception pointer from address of LR
+    set $_ep = (uint32_t *)($_ - 20)
+    # SP in cmac address space
+    set $_cmac_sp = (uint32_t *)((int)$_ep - (int)$_cmac_ram_start + 
0x20000000)
+
+    # Exception in system mode, Trap Frame just before exception frame
+    if $_ep[-1] == 0xFFFFFFF1 || $_ep[-1] == 0xFFFFFFF9
+        set $_tf = $_ep - 10
+    else

Review comment:
       btw: what is _tf used for?




----------------------------------------------------------------
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:
us...@infra.apache.org


Reply via email to