mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-23 01:13:23 +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
|
SYSCALL_TEST_DIR ?= /tmp
|
||||||
EXTRA_BLOCKLISTS_DIRS ?= ""
|
EXTRA_BLOCKLISTS_DIRS ?= ""
|
||||||
RELEASE_MODE ?= 0
|
RELEASE_MODE ?= 0
|
||||||
|
GDB_TCP_PORT ?= 1234
|
||||||
# End of auto test features.
|
# End of auto test features.
|
||||||
|
|
||||||
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
CARGO_OSDK := ~/.cargo/bin/cargo-osdk
|
||||||
@ -139,12 +140,12 @@ else ifeq ($(AUTO_TEST), boot)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
.PHONY: gdb_server
|
.PHONY: gdb_server
|
||||||
gdb_server: build
|
gdb_server: initramfs $(CARGO_OSDK)
|
||||||
@cd kernel && cargo osdk run $(CARGO_OSDK_ARGS) -G --vsc --gdb-server-addr :1234
|
@cargo osdk run $(CARGO_OSDK_ARGS) -G --vsc --gdb-server-addr :$(GDB_TCP_PORT)
|
||||||
|
|
||||||
.PHONY: gdb_client
|
.PHONY: gdb_client
|
||||||
gdb_client: $(CARGO_OSDK)
|
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
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
|
@ -7,7 +7,7 @@ use std::{path::Path, process};
|
|||||||
|
|
||||||
use bin::strip_elf_for_qemu;
|
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::{
|
use crate::{
|
||||||
base_crate::new_base_crate,
|
base_crate::new_base_crate,
|
||||||
bundle::{
|
bundle::{
|
||||||
@ -155,12 +155,9 @@ fn build_kernel_elf(
|
|||||||
}
|
}
|
||||||
|
|
||||||
let aster_bin_path = cargo_target_directory.as_ref().join(target);
|
let aster_bin_path = cargo_target_directory.as_ref().join(target);
|
||||||
let aster_bin_path = if args.profile == "dev" {
|
let aster_bin_path = aster_bin_path
|
||||||
aster_bin_path.join("debug")
|
.join(profile_name_adapter(&args.profile))
|
||||||
} else {
|
.join(get_current_crate_info().name);
|
||||||
aster_bin_path.join(&args.profile)
|
|
||||||
}
|
|
||||||
.join(get_current_crate_info().name);
|
|
||||||
|
|
||||||
AsterBin::new(
|
AsterBin::new(
|
||||||
aster_bin_path,
|
aster_bin_path,
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
// SPDX-License-Identifier: MPL-2.0
|
// 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::config_manager::DebugConfig;
|
||||||
|
|
||||||
use crate::util::get_target_directory;
|
use crate::util::get_target_directory;
|
||||||
@ -9,7 +9,7 @@ use std::process::Command;
|
|||||||
pub fn execute_debug_command(config: &DebugConfig) {
|
pub fn execute_debug_command(config: &DebugConfig) {
|
||||||
let DebugConfig { cargo_args, remote } = config;
|
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()
|
let file_path = get_target_directory()
|
||||||
.join("x86_64-unknown-none")
|
.join("x86_64-unknown-none")
|
||||||
.join(profile)
|
.join(profile)
|
||||||
|
@ -60,6 +60,18 @@ pub fn execute_run_command(config: &RunConfig) {
|
|||||||
.collect();
|
.collect();
|
||||||
let mut manifest = config.manifest.clone();
|
let mut manifest = config.manifest.clone();
|
||||||
manifest.qemu.args.extend(qemu_gdb_args);
|
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
|
manifest
|
||||||
} else {
|
} else {
|
||||||
config.manifest.clone()
|
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(|| {
|
let _vsc_launch_file = config.gdb_server_args.vsc_launch_file.then(|| {
|
||||||
vsc::check_gdb_config(&config.gdb_server_args);
|
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)
|
vsc::VscLaunchConfig::new(profile, &config.gdb_server_args.gdb_server_addr)
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -15,7 +15,7 @@ pub fn cargo() -> Command {
|
|||||||
Command::new("cargo")
|
Command::new("cargo")
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn profile_adapter(profile: &str) -> &str {
|
pub fn profile_name_adapter(profile: &str) -> &str {
|
||||||
match profile {
|
match profile {
|
||||||
"dev" => "debug",
|
"dev" => "debug",
|
||||||
_ => profile,
|
_ => profile,
|
||||||
|
Reference in New Issue
Block a user