Add test for address triggers.
[riscv-tests.git] / debug / gdbserver.py
1 #!/usr/bin/env python
2
3 import os
4 import sys
5 import argparse
6 import unittest
7 import tempfile
8 import time
9 import random
10 import binascii
11
12 import testlib
13
14
15 MSTATUS_UIE = 0x00000001
16 MSTATUS_SIE = 0x00000002
17 MSTATUS_HIE = 0x00000004
18 MSTATUS_MIE = 0x00000008
19 MSTATUS_UPIE = 0x00000010
20 MSTATUS_SPIE = 0x00000020
21 MSTATUS_HPIE = 0x00000040
22 MSTATUS_MPIE = 0x00000080
23 MSTATUS_SPP = 0x00000100
24 MSTATUS_HPP = 0x00000600
25 MSTATUS_MPP = 0x00001800
26 MSTATUS_FS = 0x00006000
27 MSTATUS_XS = 0x00018000
28 MSTATUS_MPRV = 0x00020000
29 MSTATUS_PUM = 0x00040000
30 MSTATUS_MXR = 0x00080000
31 MSTATUS_VM = 0x1F000000
32 MSTATUS32_SD = 0x80000000
33 MSTATUS64_SD = 0x8000000000000000
34
35 def gdb(
36 target=None,
37 port=None,
38 binary=None
39 ):
40
41 gdb = None
42 if parsed.gdb:
43 gdb = testlib.Gdb(parsed.gdb)
44 else:
45 gdb = testlib.Gdb()
46
47 if binary:
48 gdb.command("file %s" % binary)
49 if target:
50 gdb.command("set arch riscv:rv%d" % target.xlen)
51 gdb.command("set remotetimeout %d" % target.timeout_sec)
52 if port:
53 gdb.command("target extended-remote localhost:%d" % port)
54
55 gdb.p("$priv=3")
56
57 return gdb
58
59
60 def ihex_line(address, record_type, data):
61 assert len(data) < 128
62 line = ":%02X%04X%02X" % (len(data), address, record_type)
63 check = len(data)
64 check += address % 256
65 check += address >> 8
66 check += record_type
67 for char in data:
68 value = ord(char)
69 check += value
70 line += "%02X" % value
71 line += "%02X\n" % ((256-check)%256)
72 return line
73
74 def ihex_parse(line):
75 assert line.startswith(":")
76 line = line[1:]
77 data_len = int(line[:2], 16)
78 address = int(line[2:6], 16)
79 record_type = int(line[6:8], 16)
80 data = ""
81 for i in range(data_len):
82 data += "%c" % int(line[8+2*i:10+2*i], 16)
83 return record_type, address, data
84
85 def readable_binary_string(s):
86 return "".join("%02x" % ord(c) for c in s)
87
88 class DeleteServer(unittest.TestCase):
89 def tearDown(self):
90 del self.server
91
92 class SimpleRegisterTest(DeleteServer):
93 def setUp(self):
94 self.server = target.server()
95 self.gdb = gdb(target, self.server.port)
96
97 # 0x13 is nop
98 self.gdb.command("p *((int*) 0x%x)=0x13" % target.ram)
99 self.gdb.command("p *((int*) 0x%x)=0x13" % (target.ram + 4))
100 self.gdb.command("p *((int*) 0x%x)=0x13" % (target.ram + 8))
101 self.gdb.p("$pc=0x%x" % target.ram)
102
103 def check_reg(self, name):
104 a = random.randrange(1<<target.xlen)
105 b = random.randrange(1<<target.xlen)
106 self.gdb.p("$%s=0x%x" % (name, a))
107 self.gdb.stepi()
108 self.assertEqual(self.gdb.p("$%s" % name), a)
109 self.gdb.p("$%s=0x%x" % (name, b))
110 self.gdb.stepi()
111 self.assertEqual(self.gdb.p("$%s" % name), b)
112
113 def test_s0(self):
114 # S0 is saved/restored in DSCRATCH
115 self.check_reg("s0")
116
117 def test_s1(self):
118 # S1 is saved/restored in Debug RAM
119 self.check_reg("s1")
120
121 def test_t0(self):
122 # T0 is not saved/restored at all
123 self.check_reg("t2")
124
125 def test_t2(self):
126 # T2 is not saved/restored at all
127 self.check_reg("t2")
128
129 class SimpleMemoryTest(DeleteServer):
130 def setUp(self):
131 self.server = target.server()
132 self.gdb = gdb(target, self.server.port)
133
134 def access_test(self, size, data_type):
135 self.assertEqual(self.gdb.p("sizeof(%s)" % data_type),
136 size)
137 a = 0x86753095555aaaa & ((1<<(size*8))-1)
138 b = 0xdeadbeef12345678 & ((1<<(size*8))-1)
139 self.gdb.p("*((%s*)0x%x) = 0x%x" % (data_type, target.ram, a))
140 self.gdb.p("*((%s*)0x%x) = 0x%x" % (data_type, target.ram + size, b))
141 self.assertEqual(self.gdb.p("*((%s*)0x%x)" % (data_type, target.ram)), a)
142 self.assertEqual(self.gdb.p("*((%s*)0x%x)" % (data_type, target.ram + size)), b)
143
144 def test_8(self):
145 self.access_test(1, 'char')
146
147 def test_16(self):
148 self.access_test(2, 'short')
149
150 def test_32(self):
151 self.access_test(4, 'int')
152
153 def test_64(self):
154 self.access_test(8, 'long long')
155
156 def test_block(self):
157 length = 1024
158 line_length = 16
159 a = tempfile.NamedTemporaryFile(suffix=".ihex")
160 data = ""
161 for i in range(length / line_length):
162 line_data = "".join(["%c" % random.randrange(256) for _ in range(line_length)])
163 data += line_data
164 a.write(ihex_line(i * line_length, 0, line_data))
165 a.flush()
166
167 self.gdb.command("restore %s 0x%x" % (a.name, target.ram))
168 for offset in range(0, length, 19*4) + [length-4]:
169 value = self.gdb.p("*((int*)0x%x)" % (target.ram + offset))
170 written = ord(data[offset]) | \
171 (ord(data[offset+1]) << 8) | \
172 (ord(data[offset+2]) << 16) | \
173 (ord(data[offset+3]) << 24)
174 self.assertEqual(value, written)
175
176 b = tempfile.NamedTemporaryFile(suffix=".ihex")
177 self.gdb.command("dump ihex memory %s 0x%x 0x%x" % (b.name, target.ram,
178 target.ram + length))
179 for line in b:
180 record_type, address, line_data = ihex_parse(line)
181 if (record_type == 0):
182 self.assertEqual(readable_binary_string(line_data),
183 readable_binary_string(data[address:address+len(line_data)]))
184
185 class InstantHaltTest(DeleteServer):
186 def setUp(self):
187 self.server = target.server()
188 self.gdb = gdb(target, self.server.port)
189
190 def test_instant_halt(self):
191 self.assertEqual(target.reset_vector, self.gdb.p("$pc"))
192 # mcycle and minstret have no defined reset value.
193 mstatus = self.gdb.p("$mstatus")
194 self.assertEqual(mstatus & (MSTATUS_MIE | MSTATUS_MPRV |
195 MSTATUS_VM), 0)
196
197 def test_change_pc(self):
198 """Change the PC right as we come out of reset."""
199 # 0x13 is nop
200 self.gdb.command("p *((int*) 0x%x)=0x13" % target.ram)
201 self.gdb.command("p *((int*) 0x%x)=0x13" % (target.ram + 4))
202 self.gdb.command("p *((int*) 0x%x)=0x13" % (target.ram + 8))
203 self.gdb.p("$pc=0x%x" % target.ram)
204 self.gdb.stepi()
205 self.assertEqual((target.ram + 4), self.gdb.p("$pc"))
206 self.gdb.stepi()
207 self.assertEqual((target.ram + 8), self.gdb.p("$pc"))
208
209 class DebugTest(DeleteServer):
210 def setUp(self):
211 # Include malloc so that gdb can make function calls. I suspect this
212 # malloc will silently blow through the memory set aside for it, so be
213 # careful.
214 self.binary = target.compile("programs/debug.c", "programs/checksum.c",
215 "programs/tiny-malloc.c", "-DDEFINE_MALLOC", "-DDEFINE_FREE")
216 self.server = target.server()
217 self.gdb = gdb(target, self.server.port, self.binary)
218 self.gdb.load()
219 self.gdb.b("_exit")
220
221 def exit(self, expected_result = 0xc86455d4):
222 output = self.gdb.c()
223 self.assertIn("Breakpoint", output)
224 self.assertIn("_exit", output)
225 self.assertEqual(self.gdb.p("status"), expected_result)
226
227 def test_function_call(self):
228 self.gdb.b("main:start")
229 self.gdb.c()
230 self.assertEqual(self.gdb.p('fib(6)'), 8)
231 self.assertEqual(self.gdb.p('fib(7)'), 13)
232 self.exit()
233
234 def test_change_string(self):
235 text = "This little piggy went to the market."
236 self.gdb.b("main:start")
237 self.gdb.c()
238 self.gdb.p('fox = "%s"' % text)
239 self.exit(0x43b497b8)
240
241 def test_turbostep(self):
242 """Single step a bunch of times."""
243 self.gdb.b("main:start")
244 self.gdb.c()
245 self.gdb.command("p i=0");
246 last_pc = None
247 advances = 0
248 jumps = 0
249 for _ in range(100):
250 self.gdb.stepi()
251 pc = self.gdb.p("$pc")
252 self.assertNotEqual(last_pc, pc)
253 if (last_pc and pc > last_pc and pc - last_pc <= 4):
254 advances += 1
255 else:
256 jumps += 1
257 last_pc = pc
258 # Some basic sanity that we're not running between breakpoints or
259 # something.
260 self.assertGreater(jumps, 10)
261 self.assertGreater(advances, 50)
262
263 def test_exit(self):
264 self.exit()
265
266 def test_symbols(self):
267 self.gdb.b("main")
268 self.gdb.b("rot13")
269 output = self.gdb.c()
270 self.assertIn(", main ", output)
271 output = self.gdb.c()
272 self.assertIn(", rot13 ", output)
273
274 def test_breakpoint(self):
275 self.gdb.b("rot13")
276 # The breakpoint should be hit exactly 2 times.
277 for i in range(2):
278 output = self.gdb.c()
279 self.gdb.p("$pc")
280 self.assertIn("Breakpoint ", output)
281 #TODO self.assertIn("rot13 ", output)
282 self.exit()
283
284 def test_hwbp_1(self):
285 if target.instruction_hardware_breakpoint_count < 1:
286 return
287
288 self.gdb.hbreak("rot13")
289 # The breakpoint should be hit exactly 2 times.
290 for i in range(2):
291 output = self.gdb.c()
292 self.gdb.p("$pc")
293 self.assertIn("Breakpoint ", output)
294 #TODO self.assertIn("rot13 ", output)
295 self.exit()
296
297 def test_hwbp_2(self):
298 if target.instruction_hardware_breakpoint_count < 2:
299 return
300
301 self.gdb.hbreak("main")
302 self.gdb.hbreak("rot13")
303 # We should hit 3 breakpoints.
304 for i in range(3):
305 output = self.gdb.c()
306 self.gdb.p("$pc")
307 self.assertIn("Breakpoint ", output)
308 #TODO self.assertIn("rot13 ", output)
309 self.exit()
310
311 def test_too_many_hwbp(self):
312 for i in range(30):
313 self.gdb.hbreak("*rot13 + %d" % (i * 4))
314
315 output = self.gdb.c()
316 self.assertIn("Cannot insert hardware breakpoint", output)
317 # Clean up, otherwise the hardware breakpoints stay set and future
318 # tests may fail.
319 self.gdb.command("D")
320
321 def test_address_trigger(self):
322 self.gdb.b("main:start")
323 self.gdb.c()
324 self.gdb.command("watch fox[13]");
325
326 output = self.gdb.c()
327 self.assertNotIn("Could not insert", output)
328 self.assertIn("rot13", output)
329 output = self.gdb.command("up")
330 self.assertIn("in main", output)
331 self.assertEqual(self.gdb.p_string("fox"),
332 "Gur dhvpx oebjn fox jumps of the lazy dog.")
333
334 output = self.gdb.c()
335 self.assertNotIn("Could not insert", output)
336 self.assertIn("rot13", output)
337 output = self.gdb.command("up")
338 self.assertIn("in main", output)
339 self.assertEqual(self.gdb.p_string("fox"),
340 "The quick browa sbk whzcf bs gur ynml qbt.")
341
342 def test_registers(self):
343 # Get to a point in the code where some registers have actually been
344 # used.
345 self.gdb.b("rot13")
346 self.gdb.c()
347 self.gdb.c()
348 # Try both forms to test gdb.
349 for cmd in ("info all-registers", "info registers all"):
350 output = self.gdb.command(cmd)
351 self.assertNotIn("Could not", output)
352 for reg in ('zero', 'ra', 'sp', 'gp', 'tp'):
353 self.assertIn(reg, output)
354
355 #TODO
356 # mcpuid is one of the few registers that should have the high bit set
357 # (for rv64).
358 # Leave this commented out until gdb and spike agree on the encoding of
359 # mcpuid (which is going to be renamed to misa in any case).
360 #self.assertRegexpMatches(output, ".*mcpuid *0x80")
361
362 #TODO:
363 # The instret register should always be changing.
364 #last_instret = None
365 #for _ in range(5):
366 # instret = self.gdb.p("$instret")
367 # self.assertNotEqual(instret, last_instret)
368 # last_instret = instret
369 # self.gdb.stepi()
370
371 self.exit()
372
373 def test_interrupt(self):
374 """Sending gdb ^C while the program is running should cause it to halt."""
375 self.gdb.b("main:start")
376 self.gdb.c()
377 self.gdb.p("i=123");
378 self.gdb.c(wait=False)
379 time.sleep(0.1)
380 output = self.gdb.interrupt()
381 #TODO: assert "main" in output
382 self.assertGreater(self.gdb.p("j"), 10)
383 self.gdb.p("i=0");
384 self.exit()
385
386 class StepTest(DeleteServer):
387 def setUp(self):
388 self.binary = target.compile("programs/step.S")
389 self.server = target.server()
390 self.gdb = gdb(target, self.server.port, self.binary)
391 self.gdb.load()
392 self.gdb.b("main")
393 self.gdb.c()
394
395 def test_step(self):
396 main = self.gdb.p("$pc")
397 for expected in (4, 8, 0xc, 0x10, 0x18, 0x1c, 0x28, 0x20, 0x2c, 0x2c):
398 self.gdb.stepi()
399 pc = self.gdb.p("$pc")
400 self.assertEqual("%x" % pc, "%x" % (expected + main))
401
402 class RegsTest(DeleteServer):
403 def setUp(self):
404 self.binary = target.compile("programs/regs.S")
405 self.server = target.server()
406 self.gdb = gdb(target, self.server.port, self.binary)
407 self.gdb.load()
408 self.gdb.b("main")
409 self.gdb.b("handle_trap")
410 self.gdb.c()
411
412 def test_write_gprs(self):
413 regs = [("x%d" % n) for n in range(2, 32)]
414
415 self.gdb.p("$pc=write_regs")
416 for i, r in enumerate(regs):
417 self.gdb.p("$%s=%d" % (r, (0xdeadbeef<<i)+17))
418 self.gdb.p("$x1=data")
419 self.gdb.command("b all_done")
420 output = self.gdb.c()
421 self.assertIn("Breakpoint ", output)
422
423 # Just to get this data in the log.
424 self.gdb.command("x/30gx data")
425 self.gdb.command("info registers")
426 for n in range(len(regs)):
427 self.assertEqual(self.gdb.x("data+%d" % (8*n), 'g'),
428 ((0xdeadbeef<<n)+17) & ((1<<target.xlen)-1))
429
430 def test_write_csrs(self):
431 # As much a test of gdb as of the simulator.
432 self.gdb.p("$mscratch=0")
433 self.gdb.stepi()
434 self.assertEqual(self.gdb.p("$mscratch"), 0)
435 self.gdb.p("$mscratch=123")
436 self.gdb.stepi()
437 self.assertEqual(self.gdb.p("$mscratch"), 123)
438
439 self.gdb.command("p $pc=write_regs")
440 self.gdb.command("p $a0=data")
441 self.gdb.command("b all_done")
442 self.gdb.command("c")
443
444 self.assertEqual(123, self.gdb.p("$mscratch"))
445 self.assertEqual(123, self.gdb.p("$x1"))
446 self.assertEqual(123, self.gdb.p("$csr832"))
447
448 class DownloadTest(DeleteServer):
449 def setUp(self):
450 length = min(2**20, target.ram_size - 2048)
451 download_c = tempfile.NamedTemporaryFile(prefix="download_", suffix=".c")
452 download_c.write("#include <stdint.h>\n")
453 download_c.write("unsigned int crc32a(uint8_t *message, unsigned int size);\n")
454 download_c.write("uint32_t length = %d;\n" % length)
455 download_c.write("uint8_t d[%d] = {\n" % length)
456 self.crc = 0
457 for i in range(length / 16):
458 download_c.write(" /* 0x%04x */ " % (i * 16));
459 for _ in range(16):
460 value = random.randrange(1<<8)
461 download_c.write("%d, " % value)
462 self.crc = binascii.crc32("%c" % value, self.crc)
463 download_c.write("\n");
464 download_c.write("};\n");
465 download_c.write("uint8_t *data = &d[0];\n");
466 download_c.write("uint32_t main() { return crc32a(data, length); }\n")
467 download_c.flush()
468
469 if self.crc < 0:
470 self.crc += 2**32
471
472 self.binary = target.compile(download_c.name, "programs/checksum.c")
473 self.server = target.server()
474 self.gdb = gdb(target, self.server.port, self.binary)
475
476 def test_download(self):
477 output = self.gdb.load()
478 self.gdb.command("b _exit")
479 self.gdb.c()
480 self.assertEqual(self.gdb.p("status"), self.crc)
481
482 class MprvTest(DeleteServer):
483 def setUp(self):
484 self.binary = target.compile("programs/mprv.S")
485 self.server = target.server()
486 self.gdb = gdb(target, self.server.port, self.binary)
487 self.gdb.load()
488
489 def test_mprv(self):
490 """Test that the debugger can access memory when MPRV is set."""
491 self.gdb.c(wait=False)
492 time.sleep(0.5)
493 self.gdb.interrupt()
494 output = self.gdb.command("p/x *(int*)(((char*)&data)-0x80000000)")
495 self.assertIn("0xbead", output)
496
497 class PrivTest(DeleteServer):
498 def setUp(self):
499 self.binary = target.compile("programs/priv.S")
500 self.server = target.server()
501 self.gdb = gdb(target, self.server.port, self.binary)
502 self.gdb.load()
503
504 misa = self.gdb.p("$misa")
505 self.supported = set()
506 if misa & (1<<20):
507 self.supported.add(0)
508 if misa & (1<<18):
509 self.supported.add(1)
510 if misa & (1<<7):
511 self.supported.add(2)
512 self.supported.add(3)
513
514 def test_rw(self):
515 """Test reading/writing priv."""
516 for privilege in range(4):
517 self.gdb.p("$priv=%d" % privilege)
518 self.gdb.stepi()
519 actual = self.gdb.p("$priv")
520 self.assertIn(actual, self.supported)
521 if privilege in self.supported:
522 self.assertEqual(actual, privilege)
523
524 def test_change(self):
525 """Test that the core's privilege level actually changes."""
526
527 if 0 not in self.supported:
528 # TODO: return not applicable
529 return
530
531 self.gdb.b("main")
532 self.gdb.c()
533
534 # Machine mode
535 self.gdb.p("$priv=3")
536 main = self.gdb.p("$pc")
537 self.gdb.stepi()
538 self.assertEqual("%x" % self.gdb.p("$pc"), "%x" % (main+4))
539
540 # User mode
541 self.gdb.p("$priv=0")
542 self.gdb.stepi()
543 # Should have taken an exception, so be nowhere near main.
544 pc = self.gdb.p("$pc")
545 self.assertTrue(pc < main or pc > main + 0x100)
546
547 class Target(object):
548 directory = None
549 timeout_sec = 2
550
551 def server(self):
552 raise NotImplementedError
553
554 def compile(self, *sources):
555 binary_name = "%s_%s-%d" % (
556 self.name,
557 os.path.basename(os.path.splitext(sources[0])[0]),
558 self.xlen)
559 if parsed.isolate:
560 self.temporary_binary = tempfile.NamedTemporaryFile(
561 prefix=binary_name + "_")
562 binary_name = self.temporary_binary.name
563 testlib.compile(sources +
564 ("programs/entry.S", "programs/init.c",
565 "-I", "../env",
566 "-T", "targets/%s/link.lds" % (self.directory or self.name),
567 "-nostartfiles",
568 "-mcmodel=medany",
569 "-o", binary_name),
570 xlen=self.xlen)
571 return binary_name
572
573 class SpikeTarget(Target):
574 directory = "spike"
575 ram = 0x80010000
576 ram_size = 5 * 1024 * 1024
577 instruction_hardware_breakpoint_count = 4
578 reset_vector = 0x1000
579
580 class Spike64Target(SpikeTarget):
581 name = "spike64"
582 xlen = 64
583
584 def server(self):
585 return testlib.Spike(parsed.cmd, halted=True)
586
587 class Spike32Target(SpikeTarget):
588 name = "spike32"
589 xlen = 32
590
591 def server(self):
592 return testlib.Spike(parsed.cmd, halted=True, xlen=32)
593
594 class FreedomE300Target(Target):
595 name = "freedom-e300"
596 xlen = 32
597 ram = 0x80000000
598 ram_size = 16 * 1024
599 instruction_hardware_breakpoint_count = 2
600
601 def server(self):
602 return testlib.Openocd(cmd=parsed.cmd,
603 config="targets/%s/openocd.cfg" % self.name)
604
605 class FreedomE300SimTarget(Target):
606 name = "freedom-e300-sim"
607 xlen = 32
608 timeout_sec = 240
609 ram = 0x80000000
610 ram_size = 256 * 1024 * 1024
611 instruction_hardware_breakpoint_count = 2
612
613 def server(self):
614 sim = testlib.VcsSim(simv=parsed.run, debug=False)
615 openocd = testlib.Openocd(cmd=parsed.cmd,
616 config="targets/%s/openocd.cfg" % self.name,
617 otherProcess = sim)
618 time.sleep(20)
619 return openocd
620
621 class FreedomU500Target(Target):
622 name = "freedom-u500"
623 xlen = 64
624 ram = 0x80000000
625 ram_size = 16 * 1024
626 instruction_hardware_breakpoint_count = 2
627
628 def server(self):
629 return testlib.Openocd(cmd=parsed.cmd,
630 config="targets/%s/openocd.cfg" % self.name)
631
632 class FreedomU500SimTarget(Target):
633 name = "freedom-u500-sim"
634 xlen = 64
635 timeout_sec = 240
636 ram = 0x80000000
637 ram_size = 256 * 1024 * 1024
638 instruction_hardware_breakpoint_count = 2
639
640 def server(self):
641 sim = testlib.VcsSim(simv=parsed.run, debug=False)
642 openocd = testlib.Openocd(cmd=parsed.cmd,
643 config="targets/%s/openocd.cfg" % self.name,
644 otherProcess = sim)
645 time.sleep(20)
646 return openocd
647
648 targets = [
649 Spike32Target,
650 Spike64Target,
651 FreedomE300Target,
652 FreedomU500Target,
653 FreedomE300SimTarget,
654 FreedomU500SimTarget]
655
656 def main():
657 parser = argparse.ArgumentParser(
658 epilog="""
659 Example command line from the real world:
660 Run all RegsTest cases against a physical FPGA, with custom openocd command:
661 ./gdbserver.py --freedom-e-300 --cmd "$HOME/SiFive/openocd/src/openocd -s $HOME/SiFive/openocd/tcl -d" -- -vf RegsTest
662 """)
663 group = parser.add_mutually_exclusive_group(required=True)
664 for t in targets:
665 group.add_argument("--%s" % t.name, action="store_const", const=t,
666 dest="target")
667 parser.add_argument("--run",
668 help="The command to use to start the actual target (e.g. simulation)")
669 parser.add_argument("--cmd",
670 help="The command to use to start the debug server.")
671 parser.add_argument("--gdb",
672 help="The command to use to start gdb.")
673
674 xlen_group = parser.add_mutually_exclusive_group()
675 xlen_group.add_argument("--32", action="store_const", const=32, dest="xlen",
676 help="Force the target to be 32-bit.")
677 xlen_group.add_argument("--64", action="store_const", const=64, dest="xlen",
678 help="Force the target to be 64-bit.")
679
680 parser.add_argument("--isolate", action="store_true",
681 help="Try to run in such a way that multiple instances can run at "
682 "the same time. This may make it harder to debug a failure if it "
683 "does occur.")
684
685 parser.add_argument("unittest", nargs="*")
686 global parsed
687 parsed = parser.parse_args()
688
689 global target
690 target = parsed.target()
691
692 if parsed.xlen:
693 target.xlen = parsed.xlen
694
695 unittest.main(argv=[sys.argv[0]] + parsed.unittest)
696
697 # TROUBLESHOOTING TIPS
698 # If a particular test fails, run just that one test, eg.:
699 # ./gdbserver.py MprvTest.test_mprv
700 # Then inspect gdb.log and spike.log to see what happened in more detail.
701
702 if __name__ == '__main__':
703 sys.exit(main())