Skip to content

Commit

Permalink
remove gdb feature guard for sandbox config
Browse files Browse the repository at this point in the history
- the user experience is not great as the fields and methods
related to gdb port are not accessible unless the gdb feature
is turned on.
- if one runs the build command in the cli and provides the --features gdb
the IDE will not know that the feature is enabled and will show
errors as it doesn't know about the fields/methods

Signed-off-by: Doru Blânzeanu <[email protected]>
  • Loading branch information
dblnz committed Feb 5, 2025
1 parent af0a52a commit 6cc6184
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions src/hyperlight_host/src/sandbox/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ use crate::mem::exe::ExeInfo;
#[derive(Copy, Clone, Debug, Eq, PartialEq)]
#[repr(C)]
pub struct SandboxConfiguration {
#[cfg(gdb)]
/// Guest gdb debug port
guest_debug_port: Option<u16>,
/// The maximum size of the guest error buffer.
Expand Down Expand Up @@ -139,9 +138,8 @@ impl SandboxConfiguration {
pub const MIN_KERNEL_STACK_SIZE: usize = 0x1000;
/// The default value for kernel stack size
pub const DEFAULT_KERNEL_STACK_SIZE: usize = Self::MIN_KERNEL_STACK_SIZE;
#[cfg(gdb)]
/// The minimum value for debug port
pub const MIN_GUEST_DEBUG_PORT: u16 = 9000;
pub const MIN_GUEST_DEBUG_PORT: u16 = 1024;

#[allow(clippy::too_many_arguments)]
/// Create a new configuration for a sandbox with the given sizes.
Expand All @@ -159,7 +157,7 @@ impl SandboxConfiguration {
max_initialization_time: Option<Duration>,
max_wait_for_cancellation: Option<Duration>,
guest_panic_context_buffer_size: usize,
#[cfg(gdb)] guest_debug_port: Option<u16>,
guest_debug_port: Option<u16>,
) -> Self {
Self {
input_data_size: max(input_data_size, Self::MIN_INPUT_SIZE),
Expand Down Expand Up @@ -227,7 +225,6 @@ impl SandboxConfiguration {
guest_panic_context_buffer_size,
Self::MIN_GUEST_PANIC_CONTEXT_BUFFER_SIZE,
),
#[cfg(gdb)]
guest_debug_port,
}
}
Expand Down Expand Up @@ -355,7 +352,6 @@ impl SandboxConfiguration {
);
}

#[cfg(gdb)]
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
/// Sets the configuration for the guest debug
pub fn set_guest_debug_port(&mut self, port: u16) {
Expand Down Expand Up @@ -406,7 +402,6 @@ impl SandboxConfiguration {
self.max_initialization_time
}

#[cfg(gdb)]
#[instrument(skip_all, parent = Span::current(), level= "Trace")]
pub(crate) fn get_guest_debug_port(&self) -> Option<u16> {
self.guest_debug_port
Expand Down Expand Up @@ -460,7 +455,6 @@ impl Default for SandboxConfiguration {
None,
None,
Self::DEFAULT_GUEST_PANIC_CONTEXT_BUFFER_SIZE,
#[cfg(gdb)]
None,
)
}
Expand Down Expand Up @@ -504,7 +498,6 @@ mod tests {
MAX_WAIT_FOR_CANCELLATION_OVERRIDE as u64,
)),
GUEST_PANIC_CONTEXT_BUFFER_SIZE_OVERRIDE,
#[cfg(gdb)]
None,
);
let exe_infos = vec![
Expand Down Expand Up @@ -569,7 +562,6 @@ mod tests {
SandboxConfiguration::MIN_MAX_WAIT_FOR_CANCELLATION as u64 - 1,
)),
SandboxConfiguration::MIN_GUEST_PANIC_CONTEXT_BUFFER_SIZE - 1,
#[cfg(gdb)]
None,
);
assert_eq!(SandboxConfiguration::MIN_INPUT_SIZE, cfg.input_data_size);
Expand Down Expand Up @@ -741,7 +733,6 @@ mod tests {
}

#[test]
#[cfg(gdb)]
fn guest_debug_port(port in 9000..=u16::MAX) {
let mut cfg = SandboxConfiguration::default();
cfg.set_guest_debug_port(port);
Expand Down

0 comments on commit 6cc6184

Please sign in to comment.