mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-23 02:05:57 +01:00
gdb: move all tests to userland
This commit is contained in:
1
userland/arch/aarch64/gdb_tests/README.adoc
Normal file
1
userland/arch/aarch64/gdb_tests/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests
|
||||
41
userland/arch/aarch64/gdb_tests/floating_registers.S
Normal file
41
userland/arch/aarch64/gdb_tests/floating_registers.S
Normal file
@@ -0,0 +1,41 @@
|
||||
/* https://github.com/cirosantilli/arm-assembly-cheat/blob/c19e187e98e99f2f4a042783ca238aa4eb2292ab/v8/floating_point.S */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
/* 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
|
||||
LKMC_ASSERT(beq)
|
||||
|
||||
/* 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
|
||||
LKMC_ASSERT(beq)
|
||||
|
||||
/* 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
|
||||
LKMC_ASSERT(beq)
|
||||
|
||||
LKMC_EPILOGUE
|
||||
30
userland/arch/aarch64/gdb_tests/floating_registers.py
Normal file
30
userland/arch/aarch64/gdb_tests/floating_registers.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
|
||||
|
||||
10
userland/arch/aarch64/gdb_tests/integer_registers.S
Normal file
10
userland/arch/aarch64/gdb_tests/integer_registers.S
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
/* 1 + 2 == 3 */
|
||||
mov x0, 1
|
||||
/* test-gdb-op1 */
|
||||
add x1, x0, 2
|
||||
/* test-gdb-result */
|
||||
LKMC_ASSERT_EQ(x1, =3)
|
||||
LKMC_EPILOGUE
|
||||
7
userland/arch/aarch64/gdb_tests/integer_registers.py
Normal file
7
userland/arch/aarch64/gdb_tests/integer_registers.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def test(self):
|
||||
self.sendline('tbreak main')
|
||||
self.sendline('continue')
|
||||
self.continue_to('op1')
|
||||
assert self.get_int('$x0') == 1
|
||||
self.continue_to('result')
|
||||
assert self.get_int('$x1') == 3
|
||||
30
userland/arch/aarch64/gdb_tests/set_registers.S
Normal file
30
userland/arch/aarch64/gdb_tests/set_registers.S
Normal file
@@ -0,0 +1,30 @@
|
||||
/* Test that we can set registers from GDB. */
|
||||
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov x0, 1
|
||||
/* test-gdb-x0 */
|
||||
mov x1, 2
|
||||
/* test-gdb-x1 */
|
||||
|
||||
mov x29, 1
|
||||
/* test-gdb-x29 */
|
||||
mov x30, 2
|
||||
/* test-gdb-x30 */
|
||||
|
||||
fmov d0, 1.5
|
||||
/* test-gdb-d0 */
|
||||
fmov d1, 2.5
|
||||
/* test-gdb-d1 */
|
||||
|
||||
fmov d30, 1.5
|
||||
/* test-gdb-d30 */
|
||||
fmov d31, 2.5
|
||||
/* test-gdb-d31 */
|
||||
|
||||
/* Exit required since we messed up with x30 which is the lr. */
|
||||
mov x0, 0
|
||||
bl exit
|
||||
|
||||
LKMC_EPILOGUE
|
||||
27
userland/arch/aarch64/gdb_tests/set_registers.py
Normal file
27
userland/arch/aarch64/gdb_tests/set_registers.py
Normal file
@@ -0,0 +1,27 @@
|
||||
def test(self):
|
||||
self.sendline('tbreak main')
|
||||
self.sendline('continue')
|
||||
|
||||
self.continue_to('x0')
|
||||
self.sendline('set $x0 = 3')
|
||||
self.continue_to('x1')
|
||||
assert self.get_int('$x0') == 3
|
||||
assert self.get_int('$x1') == 2
|
||||
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
|
||||
|
||||
self.continue_to('d0')
|
||||
self.sendline('set $d0 = 3.5')
|
||||
self.continue_to('d1')
|
||||
assert self.get_float('$d0') == 3.5
|
||||
assert self.get_float('$d1') == 2.5
|
||||
self.sendline('set $d31 = 3.5')
|
||||
self.continue_to('d30')
|
||||
assert self.get_float('$d30') == 1.5
|
||||
assert self.get_float('$d31') == 3.5
|
||||
self.continue_to('d31')
|
||||
assert self.get_float('$d31') == 2.5
|
||||
1
userland/arch/arm/gdb_tests/README.adoc
Normal file
1
userland/arch/arm/gdb_tests/README.adoc
Normal file
@@ -0,0 +1 @@
|
||||
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests
|
||||
10
userland/arch/arm/gdb_tests/integer_registers.S
Normal file
10
userland/arch/arm/gdb_tests/integer_registers.S
Normal file
@@ -0,0 +1,10 @@
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
/* 1 + 2 == 3 */
|
||||
mov r0, 1
|
||||
/* test-gdb-op1 */
|
||||
add r1, r0, 2
|
||||
/* test-gdb-result */
|
||||
LKMC_ASSERT_EQ(r1, =3)
|
||||
LKMC_EPILOGUE
|
||||
7
userland/arch/arm/gdb_tests/integer_registers.py
Normal file
7
userland/arch/arm/gdb_tests/integer_registers.py
Normal file
@@ -0,0 +1,7 @@
|
||||
def test(self):
|
||||
self.sendline('tbreak main')
|
||||
self.sendline('continue')
|
||||
self.continue_to('op1')
|
||||
assert self.get_int('$r0') == 1
|
||||
self.continue_to('result')
|
||||
assert self.get_int('$r1') == 3
|
||||
8
userland/arch/arm/gdb_tests/set_registers.S
Normal file
8
userland/arch/arm/gdb_tests/set_registers.S
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <lkmc.h>
|
||||
|
||||
LKMC_PROLOGUE
|
||||
mov r0, 1
|
||||
/* test-gdb-r0 */
|
||||
mov r1, 2
|
||||
/* test-gdb-r1 */
|
||||
LKMC_EPILOGUE
|
||||
8
userland/arch/arm/gdb_tests/set_registers.py
Normal file
8
userland/arch/arm/gdb_tests/set_registers.py
Normal 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
|
||||
Reference in New Issue
Block a user