diff --git a/osdk/src/commands/debug.rs b/osdk/src/commands/debug.rs index 6cb207d9b..46247abed 100644 --- a/osdk/src/commands/debug.rs +++ b/osdk/src/commands/debug.rs @@ -2,17 +2,17 @@ use crate::{ cli::DebugArgs, - commands::util::{bin_file_name, profile_name_adapter}, - util::get_target_directory, + commands::util::bin_file_name, + util::{get_current_crate_info, get_target_directory}, }; use std::process::Command; -pub fn execute_debug_command(profile: &str, args: &DebugArgs) { +pub fn execute_debug_command(_profile: &str, args: &DebugArgs) { let remote = &args.remote; let file_path = get_target_directory() - .join("x86_64-unknown-none") - .join(profile_name_adapter(profile)) + .join("osdk") + .join(get_current_crate_info().name) .join(bin_file_name()); println!("Debugging {}", file_path.display()); diff --git a/osdk/src/commands/launch.json.template b/osdk/src/commands/launch.json.template index 0ded500d9..a201cf88a 100644 --- a/osdk/src/commands/launch.json.template +++ b/osdk/src/commands/launch.json.template @@ -5,7 +5,7 @@ "name": "Debug Asterinas(#PROFILE#)", "type": "lldb", "request": "custom", - "targetCreateCommands": ["target create ${workspaceFolder}/target/x86_64-unknown-none/#PROFILE#/#BIN_NAME#"], + "targetCreateCommands": ["target create ${workspaceFolder}/target/osdk/#CRATE_NAME#/#BIN_NAME#"], "processCreateCommands": ["gdb-remote #ADDR_PORT#"] } ] diff --git a/osdk/src/commands/run.rs b/osdk/src/commands/run.rs index 6a44f2ca4..07c07c494 100644 --- a/osdk/src/commands/run.rs +++ b/osdk/src/commands/run.rs @@ -56,17 +56,17 @@ pub fn execute_run_command(config: &Config, gdb_server_args: &GdbServerArgs) { config.run.qemu.args = splitted.join(" "); // Ensure debug info added when debugging in the release profile. - if config.run.build.profile == "release" { + if config.run.build.profile.contains("release") { config .run .build .override_configs - .push("profile.release.debug=true".to_owned()); + .push(format!("profile.{}.debug=true", config.run.build.profile)); } } let _vsc_launch_file = gdb_server_args.vsc_launch_file.then(|| { vsc::check_gdb_config(gdb_server_args); - let profile = super::util::profile_name_adapter(&config.build.profile); + let profile = super::util::profile_name_adapter(&config.run.build.profile); vsc::VscLaunchConfig::new(profile, &gdb_server_args.gdb_server_addr) }); @@ -124,7 +124,11 @@ mod gdb { } mod vsc { - use crate::{cli::GdbServerArgs, commands::util::bin_file_name, util::get_cargo_metadata}; + use crate::{ + cli::GdbServerArgs, + commands::util::bin_file_name, + util::{get_cargo_metadata, get_current_crate_info}, + }; use serde_json::{from_str, Value}; use std::{ fs::{read_to_string, write as write_file}, @@ -242,6 +246,7 @@ mod vsc { ) -> Result<(), std::io::Error> { let contents = include_str!("launch.json.template") .replace("#PROFILE#", profile) + .replace("#CRATE_NAME#", &get_current_crate_info().name) .replace("#BIN_NAME#", &bin_file_name()) .replace( "#ADDR_PORT#",