diff --git a/.vscode/launch.json b/.vscode/launch.json index 1952561..ec68f01 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -2,7 +2,7 @@ "version": "0.2.0", "configurations": [ { - "name": "Debug", + "name": "Debug Test", "preLaunchTask": "build test", "type": "cppdbg", "request": "launch", @@ -21,5 +21,25 @@ } ] }, + { + "name": "Debug Kernel", + "preLaunchTask": "build kernel", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/target/kernel_exe", + "cwd": "${workspaceFolder}", + "MIMode": "gdb", + "miDebuggerPath": "/usr/bin/gdb-multiarch", + "miDebuggerServerAddress": "localhost:1234", + "setupCommands": [ + { + "text": "-enable-pretty-printing", + "ignoreFailures": true + }, + { + "text": "set output-radix 16" + } + ] + }, ] } \ No newline at end of file diff --git a/.vscode/prepare_kernel.sh b/.vscode/prepare_kernel.sh new file mode 100755 index 0000000..fde4f51 --- /dev/null +++ b/.vscode/prepare_kernel.sh @@ -0,0 +1,3 @@ +#!/bin/bash +TARGET=$(make build-target 2>/dev/null) +cp "./target/$TARGET/debug/kernel" target/kernel_exe diff --git a/.vscode/prepare_test.sh b/.vscode/prepare_test.sh index 839429a..b2b773b 100755 --- a/.vscode/prepare_test.sh +++ b/.vscode/prepare_test.sh @@ -1,2 +1,2 @@ #!/bin/bash -cargo xtask test --arch=riscv64 --dump 2>/dev/null | jq -r '[inputs] | map(select(has("executable")) | .executable) | last' | xargs -I{} cp {} target/test_exe +make kernel-test-dump 2>/dev/null | jq -r '[inputs] | map(select(has("executable")) | .executable) | last' | xargs -I{} cp {} target/test_exe diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 82539bc..3428dcf 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -6,6 +6,12 @@ "label": "build test", "command": "./.vscode/prepare_test.sh", "problemMatcher": [] + }, + { + "type": "shell", + "label": "build kernel", + "command": "./.vscode/prepare_kernel.sh", + "problemMatcher": [] } ] } \ No newline at end of file diff --git a/Makefile b/Makefile index b9f3ac2..971e08a 100644 --- a/Makefile +++ b/Makefile @@ -32,6 +32,12 @@ test: cargo test -p utils env RUSTFLAGS="$(RUSTFLAGS)" cargo test $(CARGO_TARGET_ARGS) --bin=kernel +kernel-test-dump: + @env RUSTFLAGS="$(RUSTFLAGS)" cargo test $(CARGO_TARGET_ARGS) --bin=kernel --no-run --message-format=json + +build-target: + @echo $(BUILD_TARGET) + clean: cargo clean @@ -64,4 +70,4 @@ qemu-replay: kernel replay.qcow2 -drive file=replay.qcow2,if=none,id=rr \ -s -S -.PHONY: kernel clippy test clean qemu qemu-gdb qemu-record qemu-replay +.PHONY: kernel clippy test kernel-test-dump build-target clean qemu qemu-gdb qemu-record qemu-replay