mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-27 00:50:43 +00:00
bx-cli: print clwb VEH traps : 0 when no CLWB records exist
Signed-off-by: ates <ahmetrizaates@hotmail.com>
This commit is contained in:
1 parent
a8c4dbb77e
commit
829a94fa2f
1 file changed
+24
-5
@@ -153,6 +153,16 @@ fn cmd_probe(path: &str) -> ExitCode {
|
||||
ExitCode::SUCCESS
|
||||
}
|
||||
|
||||
fn format_clwb_line(clwb_events: usize, clwb_trap_lower_bound: Option<u64>) -> String {
|
||||
if let Some(lower_bound) = clwb_trap_lower_bound {
|
||||
format!("clwb VEH traps : at least {lower_bound} (sampled)")
|
||||
} else if clwb_events == 0 {
|
||||
"clwb VEH traps : 0".to_string()
|
||||
} else {
|
||||
format!("clwb VEH samples : {clwb_events}")
|
||||
}
|
||||
}
|
||||
|
||||
fn cmd_trace(path: &str) -> ExitCode {
|
||||
let text = match fs::read_to_string(path) {
|
||||
Ok(s) => s,
|
||||
@@ -163,11 +173,10 @@ fn cmd_trace(path: &str) -> ExitCode {
|
||||
};
|
||||
let summary = summarize_jsonl(&text);
|
||||
println!("Trace events : {}", summary.total_lines);
|
||||
if let Some(lower_bound) = summary.clwb_trap_lower_bound {
|
||||
println!("clwb VEH traps : at least {lower_bound} (sampled)");
|
||||
} else {
|
||||
println!("clwb VEH samples : {}", summary.clwb_events);
|
||||
}
|
||||
println!(
|
||||
"{}",
|
||||
format_clwb_line(summary.clwb_events, summary.clwb_trap_lower_bound)
|
||||
);
|
||||
println!("ADX illegal ops : {}", summary.adx_errors);
|
||||
if !summary.unhandled_exceptions.is_empty() {
|
||||
println!(
|
||||
@@ -433,4 +442,14 @@ mod tests {
|
||||
"Z:\\tmp\\bx-test.jsonl"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn formats_clwb_summary_lines() {
|
||||
assert_eq!(format_clwb_line(0, None), "clwb VEH traps : 0");
|
||||
assert_eq!(format_clwb_line(2, None), "clwb VEH samples : 2");
|
||||
assert_eq!(
|
||||
format_clwb_line(3, Some(4)),
|
||||
"clwb VEH traps : at least 4 (sampled)"
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user