Skip to content

Commit

Permalink
fix documentation and remove unnecessary comments
Browse files Browse the repository at this point in the history
Signed-off-by: Doru Blânzeanu <[email protected]>
  • Loading branch information
dblnz committed Jan 22, 2025
1 parent 16492de commit 2a36f06
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 11 deletions.
10 changes: 6 additions & 4 deletions docs/how-to-debug-a-hyperlight-guest.md
Original file line number Diff line number Diff line change
@@ -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.

Expand All @@ -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
Expand All @@ -23,4 +23,6 @@ set disassemble-next-line on
enable pretty-printer
layout regs
layout src
```
```

One can find more information about the `.gdbinit` file at [gdbinit(5)](https://www.man7.org/linux/man-pages/man5/gdbinit.5.html).
1 change: 0 additions & 1 deletion src/hyperlight_host/src/hypervisor/gdb/kvm_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -176,7 +176,6 @@ impl HyperlightKvmSandboxTarget {

/// Translates the guest address to physical address
fn translate_gva(&self, gva: u64) -> Result<u64, GdbTargetError> {
// TODO: Properly handle errors
let tr = self
.vcpu_fd
.lock()
Expand Down
8 changes: 2 additions & 6 deletions src/hyperlight_host/src/hypervisor/gdb/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,8 @@ impl From<io::Error> for GdbTargetError {
}

impl From<DebugMessage> for GdbTargetError {
fn from(value: DebugMessage) -> Self {
match value {
DebugMessage::VcpuStoppedEv => GdbTargetError::UnexpectedMessageError,
_ => GdbTargetError::UnexpectedMessageError,
}
fn from(_value: DebugMessage) -> Self {
GdbTargetError::UnexpectedMessageError
}
}

Expand Down Expand Up @@ -140,7 +137,6 @@ where
<T as Target>::Error:
std::fmt::Debug + Send + From<io::Error> + From<DebugMessage> + From<TryRecvError>,
{
// TODO: Address multiple sandboxes scenario
let socket = format!("localhost:{}", 8081);

log::info!("Listening on {:?}", socket);
Expand Down

0 comments on commit 2a36f06

Please sign in to comment.