コード例 #1
0
ファイル: gdbserver.py プロジェクト: mwachs5/riscv-tests
    def check_triggers(self, tdata1_lsbs, tdata2):
        dmode = 1 << (self.target.xlen-5)

        triggers = []

        if self.target.xlen == 32:
            xlen_type = 'int'
        elif self.target.xlen == 64:
            xlen_type = 'long long'
        else:
            raise NotImplementedError

        dmode_count = 0
        i = 0
        for i in range(16):
            tdata1 = self.gdb.p("((%s *)&data)[%d]" % (xlen_type, 2*i))
            if tdata1 == 0:
                break
            tdata2 = self.gdb.p("((%s *)&data)[%d]" % (xlen_type, 2*i+1))

            if tdata1 & dmode:
                dmode_count += 1
            else:
                assertEqual(tdata1 & 0xffff, tdata1_lsbs)
                assertEqual(tdata2, tdata2)

        assertGreater(i, 1)
        assertEqual(dmode_count, 1)

        return triggers
コード例 #2
0
ファイル: gdbserver.py プロジェクト: riscv/riscv-tests
    def test(self):
        self.gdb.b("main")
        output = self.gdb.c()
        assertIn(" main ", output)
        self.gdb.b("trap_entry")
        output = self.gdb.c()
        assertIn(" trap_entry ", output)
        assertEqual(self.gdb.p("$mip") & 0x80, 0x80)
        assertEqual(self.gdb.p("interrupt_count"), 0)
        # You'd expect local to still be 0, but it looks like spike doesn't
        # jump to the interrupt handler immediately after the write to
        # mtimecmp.
        assertLess(self.gdb.p("local"), 1000)
        self.gdb.command("delete breakpoints")
        for _ in range(10):
            self.gdb.c(wait=False)
            time.sleep(2)
            self.gdb.interrupt()
            interrupt_count = self.gdb.p("interrupt_count")
            local = self.gdb.p("local")
            if interrupt_count > 1000 and \
                    local > 1000:
                return

        assertGreater(interrupt_count, 1000)
        assertGreater(local, 1000)
コード例 #3
0
ファイル: gdbserver.py プロジェクト: mwachs5/riscv-tests
 def test(self):
     output = self.gdb.command("compare-sections")
     matched = 0
     for line in output.splitlines():
         if line.startswith("Section"):
             assert line.endswith("matched.")
             matched += 1
     assertGreater(matched, 1)
コード例 #4
0
ファイル: gdbserver.py プロジェクト: mwachs5/riscv-tests
 def test(self):
     """Sending gdb ^C while the program is running should cause it to
     halt."""
     self.gdb.b("main:start")
     self.gdb.c()
     self.gdb.p("i=123")
     self.gdb.c(wait=False)
     time.sleep(0.5)
     output = self.gdb.interrupt()
     assert "main" in output
     assertGreater(self.gdb.p("j"), 10)
     self.gdb.p("i=0")
     self.exit()
コード例 #5
0
ファイル: gdbserver.py プロジェクト: mwachs5/riscv-tests
 def test(self):
     """Single step a bunch of times."""
     self.gdb.b("main:start")
     self.gdb.c()
     self.gdb.command("p i=0")
     last_pc = None
     advances = 0
     jumps = 0
     for _ in range(100):
         self.gdb.stepi()
         pc = self.gdb.p("$pc")
         assertNotEqual(last_pc, pc)
         if last_pc and pc > last_pc and pc - last_pc <= 4:
             advances += 1
         else:
             jumps += 1
         last_pc = pc
     # Some basic sanity that we're not running between breakpoints or
     # something.
     assertGreater(jumps, 10)
     assertGreater(advances, 50)
コード例 #6
0
ファイル: gdbserver.py プロジェクト: yunshengtw/riscv-sodor
 def test(self):
     previous_hart_count = [0 for h in self.target.harts]
     previous_interrupt_count = [0 for h in self.target.harts]
     for _ in range(10):
         self.gdb.c(wait=False)
         time.sleep(2)
         self.gdb.interrupt()
         self.gdb.p("$mie")
         self.gdb.p("$mip")
         self.gdb.p("$mstatus")
         self.gdb.p("$priv")
         self.gdb.p("buf", fmt="")
         hart_count = self.gdb.p("hart_count")
         interrupt_count = self.gdb.p("interrupt_count")
         for i, h in enumerate(self.target.harts):
             assertGreater(hart_count[i], previous_hart_count[i])
             assertGreater(interrupt_count[i], previous_interrupt_count[i])
             self.gdb.select_hart(h)
             pc = self.gdb.p("$pc")
             self.gdb.stepi()
             stepped_pc = self.gdb.p("$pc")
             assertNotEqual(pc, stepped_pc)