gdb: move all tests to userland

This commit is contained in:
Ciro Santilli 六四事件 法轮功
2019-05-26 00:00:01 +00:00
parent dbfec89e03
commit 12005528ef
18 changed files with 49 additions and 65 deletions

View File

@@ -1,5 +0,0 @@
/* Call a C function. */
.global main
main:
mov x0, 0
bl exit

View 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;
}

View File

@@ -1,5 +0,0 @@
/* Return to ensure that the post main works. */
.global main
main:
mov x0, 0
ret

View File

@@ -1,5 +0,0 @@
/* https://github.com/cirosantilli/linux-kernel-module-cheat#magic-failure-string */
.global main
main:
mov x0, 1
ret

View File

@@ -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

View File

@@ -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 <inttypes.h>
int main(void) {
uint32_t cpsr;
/*uint32_t mvfr1;*/
__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);
/* 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);*/
return 0;
}

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests

View File

@@ -1,7 +1,8 @@
/* https://github.com/cirosantilli/arm-assembly-cheat/blob/c19e187e98e99f2f4a042783ca238aa4eb2292ab/v8/floating_point.S */
.global main
main:
#include <lkmc.h>
LKMC_PROLOGUE
/* 1.5 + 2.5 == 4.0 */
fmov d0, 1.5
/* test-gdb-d0 */
@@ -11,9 +12,7 @@ main:
/* test-gdb-d2 */
fmov d3, 4.0
fcmp d2, d3
beq 1f
bl abort
1:
LKMC_ASSERT(beq)
/* Now in 32-bit. */
fmov s0, 1.5
@@ -25,9 +24,7 @@ main:
fadd s2, s0, s1
fmov s3, 4.0
fcmp s2, s3
beq 1f
bl abort
1:
LKMC_ASSERT(beq)
/* Higher registers. */
fmov d28, 1.5
@@ -39,9 +36,6 @@ main:
fmov d31, 4.0
/* test-gdb-d31 */
fcmp d30, d31
beq 1f
bl abort
1:
LKMC_ASSERT(beq)
mov x0, 0
ret
LKMC_EPILOGUE

View File

@@ -1,13 +1,10 @@
.global main
main:
#include <lkmc.h>
LKMC_PROLOGUE
/* 1 + 2 == 3 */
mov x0, 1
/* test-gdb-op1 */
add x1, x0, 2
/* test-gdb-result */
cmp x1, 3
beq 1f
bl abort
1:
mov x0, 0
ret
LKMC_ASSERT_EQ(x1, =3)
LKMC_EPILOGUE

View File

@@ -1,9 +1,8 @@
/* Test that we can move:
* - set registers
* - read x30
*/
.global main
main:
/* Test that we can set registers from GDB. */
#include <lkmc.h>
LKMC_PROLOGUE
mov x0, 1
/* test-gdb-x0 */
mov x1, 2
@@ -27,3 +26,5 @@ main:
/* Exit required since we messed up with x30 which is the lr. */
mov x0, 0
bl exit
LKMC_EPILOGUE

View File

@@ -0,0 +1 @@
https://github.com/cirosantilli/linux-kernel-module-cheat#gdb-tests

View 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

View File

@@ -1,11 +1,8 @@
/* See the aarch64 version. */
#include <lkmc.h>
LKMC_PROLOGUE
mov r0, #1
mov r0, 1
/* test-gdb-r0 */
mov r1, #2
mov r1, 2
/* test-gdb-r1 */
mov r0, #0
LKMC_EPILOGUE