add simple debug test for riscv-none-elf-gdb

This commit is contained in:
James Stine 2024-06-08 18:12:10 -05:00
parent 4fad0b0249
commit c3243caacf
3 changed files with 34 additions and 0 deletions

View File

@ -0,0 +1,15 @@
TARGET = simple
$(TARGET).objdump: $(TARGET)
riscv64-unknown-elf-objdump -S -D $(TARGET) > $(TARGET).objdump
spike $(TARGET)
$(TARGET): $(TARGET).c Makefile
riscv64-unknown-elf-gcc -o $(TARGET) -g\
-march=rv64gc -mabi=lp64d -mcmodel=medany \
-nostdlib -static -lm -fno-tree-loop-distribute-patterns \
-T../../../examples/C/common/test.ld -I../../../examples/C/common/ \
$(TARGET).c ../../../examples/C/common/crt.S ../../../examples/C/common/syscalls.c
clean:
rm -f $(TARGET) $(TARGET).objdump

BIN
tests/debug/simple/simple Executable file

Binary file not shown.

View File

@ -0,0 +1,19 @@
#include <stdio.h>
int main() {
// This is just random simple instructions
// to test the RISC-V debug gdb
asm("li a0, 0x1000");
asm("addi a1, a0, 0x100");
asm("addi a2, a1, 0x200");
asm("li a3, 0x4000000");
asm("sw a0, 0(a3)");
asm("sw a1, 4(a3)");
asm("lw a4, 0(a3)");
asm("lw a5, 4(a3)");
asm("lw a5, 4(a3)");
asm("nop");
while(1);
}