Skip to content

Commit e54635c

Browse files
committed
make gdb test automation even awesomer
1 parent a068722 commit e54635c

File tree

8 files changed

+65
-39
lines changed

8 files changed

+65
-39
lines changed

README.adoc

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ Reserve 12Gb of disk and run:
3232
....
3333
git clone https://github.com/cirosantilli/linux-kernel-module-cheat
3434
cd linux-kernel-module-cheat
35-
./build --download-dependencies
35+
./build --download-dependencies qemu-buildroot
3636
./run
3737
....
3838

@@ -1321,7 +1321,7 @@ Tested on 4f4749148273c282e80b58c59db1b47049e190bf + 1.
13211321

13221322
=== GDB step debug early boot
13231323

1324-
TODO sucessfully debu the very first instruction that the Linux kernel runs, before `start_kernel`!
1324+
TODO successfully debug the very first instruction that the Linux kernel runs, before `start_kernel`!
13251325

13261326
Break at the very first instruction executed by QEMU:
13271327

@@ -9116,6 +9116,8 @@ Remote debugging using localhost:7000
91169116
Remote 'g' packet reply is too long: 000000000000000090a4f90fc0ffffff4875450ec0ffffff01000000000000000100000000000000000000000000000001000000000000000000000000000000ffffffffffffffff646d60616b64fffe7f7f7f7f7f7f7f7f0101010101010101300000000000000000000000ffffffff48454422207d2c2017162f21262820160100000000000000070000000000000001000000000000004075450ec0ffffffc073450ec0ffffff82080000000000004075450ec0ffffff8060f90fc0ffffffc073450ec0fffffff040900880ffffff40ab400ec0ffffff586d900880ffffff0068a20ec0ffffff903b010880ffffffc8ff210880ffffff903b010880ffffffccff210880ffffff050000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
91179117
....
91189118

9119+
See: <<remote-g-packet-reply-is-too-long>>
9120+
91199121
and gem5 says:
91209122

91219123
....
@@ -10165,6 +10167,10 @@ You can also find executables that don't use the bootloader at all under `bareme
1016510167
./run --arch arm --baremetal arch/arm/no_bootloader/semihost_exit --wait-gdb
1016610168
....
1016710169

10170+
The cool thing about those examples is that you start at the very first instruction of your program, which gives more control.
10171+
10172+
However, those examples tend to be less portable, so we use examples with the bootloader for the most part.
10173+
1016810174
Alternatively, skip directly to the C program main function with:
1016910175

1017010176
....
@@ -11450,19 +11456,27 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
1145011456
./test-gdb
1145111457
....
1145211458

11459+
Not all of them are passing right now due to: <<gem5-gdb-step-debug-kernel-aarch64>>.
11460+
1145311461
If something goes wrong, re-run the test commands manually and use `--verbose` to understand what happened:
1145411462

1145511463
....
1145611464
./run --arch arm --background --baremetal add --wait-gdb &
1145711465
./run-gdb --arch arm --baremetal add --test --verbose
1145811466
....
1145911467

11468+
and possibly repeat the GDB steps manually with the usual:
11469+
11470+
....
11471+
./run-gdb --arch arm --baremetal add --no-continue --verbose
11472+
....
11473+
1146011474
Sources:
1146111475

1146211476
* link:build-test-gdb[]
1146311477
* link:test-gdb[]
1146411478

11465-
For the Linux kenel, do the following manual tests for now.
11479+
For the Linux kernel, do the following manual tests for now.
1146611480

1146711481
Shell 1:
1146811482

baremetal/arch/aarch64/regs.S

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* - read x30 */
44
.global main
55
main:
6-
/* test-gdb-before-x29 */
76
mov x0, #1
87
/* test-gdb-x0 */
98
mov x1, #2

baremetal/arch/aarch64/regs.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,11 @@
11
def test(self):
22
self.sendline('tbreak main')
33
self.sendline('continue')
4+
self.continue_to('x0')
5+
self.sendline('set $x0 = 3')
46
self.continue_to('x1')
7+
assert self.get_int('$x0') == 3
8+
assert self.get_int('$x1') == 2
59
self.sendline('set $x30 = 3')
610
self.continue_to('x29')
711
assert self.get_int('$x29') == 1

baremetal/arch/arm/regs.S

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/* See the aarch64 version. */
2+
.global main
3+
main:
4+
mov r0, #1
5+
/* test-gdb-r0 */
6+
mov r1, #2
7+
/* test-gdb-r1 */
8+
bx lr

