Skip to content

Commit 3c5e38d

Browse files
committed
[trace-guest] remove unwind_guest feature
- This feature is not used separate from the mem_profile - All the unwind logic is now gated by mem_profile Signed-off-by: Doru Blânzeanu <dblnz@pm.me>
1 parent 34b8fd6 commit 3c5e38d

File tree

16 files changed

+48
-56
lines changed

16 files changed

+48
-56
lines changed

Justfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ check:
234234
{{ cargo-cmd }} check -p hyperlight-host --features crashdump {{ target-triple-flag }}
235235
{{ cargo-cmd }} check -p hyperlight-host --features print_debug {{ target-triple-flag }}
236236
{{ cargo-cmd }} check -p hyperlight-host --features gdb {{ target-triple-flag }}
237-
{{ cargo-cmd }} check -p hyperlight-host --features trace_guest,unwind_guest,mem_profile {{ target-triple-flag }}
237+
{{ cargo-cmd }} check -p hyperlight-host --features trace_guest,mem_profile {{ target-triple-flag }}
238238

239239
fmt-check:
240240
cargo +nightly fmt --all -- --check

docs/hyperlight-metrics-logs-and-traces.md

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,12 +94,11 @@ Once the container or the exe is running, the trace output can be viewed in the
9494

9595
## Guest Tracing, Unwinding, and Memory Profiling
9696

97-
Hyperlight provides advanced observability features for guest code running inside micro virtual machines. You can enable guest-side tracing, stack unwinding, and memory profiling using the `trace_guest`, `unwind_guest`, and `mem_profile` features. This section explains how to build, run, and inspect guest traces.
97+
Hyperlight provides advanced observability features for guest code running inside micro virtual machines. You can enable guest-side tracing, stack unwinding, and memory profiling using the `trace_guest` and `mem_profile` features. This section explains how to build, run, and inspect guest traces.
9898

9999
The following features are available for guest tracing:
100100
- `trace_guest`: Enables tracing for guest code, capturing function calls and execution time.
101-
- `unwind_guest`: Enables stack unwinding for guest code, allowing you to capture stack traces.
102-
- `mem_profile`: Enables memory profiling for guest code, capturing memory allocations and usage.
101+
- `mem_profile`: Enables memory profiling for guest code with stack uwinding, capturing memory allocations and usage.
103102

104103
### Building a Guest with Tracing Support
105104

