From ebef0e0202e9d58907963d632549c2ca9bfa8ea5 Mon Sep 17 00:00:00 2001 From: Josh Ferrell Date: Fri, 5 Jul 2024 15:13:23 -0400 Subject: Misc small dwarf perf improvements --- rust/examples/dwarf/dwarf_import/src/functions.rs | 59 ++++++++++++----------- 1 file changed, 31 insertions(+), 28 deletions(-) (limited to 'rust/examples/dwarf/dwarf_import/src/functions.rs') diff --git a/rust/examples/dwarf/dwarf_import/src/functions.rs b/rust/examples/dwarf/dwarf_import/src/functions.rs index fa1755fa..f418a47f 100644 --- a/rust/examples/dwarf/dwarf_import/src/functions.rs +++ b/rust/examples/dwarf/dwarf_import/src/functions.rs @@ -30,41 +30,44 @@ fn get_parameters>( debug_info_builder: &mut DebugInfoBuilder, ) -> (Vec>, bool) { if !entry.has_children() { - (vec![], false) - } else { - // We make a new tree from the current entry to iterate over its children - let mut sub_die_tree = unit.entries_tree(Some(entry.offset())).unwrap(); - let root = sub_die_tree.root().unwrap(); + return (vec![], false); + } + + // We make a new tree from the current entry to iterate over its children + let mut sub_die_tree = unit.entries_tree(Some(entry.offset())).unwrap(); + let root = sub_die_tree.root().unwrap(); + + let mut variable_arguments = false; + let mut result = vec![]; + let mut children = root.children(); + while let Some(child) = children.next().unwrap() { + match child.entry().tag() { + constants::DW_TAG_formal_parameter => { + //TODO: if the param type is a typedef to an anonymous struct (typedef struct {...} foo) then this is reoslved to an anonymous struct instead of foo + // We should still recurse to make sure we load all types this param type depends on, but + let name = debug_info_builder_context.get_name(unit, child.entry()); - let mut variable_arguments = false; - let mut result = vec![]; - let mut children = root.children(); - while let Some(child) = children.next().unwrap() { - match child.entry().tag() { - constants::DW_TAG_formal_parameter => { - let name = debug_info_builder_context.get_name(unit, child.entry()); - let type_ = get_type( - unit, - child.entry(), - debug_info_builder_context, - debug_info_builder, - ); - if let Some(parameter_name) = name { - if let Some(parameter_type) = type_ { - result.push(Some((parameter_name, parameter_type))); - } else { - result.push(Some((parameter_name, 0))) - } + let type_ = get_type( + unit, + child.entry(), + debug_info_builder_context, + debug_info_builder, + ); + if let Some(parameter_name) = name { + if let Some(parameter_type) = type_ { + result.push(Some((parameter_name, parameter_type))); } else { - result.push(None) + result.push(Some((parameter_name, 0))) } + } else { + result.push(None) } - constants::DW_TAG_unspecified_parameters => variable_arguments = true, - _ => (), } + constants::DW_TAG_unspecified_parameters => variable_arguments = true, + _ => (), } - (result, variable_arguments) } + (result, variable_arguments) } pub(crate) fn parse_function_entry>( -- cgit v1.3.1