Fix debug target path in OSDK

This commit is contained in:
fgh1999
2024-06-26 09:51:24 +00:00
committed by Tate, Hongliang Tian
parent 5d9868964b
commit 18b11ec193
3 changed files with 15 additions and 10 deletions

View File

@ -2,17 +2,17 @@
use crate::{ use crate::{
cli::DebugArgs, cli::DebugArgs,
commands::util::{bin_file_name, profile_name_adapter}, commands::util::bin_file_name,
util::get_target_directory, util::{get_current_crate_info, get_target_directory},
}; };
use std::process::Command; 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 remote = &args.remote;
let file_path = get_target_directory() let file_path = get_target_directory()
.join("x86_64-unknown-none") .join("osdk")
.join(profile_name_adapter(profile)) .join(get_current_crate_info().name)
.join(bin_file_name()); .join(bin_file_name());
println!("Debugging {}", file_path.display()); println!("Debugging {}", file_path.display());

View File

@ -5,7 +5,7 @@
"name": "Debug Asterinas(#PROFILE#)", "name": "Debug Asterinas(#PROFILE#)",
"type": "lldb", "type": "lldb",
"request": "custom", "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#"] "processCreateCommands": ["gdb-remote #ADDR_PORT#"]
} }
] ]

View File

@ -56,17 +56,17 @@ pub fn execute_run_command(config: &Config, gdb_server_args: &GdbServerArgs) {
config.run.qemu.args = splitted.join(" "); config.run.qemu.args = splitted.join(" ");
// Ensure debug info added when debugging in the release profile. // Ensure debug info added when debugging in the release profile.
if config.run.build.profile == "release" { if config.run.build.profile.contains("release") {
config config
.run .run
.build .build
.override_configs .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(|| { let _vsc_launch_file = gdb_server_args.vsc_launch_file.then(|| {
vsc::check_gdb_config(gdb_server_args); 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) vsc::VscLaunchConfig::new(profile, &gdb_server_args.gdb_server_addr)
}); });
@ -124,7 +124,11 @@ mod gdb {
} }
mod vsc { 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 serde_json::{from_str, Value};
use std::{ use std::{
fs::{read_to_string, write as write_file}, fs::{read_to_string, write as write_file},
@ -242,6 +246,7 @@ mod vsc {
) -> Result<(), std::io::Error> { ) -> Result<(), std::io::Error> {
let contents = include_str!("launch.json.template") let contents = include_str!("launch.json.template")
.replace("#PROFILE#", profile) .replace("#PROFILE#", profile)
.replace("#CRATE_NAME#", &get_current_crate_info().name)
.replace("#BIN_NAME#", &bin_file_name()) .replace("#BIN_NAME#", &bin_file_name())
.replace( .replace(
"#ADDR_PORT#", "#ADDR_PORT#",