From c0c145ff7286d99edbd4b367bca4e228cae1a3ac Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Wed, 23 Aug 2023 12:53:23 -0400 Subject: DWARF Import : More optimizations --- rust/examples/dwarf/dwarf_import/src/lib.rs | 47 +++++++++++++---------------- 1 file changed, 21 insertions(+), 26 deletions(-) (limited to 'rust/examples/dwarf/dwarf_import/src/lib.rs') diff --git a/rust/examples/dwarf/dwarf_import/src/lib.rs b/rust/examples/dwarf/dwarf_import/src/lib.rs index cc87e1c6..6ec2e5ad 100644 --- a/rust/examples/dwarf/dwarf_import/src/lib.rs +++ b/rust/examples/dwarf/dwarf_import/src/lib.rs @@ -111,34 +111,22 @@ fn recover_names>( resolve_namespace_name(dwarf, &unit, entry, &mut namespace_qualifiers, depth); } - constants::DW_TAG_class_type => { + constants::DW_TAG_class_type + | constants::DW_TAG_structure_type + | constants::DW_TAG_union_type => { if let Some(name) = get_name(dwarf, &unit, entry) { namespace_qualifiers.push((depth, name)) } else { - namespace_qualifiers.push((depth, CString::new("anonymous_class").unwrap())) - } - - debug_info_builder.set_name( - get_uid(&unit, entry), - CString::new( - simplify_str_to_str( - namespace_qualifiers - .iter() - .map(|(_, namespace)| namespace.to_string_lossy().to_string()) - .collect::>() - .join("::"), - ) - .as_str(), - ) - .unwrap(), - ); - } - constants::DW_TAG_structure_type => { - if let Some(name) = get_name(dwarf, &unit, entry) { - namespace_qualifiers.push((depth, name)) - } else { - namespace_qualifiers - .push((depth, CString::new("anonymous_structure").unwrap())) + namespace_qualifiers.push(( + depth, + CString::new(match entry.tag() { + constants::DW_TAG_class_type => "anonymous_class", + constants::DW_TAG_structure_type => "anonymous_structure", + constants::DW_TAG_union_type => "anonymous_union", + _ => unreachable!(), + }) + .unwrap(), + )) } debug_info_builder.set_name( get_uid(&unit, entry), @@ -155,7 +143,9 @@ fn recover_names>( .unwrap(), ); } - _ => { + constants::DW_TAG_typedef + | constants::DW_TAG_subprogram + | constants::DW_TAG_enumeration_type => { if let Some(name) = get_name(dwarf, &unit, entry) { debug_info_builder.set_name( get_uid(&unit, entry), @@ -176,6 +166,11 @@ fn recover_names>( ); } } + _ => { + if let Some(name) = get_name(dwarf, &unit, entry) { + debug_info_builder.set_name(get_uid(&unit, entry), name); + } + } } } } -- cgit v1.3.1