Skip to content

Commit 920efeb

Browse files
committed
fixup: add constants instead of hardcoded values and add more comments
Signed-off-by: Doru Blânzeanu <[email protected]>
1 parent ac2d0c1 commit 920efeb

File tree

1 file changed

+12
-2
lines changed

1 file changed

+12
-2
lines changed

src/hyperlight_host/src/hypervisor/crashdump.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,18 @@ use super::Hypervisor;
2626
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
2727
use crate::{new_error, Result};
2828

29+
/// This constant is used to identify the XSAVE state in the core dump
2930
const NT_X86_XSTATE: u32 = 0x202;
31+
/// This constant identifies the entry point of the program in an Auxiliary Vector
32+
/// note of ELF. This tells a debugger whether the entry point of the program changed
33+
/// so it can load the symbols correctly.
3034
const AT_ENTRY: u64 = 9;
35+
/// This constant is used to mark the end of the Auxiliary Vector note
3136
const AT_NULL: u64 = 0;
37+
/// The PID of the core dump process - this is a placeholder value
38+
const CORE_DUMP_PID: i32 = 1;
39+
/// The page size of the core dump
40+
const CORE_DUMP_PAGE_SIZE: usize = 0x1000;
3241

3342
/// Structure to hold the crash dump context
3443
/// This structure contains the information needed to create a core dump
@@ -152,13 +161,13 @@ impl GuestView {
152161

153162
impl ProcessInfoSource for GuestView {
154163
fn pid(&self) -> i32 {
155-
1
164+
CORE_DUMP_PID
156165
}
157166
fn threads(&self) -> &[elfcore::ThreadView] {
158167
&self.threads
159168
}
160169
fn page_size(&self) -> usize {
161-
0x1000
170+
CORE_DUMP_PAGE_SIZE
162171
}
163172
fn aux_vector(&self) -> Option<&[elfcore::Elf64_Auxv]> {
164173
Some(&self.aux_vector)
@@ -167,6 +176,7 @@ impl ProcessInfoSource for GuestView {
167176
&self.regions
168177
}
169178
fn mapped_files(&self) -> Option<&[elfcore::MappedFile]> {
179+
// We don't have mapped files
170180
None
171181
}
172182
}

0 commit comments

Comments
 (0)