Skip to content

Commit b139ec4

Browse files
committed
Do not output anything for empty callstacks
This crashed inferno in debug mode when it parsed the output because of an underflow (On let last = self.stack.len() - 1;)
1 parent daacd76 commit b139ec4

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

src/lib.rs

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -799,6 +799,7 @@ impl CollectionResults {
799799
let mut v = vec![];
800800

801801
for callstack in self.iter_callstacks() {
802+
let mut empty_callstack = true;
802803
callstack.iter_resolved_addresses(
803804
&pdb_db,
804805
&mut v,
@@ -809,8 +810,10 @@ impl CollectionResults {
809810
return Ok(());
810811
}
811812
}
813+
let mut printed = false;
812814
for symbol_name in symbol_names {
813815
if let Some(image_name) = image_name {
816+
printed = true;
814817
if displacement != 0 {
815818
writeln!(w, "\t\t{image_name}`{symbol_name}+0x{displacement:X}")?;
816819
} else {
@@ -819,22 +822,29 @@ impl CollectionResults {
819822
} else {
820823
// Image name not found
821824
if displacement != 0 {
825+
printed = true;
822826
writeln!(w, "\t\t{symbol_name}+0x{displacement:X}")?;
823827
} else {
824-
writeln!(w, "\t\t{symbol_name}")?;
828+
if !symbol_name.is_empty() {
829+
printed = true;
830+
writeln!(w, "\t\t{symbol_name}")?;
831+
}
825832
}
826833
}
827834
}
828-
if symbol_names.is_empty() {
835+
if symbol_names.is_empty() || !printed {
829836
// Symbol not found
830837
writeln!(w, "\t\t`0x{address:X}")?;
831838
}
839+
empty_callstack = false;
832840
Ok(())
833841
},
834842
)?;
835-
//}
836-
let count = callstack.sample_count;
837-
write!(w, "\t\t{count}\n\n")?;
843+
844+
if !empty_callstack {
845+
let count = callstack.sample_count;
846+
write!(w, "\t\t{count}\n\n")?;
847+
}
838848
}
839849
Ok(())
840850
}

0 commit comments

Comments
 (0)