mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
add more gdb tests
This commit is contained in:
@@ -4,8 +4,11 @@
|
||||
main:
|
||||
/* 1.5 + 2.5 == 4.0 */
|
||||
fmov d0, #1.5
|
||||
/* test-gdb-d0 */
|
||||
fmov d1, #2.5
|
||||
/* test-gdb-d1 */
|
||||
fadd d2, d0, d1
|
||||
/* test-gdb-d2 */
|
||||
fmov d3, #4.0
|
||||
fcmp d2, d3
|
||||
beq 1f
|
||||
@@ -14,7 +17,11 @@ main:
|
||||
|
||||
/* Now in 32-bit. */
|
||||
fmov s0, #1.5
|
||||
/* test-gdb-s0 */
|
||||
fmov s1, #2.5
|
||||
/* test-gdb-s1 */
|
||||
fadd s2, s0, s1
|
||||
/* test-gdb-s2 */
|
||||
fadd s2, s0, s1
|
||||
fmov s3, #4.0
|
||||
fcmp s2, s3
|
||||
@@ -22,4 +29,17 @@ main:
|
||||
bl assert_fail
|
||||
1:
|
||||
|
||||
/* Higher registers. */
|
||||
fmov d28, #1.5
|
||||
/* test-gdb-d28 */
|
||||
fmov d29, #2.5
|
||||
/* test-gdb-d29 */
|
||||
fadd d30, d28, d29
|
||||
/* test-gdb-d30 */
|
||||
fmov d31, #4.0
|
||||
/* test-gdb-d31 */
|
||||
fcmp d30, d31
|
||||
beq 1f
|
||||
bl assert_fail
|
||||
1:
|
||||
ret
|
||||
30
baremetal/arch/aarch64/fadd.py
Normal file
30
baremetal/arch/aarch64/fadd.py
Normal file
@@ -0,0 +1,30 @@
|
||||
def test(self):
|
||||
self.sendline('tbreak main')
|
||||
self.sendline('continue')
|
||||
|
||||
# Double.
|
||||
self.continue_to('d0')
|
||||
assert self.get_float('$d0') == 1.5
|
||||
self.continue_to('d1')
|
||||
assert self.get_float('$d1') == 2.5
|
||||
self.continue_to('d2')
|
||||
assert self.get_float('$d2') == 4.0
|
||||
|
||||
# Single.
|
||||
self.continue_to('s0')
|
||||
assert self.get_float('$s0') == 1.5
|
||||
self.continue_to('s1')
|
||||
assert self.get_float('$s1') == 2.5
|
||||
self.continue_to('s2')
|
||||
assert self.get_float('$s2') == 4.0
|
||||
|
||||
# High registers..
|
||||
self.continue_to('d28')
|
||||
assert self.get_float('$d28') == 1.5
|
||||
self.continue_to('d29')
|
||||
assert self.get_float('$d29') == 2.5
|
||||
self.continue_to('d30')
|
||||
assert self.get_float('$d30') == 4.0
|
||||
self.continue_to('d31')
|
||||
assert self.get_float('$d31') == 4.0
|
||||
|
||||
19
baremetal/arch/aarch64/regs.S
Normal file
19
baremetal/arch/aarch64/regs.S
Normal file
@@ -0,0 +1,19 @@
|
||||
/* Test that we can move:
|
||||
* - set registers
|
||||
* - read x30 */
|
||||
.global main
|
||||
main:
|
||||
/* test-gdb-before-x29 */
|
||||
mov x0, #1
|
||||
/* test-gdb-x0 */
|
||||
mov x1, #2
|
||||
/* test-gdb-x1 */
|
||||
|
||||
mov x29, #1
|
||||
/* test-gdb-x29 */
|
||||
mov x30, #2
|
||||
/* test-gdb-x30 */
|
||||
|
||||
/* Exit required since we meesed up with x30 which is the lr. */
|
||||
mov x0, #0
|
||||
bl exit
|
||||
10
baremetal/arch/aarch64/regs.py
Normal file
10
baremetal/arch/aarch64/regs.py
Normal file
@@ -0,0 +1,10 @@
|
||||
def test(self):
|
||||
self.sendline('tbreak main')
|
||||
self.sendline('continue')
|
||||
self.continue_to('x1')
|
||||
self.sendline('set $x30 = 3')
|
||||
self.continue_to('x29')
|
||||
assert self.get_int('$x29') == 1
|
||||
assert self.get_int('$x30') == 3
|
||||
self.continue_to('x30')
|
||||
assert self.get_int('$x30') == 2
|
||||
10
run-gdb
10
run-gdb
@@ -64,6 +64,10 @@ class GdbTestcase:
|
||||
self.sendline('printf "%d\\n", {}'.format(int_id))
|
||||
return int(self.before())
|
||||
|
||||
def get_float(self, float_id):
|
||||
self.sendline('printf "%f\\n", {}'.format(float_id))
|
||||
return float(self.before())
|
||||
|
||||
def find_line(self, lineid):
|
||||
'''
|
||||
Search for the first line that contains a comment line
|
||||
@@ -107,7 +111,11 @@ def main(args, extra_args=None):
|
||||
elif args.verbose:
|
||||
# The output of this would affect the tests.
|
||||
# https://stackoverflow.com/questions/13496389/gdb-remote-protocol-how-to-analyse-packets
|
||||
before.extend(['-ex', 'set debug remote 1', common.Newline])
|
||||
# Also be opinionated and set remotetimeout to allow you to step debug the emulator at the same time.
|
||||
before.extend([
|
||||
'-ex', 'set debug remote 1', common.Newline,
|
||||
'-ex', 'set remotetimeout 99999', common.Newline,
|
||||
])
|
||||
if args.break_at is not None:
|
||||
break_at = ['-ex', 'break {}'.format(args.break_at), common.Newline]
|
||||
else:
|
||||
|
||||
12
test-gdb
12
test-gdb
@@ -8,6 +8,9 @@ wait
|
||||
./run --arch arm --background --baremetal arch/arm/add --wait-gdb &
|
||||
./run-gdb --arch arm --baremetal arch/arm/add --test "$@"
|
||||
wait
|
||||
./run --arch aarch64 --background --baremetal add --wait-gdb &
|
||||
./run-gdb --arch aarch64 --baremetal add --test "$@"
|
||||
wait
|
||||
./run --arch aarch64 --background --baremetal arch/aarch64/add --wait-gdb &
|
||||
./run-gdb --arch aarch64 --baremetal arch/aarch64/add --test "$@"
|
||||
wait
|
||||
@@ -19,6 +22,15 @@ wait
|
||||
./run --arch arm --background --baremetal arch/arm/add --gem5 --wait-gdb &
|
||||
./run-gdb --arch arm --baremetal arch/arm/add --gem5 --test "$@"
|
||||
wait
|
||||
./run --arch aarch64 --background --baremetal add --gem5 --wait-gdb &
|
||||
./run-gdb --arch aarch64 --baremetal add --gem5 --test "$@"
|
||||
wait
|
||||
./run --arch aarch64 --background --baremetal arch/aarch64/add --gem5 --wait-gdb &
|
||||
./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
|
||||
|
||||
Reference in New Issue
Block a user