def setUp(self): self.binary = testlib.compile("debug.c") self.spike = testlib.Spike(self.binary, halted=False) self.gdb = testlib.Gdb() self.gdb.command("file %s" % self.binary) self.gdb.command("target extended-remote localhost:%d" % self.spike.port)
def setUp(self): length = 2**20 fd = file("data.c", "w") fd.write("#include <stdint.h>\n") fd.write("uint32_t length = %d;\n" % length) fd.write("uint8_t d[%d] = {\n" % length) self.crc = 0 for i in range(length / 16): fd.write(" /* 0x%04x */ " % (i * 16)) for _ in range(16): value = random.randrange(1 << 8) fd.write("%d, " % value) self.crc = binascii.crc32("%c" % value, self.crc) fd.write("\n") fd.write("};\n") fd.write("uint8_t *data = &d[0];\n") fd.close() self.binary = testlib.compile("checksum.c", "data.c", "start.S", "-mcmodel=medany", "-T", "standalone.lds", "-nostartfiles") self.spike = testlib.Spike(None, halted=True) self.gdb = testlib.Gdb() self.gdb.command("file %s" % self.binary) self.gdb.command("target extended-remote localhost:%d" % self.spike.port)
def startGdb(self, port=None, binary=None, server_cmd=None, config=None, riscv_gdb_cmd=None, verbose=False): """Start a gdb session with the riscv core on the GFE Args: port (int, optional): TCP port for GDB connection over openocd server_cmd (string, optional): The base openocd command to run config (string, optional): Path to the openocd debugger configuration riscv_gdb_cmd (string, optional): Base gdb command for the riscv gdb program """ if not server_cmd: server_cmd = self.openocd_command if not config: config = self.openocd_cfg_path if not riscv_gdb_cmd: riscv_gdb_cmd = self.gdb_path self.openocd_session = testlib.Openocd(server_cmd=server_cmd, config=config, debug=False) self.gdb_session = testlib.Gdb(cmd=riscv_gdb_cmd, ports=self.openocd_session.gdb_ports, binary=binary, xlen=self.xlen) self.gdb_session.connect()
def setUp(self): self.binary = testlib.compile("mprv.S", "-T", "standalone.lds", "-nostartfiles") self.spike = testlib.Spike(None, halted=True) self.gdb = testlib.Gdb() self.gdb.command("file %s" % self.binary) self.gdb.command("target extended-remote localhost:%d" % self.spike.port) self.gdb.command("load")
def gdb( target=None, port=None, binary=None ): g = None if parsed.gdb: g = testlib.Gdb(parsed.gdb) else: g = testlib.Gdb() if binary: g.command("file %s" % binary) if target: g.command("set arch riscv:rv%d" % target.xlen) g.command("set remotetimeout %d" % target.timeout_sec) if port: g.command("target extended-remote localhost:%d" % port) g.p("$priv=3") return g
def gdb(): if parsed.gdb: return testlib.Gdb(parsed.gdb) else: return testlib.Gdb()