Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Hyperlight KVM guest debugging using gdb #111

Open
wants to merge 23 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
34f6813
add basic gdb target for a HLSandbox
dblnz Dec 16, 2024
c11143e
create gdb thread when KVM driver is created
dblnz Dec 16, 2024
edadd8f
add gdb event loop execution
dblnz Dec 16, 2024
25b424d
remove unnecessary locks
dblnz Dec 17, 2024
5fa8355
pass the necessary handles to the target
dblnz Dec 17, 2024
63dfb87
disable guest timeouts when gdb features is enabled
dblnz Dec 17, 2024
9fb7b2f
add communication channel between gdb and hypervisor
dblnz Dec 17, 2024
bc222a5
vcpu state synchronization between hypervisor and gdb client
dblnz Dec 17, 2024
38de187
add target internal state that keeps track whether the vcpu is paused
dblnz Dec 17, 2024
f589255
add entrypoint breakpoint support
dblnz Dec 17, 2024
2a144ca
add stop reason transmission to gdb
dblnz Dec 17, 2024
e92f1cd
fixup kvm vcpu run
dblnz Dec 17, 2024
bbfcad1
add read and write registers support
dblnz Dec 17, 2024
a45d5e0
add read/write address and text section offset support
dblnz Dec 17, 2024
b917859
add hw breakpoint support
dblnz Dec 17, 2024
f8a0e12
add gdb resume capabilities
dblnz Dec 17, 2024
95615ed
add gdb step capabilities
dblnz Dec 17, 2024
11d18c7
rename target file to kvm specific name
dblnz Jan 22, 2025
1322701
change gdb feature to support generics for future improvements
dblnz Jan 22, 2025
35c4f60
fix issues for windows and mshv
dblnz Jan 22, 2025
791aaf8
add documentation about how to debug a guest binary
dblnz Jan 22, 2025
16492de
add sw breakpoint support
dblnz Jan 22, 2025
2a36f06
fix documentation and remove unnecessary comments
dblnz Jan 22, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions src/hyperlight_host/src/hypervisor/hypervisor_handler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,6 +545,16 @@ impl HypervisorHandler {
/// and still have to receive after sorting that out without sending
/// an extra message.
pub(crate) fn try_receive_handler_msg(&self) -> Result<()> {
#[cfg(gdb)]
match self.communication_channels.from_handler_rx.recv() {
Ok(msg) => match msg {
HandlerMsg::Error(e) => Err(e),
HandlerMsg::FinishedHypervisorHandlerAction => Ok(()),
},
Err(_) => Err(HyperlightError::HypervisorHandlerMessageReceiveTimedout()),
}

#[cfg(not(gdb))]
Comment on lines +548 to +557
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Disabling the timeout might be helpful for scenarios other than debugging too. Might want to put this under a different feature flag or even as a runtime option. Though, that's not too related to this PR, so maybe leaving it like this is OK for now 👍

match self
.communication_channels
.from_handler_rx
Expand Down