@@ -140,7 +139,7 @@ This command will list the stack frames and tracing information captured during
140139
cargo run -p trace_dump ./src/tests/rust_guests/bin/debug/simpleguest ./trace/<UUID>.trace list_frames
141140
```
142141

143-
You can use additional features such as `unwind_guest` and `mem_profile` by enabling them during the build and run steps.
142+
You can use the `mem_profile` additional feature by enabling them during the build and run steps.
144143

145144
> **Note:** Make sure to follow the build and run steps in order, and ensure that the guest binaries are up to date before running the host example.
146145

src/hyperlight_common/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ spin = "0.10.0"
2626
default = ["tracing"]
2727
fuzzing = ["dep:arbitrary"]
2828
trace_guest = []
29-
unwind_guest = []
3029
mem_profile = []
3130
std = []
3231

src/hyperlight_common/src/outb.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub enum OutBAction {
9999
CallFunction = 101,
100100
Abort = 102,
101101
DebugPrint = 103,
102-
#[cfg(feature = "unwind_guest")]
102+
#[cfg(feature = "mem_profile")]
103103
TraceRecordStack = 104,
104104
#[cfg(feature = "mem_profile")]
105105
TraceMemoryAlloc = 105,
@@ -117,7 +117,7 @@ impl TryFrom<u16> for OutBAction {
117117
101 => Ok(OutBAction::CallFunction),
118118
102 => Ok(OutBAction::Abort),
119119
103 => Ok(OutBAction::DebugPrint),
120-
#[cfg(feature = "unwind_guest")]
120+
#[cfg(feature = "mem_profile")]
121121
104 => Ok(OutBAction::TraceRecordStack),
122122
#[cfg(feature = "mem_profile")]
123123
105 => Ok(OutBAction::TraceMemoryAlloc),

src/hyperlight_guest_bin/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ default = ["libc", "printf"]
1818
libc = [] # compile musl libc
1919
printf = [ "libc" ] # compile printf
2020
trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest/trace_guest", "hyperlight-guest-tracing/trace"]
21-
mem_profile = ["hyperlight-common/unwind_guest","hyperlight-common/mem_profile"]
21+
mem_profile = ["hyperlight-common/mem_profile"]
2222

2323
[dependencies]
2424
hyperlight-guest = { workspace = true, default-features = false }

src/hyperlight_host/Cargo.toml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,10 +133,7 @@ print_debug = []
133133
# Dumps the VM state to a file on unexpected errors or crashes. The path of the file will be printed on stdout and logged.
134134
crashdump = ["dep:chrono"]
135135
trace_guest = ["hyperlight-common/trace_guest", "hyperlight-guest-tracing/trace"]
136-
# This feature enables unwinding the guest stack from the host, in
137-
# order to produce stack traces for debugging or profiling.
138-
unwind_guest = [ "trace_guest", "dep:framehop", "dep:fallible-iterator", "hyperlight-common/unwind_guest" ]
139-
mem_profile = [ "unwind_guest", "hyperlight-common/mem_profile" ]
136+
mem_profile = [ "trace_guest", "dep:framehop", "dep:fallible-iterator", "hyperlight-common/mem_profile" ]
140137
kvm = ["dep:kvm-bindings", "dep:kvm-ioctls"]
141138
# This feature is deprecated in favor of mshv3
142139
mshv2 = ["dep:mshv-bindings2", "dep:mshv-ioctls2"]

src/hyperlight_host/src/hypervisor/hyperv_linux.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1121,7 +1121,7 @@ impl Drop for HypervLinuxDriver {
11211121
#[cfg(test)]
11221122
mod tests {
11231123
use super::*;
1124-
#[cfg(feature = "unwind_guest")]
1124+
#[cfg(feature = "mem_profile")]
11251125
use crate::mem::exe::DummyUnwindInfo;
11261126
use crate::mem::memory_region::MemoryRegionVecBuilder;
11271127
use crate::mem::shared_mem::{ExclusiveSharedMemory, SharedMemory};
@@ -1192,7 +1192,7 @@ mod tests {
11921192
},
11931193
#[cfg(feature = "trace_guest")]
11941194
TraceInfo::new(
1195-
#[cfg(feature = "unwind_guest")]
1195+
#[cfg(feature = "mem_profile")]
11961196
Arc::new(DummyUnwindInfo {}),
11971197
)
11981198
.unwrap(),

src/hyperlight_host/src/mem/elf.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ See the License for the specific language governing permissions and
1414
limitations under the License.
1515
*/
1616

17-
#[cfg(feature = "unwind_guest")]
17+
#[cfg(feature = "mem_profile")]
1818
use std::sync::Arc;
1919

2020
#[cfg(target_arch = "aarch64")]
@@ -29,7 +29,7 @@ use goblin::elf64::program_header::PT_LOAD;
2929

3030
use crate::{Result, log_then_return, new_error};
3131

32-
#[cfg(feature = "unwind_guest")]
32+
#[cfg(feature = "mem_profile")]
3333
struct ResolvedSectionHeader {
3434
name: String,
3535
addr: u64,
@@ -40,13 +40,13 @@ struct ResolvedSectionHeader {
4040
pub(crate) struct ElfInfo {
4141
payload: Vec<u8>,
4242
phdrs: ProgramHeaders,
43-
#[cfg(feature = "unwind_guest")]
43+
#[cfg(feature = "mem_profile")]
4444
shdrs: Vec<ResolvedSectionHeader>,
4545
entry: u64,
4646
relocs: Vec<Reloc>,
4747
}
4848

49-
#[cfg(feature = "unwind_guest")]
49+
#[cfg(feature = "mem_profile")]
5050
struct UnwindInfo {
5151
payload: Vec<u8>,
5252
load_addr: u64,
@@ -55,7 +55,7 @@ struct UnwindInfo {
5555
shdrs: Vec<ResolvedSectionHeader>,
5656
}
5757

58-
#[cfg(feature = "unwind_guest")]
58+
#[cfg(feature = "mem_profile")]
5959
impl super::exe::UnwindInfo for UnwindInfo {
6060
fn as_module(&self) -> framehop::Module<Vec<u8>> {
6161
framehop::Module::new(
@@ -72,7 +72,7 @@ impl super::exe::UnwindInfo for UnwindInfo {
7272
}
7373
}
7474

75-
#[cfg(feature = "unwind_guest")]
75+
#[cfg(feature = "mem_profile")]
7676
impl UnwindInfo {
7777
fn resolved_section_header(&self, name: &[u8]) -> Option<&ResolvedSectionHeader> {
7878
self.shdrs
@@ -81,7 +81,7 @@ impl UnwindInfo {
8181
}
8282
}
8383

84-
#[cfg(feature = "unwind_guest")]
84+
#[cfg(feature = "mem_profile")]
8585
impl framehop::ModuleSectionInfo<Vec<u8>> for &UnwindInfo {
8686
fn base_svma(&self) -> u64 {
8787
self.base_svma
@@ -122,7 +122,7 @@ impl ElfInfo {
122122
Ok(ElfInfo {
123123
payload: bytes.to_vec(),
124124
phdrs: elf.program_headers,
125-
#[cfg(feature = "unwind_guest")]
125+
#[cfg(feature = "mem_profile")]
126126
shdrs: elf
127127
.section_headers
128128
.iter()
@@ -206,7 +206,7 @@ impl ElfInfo {
206206
}
207207
}
208208
cfg_if::cfg_if! {
209-
if #[cfg(feature = "unwind_guest")] {
209+
if #[cfg(feature = "mem_profile")] {
210210
let va_size = self.get_va_size() as u64;
211211
let base_svma = self.get_base_va();
212212
Ok(Arc::new(UnwindInfo {

src/hyperlight_host/src/mem/exe.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ limitations under the License.
1616

1717
use std::fs::File;
1818
use std::io::Read;
19-
#[cfg(feature = "unwind_guest")]
19+
#[cfg(feature = "mem_profile")]
2020
use std::sync::Arc;
2121
use std::vec::Vec;
2222

@@ -39,15 +39,15 @@ pub enum ExeInfo {
3939
const DEFAULT_ELF_STACK_RESERVE: u64 = 65536;
4040
const DEFAULT_ELF_HEAP_RESERVE: u64 = 131072;
4141

42-
#[cfg(feature = "unwind_guest")]
42+
#[cfg(feature = "mem_profile")]
4343
pub(crate) trait UnwindInfo: Send + Sync {
4444
fn as_module(&self) -> framehop::Module<Vec<u8>>;
4545
fn hash(&self) -> blake3::Hash;
4646
}
4747

48-
#[cfg(feature = "unwind_guest")]
48+
#[cfg(feature = "mem_profile")]
4949
pub(crate) struct DummyUnwindInfo {}
50-
#[cfg(feature = "unwind_guest")]
50+
#[cfg(feature = "mem_profile")]
5151
impl UnwindInfo for DummyUnwindInfo {
5252
fn as_module(&self) -> framehop::Module<Vec<u8>> {
5353
framehop::Module::new("unsupported".to_string(), 0..0, 0, self)
@@ -56,7 +56,7 @@ impl UnwindInfo for DummyUnwindInfo {
5656
blake3::Hash::from_bytes([0; 32])
5757
}
5858
}
59-
#[cfg(feature = "unwind_guest")]
59+
#[cfg(feature = "mem_profile")]
6060
impl<A> framehop::ModuleSectionInfo<A> for &DummyUnwindInfo {
6161
fn base_svma(&self) -> u64 {
6262
0
@@ -69,9 +69,9 @@ impl<A> framehop::ModuleSectionInfo<A> for &DummyUnwindInfo {
6969
}
7070
}
7171

72-
#[cfg(feature = "unwind_guest")]
72+
#[cfg(feature = "mem_profile")]
7373
pub(crate) type LoadInfo = Arc<dyn UnwindInfo>;
74-
#[cfg(not(feature = "unwind_guest"))]
74+
#[cfg(not(feature = "mem_profile"))]
7575
pub(crate) type LoadInfo = ();
7676

7777
impl ExeInfo {

src/hyperlight_host/src/mem/mgr.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ impl SandboxMemoryManager<ExclusiveSharedMemory> {
347347
}
348348

349349
// The load method returns a LoadInfo which can also be a different type once the
350-
// `unwind_guest` feature is enabled.
350+
// `mem_profile` feature is enabled.
351351
#[allow(clippy::let_unit_value)]
352352
let load_info = exe_info.load(
353353
load_addr.clone().try_into()?,

0 commit comments

Comments
 (0)