mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-10 05:46:48 +00:00
Add debug subcommand in OSDK
This commit is contained in:
parent
5fd3b1bc2f
commit
28127850aa
@ -76,6 +76,7 @@ Currently we support following commands:
|
|||||||
- **new**: Create a new kernel package or library package
|
- **new**: Create a new kernel package or library package
|
||||||
- **build**: Compile the project and its dependencies
|
- **build**: Compile the project and its dependencies
|
||||||
- **run**: Run the kernel with a VMM
|
- **run**: Run the kernel with a VMM
|
||||||
|
- **debug**: Debug a remote target via GDB
|
||||||
- **test**: Execute kernel mode unit test by starting a VMM
|
- **test**: Execute kernel mode unit test by starting a VMM
|
||||||
- **check**: Analyze the current package and report errors
|
- **check**: Analyze the current package and report errors
|
||||||
- **clippy**: Check the current package and catch common mistakes
|
- **clippy**: Check the current package and catch common mistakes
|
||||||
|
@ -131,8 +131,12 @@ pub struct DebugArgs {
|
|||||||
pub cargo_args: CargoArgs,
|
pub cargo_args: CargoArgs,
|
||||||
#[command(flatten)]
|
#[command(flatten)]
|
||||||
pub osdk_args: OsdkArgs,
|
pub osdk_args: OsdkArgs,
|
||||||
#[arg(name = "ROLE", help = "'client' or 'server'", default_value = "server")]
|
#[arg(
|
||||||
pub role: String,
|
long,
|
||||||
|
help = "Specify the address of the remote target",
|
||||||
|
default_value = ".aster-gdb-socket"
|
||||||
|
)]
|
||||||
|
pub remote: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Parser)]
|
#[derive(Debug, Parser)]
|
||||||
|
@ -7,22 +7,19 @@ use crate::util::get_target_directory;
|
|||||||
use std::process::Command;
|
use std::process::Command;
|
||||||
|
|
||||||
pub fn execute_debug_command(config: &DebugConfig) {
|
pub fn execute_debug_command(config: &DebugConfig) {
|
||||||
let DebugConfig {
|
let DebugConfig { cargo_args, remote } = config;
|
||||||
manifest,
|
|
||||||
cargo_args,
|
|
||||||
} = config;
|
|
||||||
|
|
||||||
let profile = profile_adapter(&cargo_args.profile);
|
let profile = profile_adapter(&cargo_args.profile);
|
||||||
let file_path = get_target_directory()
|
let file_path = get_target_directory()
|
||||||
.join("x86_64-unknown-none")
|
.join("x86_64-unknown-none")
|
||||||
.join(profile)
|
.join(profile)
|
||||||
.join(bin_file_name());
|
.join(bin_file_name());
|
||||||
println!("Debugging {:?}", file_path);
|
println!("Debugging {}", file_path.display());
|
||||||
|
|
||||||
let mut gdb = Command::new("gdb");
|
let mut gdb = Command::new("gdb");
|
||||||
gdb.args([
|
gdb.args([
|
||||||
"-ex",
|
"-ex",
|
||||||
"target remote :1234",
|
format!("target remote {}", remote).as_str(),
|
||||||
"-ex",
|
"-ex",
|
||||||
format!("file {}", file_path.display()).as_str(),
|
format!("file {}", file_path.display()).as_str(),
|
||||||
]);
|
]);
|
||||||
|
@ -76,16 +76,15 @@ impl RunConfig {
|
|||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
pub struct DebugConfig {
|
pub struct DebugConfig {
|
||||||
pub manifest: OsdkManifest,
|
|
||||||
pub cargo_args: CargoArgs,
|
pub cargo_args: CargoArgs,
|
||||||
|
pub remote: String,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DebugConfig {
|
impl DebugConfig {
|
||||||
pub fn parse(args: &DebugArgs) -> Self {
|
pub fn parse(args: &DebugArgs) -> Self {
|
||||||
let cargo_args = split_features(&args.cargo_args);
|
|
||||||
Self {
|
Self {
|
||||||
manifest: get_final_manifest(&cargo_args, &args.osdk_args),
|
cargo_args: split_features(&args.cargo_args),
|
||||||
cargo_args,
|
remote: args.remote.clone(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user