Skip to content

Commit

Permalink
[debug] Support wide range of platforms in HwbpManual
Browse files Browse the repository at this point in the history
  • Loading branch information
lz-bro committed Nov 1, 2024
1 parent fa2f65c commit 0f3a832
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions debug/gdbserver.py
Original file line number Diff line number Diff line change
Expand Up @@ -649,7 +649,7 @@ def MCONTROL_TYPE(xlen):
def MCONTROL_DMODE(xlen):
return 1<<((xlen)-5)
def MCONTROL_MASKMAX(xlen):
return 0x3<<((xlen)-11)
return 0x3f<<((xlen)-11)

MCONTROL_SELECT = 1<<19
MCONTROL_TIMING = 1<<18
Expand All @@ -666,6 +666,7 @@ def MCONTROL_MASKMAX(xlen):

MCONTROL_TYPE_NONE = 0
MCONTROL_TYPE_MATCH = 2
MCONTROL_TYPE_MATCH6 = 6

MCONTROL_ACTION_DEBUG_EXCEPTION = 0
MCONTROL_ACTION_DEBUG_MODE = 1
Expand Down Expand Up @@ -713,11 +714,23 @@ def set_manual_trigger(self, tdata1, tdata2):
self.gdb.p("$tdata1=0")
# Need to write a valid value to tdata2 before writing tdata1
self.gdb.p(f"$tdata2=0x{tdata2:x}")
self.gdb.p(f"$tdata1=0x{tdata1:x}")

tdata1_t2 = set_field(tdata1, MCONTROL_TYPE(self.hart.xlen),
MCONTROL_TYPE_MATCH)
self.gdb.p(f"$tdata1=0x{tdata1_t2:x}")
tdata2_rb = self.gdb.p("$tdata2")
tdata1_rb = self.gdb.p("$tdata1")
if tdata1_rb == tdata1 and tdata2_rb == tdata2:
maskmax_rb = tdata1_rb & MCONTROL_MASKMAX(self.hart.xlen)
tdata1_t2 = tdata1_t2 | maskmax_rb
if tdata1_rb == tdata1_t2 and tdata2_rb == tdata2:
return tselect

tdata1_t6 = set_field(tdata1, MCONTROL_TYPE(self.hart.xlen),
MCONTROL_TYPE_MATCH6)
self.gdb.p(f"$tdata1=0x{tdata1_t6:x}")
tdata2_rb = self.gdb.p("$tdata2")
tdata1_rb = self.gdb.p("$tdata1")
if tdata1_rb == tdata1_t6 and tdata2_rb == tdata2:
return tselect

type_rb = tdata1_rb & MCONTROL_TYPE(self.hart.xlen)
Expand Down Expand Up @@ -747,8 +760,6 @@ def test(self):

#self.gdb.hbreak("rot13")
tdata1 = MCONTROL_DMODE(self.hart.xlen)
tdata1 = set_field(tdata1, MCONTROL_TYPE(self.hart.xlen),
MCONTROL_TYPE_MATCH)
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 Down

0 comments on commit 0f3a832

Please sign in to comment.