summaryrefslogtreecommitdiff
path: root/rust/examples/dwarf/dwarf_import/src/lib.rs
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2023-08-23 12:53:23 -0400
committerKyleMiles <krm504@nyu.edu>2023-08-25 11:18:38 -0400
commitc0c145ff7286d99edbd4b367bca4e228cae1a3ac (patch)
tree5268b4c86520eb24bc4e0bae732df2173fc7f7b7 /rust/examples/dwarf/dwarf_import/src/lib.rs
parent7849cda3f9be3ba7da2abb0e7f4d9f201b43fa50 (diff)
DWARF Import : More optimizations
Diffstat (limited to 'rust/examples/dwarf/dwarf_import/src/lib.rs')
-rw-r--r--rust/examples/dwarf/dwarf_import/src/lib.rs47
1 files changed, 21 insertions, 26 deletions
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<R: Reader<Offset = usize>>(
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::<Vec<String>>()
- .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<R: Reader<Offset = usize>>(
.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<R: Reader<Offset = usize>>(
);
}
}
+ _ => {
+ if let Some(name) = get_name(dwarf, &unit, entry) {
+ debug_info_builder.set_name(get_uid(&unit, entry), name);
+ }
+ }
}
}
}