diff options
Diffstat (limited to 'debug')
-rwxr-xr-x | debug/gdbserver.py | 15 | ||||
-rw-r--r-- | debug/programs/debug.c | 5 | ||||
-rw-r--r-- | debug/programs/regs.S | 1 | ||||
-rw-r--r-- | debug/testlib.py | 4 |
4 files changed, 17 insertions, 8 deletions
diff --git a/debug/gdbserver.py b/debug/gdbserver.py index b6e7cf9..783fdc7 100755 --- a/debug/gdbserver.py +++ b/debug/gdbserver.py @@ -921,9 +921,12 @@ class RegsTest(GdbSingleHartTest): compile_args = ("programs/regs.S", ) def setup(self): self.gdb.load() - self.gdb.b("main") + main_bp = self.gdb.b("main") + output = self.gdb.c() + assertIn("Breakpoint ", output) + assertIn("main", output) + self.gdb.command("delete %d" % main_bp) self.gdb.b("handle_trap") - self.gdb.c() class WriteGprs(RegsTest): def test(self): @@ -932,16 +935,16 @@ class WriteGprs(RegsTest): self.gdb.p("$pc=write_regs") for i, r in enumerate(regs): self.gdb.p("$%s=%d" % (r, (0xdeadbeef<<i)+17)) - self.gdb.p("$x1=data") + self.gdb.p("$x1=&data") self.gdb.command("b all_done") output = self.gdb.c() assertIn("Breakpoint ", output) # Just to get this data in the log. - self.gdb.command("x/30gx data") + self.gdb.command("x/30gx &data") self.gdb.command("info registers") for n in range(len(regs)): - assertEqual(self.gdb.x("data+%d" % (8*n), 'g'), + assertEqual(self.gdb.x("(char*)(&data)+%d" % (8*n), 'g'), ((0xdeadbeef<<n)+17) & ((1<<self.hart.xlen)-1)) class WriteCsrs(RegsTest): @@ -955,7 +958,7 @@ class WriteCsrs(RegsTest): assertEqual(self.gdb.p("$mscratch"), 123) self.gdb.p("$pc=write_regs") - self.gdb.p("$x1=data") + self.gdb.p("$x1=&data") self.gdb.command("b all_done") self.gdb.command("c") diff --git a/debug/programs/debug.c b/debug/programs/debug.c index 3ba51bc..44b4b51 100644 --- a/debug/programs/debug.c +++ b/debug/programs/debug.c @@ -53,9 +53,12 @@ int main() volatile int i = 0; int j = 0; - char *fox = "The quick brown fox jumps of the lazy dog."; + static char fox[43]; unsigned int checksum = 0; + /* fox needs to be writable, but the string could be in ROM. */ + strcpy(fox, "The quick brown fox jumps of the lazy dog."); + start: while (i) j++; diff --git a/debug/programs/regs.S b/debug/programs/regs.S index 50dafa2..63889dc 100644 --- a/debug/programs/regs.S +++ b/debug/programs/regs.S @@ -52,6 +52,7 @@ write_regs: all_done: j all_done + .section .bss .balign 16 data: .fill 64, 8, 0 diff --git a/debug/testlib.py b/debug/testlib.py index d278692..fa79abe 100644 --- a/debug/testlib.py +++ b/debug/testlib.py @@ -579,7 +579,9 @@ class Gdb(object): output = self.command("b %s" % location, ops=5) assert "not defined" not in output assert "Breakpoint" in output - return output + m = re.search(r"Breakpoint (\d+),? ", output) + assert m, output + return int(m.group(1)) def hbreak(self, location): output = self.command("hbreak %s" % location, ops=5) |