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,5 +0,0 @@
|
|||||||
/* Call a C function. */
|
|
||||||
.global main
|
|
||||||
main:
|
|
||||||
mov x0, 0
|
|
||||||
bl exit
|
|
||||||
11
baremetal/arch/aarch64/dump_regs.c
Normal file
11
baremetal/arch/aarch64/dump_regs.c
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
/* Dump as many registers as we feel like to see initial CPU state. */
|
||||||
|
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <inttypes.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
uint32_t sctlr_el1;
|
||||||
|
__asm__ ("mrs %0, sctlr_el1" : "=r" (sctlr_el1) : :);
|
||||||
|
printf("sctlr_el1 0x%" PRIx32 "\n", sctlr_el1);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
/* Return to ensure that the post main works. */
|
|
||||||
.global main
|
|
||||||
main:
|
|
||||||
mov x0, 0
|
|
||||||
ret
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
|
|
||||||
.global main
|
|
||||||
main:
|
|
||||||
mov x0, 1
|
|
||||||
ret
|
|
||||||
@@ -1,13 +0,0 @@
|
|||||||
.global main
|
|
||||||
main:
|
|
||||||
/* 1 + 2 == 3 */
|
|
||||||
mov r0, #1
|
|
||||||
/* test-gdb-op1 */
|
|
||||||
add r1, r0, #2
|
|
||||||
/* test-gdb-result */
|
|
||||||
cmp r1, #3
|
|
||||||
beq 1f
|
|
||||||
bl abort
|
|
||||||
1:
|
|
||||||
mov r0, #0
|
|
||||||
bx lr
|
|
||||||
@@ -1,15 +1,15 @@
|
|||||||
/* I want to move el and all other "what's the initial value of such system register" into here. */
|
|
||||||
|
|
||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
|
||||||
int main(void) {
|
int main(void) {
|
||||||
uint32_t cpsr;
|
uint32_t cpsr;
|
||||||
/*uint32_t mvfr1;*/
|
|
||||||
__asm__ ("mrs %0, cpsr" : "=r" (cpsr) : :);
|
__asm__ ("mrs %0, cpsr" : "=r" (cpsr) : :);
|
||||||
/* TODO this is blowing up an exception, how to I read from it? */
|
|
||||||
/*__asm__ ("vmrs %0, mvfr1" : "=r" (mvfr1) : :);*/
|
|
||||||
printf("cpsr %" PRIx32 "\n", cpsr);
|
printf("cpsr %" PRIx32 "\n", cpsr);
|
||||||
|
|
||||||
|
/* TODO this is blowing up an exception, how to I read from it? */
|
||||||
|
/*uint32_t mvfr1;*/
|
||||||
|
/*__asm__ ("vmrs %0, mvfr1" : "=r" (mvfr1) : :);*/
|
||||||
/*printf("mvfr1 %" PRIx32 "\n", mvfr1);*/
|
/*printf("mvfr1 %" PRIx32 "\n", mvfr1);*/
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
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
|
||||||
@@ -1,7 +1,8 @@
|
|||||||
/* https://github.com/cirosantilli/arm-assembly-cheat/blob/c19e187e98e99f2f4a042783ca238aa4eb2292ab/v8/floating_point.S */
|
/* https://github.com/cirosantilli/arm-assembly-cheat/blob/c19e187e98e99f2f4a042783ca238aa4eb2292ab/v8/floating_point.S */
|
||||||
|
|
||||||
.global main
|
#include <lkmc.h>
|
||||||
main:
|
|
||||||
|
LKMC_PROLOGUE
|
||||||
/* 1.5 + 2.5 == 4.0 */
|
/* 1.5 + 2.5 == 4.0 */
|
||||||
fmov d0, 1.5
|
fmov d0, 1.5
|
||||||
/* test-gdb-d0 */
|
/* test-gdb-d0 */
|
||||||
@@ -11,9 +12,7 @@ main:
|
|||||||
/* test-gdb-d2 */
|
/* test-gdb-d2 */
|
||||||
fmov d3, 4.0
|
fmov d3, 4.0
|
||||||
fcmp d2, d3
|
fcmp d2, d3
|
||||||
beq 1f
|
LKMC_ASSERT(beq)
|
||||||
bl abort
|
|
||||||
1:
|
|
||||||
|
|
||||||
/* Now in 32-bit. */
|
/* Now in 32-bit. */
|
||||||
fmov s0, 1.5
|
fmov s0, 1.5
|
||||||
@@ -25,9 +24,7 @@ main:
|
|||||||
fadd s2, s0, s1
|
fadd s2, s0, s1
|
||||||
fmov s3, 4.0
|
fmov s3, 4.0
|
||||||
fcmp s2, s3
|
fcmp s2, s3
|
||||||
beq 1f
|
LKMC_ASSERT(beq)
|
||||||
bl abort
|
|
||||||
1:
|
|
||||||
|
|
||||||
/* Higher registers. */
|
/* Higher registers. */
|
||||||
fmov d28, 1.5
|
fmov d28, 1.5
|
||||||
@@ -39,9 +36,6 @@ main:
|
|||||||
fmov d31, 4.0
|
fmov d31, 4.0
|
||||||
/* test-gdb-d31 */
|
/* test-gdb-d31 */
|
||||||
fcmp d30, d31
|
fcmp d30, d31
|
||||||
beq 1f
|
LKMC_ASSERT(beq)
|
||||||
bl abort
|
|
||||||
1:
|
|
||||||
|
|
||||||
mov x0, 0
|
LKMC_EPILOGUE
|
||||||
ret
|
|
||||||
@@ -1,13 +1,10 @@
|
|||||||
.global main
|
#include <lkmc.h>
|
||||||
main:
|
|
||||||
|
LKMC_PROLOGUE
|
||||||
/* 1 + 2 == 3 */
|
/* 1 + 2 == 3 */
|
||||||
mov x0, 1
|
mov x0, 1
|
||||||
/* test-gdb-op1 */
|
/* test-gdb-op1 */
|
||||||
add x1, x0, 2
|
add x1, x0, 2
|
||||||
/* test-gdb-result */
|
/* test-gdb-result */
|
||||||
cmp x1, 3
|
LKMC_ASSERT_EQ(x1, =3)
|
||||||
beq 1f
|
LKMC_EPILOGUE
|
||||||
bl abort
|
|
||||||
1:
|
|
||||||
mov x0, 0
|
|
||||||
ret
|
|
||||||
@@ -1,9 +1,8 @@
|
|||||||
/* Test that we can move:
|
/* Test that we can set registers from GDB. */
|
||||||
* - set registers
|
|
||||||
* - read x30
|
#include <lkmc.h>
|
||||||
*/
|
|
||||||
.global main
|
LKMC_PROLOGUE
|
||||||
main:
|
|
||||||
mov x0, 1
|
mov x0, 1
|
||||||
/* test-gdb-x0 */
|
/* test-gdb-x0 */
|
||||||
mov x1, 2
|
mov x1, 2
|
||||||
@@ -27,3 +26,5 @@ main:
|
|||||||
/* Exit required since we messed up with x30 which is the lr. */
|
/* Exit required since we messed up with x30 which is the lr. */
|
||||||
mov x0, 0
|
mov x0, 0
|
||||||
bl exit
|
bl exit
|
||||||
|
|
||||||
|
LKMC_EPILOGUE
|
||||||
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
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
/* See the aarch64 version. */
|
|
||||||
|
|
||||||
#include <lkmc.h>
|
#include <lkmc.h>
|
||||||
|
|
||||||
LKMC_PROLOGUE
|
LKMC_PROLOGUE
|
||||||
mov r0, #1
|
mov r0, 1
|
||||||
/* test-gdb-r0 */
|
/* test-gdb-r0 */
|
||||||
mov r1, #2
|
mov r1, 2
|
||||||
/* test-gdb-r1 */
|
/* test-gdb-r1 */
|
||||||
mov r0, #0
|
|
||||||
LKMC_EPILOGUE
|
LKMC_EPILOGUE
|
||||||
Reference in New Issue
Block a user