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