make gdb test automation even awesomer

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2018-11-13 00:00:00 +00:00
parent a06872241b
commit e54635c3ab
8 changed files with 65 additions and 39 deletions

View File

@@ -32,7 +32,7 @@ Reserve 12Gb of disk and run:
.... ....
git clone https://github.com/cirosantilli/linux-kernel-module-cheat git clone https://github.com/cirosantilli/linux-kernel-module-cheat
cd linux-kernel-module-cheat cd linux-kernel-module-cheat
./build --download-dependencies ./build --download-dependencies qemu-buildroot
./run ./run
.... ....
@@ -1321,7 +1321,7 @@ Tested on 4f4749148273c282e80b58c59db1b47049e190bf + 1.
=== GDB step debug early boot === GDB step debug early boot
TODO sucessfully debu the very first instruction that the Linux kernel runs, before `start_kernel`! TODO successfully debug the very first instruction that the Linux kernel runs, before `start_kernel`!
Break at the very first instruction executed by QEMU: Break at the very first instruction executed by QEMU:
@@ -9116,6 +9116,8 @@ Remote debugging using localhost:7000
Remote 'g' packet reply is too long: 000000000000000090a4f90fc0ffffff4875450ec0ffffff01000000000000000100000000000000000000000000000001000000000000000000000000000000ffffffffffffffff646d60616b64fffe7f7f7f7f7f7f7f7f0101010101010101300000000000000000000000ffffffff48454422207d2c2017162f21262820160100000000000000070000000000000001000000000000004075450ec0ffffffc073450ec0ffffff82080000000000004075450ec0ffffff8060f90fc0ffffffc073450ec0fffffff040900880ffffff40ab400ec0ffffff586d900880ffffff0068a20ec0ffffff903b010880ffffffc8ff210880ffffff903b010880ffffffccff210880ffffff050000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 Remote 'g' packet reply is too long: 000000000000000090a4f90fc0ffffff4875450ec0ffffff01000000000000000100000000000000000000000000000001000000000000000000000000000000ffffffffffffffff646d60616b64fffe7f7f7f7f7f7f7f7f0101010101010101300000000000000000000000ffffffff48454422207d2c2017162f21262820160100000000000000070000000000000001000000000000004075450ec0ffffffc073450ec0ffffff82080000000000004075450ec0ffffff8060f90fc0ffffffc073450ec0fffffff040900880ffffff40ab400ec0ffffff586d900880ffffff0068a20ec0ffffff903b010880ffffffc8ff210880ffffff903b010880ffffffccff210880ffffff050000200000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
.... ....
See: <<remote-g-packet-reply-is-too-long>>
and gem5 says: and gem5 says:
.... ....
@@ -10165,6 +10167,10 @@ You can also find executables that don't use the bootloader at all under `bareme
./run --arch arm --baremetal arch/arm/no_bootloader/semihost_exit --wait-gdb ./run --arch arm --baremetal arch/arm/no_bootloader/semihost_exit --wait-gdb
.... ....
The cool thing about those examples is that you start at the very first instruction of your program, which gives more control.
However, those examples tend to be less portable, so we use examples with the bootloader for the most part.
Alternatively, skip directly to the C program main function with: Alternatively, skip directly to the C program main function with:
.... ....
@@ -11450,6 +11456,8 @@ We have some link:https://github.com/pexpect/pexpect[pexpect] automated tests fo
./test-gdb ./test-gdb
.... ....
Not all of them are passing right now due to: <<gem5-gdb-step-debug-kernel-aarch64>>.
If something goes wrong, re-run the test commands manually and use `--verbose` to understand what happened: If something goes wrong, re-run the test commands manually and use `--verbose` to understand what happened:
.... ....
@@ -11457,12 +11465,18 @@ If something goes wrong, re-run the test commands manually and use `--verbose` t
./run-gdb --arch arm --baremetal add --test --verbose ./run-gdb --arch arm --baremetal add --test --verbose
.... ....
and possibly repeat the GDB steps manually with the usual:
....
./run-gdb --arch arm --baremetal add --no-continue --verbose
....
Sources: Sources:
* link:build-test-gdb[] * link:build-test-gdb[]
* link:test-gdb[] * link:test-gdb[]
For the Linux kenel, do the following manual tests for now. For the Linux kernel, do the following manual tests for now.
Shell 1: Shell 1:

View File

@@ -3,7 +3,6 @@
* - read x30 */ * - read x30 */
.global main .global main
main: main:
/* test-gdb-before-x29 */
mov x0, #1 mov x0, #1
/* test-gdb-x0 */ /* test-gdb-x0 */
mov x1, #2 mov x1, #2

View File

