Quellcode durchsuchen

[GDB] Test suite for the GDB stub

tags/v0.9.4
Stefan Hajnoczi vor 16 Jahren
Ursprung
Commit
4180815a90
2 geänderte Dateien mit 109 neuen und 0 gelöschten Zeilen
  1. 29
    0
      src/tests/gdbstub_test.S
  2. 80
    0
      src/tests/gdbstub_test.gdb

+ 29
- 0
src/tests/gdbstub_test.S Datei anzeigen

@@ -0,0 +1,29 @@
1
+	.arch i386
2
+	.section ".text"
3
+	.code32
4
+gdbstub_test:
5
+	/* 1. Read registers test */
6
+	movl    $0xea010203, %eax
7
+	movl    $0xeb040506, %ebx
8
+	movl    $0xec070809, %ecx
9
+	movl    $0xed0a0b0c, %edx
10
+	movl    $0x510d0e0f, %esi
11
+	movl    $0xd1102030, %edi
12
+	int	$3
13
+
14
+	/* 2. Write registers test */
15
+	int	$3
16
+
17
+	/* 3. Read memory test */
18
+	subl	$8, %esp
19
+	movl	$0x11223344, 4(%esp)
20
+	movw	$0x5566, 2(%esp)
21
+	movb	$0x77, (%esp)
22
+	int	$3
23
+
24
+	/* 4. Write memory test */
25
+	int	$3
26
+	addl	$8, %esp
27
+
28
+1:
29
+	jmp	1b

+ 80
- 0
src/tests/gdbstub_test.gdb Datei anzeigen

@@ -0,0 +1,80 @@
1
+#!/usr/bin/gdb -x
2
+# Test suite for GDB remote debugging
3
+# Run:
4
+#   make bin/gpxe.hd.tmp
5
+#   make
6
+#   tests/gdbstub_test.gdb
7
+
8
+define gpxe_load_symbols
9
+	file bin/gpxe.hd.tmp
10
+end
11
+
12
+define gpxe_connect
13
+	target remote localhost:4444
14
+end
15
+
16
+define gpxe_assert
17
+	if $arg0 != $arg1
18
+		echo FAIL $arg2\n
19
+	else
20
+		echo PASS $arg2\n
21
+	end
22
+end
23
+
24
+define gpxe_start_tests
25
+	jump gdbstub_test
26
+end
27
+
28
+define gpxe_test_regs_read
29
+	gpxe_assert $eax 0xea010203 "gpxe_test_regs_read eax"
30
+	gpxe_assert $ebx 0xeb040506 "gpxe_test_regs_read ebx"
31
+	gpxe_assert $ecx 0xec070809 "gpxe_test_regs_read ecx"
32
+	gpxe_assert $edx 0xed0a0b0c "gpxe_test_regs_read edx"
33
+	gpxe_assert $esi 0x510d0e0f "gpxe_test_regs_read esi"
34
+	gpxe_assert $edi 0xd1102030 "gpxe_test_regs_read edi"
35
+end
36
+
37
+define gpxe_test_regs_write
38
+	set $eax = 0xea112233
39
+	set $ebx = 0xeb445566
40
+	set $ecx = 0xec778899
41
+	set $edx = 0xedaabbcc
42
+	set $esi = 0x51ddeeff
43
+	set $edi = 0xd1010203
44
+	c
45
+	gpxe_assert $eax 0xea112233 "gpxe_test_regs_write eax"
46
+	gpxe_assert $ebx 0xeb445566 "gpxe_test_regs_write ebx"
47
+	gpxe_assert $ecx 0xec778899 "gpxe_test_regs_write ecx"
48
+	gpxe_assert $edx 0xedaabbcc "gpxe_test_regs_write edx"
49
+	gpxe_assert $esi 0x51ddeeff "gpxe_test_regs_write esi"
50
+	gpxe_assert $edi 0xd1010203 "gpxe_test_regs_write edi"
51
+
52
+	# This assumes segment selectors are always 0x10 or 0x8 (for code).
53
+	gpxe_assert $cs 0x08 "gpxe_test_regs_write cs"
54
+	gpxe_assert $ds 0x10 "gpxe_test_regs_write ds"
55
+end
56
+
57
+define gpxe_test_mem_read
58
+	c
59
+	gpxe_assert ({int}($esp+4)) 0x11223344 "gpxe_test_mem_read int"
60
+	gpxe_assert ({short}($esp+2)) 0x5566 "gpxe_test_mem_read short"
61
+	gpxe_assert ({char}($esp)) 0x77 "gpxe_test_mem_read char"
62
+end
63
+
64
+define gpxe_test_mem_write
65
+	set ({int}($esp+4)) = 0xaabbccdd
66
+	set ({short}($esp+2)) = 0xeeff
67
+	set ({char}($esp)) = 0x99
68
+	c
69
+	gpxe_assert ({int}($esp+4)) 0xaabbccdd "gpxe_test_mem_write int"
70
+	gpxe_assert ({short}($esp+2)) (short)0xeeff "gpxe_test_mem_write short"
71
+	gpxe_assert ({char}($esp)) (char)0x99 "gpxe_test_mem_write char"
72
+end
73
+
74
+gpxe_load_symbols
75
+gpxe_connect
76
+gpxe_start_tests
77
+gpxe_test_regs_read
78
+gpxe_test_regs_write
79
+gpxe_test_mem_read
80
+gpxe_test_mem_write

Laden…
Abbrechen
Speichern