aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2020-03-26 09:09:07 -0700
committerGitHub <noreply@github.com>2020-03-26 09:09:07 -0700
commit094985d1cfafe00548751285271bf8aab40f8d6d (patch)
treeddb5e3dd62ece964346ab88d84321643be1811d3
parent5fe6092f9917d80f4d1bfd02ce36275a87c89910 (diff)
downloadriscv-tests-094985d1cfafe00548751285271bf8aab40f8d6d.zip
riscv-tests-094985d1cfafe00548751285271bf8aab40f8d6d.tar.gz
riscv-tests-094985d1cfafe00548751285271bf8aab40f8d6d.tar.bz2
Write a NOP program in PrivRw test. (#260)
Otherwise it only passes intermittently when I change _start, which is very confusing.
-rwxr-xr-xdebug/gdbserver.py11
-rw-r--r--debug/testlib.py6
2 files changed, 8 insertions, 9 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index db339a9..8800137 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -93,13 +93,7 @@ class SimpleRegisterTest(GdbTest):
assertEqual(self.gdb.p("$%s" % alias), b)
def setup(self):
- # 0x13 is nop
- self.gdb.command("p *((int*) 0x%x)=0x13" % self.hart.ram)
- self.gdb.command("p *((int*) 0x%x)=0x13" % (self.hart.ram + 4))
- self.gdb.command("p *((int*) 0x%x)=0x13" % (self.hart.ram + 8))
- self.gdb.command("p *((int*) 0x%x)=0x13" % (self.hart.ram + 12))
- self.gdb.command("p *((int*) 0x%x)=0x13" % (self.hart.ram + 16))
- self.gdb.p("$pc=0x%x" % self.hart.ram)
+ self.write_nop_program(5)
class SimpleS0Test(SimpleRegisterTest):
def test(self):
@@ -1256,8 +1250,7 @@ class PrivTest(GdbSingleHartTest):
class PrivRw(PrivTest):
def test(self):
"""Test reading/writing priv."""
- # Leave the PC at _start, where the first 4 instructions should be
- # legal in any mode.
+ self.write_nop_program(4)
for privilege in range(4):
self.gdb.p("$priv=%d" % privilege)
self.gdb.stepi()
diff --git a/debug/testlib.py b/debug/testlib.py
index d969999..3d714df 100644
--- a/debug/testlib.py
+++ b/debug/testlib.py
@@ -1022,6 +1022,12 @@ class GdbTest(BaseTest):
BaseTest.__init__(self, target, hart=hart)
self.gdb = None
+ def write_nop_program(self, count):
+ for i in range(count):
+ # 0x13 is nop
+ self.gdb.command("p *((int*) 0x%x)=0x13" % (self.hart.ram + i * 4))
+ self.gdb.p("$pc=0x%x" % self.hart.ram)
+
def classSetup(self):
BaseTest.classSetup(self)