Skip to content

Commit

Permalink
Do not output anything for empty callstacks
Browse files Browse the repository at this point in the history
This crashed inferno in debug mode when it parsed the output because of an underflow (On let last = self.stack.len() - 1;)
  • Loading branch information
nico-abram committed May 2, 2024
1 parent daacd76 commit b139ec4
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -799,6 +799,7 @@ impl CollectionResults {
let mut v = vec![];

for callstack in self.iter_callstacks() {
let mut empty_callstack = true;
callstack.iter_resolved_addresses(
&pdb_db,
&mut v,
Expand All @@ -809,8 +810,10 @@ impl CollectionResults {
return Ok(());
}
}
let mut printed = false;
for symbol_name in symbol_names {
if let Some(image_name) = image_name {
printed = true;
if displacement != 0 {
writeln!(w, "\t\t{image_name}`{symbol_name}+0x{displacement:X}")?;
} else {
Expand All @@ -819,22 +822,29 @@ impl CollectionResults {
} else {
// Image name not found
if displacement != 0 {
printed = true;
writeln!(w, "\t\t{symbol_name}+0x{displacement:X}")?;
} else {
writeln!(w, "\t\t{symbol_name}")?;
if !symbol_name.is_empty() {
printed = true;
writeln!(w, "\t\t{symbol_name}")?;
}
}
}
}
if symbol_names.is_empty() {
if symbol_names.is_empty() || !printed {
// Symbol not found
writeln!(w, "\t\t`0x{address:X}")?;
}
empty_callstack = false;
Ok(())
},
)?;
//}
let count = callstack.sample_count;
write!(w, "\t\t{count}\n\n")?;

if !empty_callstack {
let count = callstack.sample_count;
write!(w, "\t\t{count}\n\n")?;
}
}
Ok(())
}
Expand Down

0 comments on commit b139ec4

Please sign in to comment.