Add back code to clean up triggers in entry.S
authorTim Newsome <tim@sifive.com>
Fri, 21 Jul 2017 03:43:18 +0000 (20:43 -0700)
committerTim Newsome <tim@sifive.com>
Fri, 21 Jul 2017 03:43:18 +0000 (20:43 -0700)
Then for targets that can't handle this because they don't implement
hmode, add a target setting that allows that to be specified.

debug/gdbserver.py
debug/programs/entry.S
debug/targets.py

index f6c61c3eae7877d9fa99062ebbf947c238832e54..80985fd8022dccdd83f8de6008168cf0d577a64d 100755 (executable)
@@ -329,6 +329,12 @@ class Hwbp1(DebugTest):
         if self.target.instruction_hardware_breakpoint_count < 1:
             return 'not_applicable'
 
+        if not self.target.honors_tdata1_hmode:
+            # Run to main before setting the breakpoint, because startup code
+            # will otherwise clear the trigger that we set.
+            self.gdb.b("main")
+            self.gdb.c()
+
         self.gdb.hbreak("rot13")
         # The breakpoint should be hit exactly 2 times.
         for _ in range(2):
@@ -560,6 +566,9 @@ class TriggerStoreAddressInstant(TriggerTest):
         assertEqual(self.gdb.p("$a0"), self.gdb.p("&data"))
 
 class TriggerDmode(TriggerTest):
+    def early_applicable(self):
+        return self.target.honors_tdata1_hmode
+
     def check_triggers(self, tdata1_lsbs, tdata2):
         dmode = 1 << (self.target.xlen-5)
 
index 302d409c55bb3d297c5fc8a1dc5019d27b83f82d..ff8ae3092a517ad20ce2860b7b56ac2d1cd05b5a 100755 (executable)
@@ -64,6 +64,15 @@ handle_reset:
   # initialize stack pointer
   la sp, stack_top
 
+  # Clear all hardware triggers
+  li    t0, ~0
+1:
+  addi  t0, t0, 1
+  csrw  CSR_TSELECT, t0
+  csrw  CSR_TDATA1, zero
+  csrr  t1, CSR_TSELECT
+  beq   t0, t1, 1b
+
   # perform the rest of initialization in C
   j _init
 
index ae81517654f85d705b29e607d26d88ac0918219e..296b0a95f72929c621b334da11954a8b45dab7ca 100644 (file)
@@ -34,6 +34,12 @@ class Target(object):
     # before starting the test.
     gdb_setup = []
 
+    # Implements dmode in tdata1 as described in the spec. Targets that need
+    # this value set to False are not compliant with the spec (but still usable
+    # as long as running code doesn't try to mess with triggers set by an
+    # external debugger).
+    honors_tdata1_hmode = True
+
     # Internal variables:
     directory = None
     temporary_files = []