Skip to content

Commit 769f08a

Browse files
committed
Enable HwbpManual
Signed-off-by: 梁镇 <[email protected]> Change-Id: I2ee8718f03d6e381369b7d3bb0222563789ed525
1 parent 67e7759 commit 769f08a

File tree

2 files changed

+21
-22
lines changed

2 files changed

+21
-22
lines changed

debug/gdbserver.py

Lines changed: 21 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -613,11 +613,10 @@ def early_applicable(self):
613613
return self.hart.instruction_hardware_breakpoint_count > 0
614614

615615
def test(self):
616-
if not self.hart.honors_tdata1_hmode:
617-
# Run to main before setting the breakpoint, because startup code
618-
# will otherwise clear the trigger that we set.
619-
self.gdb.b("main")
620-
self.gdb.c()
616+
# Run to main before setting the breakpoint, because startup code
617+
# will otherwise clear the trigger that we set.
618+
self.gdb.b("main")
619+
self.gdb.c()
621620

622621
self.gdb.command("delete")
623622
self.gdb.hbreak("rot13")
@@ -631,7 +630,7 @@ def test(self):
631630
self.exit()
632631

633632
def MCONTROL_TYPE(xlen):
634-
return 0xf<<((xlen)-4)
633+
return 0x2<<((xlen)-4)
635634
def MCONTROL_DMODE(xlen):
636635
return 1<<((xlen)-5)
637636
def MCONTROL_MASKMAX(xlen):
@@ -677,15 +676,18 @@ def early_applicable(self):
677676
self.hart.instruction_hardware_breakpoint_count >= 1
678677

679678
def test(self):
680-
if not self.hart.honors_tdata1_hmode:
681-
# Run to main before setting the breakpoint, because startup code
682-
# will otherwise clear the trigger that we set.
683-
self.gdb.b("main")
684-
self.gdb.c()
679+
# Run to main before setting the breakpoint, because startup code
680+
# will otherwise clear the trigger that we set.
681+
self.gdb.b("main")
682+
self.gdb.c()
685683

686684
self.gdb.command("delete")
687685
#self.gdb.hbreak("rot13")
688-
tdata1 = MCONTROL_DMODE(self.hart.xlen)
686+
xlen = self.hart.xlen
687+
tdata1_type_exclude_mask = 0xFFFFFFF if xlen == 32 \
688+
else 0xFFFFFFFFFFFFFFF
689+
tdata1 = MCONTROL_TYPE(xlen)
690+
tdata1 |= MCONTROL_DMODE(xlen)
689691
tdata1 = set_field(tdata1, MCONTROL_ACTION, MCONTROL_ACTION_DEBUG_MODE)
690692
tdata1 = set_field(tdata1, MCONTROL_MATCH, MCONTROL_MATCH_EQUAL)
691693
tdata1 |= MCONTROL_M | MCONTROL_S | MCONTROL_U | MCONTROL_EXECUTE
@@ -697,8 +699,11 @@ def test(self):
697699
if value != tselect:
698700
raise TestNotApplicable
699701
self.gdb.p(f"$tdata1=0x{tdata1:x}")
700-
value = self.gdb.p("$tselect")
701-
if value == tdata1:
702+
value = self.gdb.p("$tdata1")
703+
if value == tdata1 or \
704+
(value >> (xlen-4) == 0x6 and \
705+
value & tdata1_type_exclude_mask == \
706+
tdata1 & tdata1_type_exclude_mask):
702707
break
703708
self.gdb.p("$tdata1=0")
704709
tselect += 1
@@ -710,6 +715,7 @@ def test(self):
710715
self.gdb.p("$pc")
711716
assertRegex(output, r"[bB]reakpoint")
712717
assertIn("rot13 ", output)
718+
self.gdb.stepi()
713719
self.gdb.p("$tdata2=&crc32a")
714720
self.gdb.c()
715721
before = self.gdb.p("$pc")
@@ -1396,8 +1402,7 @@ def test(self):
13961402

13971403
class TriggerDmode(TriggerTest):
13981404
def early_applicable(self):
1399-
return self.hart.honors_tdata1_hmode and \
1400-
self.hart.instruction_hardware_breakpoint_count > 0
1405+
return self.hart.instruction_hardware_breakpoint_count > 0
14011406

14021407
def check_triggers(self, tdata1_lsbs, tdata2):
14031408
dmode = 1 << (self.hart.xlen-5)

debug/targets.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,6 @@ class Hart:
1919
# defined. Defaults to <name>.lds.
2020
link_script_path = None
2121

22-
# Implements dmode in tdata1 as described in the spec. Harts that need
23-
# this value set to False are not compliant with the spec (but still usable
24-
# as long as running code doesn't try to mess with triggers set by an
25-
# external debugger).
26-
honors_tdata1_hmode = True
27-
2822
# Address where a r/w/x block of RAM starts, together with its size.
2923
ram = None
3024
ram_size = None

0 commit comments

Comments
 (0)