baremetal/arch/arm/regs.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
def test(self):
2+
self.sendline('tbreak main')
3+
self.sendline('continue')
4+
self.continue_to('r0')
5+
self.sendline('set $r0 = 3')
6+
self.continue_to('r1')
7+
assert self.get_int('$r0') == 3
8+
assert self.get_int('$r1') == 2

baremetal/lib/common.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include <stdio.h>
12
#include <stdlib.h>
23
#include <sys/stat.h>
34

build

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ Extra args to pass to all scripts.
307307
'''
308308
)
309309
parser.add_argument('components', choices=list(name_to_component_map.keys()) + [[]], default=[], nargs='*', help='''\
310-
Which components to build.
310+
Which components to build. Default: qemu-buildroot
311311
'''.format(common.default_arch))
312312
common.add_dry_run_argument(parser)
313313
args = parser.parse_args()

test-gdb

Lines changed: 26 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,28 @@
11
#!/usr/bin/env bash
22
set -eux
3-
4-
# QEMU
5-
./run --arch arm --background --baremetal add --wait-gdb &
6-
./run-gdb --arch arm --baremetal add --test "$@"
7-
wait
8-
./run --arch arm --background --baremetal arch/arm/add --wait-gdb &
9-
./run-gdb --arch arm --baremetal arch/arm/add --test "$@"
10-
wait
11-
./run --arch aarch64 --background --baremetal add --wait-gdb &
12-
./run-gdb --arch aarch64 --baremetal add --test "$@"
13-
wait
14-
./run --arch aarch64 --background --baremetal arch/aarch64/add --wait-gdb &
15-
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --test "$@"
16-
wait
17-
18-
# gem5
19-
./run --arch arm --background --baremetal add --gem5 --wait-gdb &
20-
./run-gdb --arch arm --baremetal add --gem5 --test "$@"
21-
wait
22-
./run --arch arm --background --baremetal arch/arm/add --gem5 --wait-gdb &
23-
./run-gdb --arch arm --baremetal arch/arm/add --gem5 --test "$@"
24-
wait
25-
./run --arch aarch64 --background --baremetal add --gem5 --wait-gdb &
26-
./run-gdb --arch aarch64 --baremetal add --gem5 --test "$@"
27-
wait
28-
./run --arch aarch64 --background --baremetal arch/aarch64/add --gem5 --wait-gdb &
29-
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --gem5 --test "$@"
30-
wait
31-
./run --arch aarch64 --background --baremetal arch/aarch64/regs --gem5 --wait-gdb &
32-
./run-gdb --arch aarch64 --baremetal arch/aarch64/regs --gem5 --test "$@"
33-
wait
34-
./run --arch aarch64 --background --baremetal arch/aarch64/fadd --gem5 --wait-gdb &
35-
./run-gdb --arch aarch64 --baremetal arch/aarch64/fadd --gem5 --test "$@"
36-
wait
3+
for gem5 in '' --gem5; do
4+
./run --arch arm --background --baremetal add $gem5 --wait-gdb &
5+
./run-gdb --arch arm --baremetal add $gem5 --test "$@"
6+
wait
7+
./run --arch arm --background --baremetal arch/arm/add $gem5 --wait-gdb &
8+
./run-gdb --arch arm --baremetal arch/arm/add $gem5 --test "$@"
9+
wait
10+
./run --arch arm --background --baremetal arch/arm/regs $gem5 --wait-gdb &
11+
./run-gdb --arch arm --baremetal arch/arm/regs $gem5 --test "$@"
12+
wait
13+
./run --arch aarch64 --background --baremetal add $gem5 --wait-gdb &
14+
./run-gdb --arch aarch64 --baremetal add $gem5 --test "$@"
15+
wait
16+
./run --arch aarch64 --background --baremetal arch/aarch64/add $gem5 --wait-gdb &
17+
./run-gdb --arch aarch64 --baremetal arch/aarch64/add $gem5 --test "$@"
18+
wait
19+
./run --arch aarch64 --background --baremetal arch/aarch64/regs $gem5 --wait-gdb &
20+
./run-gdb --arch aarch64 --baremetal arch/aarch64/regs $gem5 --test "$@"
21+
wait
22+
./run --arch aarch64 --background --baremetal arch/aarch64/fadd $gem5 --wait-gdb &
23+
./run-gdb --arch aarch64 --baremetal arch/aarch64/fadd $gem5 --test "$@"
24+
wait
25+
./run --arch aarch64 --background --baremetal arch/aarch64/regs $gem5 --wait-gdb &
26+
./run-gdb --arch aarch64 --baremetal arch/aarch64/regs $gem5 --test "$@"
27+
wait
28+
done

0 commit comments

Comments
 (0)