From d1d2316ebbae1992197206ab3c3db1c9f5b16129 Mon Sep 17 00:00:00 2001 From: dbalatoni13 <40299962+dbalatoni13@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:16:04 +0200 Subject: [PATCH 1/2] Add support for structure types and enums being nested in structure types --- src/util/dwarf.rs | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/util/dwarf.rs b/src/util/dwarf.rs index 12435a0..5250644 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,11 +2018,10 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result { TagKind::GlobalVariable => { // TODO } - TagKind::StructureType - | TagKind::ArrayType - | TagKind::EnumerationType - | TagKind::UnionType - | TagKind::ClassType + 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 @@ -2036,6 +2040,7 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result { byte_size, members, bases, + inner_types, }) } From 598140233fd1f1652744ac1723ba174925965d94 Mon Sep 17 00:00:00 2001 From: dbalatoni13 <40299962+dbalatoni13@users.noreply.github.com> Date: Mon, 29 Sep 2025 17:22:01 +0200 Subject: [PATCH 2/2] Fix formatting --- src/util/dwarf.rs | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/util/dwarf.rs b/src/util/dwarf.rs index 5250644..e96123c 100644 --- a/src/util/dwarf.rs +++ b/src/util/dwarf.rs @@ -2018,12 +2018,15 @@ fn process_structure_tag(info: &DwarfInfo, tag: &Tag) -> Result { TagKind::GlobalVariable => { // TODO } - 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 => { + 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),