From 4585954404982498919160349545491853828464 Mon Sep 17 00:00:00 2001 From: Glenn Smith Date: Mon, 29 Apr 2024 19:15:33 -0400 Subject: PDB: Prefer private symbols to public --- rust/examples/pdb-ng/src/symbol_parser.rs | 60 ++++++++++++++++++++++++------- 1 file changed, 48 insertions(+), 12 deletions(-) (limited to 'rust/examples') diff --git a/rust/examples/pdb-ng/src/symbol_parser.rs b/rust/examples/pdb-ng/src/symbol_parser.rs index 7193da7d..5a1d8761 100644 --- a/rust/examples/pdb-ng/src/symbol_parser.rs +++ b/rust/examples/pdb-ng/src/symbol_parser.rs @@ -330,12 +330,30 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { .into_iter() .map(|(_, sym)| sym.clone()) .sorted_by_key(|sym| match sym { - ParsedSymbol::Data(ParsedDataSymbol { type_, .. }) => { - type_.as_ref().map(|ty| ty.confidence).unwrap_or(0) - } - ParsedSymbol::Procedure(ParsedProcedure { type_, .. }) => { - type_.as_ref().map(|ty| ty.confidence).unwrap_or(0) - } + ParsedSymbol::Data(ParsedDataSymbol { + type_, is_public, .. + }) => type_ + .as_ref() + .map(|ty| { + if *is_public { + ty.confidence / 2 + } else { + ty.confidence + } + }) + .unwrap_or(0), + ParsedSymbol::Procedure(ParsedProcedure { + type_, is_public, .. + }) => type_ + .as_ref() + .map(|ty| { + if *is_public { + ty.confidence / 2 + } else { + ty.confidence + } + }) + .unwrap_or(0), _ => 0, }) .collect::>(), @@ -343,12 +361,30 @@ impl<'a, S: Source<'a> + 'a> PDBParserInstance<'a, S> { .into_iter() .map(|(_, func)| func.clone()) .sorted_by_key(|sym| match sym { - ParsedSymbol::Data(ParsedDataSymbol { type_, .. }) => { - type_.as_ref().map(|ty| ty.confidence).unwrap_or(0) - } - ParsedSymbol::Procedure(ParsedProcedure { type_, .. }) => { - type_.as_ref().map(|ty| ty.confidence).unwrap_or(0) - } + ParsedSymbol::Data(ParsedDataSymbol { + type_, is_public, .. + }) => type_ + .as_ref() + .map(|ty| { + if *is_public { + ty.confidence / 2 + } else { + ty.confidence + } + }) + .unwrap_or(0), + ParsedSymbol::Procedure(ParsedProcedure { + type_, is_public, .. + }) => type_ + .as_ref() + .map(|ty| { + if *is_public { + ty.confidence / 2 + } else { + ty.confidence + } + }) + .unwrap_or(0), _ => 0, }) .collect::>(), -- cgit v1.3.1