You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mynewt.apache.org by je...@apache.org on 2021/02/24 11:09:15 UTC

[mynewt-core] 02/05: hw/scripts: Small improvements for MTB display

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

jerzy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/mynewt-core.git

commit bc29392e78e84c49363eb569b307db1d04b2a806
Author: Jerzy Kasenberg <je...@codecoup.pl>
AuthorDate: Fri Feb 5 13:28:55 2021 +0100

    hw/scripts: Small improvements for MTB display
    
    - MTB display is not stopped when non existing memory is accessed,
      this may happen when execution reaches address 0 for example
    - script was no displaying instructions starting from point when
      exception occurred to exception handler
---
 hw/scripts/micro-trace-buffer.py | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)

diff --git a/hw/scripts/micro-trace-buffer.py b/hw/scripts/micro-trace-buffer.py
index 80df78e..5abc402 100644
--- a/hw/scripts/micro-trace-buffer.py
+++ b/hw/scripts/micro-trace-buffer.py
@@ -99,11 +99,14 @@ class MicroTraceBuffer(gdb.Command):
         self._print(f"    ~A~0x{addr:08x}:    ~D~{asm}")
 
     def _disassemble(self, start: int, end: int):
-        disasm = self._arch.disassemble(start, end)
-        for instr in disasm:
-            addr = instr["addr"]
-            asm = instr["asm"].expandtabs(8)
-            self._describe_instr(addr, asm)
+        try:
+            disasm = self._arch.disassemble(start, end)
+            for instr in disasm:
+                addr = instr["addr"]
+                asm = instr["asm"].expandtabs(8)
+                self._describe_instr(addr, asm)
+        except gdb.MemoryError:
+            print(f"Error disassembling 0x{start:08x}-0x{end:08x}")
         print()
 
     def _cmd_decode(self):
@@ -154,10 +157,10 @@ class MicroTraceBuffer(gdb.Command):
                 if mtb_pkt_src & 0xff000000 == 0xff000000:
                     self._print(f"~X~Exception return (LR: 0x{mtb_pkt_src:08x}, "
                                 f"ret address: 0x{mtb_pkt_dst:08x})")
+                    print()
+                    continue
                 else:
                     self._print(f"~X~Exception entry (ret address: 0x{mtb_pkt_src:08x})")
-                print()
-                continue
 
             # on 1st entry in trace buffer, disassemble source of the branch
             if exec_begin is None:
@@ -173,6 +176,9 @@ class MicroTraceBuffer(gdb.Command):
 
             self._disassemble(exec_begin, exec_end)
 
+            if bit_a != 0:
+                self._print(f"~X~Exception started")
+
         # disassemble target of last branch
         self._disassemble(mtb_pkt_dst, mtb_pkt_dst)