From 769f08a736a1cc4a4bf3ae93093ec44bd734e4ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=A2=81=E9=95=87?= Date: Fri, 1 Mar 2024 10:45:28 +0800 Subject: [PATCH] Enable HwbpManual MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: 梁镇 Change-Id: I2ee8718f03d6e381369b7d3bb0222563789ed525 --- debug/gdbserver.py | 37 +++++++++++++++++++++---------------- debug/targets.py | 6 ------ 2 files changed, 21 insertions(+), 22 deletions(-) diff --git a/debug/gdbserver.py b/debug/gdbserver.py index 5450adb1e..c48bcfba6 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -613,11 +613,10 @@ def early_applicable(self): return self.hart.instruction_hardware_breakpoint_count > 0 def test(self): - if not self.hart.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() + # 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.command("delete") self.gdb.hbreak("rot13") @@ -631,7 +630,7 @@ def test(self): self.exit() def MCONTROL_TYPE(xlen): - return 0xf<<((xlen)-4) + return 0x2<<((xlen)-4) def MCONTROL_DMODE(xlen): return 1<<((xlen)-5) def MCONTROL_MASKMAX(xlen): @@ -677,15 +676,18 @@ def early_applicable(self): self.hart.instruction_hardware_breakpoint_count >= 1 def test(self): - if not self.hart.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() + # 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.command("delete") #self.gdb.hbreak("rot13") - tdata1 = MCONTROL_DMODE(self.hart.xlen) + xlen = self.hart.xlen + tdata1_type_exclude_mask = 0xFFFFFFF if xlen == 32 \ + else 0xFFFFFFFFFFFFFFF + tdata1 = MCONTROL_TYPE(xlen) + tdata1 |= MCONTROL_DMODE(xlen) tdata1 = set_field(tdata1, MCONTROL_ACTION, MCONTROL_ACTION_DEBUG_MODE) tdata1 = set_field(tdata1, MCONTROL_MATCH, MCONTROL_MATCH_EQUAL) tdata1 |= MCONTROL_M | MCONTROL_S | MCONTROL_U | MCONTROL_EXECUTE @@ -697,8 +699,11 @@ def test(self): if value != tselect: raise TestNotApplicable self.gdb.p(f"$tdata1=0x{tdata1:x}") - value = self.gdb.p("$tselect") - if value == tdata1: + value = self.gdb.p("$tdata1") + if value == tdata1 or \ + (value >> (xlen-4) == 0x6 and \ + value & tdata1_type_exclude_mask == \ + tdata1 & tdata1_type_exclude_mask): break self.gdb.p("$tdata1=0") tselect += 1 @@ -710,6 +715,7 @@ def test(self): self.gdb.p("$pc") assertRegex(output, r"[bB]reakpoint") assertIn("rot13 ", output) + self.gdb.stepi() self.gdb.p("$tdata2=&crc32a") self.gdb.c() before = self.gdb.p("$pc") @@ -1396,8 +1402,7 @@ def test(self): class TriggerDmode(TriggerTest): def early_applicable(self): - return self.hart.honors_tdata1_hmode and \ - self.hart.instruction_hardware_breakpoint_count > 0 + return self.hart.instruction_hardware_breakpoint_count > 0 def check_triggers(self, tdata1_lsbs, tdata2): dmode = 1 << (self.hart.xlen-5) diff --git a/debug/targets.py b/debug/targets.py index bb7a5cf15..ff861e6df 100644 --- a/debug/targets.py +++ b/debug/targets.py @@ -19,12 +19,6 @@ class Hart: # defined. Defaults to .lds. link_script_path = None - # Implements dmode in tdata1 as described in the spec. Harts 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 - # Address where a r/w/x block of RAM starts, together with its size. ram = None ram_size = None