diff options
| author | Josh Ferrell <josh@vector35.com> | 2025-10-20 12:01:27 -0400 |
|---|---|---|
| committer | Josh Ferrell <josh@vector35.com> | 2025-10-20 12:02:53 -0400 |
| commit | 98f9bae4c7d2dc636ab0a7fe61741e7f9fccba70 (patch) | |
| tree | 5b573fcde21abae852ea913980a3bb15d0fedec8 /plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs | |
| parent | 432984039635733d2a5bf7b561e17014a6b93084 (diff) | |
[DWARF] Greatly improve handling of typedefs
Diffstat (limited to 'plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs')
| -rw-r--r-- | plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs | 35 |
1 files changed, 33 insertions, 2 deletions
diff --git a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 94f370a1..eda641ca 100644 --- a/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/plugins/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -107,6 +107,7 @@ pub(crate) struct DebugType { pub name: String, pub ty: Ref<Type>, pub commit: bool, + pub target_type_uid: Option<TypeUID>, } impl DebugType { @@ -363,17 +364,26 @@ impl DebugInfoBuilder { self.types.values() } - pub(crate) fn add_type(&mut self, type_uid: TypeUID, name: String, t: Ref<Type>, commit: bool) { + pub(crate) fn add_type( + &mut self, + type_uid: TypeUID, + name: String, + t: Ref<Type>, + commit: bool, + target_type_uid: Option<TypeUID>, + ) { if let Some(DebugType { name: existing_name, ty: existing_type, commit: _, + target_type_uid: _, }) = self.types.insert( type_uid, DebugType { name: name.clone(), ty: t.clone(), commit, + target_type_uid, }, ) { if existing_type != t && commit { @@ -608,7 +618,28 @@ impl DebugInfoBuilder { }; // TODO : Components - debug_info.add_type(&debug_type_name, &debug_type.ty, &[]); + // If it's a typedef resolve one layer down since we'd technically be defining it as a typedef to itself otherwise + if let Some(ntr) = debug_type.get_type().get_named_type_reference() { + if let Some(target_uid) = debug_type.target_type_uid { + if let Some(target_type) = self.get_type(target_uid) { + debug_info.add_type(&debug_type_name, &target_type.get_type(), &[]); + } else { + error!( + "Failed to find typedef {} target for uid {}", + debug_type_name, + ntr.name() + ); + } + } else { + error!( + "Failed to find typedef {} target uid for {}", + debug_type_name, + ntr.name() + ); + } + } else { + debug_info.add_type(&debug_type_name, &debug_type.ty, &[]); + } type_uids_by_name.insert(debug_type_name, *debug_type_uid); } } |
