summaryrefslogtreecommitdiff
path: root/rust
diff options
context:
space:
mode:
authorKyleMiles <krm504@nyu.edu>2023-08-03 12:29:35 -0400
committerKyleMiles <krm504@nyu.edu>2023-08-22 09:59:46 -0400
commitb7a03b4d5e24485691ece768c1ea219312e9b9f8 (patch)
treea4a6a65acac017011094634599dae16d87a9a710 /rust
parentf6879fc771f24778f67c84cc45b33e4921614206 (diff)
Recover parameter names even when type parsing fails (this could be a bad idea)
Diffstat (limited to 'rust')
-rw-r--r--rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs18
-rw-r--r--rust/examples/dwarf/dwarf_import/src/functions.rs8
-rw-r--r--rust/examples/dwarf/dwarf_import/src/types.rs2
3 files changed, 16 insertions, 12 deletions
diff --git a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
index aa359232..fad45f98 100644
--- a/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
+++ b/rust/examples/dwarf/dwarf_import/src/dwarfdebuginfo.rs
@@ -252,16 +252,16 @@ impl DebugInfoBuilder {
let parameters: Vec<FunctionParameter<CString>> = function
.parameters
.iter()
- .filter_map(|parameter| {
- if let Some((name, uid)) = parameter {
- Some(FunctionParameter::new(
- self.get_type(*uid).unwrap().1,
- name.clone(),
- None,
- ))
- } else {
- None
+ .filter_map(|parameter| match parameter {
+ Some((name, 0)) => {
+ Some(FunctionParameter::new(Type::void(), name.clone(), None))
}
+ Some((name, uid)) => Some(FunctionParameter::new(
+ self.get_type(*uid).unwrap().1,
+ name.clone(),
+ None,
+ )),
+ _ => None,
})
.collect();
diff --git a/rust/examples/dwarf/dwarf_import/src/functions.rs b/rust/examples/dwarf/dwarf_import/src/functions.rs
index 20858917..069f4ba3 100644
--- a/rust/examples/dwarf/dwarf_import/src/functions.rs
+++ b/rust/examples/dwarf/dwarf_import/src/functions.rs
@@ -41,8 +41,12 @@ fn get_parameters<R: Reader<Offset = usize>>(
constants::DW_TAG_formal_parameter => {
let name = get_name(dwarf, unit, child.entry());
let type_ = get_type(dwarf, unit, child.entry(), debug_info_builder);
- if let (Some(parameter_name), Some(parameter_type)) = (name, type_) {
- result.push(Some((parameter_name, parameter_type)));
+ 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)))
+ }
} else {
result.push(None)
}
diff --git a/rust/examples/dwarf/dwarf_import/src/types.rs b/rust/examples/dwarf/dwarf_import/src/types.rs
index 61a856a8..1c7201dc 100644
--- a/rust/examples/dwarf/dwarf_import/src/types.rs
+++ b/rust/examples/dwarf/dwarf_import/src/types.rs
@@ -333,7 +333,7 @@ pub(crate) fn get_type<R: Reader<Offset = usize>>(
),
// Strange Types
- constants::DW_TAG_unspecified_type => (Some(Type::void()), false), // TODO : Maybe true here
+ constants::DW_TAG_unspecified_type => (Some(Type::void()), false),
constants::DW_TAG_subroutine_type => (
handle_function(dwarf, unit, entry, debug_info_builder, entry_type),
false,