@@ -1,7 +1,11 @@
def test(self): def test(self):
self.sendline('tbreak main') self.sendline('tbreak main')
self.sendline('continue') self.sendline('continue')
self.continue_to('x0')
self.sendline('set $x0 = 3')
self.continue_to('x1') self.continue_to('x1')
assert self.get_int('$x0') == 3
assert self.get_int('$x1') == 2
self.sendline('set $x30 = 3') self.sendline('set $x30 = 3')
self.continue_to('x29') self.continue_to('x29')
assert self.get_int('$x29') == 1 assert self.get_int('$x29') == 1

View File

@@ -0,0 +1,8 @@
/* See the aarch64 version. */
.global main
main:
mov r0, #1
/* test-gdb-r0 */
mov r1, #2
/* test-gdb-r1 */
bx lr

View File

@@ -0,0 +1,8 @@
def test(self):
self.sendline('tbreak main')
self.sendline('continue')
self.continue_to('r0')
self.sendline('set $r0 = 3')
self.continue_to('r1')
assert self.get_int('$r0') == 3
assert self.get_int('$r1') == 2

View File

@@ -1,3 +1,4 @@
#include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <sys/stat.h> #include <sys/stat.h>

2
build
View File

@@ -307,7 +307,7 @@ Extra args to pass to all scripts.
''' '''
) )
parser.add_argument('components', choices=list(name_to_component_map.keys()) + [[]], default=[], nargs='*', help='''\ parser.add_argument('components', choices=list(name_to_component_map.keys()) + [[]], default=[], nargs='*', help='''\
Which components to build. Which components to build. Default: qemu-buildroot
'''.format(common.default_arch)) '''.format(common.default_arch))
common.add_dry_run_argument(parser) common.add_dry_run_argument(parser)
args = parser.parse_args() args = parser.parse_args()

View File

@@ -1,36 +1,28 @@
#!/usr/bin/env bash #!/usr/bin/env bash
set -eux set -eux
for gem5 in '' --gem5; do
# QEMU ./run --arch arm --background --baremetal add $gem5 --wait-gdb &
./run --arch arm --background --baremetal add --wait-gdb & ./run-gdb --arch arm --baremetal add $gem5 --test "$@"
./run-gdb --arch arm --baremetal add --test "$@" wait
wait ./run --arch arm --background --baremetal arch/arm/add $gem5 --wait-gdb &
./run --arch arm --background --baremetal arch/arm/add --wait-gdb & ./run-gdb --arch arm --baremetal arch/arm/add $gem5 --test "$@"
./run-gdb --arch arm --baremetal arch/arm/add --test "$@" wait
wait ./run --arch arm --background --baremetal arch/arm/regs $gem5 --wait-gdb &
./run --arch aarch64 --background --baremetal add --wait-gdb & ./run-gdb --arch arm --baremetal arch/arm/regs $gem5 --test "$@"
./run-gdb --arch aarch64 --baremetal add --test "$@" wait
wait ./run --arch aarch64 --background --baremetal add $gem5 --wait-gdb &
./run --arch aarch64 --background --baremetal arch/aarch64/add --wait-gdb & ./run-gdb --arch aarch64 --baremetal add $gem5 --test "$@"
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --test "$@" wait
wait ./run --arch aarch64 --background --baremetal arch/aarch64/add $gem5 --wait-gdb &
./run-gdb --arch aarch64 --baremetal arch/aarch64/add $gem5 --test "$@"
# gem5 wait
./run --arch arm --background --baremetal add --gem5 --wait-gdb & ./run --arch aarch64 --background --baremetal arch/aarch64/regs $gem5 --wait-gdb &
./run-gdb --arch arm --baremetal add --gem5 --test "$@" ./run-gdb --arch aarch64 --baremetal arch/aarch64/regs $gem5 --test "$@"
wait wait
./run --arch arm --background --baremetal arch/arm/add --gem5 --wait-gdb & ./run --arch aarch64 --background --baremetal arch/aarch64/fadd $gem5 --wait-gdb &
./run-gdb --arch arm --baremetal arch/arm/add --gem5 --test "$@" ./run-gdb --arch aarch64 --baremetal arch/aarch64/fadd $gem5 --test "$@"
wait wait
./run --arch aarch64 --background --baremetal add --gem5 --wait-gdb & ./run --arch aarch64 --background --baremetal arch/aarch64/regs $gem5 --wait-gdb &
./run-gdb --arch aarch64 --baremetal add --gem5 --test "$@" ./run-gdb --arch aarch64 --baremetal arch/aarch64/regs $gem5 --test "$@"
wait wait
./run --arch aarch64 --background --baremetal arch/aarch64/add --gem5 --wait-gdb & done
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --gem5 --test "$@"
wait
./run --arch aarch64 --background --baremetal arch/aarch64/regs --gem5 --wait-gdb &
./run-gdb --arch aarch64 --baremetal arch/aarch64/regs --gem5 --test "$@"
wait
./run --arch aarch64 --background --baremetal arch/aarch64/fadd --gem5 --wait-gdb &
./run-gdb --arch aarch64 --baremetal arch/aarch64/fadd --gem5 --test "$@"
wait