def test(self): self.gdb.b("read_loop") self.gdb.command("hbreak just_before_read_loop") output = self.gdb.command("jump just_before_read_loop") assertRegexpMatches(output, r"Breakpoint \d, just_before_read_loop ") output = self.gdb.c() assertRegexpMatches(output, r"Breakpoint \d, read_loop ")
def test(self): # Get to a point in the code where some registers have actually been # used. self.gdb.b("rot13") self.gdb.c() self.gdb.c() # Try both forms to test gdb. for cmd in ("info all-registers", "info registers all"): output = self.gdb.command(cmd, ops=20) for reg in ('zero', 'ra', 'sp', 'gp', 'tp'): assertIn(reg, output) for line in output.splitlines(): assertRegexpMatches(line, r"^\S") #TODO # mcpuid is one of the few registers that should have the high bit set # (for rv64). # Leave this commented out until gdb and spike agree on the encoding of # mcpuid (which is going to be renamed to misa in any case). #assertRegexpMatches(output, ".*mcpuid *0x80") #TODO: # The instret register should always be changing. #last_instret = None #for _ in range(5): # instret = self.gdb.p("$instret") # assertNotEqual(instret, last_instret) # last_instret = instret # self.gdb.stepi() self.exit()
def check_reg(self, name, alias): if self.hart.extensionSupported('F'): mstatus_fs = 0x00006000 self.gdb.p("$mstatus=$mstatus|0x%x" % mstatus_fs) self.gdb.stepi() a = random.random() b = random.random() self.gdb.p_fpr("$%s=%f" % (name, a)) assertLess(abs((self.gdb.p_fpr("$%s" % alias)) - a), .001) self.gdb.stepi() assertLess(abs((self.gdb.p_fpr("$%s" % name)) - a), .001) assertLess(abs((self.gdb.p_fpr("$%s" % alias)) - a), .001) self.gdb.p_fpr("$%s=%f" % (alias, b)) assertLess(abs((self.gdb.p_fpr("$%s" % name)) - b), .001) self.gdb.stepi() assertLess(abs((self.gdb.p_fpr("$%s" % name)) - b), .001) assertLess(abs((self.gdb.p_fpr("$%s" % alias)) - b), .001) size = self.gdb.p("sizeof($%s)" % name) if self.hart.extensionSupported('D'): assertEqual(size, 8) else: assertEqual(size, 4) else: output = self.gdb.p_raw("$" + name) assertRegexpMatches(output, r"void|Could not fetch register.*") output = self.gdb.p_raw("$" + alias) assertRegexpMatches(output, r"void|Could not fetch register.*")
def test(self): if self.target.instruction_hardware_breakpoint_count < 1: return 'not_applicable' self.gdb.hbreak("rot13") # The breakpoint should be hit exactly 2 times. for _ in range(2): output = self.gdb.c() self.gdb.p("$pc") assertRegexpMatches(output, r"[bB]reakpoint") assertIn("rot13 ", output) self.exit()
def test(self): if self.target.instruction_hardware_breakpoint_count < 2: return 'not_applicable' self.gdb.hbreak("main") self.gdb.hbreak("rot13") # We should hit 3 breakpoints. for expected in ("main", "rot13", "rot13"): output = self.gdb.c() self.gdb.p("$pc") assertRegexpMatches(output, r"[bB]reakpoint") assertIn("%s " % expected, output) self.exit()
def test(self): if self.hart.instruction_hardware_breakpoint_count < 2: raise TestNotApplicable self.gdb.command("delete") self.gdb.hbreak("main") self.gdb.hbreak("rot13") # We should hit 3 breakpoints. for expected in ("main", "rot13", "rot13"): output = self.gdb.c() self.gdb.p("$pc") assertRegexpMatches(output, r"[bB]reakpoint") assertIn("%s " % expected, output) self.gdb.command("delete") self.gdb.b("_exit") self.exit()
def test(self): if self.hart.instruction_hardware_breakpoint_count < 1: return 'not_applicable' if not self.hart.honors_tdata1_hmode: # Run to main before setting the breakpoint, because startup code # will otherwise clear the trigger that we set. self.gdb.b("main") self.gdb.c() self.gdb.hbreak("rot13") # The breakpoint should be hit exactly 2 times. for _ in range(2): output = self.gdb.c() self.gdb.p("$pc") assertRegexpMatches(output, r"[bB]reakpoint") assertIn("rot13 ", output) self.exit()
def test(self): if self.hart.instruction_hardware_breakpoint_count < 1: return 'not_applicable' if not self.hart.honors_tdata1_hmode: # Run to main before setting the breakpoint, because startup code # will otherwise clear the trigger that we set. self.gdb.b("main") self.gdb.c() self.gdb.command("delete") self.gdb.hbreak("rot13") # The breakpoint should be hit exactly 2 times. for _ in range(2): output = self.gdb.c() self.gdb.p("$pc") assertRegexpMatches(output, r"[bB]reakpoint") assertIn("rot13 ", output) self.gdb.b("_exit") self.exit()