mirror of
https://github.com/panpaul/tiny_os
synced 2024-09-20 09:45:19 +08:00
feat: add vscode debug
This commit is contained in:
parent
4647d1fd2a
commit
067a7996b4
25
.vscode/launch.json
vendored
Normal file
25
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,25 @@
|
||||
{
|
||||
"version": "0.2.0",
|
||||
"configurations": [
|
||||
{
|
||||
"name": "Debug",
|
||||
"preLaunchTask": "build test",
|
||||
"type": "cppdbg",
|
||||
"request": "launch",
|
||||
"program": "${workspaceFolder}/target/test_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"
|
||||
}
|
||||
]
|
||||
},
|
||||
]
|
||||
}
|
2
.vscode/prepare_test.sh
vendored
Executable file
2
.vscode/prepare_test.sh
vendored
Executable file
@ -0,0 +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
|
11
.vscode/tasks.json
vendored
Normal file
11
.vscode/tasks.json
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
{
|
||||
"version": "2.0.0",
|
||||
"tasks": [
|
||||
{
|
||||
"type": "shell",
|
||||
"label": "build test",
|
||||
"command": "./.vscode/prepare_test.sh",
|
||||
"problemMatcher": []
|
||||
}
|
||||
]
|
||||
}
|
@ -6,16 +6,32 @@ use xshell::cmd;
|
||||
pub struct Test {
|
||||
#[command(flatten)]
|
||||
pub artifact: Artifact,
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub debug: bool,
|
||||
#[arg(long, default_value_t = false)]
|
||||
pub dump: bool,
|
||||
}
|
||||
|
||||
impl Test {
|
||||
pub fn run(&self) -> anyhow::Result<()> {
|
||||
let sh = crate::shell()?;
|
||||
|
||||
let mut extra_args: Vec<&str> = Vec::new();
|
||||
if self.debug && !self.dump {
|
||||
extra_args.push("--");
|
||||
extra_args.push("-s");
|
||||
extra_args.push("-S");
|
||||
}
|
||||
if self.dump {
|
||||
extra_args.push("--no-run");
|
||||
extra_args.push("--message-format=json")
|
||||
}
|
||||
|
||||
cmd!(sh, "cargo test")
|
||||
.env("CARGO_ENCODED_RUSTFLAGS", self.artifact.rust_flags()?.join("\x1f"))
|
||||
.args(["--bin", "kernel"])
|
||||
.args(self.artifact.cargo_args(true)?)
|
||||
.args(extra_args)
|
||||
.run()?;
|
||||
|
||||
Ok(())
|
||||
|
Loading…
Reference in New Issue
Block a user