diff --git a/docs/how-to-debug-a-hyperlight-guest.md b/docs/how-to-debug-a-hyperlight-guest.md index 6791478d..25e26ba1 100644 --- a/docs/how-to-debug-a-hyperlight-guest.md +++ b/docs/how-to-debug-a-hyperlight-guest.md @@ -1,7 +1,7 @@ # How to debug a Hyperlight guest -Currently Hyperlight support gdb debugging of a guest running inside a Hyperlight sandbox. -When the option is enabled Hyperlight starts listening on port `8081` for a gdb connection. +Hyperlight supports gdb debugging of a guest running inside a Hyperlight sandbox. +When Hyperlight is compiled with the `gdb` feature enabled, Hyperlight starts listening on port `8081` for a gdb connection. Note: It will only accept one connection, if the connection is closed, the debug session is also closed. @@ -14,7 +14,7 @@ The execution will wait for gdb to attach. One can use a simple gdb config to provide the symbols and desired configuration: For the above example, when running from the repository root directory, the below contents -of `.gdbinit` file can be used. +of `.gdbinit` file can be used to provide configuration to gdb startup. ```gdb file src/tests/rust_guests/bin/debug/simpleguest target remote :8081 @@ -23,4 +23,6 @@ set disassemble-next-line on enable pretty-printer layout regs layout src -``` \ No newline at end of file +``` + +One can find more information about the `.gdbinit` file at [gdbinit(5)](https://www.man7.org/linux/man-pages/man5/gdbinit.5.html). diff --git a/src/hyperlight_host/src/hypervisor/gdb/kvm_target.rs b/src/hyperlight_host/src/hypervisor/gdb/kvm_target.rs index d1d97082..4b591dd6 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/kvm_target.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/kvm_target.rs @@ -176,7 +176,6 @@ impl HyperlightKvmSandboxTarget { /// Translates the guest address to physical address fn translate_gva(&self, gva: u64) -> Result { - // TODO: Properly handle errors let tr = self .vcpu_fd .lock() diff --git a/src/hyperlight_host/src/hypervisor/gdb/mod.rs b/src/hyperlight_host/src/hypervisor/gdb/mod.rs index 887065cc..9ee50069 100644 --- a/src/hyperlight_host/src/hypervisor/gdb/mod.rs +++ b/src/hyperlight_host/src/hypervisor/gdb/mod.rs @@ -43,11 +43,8 @@ impl From for GdbTargetError { } impl From for GdbTargetError { - fn from(value: DebugMessage) -> Self { - match value { - DebugMessage::VcpuStoppedEv => GdbTargetError::UnexpectedMessageError, - _ => GdbTargetError::UnexpectedMessageError, - } + fn from(_value: DebugMessage) -> Self { + GdbTargetError::UnexpectedMessageError } } @@ -140,7 +137,6 @@ where ::Error: std::fmt::Debug + Send + From + From + From, { - // TODO: Address multiple sandboxes scenario let socket = format!("localhost:{}", 8081); log::info!("Listening on {:?}", socket);