aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTim Newsome <tim@sifive.com>2023-02-28 09:07:17 -0800
committerGitHub <noreply@github.com>2023-02-28 09:07:17 -0800
commit5de4a1ebd1345d424fb7b0d1028117ffbed0aaa4 (patch)
tree72957d6b3c82ab42cc30eb96cb3b9249fe568ea1
parent2deb70dfd31248bded12deffc178348a2551a77f (diff)
parent1a003c315fa6c5382909dbe18f6fb7b8c77b0ee0 (diff)
downloadriscv-tests-5de4a1ebd1345d424fb7b0d1028117ffbed0aaa4.zip
riscv-tests-5de4a1ebd1345d424fb7b0d1028117ffbed0aaa4.tar.gz
riscv-tests-5de4a1ebd1345d424fb7b0d1028117ffbed0aaa4.tar.bz2
Merge pull request #456 from riscv-software-src/icount
Add test for icount triggers.
-rwxr-xr-xdebug/gdbserver.py27
1 files changed, 27 insertions, 0 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py
index ccbbf08..5b00310 100755
--- a/debug/gdbserver.py
+++ b/debug/gdbserver.py
@@ -1974,6 +1974,33 @@ class EtriggerTest(DebugTest):
assertIn("breakpoint", output)
assertIn("trap_entry", self.gdb.where())
+class IcountTest(DebugTest):
+ compile_args = ("programs/infinite_loop.S", "-DMULTICORE")
+
+ def setup(self):
+ DebugTest.setup(self)
+ self.gdb.b("main")
+ self.gdb.c()
+ self.gdb.command(f"monitor targets {self.hart.id}")
+
+ def test(self):
+ # Execute 2 instructions.
+ output = self.gdb.command("monitor riscv icount set m 2")
+ assertNotIn("Failed", output)
+ output = self.gdb.c()
+ assertIn("breakpoint", output)
+ main_post_csrr = self.gdb.p("&main_post_csrr")
+ assertEqual(self.gdb.p("$pc"), main_post_csrr)
+
+ self.gdb.command("monitor riscv icount clear")
+
+ # Execute 1 instruction.
+ output = self.gdb.command("monitor riscv icount set m 1")
+ assertNotIn("Failed", output)
+ output = self.gdb.c()
+ assertIn("breakpoint", output)
+ assertEqual(self.gdb.p("$pc"), main_post_csrr + 4)
+
class ItriggerTest(GdbSingleHartTest):
compile_args = ("programs/interrupt.c",)