diff --git a/.gitignore b/.gitignore index 9fc90c58..32f926a7 100644 --- a/.gitignore +++ b/.gitignore @@ -5,6 +5,7 @@ os/src/link_app.S os/src/linker.ld os/last-* os/Cargo.lock +os/.gdb_history user/build user/target/* user/.idea/* diff --git a/os/Cargo.toml b/os/Cargo.toml index c98e71ef..cc93ff4e 100644 --- a/os/Cargo.toml +++ b/os/Cargo.toml @@ -14,3 +14,6 @@ cfg-if = { version = "1.0.0" } [features] board_qemu = [] board_k210 = [] + +[profile.release] +debug = true diff --git a/os/Makefile b/os/Makefile index 505d37ec..6da9228f 100644 --- a/os/Makefile +++ b/os/Makefile @@ -11,6 +11,11 @@ SBI ?= rustsbi BOOTLOADER := ../bootloader/$(SBI)-$(BOARD).bin K210_BOOTLOADER_SIZE := 131072 +# Building mode argument +ifeq ($(MODE), release) + MODE_ARG := --release +endif + # KERNEL ENTRY ifeq ($(BOARD), qemu) KERNEL_ENTRY_PA := 0x80200000 @@ -51,7 +56,7 @@ kernel: @cd ../user && make build @echo Platform: $(BOARD) @cp src/linker-$(BOARD).ld src/linker.ld - @cargo build --release --features "board_$(BOARD)" + @cargo build $(MODE_ARG) --features "board_$(BOARD)" @rm src/linker.ld clean: @@ -92,4 +97,10 @@ debug: build tmux split-window -h "riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234'" && \ tmux -2 attach-session -d -.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check +gdbserver: build + @qemu-system-riscv64 -machine virt -nographic -bios $(BOOTLOADER) -device loader,file=$(KERNEL_BIN),addr=$(KERNEL_ENTRY_PA) -s -S + +gdbclient: + @riscv64-unknown-elf-gdb -ex 'file $(KERNEL_ELF)' -ex 'set arch riscv:rv64' -ex 'target remote localhost:1234' + +.PHONY: build env kernel clean disasm disasm-vim run-inner switch-check gdbserver gdbclient diff --git a/rust-toolchain b/rust-toolchain index 925656db..abcacd9b 100644 --- a/rust-toolchain +++ b/rust-toolchain @@ -1 +1 @@ -nightly-2022-01-19 +nightly-2022-04-11 diff --git a/user/Cargo.toml b/user/Cargo.toml index 817ca525..d843673c 100644 --- a/user/Cargo.toml +++ b/user/Cargo.toml @@ -7,3 +7,6 @@ edition = "2018" # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html [dependencies] + +[profile.release] +debug = true