From 8be90bba34fc3081fc8ef87ac4a56107707a14dd Mon Sep 17 00:00:00 2001 From: jenra-uwu Date: Sun, 25 Jul 2021 16:26:52 -0400 Subject: [PATCH] Did stuff --- Makefile | 7 ++++++- README.md | 7 +------ kernel.gdb | 2 ++ 3 files changed, 9 insertions(+), 7 deletions(-) create mode 100644 kernel.gdb diff --git a/Makefile b/Makefile index 6d5f23a..bbe690c 100644 --- a/Makefile +++ b/Makefile @@ -1,5 +1,7 @@ CODE=src/ -CC=riscv64-unknown-elf-gcc +CROSS_COMPILE=riscv64-unknown-elf- +CC=$(CROSS_COMPILE)gcc +GDB=$(CROSS_COMPILE)gdb CFLAGS=-march=rv64gc -mabi=lp64d -static -mcmodel=medany -fvisibility=hidden -nostdlib -nostartfiles -Tkernel.ld -g -Wall -Wextra EMU=qemu-system-riscv64 EFLAGS=-machine virt -cpu rv64 -bios opensbi-riscv64-generic-fw_dynamic.bin -m 256m -nographic -global virtio-mmio.force-legacy=false -s #-S @@ -11,3 +13,6 @@ all: $(CODE)*.s $(CODE)*.c run: $(EMU) $(EFLAGS) -kernel kernel + +gdb: + $(GDB) -x kernel.gdb diff --git a/README.md b/README.md index 23c103e..705c1ac 100644 --- a/README.md +++ b/README.md @@ -8,15 +8,10 @@ Install [the Newlib GNU RISC V toolchain](https://github.com/riscv/riscv-gnu-too This is the new "how to exit Vi" I guess. To exit, press control+x, unpress those keys, and then press a. ## Debugging -Execute `riscv64-unknown-elf-gdb` and run the following commands: -``` -(gdb) symbol-file kernel -(gdb) target remote localhost:1234 -``` +Execute `make gdb` and then `make run`. If you'd like to trace the execution since the beginning, uncomment the `# -S` at the end of the line in the makefile and run. This halts the emulator until a gdb connection is established. - ## Resources - [OpenSBI docs](https://github.com/riscv/riscv-sbi-doc/blob/master/riscv-sbi.adoc) - [RISC V specs](https://riscv.org/technical/specifications/) diff --git a/kernel.gdb b/kernel.gdb new file mode 100644 index 0000000..ec621e8 --- /dev/null +++ b/kernel.gdb @@ -0,0 +1,2 @@ +symbol-file kernel +target remote localhost:1234