Skip to content

Commit 7f464bc

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

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
@@ -10,9 +10,18 @@ use super::Hypervisor;
1010
use crate::mem::memory_region::{MemoryRegion, MemoryRegionFlags};
1111
use crate::{new_error, Result};
1212

13+
/// This constant is used to identify the XSAVE state in the core dump
1314
const NT_X86_XSTATE: u32 = 0x202;
15+
/// This constant identifies the entry point of the program in an Auxiliary Vector
16+
/// note of ELF. This tells a debugger whether the entry point of the program changed
17+
/// so it can load the symbols correctly.
1418
const AT_ENTRY: u64 = 9;
19+
/// This constant is used to mark the end of the Auxiliary Vector note
1520
const AT_NULL: u64 = 0;
21+
/// The PID of the core dump process - this is a placeholder value
22+
const CORE_DUMP_PID: i32 = 1;
23+
/// The page size of the core dump
24+
const CORE_DUMP_PAGE_SIZE: usize = 0x1000;
1625

1726
/// Structure to hold the crash dump context
1827
/// This structure contains the information needed to create a core dump
@@ -136,13 +145,13 @@ impl GuestView {
136145

137146
impl ProcessInfoSource for GuestView {
138147
fn pid(&self) -> i32 {
139-
1
148+
CORE_DUMP_PID
140149
}
141150
fn threads(&self) -> &[elfcore::ThreadView] {
142151
&self.threads
143152
}
144153
fn page_size(&self) -> usize {
145-
0x1000
154+
CORE_DUMP_PAGE_SIZE
146155
}
147156
fn aux_vector(&self) -> Option<&[elfcore::Elf64_Auxv]> {
148157
Some(&self.aux_vector)
@@ -151,6 +160,7 @@ impl ProcessInfoSource for GuestView {
151160
&self.regions
152161
}
153162
fn mapped_files(&self) -> Option<&[elfcore::MappedFile]> {
163+
// We don't have mapped files
154164
None
155165
}
156166
}

0 commit comments

Comments
 (0)