Skip to content

Commit 0bb1fd6

Browse files
committed
Rename cargo feature 'dump_on_crash' to 'crashdump' and alias with debug_assertions
Signed-off-by: Ludvig Liljenberg <[email protected]>
1 parent eb19598 commit 0bb1fd6

File tree

9 files changed

+23
-23
lines changed

9 files changed

+23
-23
lines changed

docs/debugging-hyperlight.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,6 @@ cargo test --package hyperlight-host --test integration_test --features print_de
3939

4040
## Dumping the memory configuration, virtual processor register state and memory contents on a crash or unexpected VM Exit
4141

42-
To dump the details of the memory configuration, the virtual processors register state and the contents of the VM memory set the feature `dump_on_crash` and run a debug build. This will result in a dump file being created in the temporary directory. The name and location of the dump file will be printed to the console and logged as an error message.
42+
To dump the details of the memory configuration, the virtual processors register state and the contents of the VM memory set the feature `crashdump` and run a debug build. This will result in a dump file being created in the temporary directory. The name and location of the dump file will be printed to the console and logged as an error message.
4343

4444
There are no tools at this time to analyze the dump file, but it can be useful for debugging.

src/hyperlight_host/Cargo.toml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,7 @@ function_call_metrics = []
118118
executable_heap = []
119119
# This feature enables printing of debug information to stdout in debug builds
120120
print_debug = []
121-
# This feature enables dunping of the VMs details to a file when an unexpected or error exit occurs in a VM in debug mode
122-
# the name of the file is output to stdout and logged.
123-
dump_on_crash = ["dep:tempfile"]
121+
crashdump = ["dep:tempfile"] # Dumps the VM state to a file on unexpected errors or crashes. The path of the file will be printed on stdout and logged. This feature can only be used in debug builds.
124122
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
125123
mshv = ["dep:mshv-bindings", "dep:mshv-ioctls"]
126124
inprocess = []

src/hyperlight_host/build.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,8 @@ fn main() -> Result<()> {
9494
// inprocess feature is aliased with debug_assertions to make it only available in debug-builds.
9595
// You should never use #[cfg(feature = "inprocess")] in the codebase. Use #[cfg(inprocess)] instead.
9696
inprocess: { all(feature = "inprocess", debug_assertions) },
97+
// crashdump feature is aliased with debug_assertions to make it only available in debug-builds.
98+
crashdump: { all(feature = "crashdump", debug_assertions) },
9799
}
98100

99101
write_built_file()?;

src/hyperlight_host/src/hypervisor/dump_on_crash.rs renamed to src/hyperlight_host/src/hypervisor/crashdump.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ use super::Hypervisor;
66
use crate::{new_error, Result};
77

