From 3cf3924281802ce606757e4a707534bad6b1ccbb Mon Sep 17 00:00:00 2001 From: KyleMiles Date: Tue, 25 Jul 2023 20:01:15 -0400 Subject: DWARF Import : Allow for duplicate type definitions; log_error when overwriting one type with another; add progress tracking; resolves #4514 --- .../dwarf/dwarf_import/src/dwarfdebuginfo.rs | 25 ++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) (limited to 'rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs') diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs index 2403c879..f82174aa 100644 --- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs +++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs @@ -146,10 +146,27 @@ impl DebugInfoBuilder { } pub fn add_type(&mut self, type_uid: TypeUID, name: CString, t: Ref, commit: bool) { - assert!(self - .types - .insert(type_uid, DebugType { name, t, commit }) - .is_none()); + if let Some(DebugType { + name: existing_name, + t: existing_type, + commit: _, + }) = self.types.insert( + type_uid, + DebugType { + name: name.clone(), + t: t.clone(), + commit, + }, + ) { + if existing_type != t { + error!("DWARF info contains duplicate type definition. Overwriting type `{}` (named `{:?}`) with `{}` (named `{:?}`)", + existing_type, + existing_name, + t, + name + ); + } + } } // TODO : Non-copy? -- cgit v1.3.1