mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-18 12:06:43 +00:00
Disable KVM when using GDB
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
4f575e2028
commit
a52e43218e
7
Makefile
7
Makefile
@ -15,6 +15,7 @@ SKIP_GRUB_MENU ?= 1
|
||||
SYSCALL_TEST_DIR ?= /tmp
|
||||
EXTRA_BLOCKLISTS_DIRS ?= ""
|
||||
RELEASE_MODE ?= 0
|
||||
GDB_TCP_PORT ?= 1234
|
||||
# End of auto test features.
|
||||
|
||||
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
||||
@ -139,12 +140,12 @@ else ifeq ($(AUTO_TEST), boot)
|
||||
endif
|
||||
|
||||
.PHONY: gdb_server
|
||||
gdb_server: build
|
||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS) -G --vsc --gdb-server-addr :1234
|
||||
gdb_server: initramfs $(CARGO_OSDK)
|
||||
@cargo osdk run $(CARGO_OSDK_ARGS) -G --vsc --gdb-server-addr :$(GDB_TCP_PORT)
|
||||
|
||||
.PHONY: gdb_client
|
||||
gdb_client: $(CARGO_OSDK)
|
||||
@cd kernel && cargo osdk debug $(CARGO_OSDK_ARGS) --remote :1234
|
||||
@cd kernel && cargo osdk debug $(CARGO_OSDK_ARGS) --remote :$(GDB_TCP_PORT)
|
||||
|
||||
.PHONY: test
|
||||
test:
|
||||
|
@ -7,7 +7,7 @@ use std::{path::Path, process};
|
||||
|
||||
use bin::strip_elf_for_qemu;
|
||||
|
||||
use super::util::{cargo, COMMON_CARGO_ARGS, DEFAULT_TARGET_RELPATH};
|
||||
use super::util::{cargo, profile_name_adapter, COMMON_CARGO_ARGS, DEFAULT_TARGET_RELPATH};
|
||||
use crate::{
|
||||
base_crate::new_base_crate,
|
||||
bundle::{
|
||||
@ -155,12 +155,9 @@ fn build_kernel_elf(
|
||||
}
|
||||
|
||||
let aster_bin_path = cargo_target_directory.as_ref().join(target);
|
||||
let aster_bin_path = if args.profile == "dev" {
|
||||
aster_bin_path.join("debug")
|
||||
} else {
|
||||
aster_bin_path.join(&args.profile)
|
||||
}
|
||||
.join(get_current_crate_info().name);
|
||||
let aster_bin_path = aster_bin_path
|
||||
.join(profile_name_adapter(&args.profile))
|
||||
.join(get_current_crate_info().name);
|
||||
|
||||
AsterBin::new(
|
||||
aster_bin_path,
|
||||
|
@ -1,6 +1,6 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use crate::commands::util::{bin_file_name, profile_adapter};
|
||||
use crate::commands::util::{bin_file_name, profile_name_adapter};
|
||||
use crate::config_manager::DebugConfig;
|
||||
|
||||
use crate::util::get_target_directory;
|
||||
@ -9,7 +9,7 @@ use std::process::Command;
|
||||
pub fn execute_debug_command(config: &DebugConfig) {
|
||||
let DebugConfig { cargo_args, remote } = config;
|
||||
|
||||
let profile = profile_adapter(&cargo_args.profile);
|
||||
let profile = profile_name_adapter(&cargo_args.profile);
|
||||
let file_path = get_target_directory()
|
||||
.join("x86_64-unknown-none")
|
||||
.join(profile)
|
||||
|
@ -60,6 +60,18 @@ pub fn execute_run_command(config: &RunConfig) {
|
||||
.collect();
|
||||
let mut manifest = config.manifest.clone();
|
||||
manifest.qemu.args.extend(qemu_gdb_args);
|
||||
|
||||
// FIXME: Disable KVM from QEMU args in debug mode.
|
||||
// Currently, the QEMU GDB server does not work properly with KVM enabled.
|
||||
let args_num = manifest.qemu.args.len();
|
||||
manifest.qemu.args.retain(|x| !x.contains("kvm"));
|
||||
if manifest.qemu.args.len() != args_num {
|
||||
println!(
|
||||
"[WARNING] KVM is forced to be disabled in GDB server currently. \
|
||||
Options related with KVM are ignored."
|
||||
);
|
||||
}
|
||||
|
||||
manifest
|
||||
} else {
|
||||
config.manifest.clone()
|
||||
@ -69,7 +81,7 @@ pub fn execute_run_command(config: &RunConfig) {
|
||||
};
|
||||
let _vsc_launch_file = config.gdb_server_args.vsc_launch_file.then(|| {
|
||||
vsc::check_gdb_config(&config.gdb_server_args);
|
||||
let profile = super::util::profile_adapter(&config.cargo_args.profile);
|
||||
let profile = super::util::profile_name_adapter(&config.cargo_args.profile);
|
||||
vsc::VscLaunchConfig::new(profile, &config.gdb_server_args.gdb_server_addr)
|
||||
});
|
||||
|
||||
|
@ -15,7 +15,7 @@ pub fn cargo() -> Command {
|
||||
Command::new("cargo")
|
||||
}
|
||||
|
||||
pub fn profile_adapter(profile: &str) -> &str {
|
||||
pub fn profile_name_adapter(profile: &str) -> &str {
|
||||
match profile {
|
||||
"dev" => "debug",
|
||||
_ => profile,
|
||||
|
Reference in New Issue
Block a user