88
/// Dump registers + memory regions + raw memory to a tempfile
9-
#[cfg(feature = "dump_on_crash")]
10-
pub(crate) fn dump_on_crash_to_tempfile(hv: &dyn Hypervisor) -> Result<()> {
9+
#[cfg(crashdump)]
10+
pub(crate) fn crashdump_to_tempfile(hv: &dyn Hypervisor) -> Result<()> {
1111
let mut temp_file = NamedTempFile::with_prefix("mem")?;
1212
let hv_details = format!("{:#x?}", hv);
1313

@@ -35,7 +35,7 @@ pub(crate) fn dump_on_crash_to_tempfile(hv: &dyn Hypervisor) -> Result<()> {
3535
let persist_path = temp_file.path().with_extension("dmp");
3636
temp_file
3737
.persist(&persist_path)
38-
.map_err(|e| new_error!("Failed to persist dump_on_crash file: {:?}", e))?;
38+
.map_err(|e| new_error!("Failed to persist crashdump file: {:?}", e))?;
3939

4040
println!("Memory dumped to file: {:?}", persist_path);
4141
log::error!("Memory dumped to file: {:?}", persist_path);

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -353,7 +353,7 @@ impl Hypervisor for HypervLinuxDriver {
353353
self as &mut dyn Hypervisor
354354
}
355355

356-
#[cfg(feature = "dump_on_crash")]
356+
#[cfg(crashdump)]
357357
fn get_memory_regions(&self) -> &[MemoryRegion] {
358358
&self.mem_regions
359359
}

src/hyperlight_host/src/hypervisor/hyperv_windows.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -536,7 +536,7 @@ impl Hypervisor for HypervWindowsDriver {
536536
self as &mut dyn Hypervisor
537537
}
538538

539-
#[cfg(feature = "dump_on_crash")]
539+
#[cfg(crashdump)]
540540
fn get_memory_regions(&self) -> &[MemoryRegion] {
541541
&self.mem_regions
542542
}

src/hyperlight_host/src/hypervisor/inprocess.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use std::fmt::Debug;
1818
use std::os::raw::c_void;
1919

2020
use super::{HyperlightExit, Hypervisor};
21-
#[cfg(feature = "dump_on_crash")]
21+
#[cfg(crashdump)]
2222
use crate::mem::memory_region::MemoryRegion;
2323
use crate::sandbox::leaked_outb::LeakedOutBWrapper;
2424
use crate::Result;
@@ -126,7 +126,7 @@ impl<'a> Hypervisor for InprocessDriver<'a> {
126126
unimplemented!("get_partition_handle should not be needed since we are in in-process mode")
127127
}
128128

129-
#[cfg(feature = "dump_on_crash")]
129+
#[cfg(crashdump)]
130130
fn get_memory_regions(&self) -> &[MemoryRegion] {
131131
unimplemented!("get_memory_regions is not supported since we are in in-process mode")
132132
}

src/hyperlight_host/src/hypervisor/kvm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl Hypervisor for KVMDriver {
326326
self as &mut dyn Hypervisor
327327
}
328328

329-
#[cfg(feature = "dump_on_crash")]
329+
#[cfg(crashdump)]
330330
fn get_memory_regions(&self) -> &[MemoryRegion] {
331331
&self.mem_regions
332332
}

src/hyperlight_host/src/hypervisor/mod.rs

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ pub(crate) mod windows_hypervisor_platform;
5555
#[cfg(target_os = "windows")]
5656
pub(crate) mod wrappers;
5757

58-
#[cfg(feature = "dump_on_crash")]
59-
pub(crate) mod dump_on_crash;
58+
#[cfg(crashdump)]
59+
pub(crate) mod crashdump;
6060

6161
use std::fmt::Debug;
6262
use std::sync::{Arc, Mutex};
@@ -187,7 +187,7 @@ pub(crate) trait Hypervisor: Debug + Sync + Send {
187187
#[cfg(target_os = "windows")]
188188
fn get_partition_handle(&self) -> windows::Win32::System::Hypervisor::WHV_PARTITION_HANDLE;
189189

190-
#[cfg(feature = "dump_on_crash")]
190+
#[cfg(crashdump)]
191191
fn get_memory_regions(&self) -> &[MemoryRegion];
192192
}
193193

@@ -212,8 +212,8 @@ impl VirtualCPU {
212212
hv.handle_io(port, data, rip, instruction_length, outb_handle_fn.clone())?
213213
}
214214
Ok(HyperlightExit::Mmio(addr)) => {
215-
#[cfg(feature = "dump_on_crash")]
216-
dump_on_crash::dump_on_crash_to_tempfile(hv)?;
215+
#[cfg(crashdump)]
216+
crashdump::crashdump_to_tempfile(hv)?;
217217

218218
mem_access_fn
219219
.clone()
@@ -224,8 +224,8 @@ impl VirtualCPU {
224224
log_then_return!("MMIO access address {:#x}", addr);
225225
}
226226
Ok(HyperlightExit::AccessViolation(addr, tried, region_permission)) => {
227-
#[cfg(feature = "dump_on_crash")]
228-
dump_on_crash::dump_on_crash_to_tempfile(hv)?;
227+
#[cfg(crashdump)]
228+
crashdump::crashdump_to_tempfile(hv)?;
229229

230230
if region_permission.intersects(MemoryRegionFlags::STACK_GUARD) {
231231
return Err(HyperlightError::StackOverflow());
@@ -250,15 +250,15 @@ impl VirtualCPU {
250250
log_then_return!(ExecutionCanceledByHost());
251251
}
252252
Ok(HyperlightExit::Unknown(reason)) => {
253-
#[cfg(feature = "dump_on_crash")]
254-
dump_on_crash::dump_on_crash_to_tempfile(hv)?;
253+
#[cfg(crashdump)]
254+
crashdump::crashdump_to_tempfile(hv)?;
255255

256256
log_then_return!("Unexpected VM Exit {:?}", reason);
257257
}
258258
Ok(HyperlightExit::Retry()) => continue,
259259
Err(e) => {
260-
#[cfg(feature = "dump_on_crash")]
261-
dump_on_crash::dump_on_crash_to_tempfile(hv)?;
260+
#[cfg(crashdump)]
261+
crashdump::crashdump_to_tempfile(hv)?;
262262

263263
return Err(e);
264264
}

0 commit comments

Comments
 (0)