Skip to content

Commit

Permalink
Enable HwbpManual
Browse files Browse the repository at this point in the history
Signed-off-by: 梁镇 <[email protected]>
Change-Id: I2ee8718f03d6e381369b7d3bb0222563789ed525
  • Loading branch information
lz-bro committed Mar 1, 2024
1 parent 67e7759 commit e880b5b
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 22 deletions.
35 changes: 19 additions & 16 deletions debug/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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):
Expand Down Expand Up @@ -677,15 +676,17 @@ 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
Expand All @@ -697,8 +698,10 @@ 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
Expand All @@ -710,6 +713,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")
Expand Down Expand Up @@ -1396,8 +1400,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)
Expand Down
6 changes: 0 additions & 6 deletions debug/targets.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,6 @@ class Hart:
# defined. Defaults to <name>.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
Expand Down

0 comments on commit e880b5b

Please sign in to comment.