diff --git a/src/util/dwarf.rs b/src/util/dwarf.rs index 12435a0..e96123c 100644 --- a/src/util/dwarf.rs +++ b/src/util/dwarf.rs @@ -740,6 +740,7 @@ pub struct StructureType { pub byte_size: Option, pub members: Vec, pub bases: Vec, + pub inner_types: Vec, } #[derive(Debug, Clone, Copy, PartialEq, Eq)] @@ -1687,6 +1688,9 @@ pub fn struct_def_string( if let Some(byte_size) = t.byte_size { writeln!(out, " // total size: {byte_size:#X}")?; } + for inner_type in &t.inner_types { + writeln!(out, "{};", &indent_all_by(4, &ud_type_def(info, typedefs, inner_type, false)?))?; + } let mut vis = match t.kind { StructureKind::Struct => Visibility::Public, StructureKind::Class => Visibility::Private, @@ -1999,6 +2003,7 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result { let mut members = Vec::new(); let mut bases = Vec::new(); + let mut inner_types = Vec::new(); for child in tag.children(&info.tags) { match child.kind { TagKind::Inheritance => bases.push(process_inheritance_tag(info, child)?), @@ -2013,13 +2018,15 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result { TagKind::GlobalVariable => { // TODO } - TagKind::StructureType - | TagKind::ArrayType - | TagKind::EnumerationType - | TagKind::UnionType - | TagKind::ClassType - | TagKind::SubroutineType - | TagKind::PtrToMemberType => { + TagKind::StructureType | TagKind::ClassType => { + inner_types.push(UserDefinedType::Structure(process_structure_tag(info, child)?)) + } + TagKind::EnumerationType => inner_types + .push(UserDefinedType::Enumeration(process_enumeration_tag(info, child)?)), + TagKind::UnionType => { + inner_types.push(UserDefinedType::Union(process_union_tag(info, child)?)) + } + TagKind::ArrayType | TagKind::SubroutineType | TagKind::PtrToMemberType => { // Variable type, ignore } kind => bail!("Unhandled StructureType child {:?}", kind), @@ -2036,6 +2043,7 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result { byte_size, members, bases, + inner_types, }) }