chore: update vscode debug script

This commit is contained in:
Paul Pan 2024-05-06 15:53:48 +08:00
parent 71faad766d
commit a2dce7ad48
5 changed files with 38 additions and 3 deletions

22
.vscode/launch.json vendored
View File

@ -2,7 +2,7 @@
"version": "0.2.0", "version": "0.2.0",
"configurations": [ "configurations": [
{ {
"name": "Debug", "name": "Debug Test",
"preLaunchTask": "build test", "preLaunchTask": "build test",
"type": "cppdbg", "type": "cppdbg",
"request": "launch", "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"
}
]
},
] ]
} }

3
.vscode/prepare_kernel.sh vendored Executable file
View File

@ -0,0 +1,3 @@
#!/bin/bash
TARGET=$(make build-target 2>/dev/null)
cp "./target/$TARGET/debug/kernel" target/kernel_exe

View File

@ -1,2 +1,2 @@
#!/bin/bash #!/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

6
.vscode/tasks.json vendored
View File

@ -6,6 +6,12 @@
"label": "build test", "label": "build test",
"command": "./.vscode/prepare_test.sh", "command": "./.vscode/prepare_test.sh",
"problemMatcher": [] "problemMatcher": []
},
{
"type": "shell",
"label": "build kernel",
"command": "./.vscode/prepare_kernel.sh",
"problemMatcher": []
} }
] ]
} }

View File

@ -32,6 +32,12 @@ test:
cargo test -p utils cargo test -p utils
env RUSTFLAGS="$(RUSTFLAGS)" cargo test $(CARGO_TARGET_ARGS) --bin=kernel 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: clean:
cargo clean cargo clean
@ -64,4 +70,4 @@ qemu-replay: kernel replay.qcow2
-drive file=replay.qcow2,if=none,id=rr \ -drive file=replay.qcow2,if=none,id=rr \
-s -S -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