diff --git a/crates/cranelift/src/debug/gc.rs b/crates/cranelift/src/debug/gc.rs index ec1b0558949f..c51bfa61775e 100644 --- a/crates/cranelift/src/debug/gc.rs +++ b/crates/cranelift/src/debug/gc.rs @@ -1,10 +1,9 @@ +use crate::debug::Reader; use crate::debug::transform::AddressTransform; -use crate::debug::{Compilation, Reader}; use gimli::UnitSectionOffset; use gimli::constants; use gimli::read; use std::collections::{HashMap, HashSet}; -use wasmtime_environ::{PrimaryMap, StaticModuleIndex}; #[derive(Debug)] pub struct Dependencies { @@ -68,17 +67,13 @@ impl Dependencies { } pub fn build_dependencies( - compilation: &mut Compilation<'_>, - dwp: &Option>>, - at: &PrimaryMap, + dwarf: &read::Dwarf>, + at: &AddressTransform, ) -> read::Result { let mut deps = Dependencies::new(); - for (i, translation) in compilation.translations.iter() { - let dwarf = &translation.debuginfo.dwarf; - let mut units = dwarf.units(); - while let Some(unit) = units.next()? { - build_unit_dependencies(unit, dwarf, dwp, &at[i], &mut deps)?; - } + let mut units = dwarf.units(); + while let Some(unit) = units.next()? { + build_unit_dependencies(unit, dwarf, at, &mut deps)?; } Ok(deps) } @@ -86,7 +81,6 @@ pub fn build_dependencies( fn build_unit_dependencies( header: read::UnitHeader>, dwarf: &read::Dwarf>, - dwp: &Option>>, at: &AddressTransform, deps: &mut Dependencies, ) -> read::Result<()> { @@ -94,17 +88,6 @@ fn build_unit_dependencies( let mut tree = unit.entries_tree(None)?; let root = tree.root()?; build_die_dependencies(root, dwarf, &unit, at, deps)?; - - if let Some(dwarf_package) = dwp { - if let Some(dwo_id) = unit.dwo_id { - if let Some(cu) = dwarf_package.find_cu(dwo_id, dwarf)? { - if let Some(unit_header) = cu.debug_info.units().next()? { - build_unit_dependencies(unit_header, &cu, &None, at, deps)?; - } - } - } - } - Ok(()) } diff --git a/crates/cranelift/src/debug/transform/mod.rs b/crates/cranelift/src/debug/transform/mod.rs index 922ad2b4a216..4eb20832df79 100644 --- a/crates/cranelift/src/debug/transform/mod.rs +++ b/crates/cranelift/src/debug/transform/mod.rs @@ -163,8 +163,6 @@ pub fn transform_dwarf( ) .flatten(); - let reachable = build_dependencies(compilation, &dwarf_package, &transforms)?.get_reachable(); - let out_encoding = gimli::Encoding { format: gimli::Format::Dwarf32, version: 4, // TODO: this should be configurable @@ -185,9 +183,8 @@ pub fn transform_dwarf( let addr_tr = &transforms[module]; let di = &translation.debuginfo; - let context = DebugInputContext { - reachable: &reachable, - }; + let reachable = build_dependencies(&di.dwarf, addr_tr)?.get_reachable(); + let out_module_synthetic_unit = ModuleSyntheticUnit::new( module, compilation, @@ -202,25 +199,31 @@ pub fn transform_dwarf( while let Some(header) = iter.next().unwrap_or(None) { let unit = di.dwarf.unit(header)?; - let mut resolved_unit = None; + let mut split_unit = None; let mut split_dwarf = None; + let mut split_reachable = None; if unit.dwo_id.is_some() { if let Some(dwarf_package) = &dwarf_package { if let Some((fused, fused_dwarf)) = replace_unit_from_split_dwarf(&unit, dwarf_package, &di.dwarf) { - resolved_unit = Some(fused); + split_reachable = + Some(build_dependencies(&fused_dwarf, addr_tr)?.get_reachable()); + split_unit = Some(fused); split_dwarf = Some(fused_dwarf); } } } + let context = DebugInputContext { + reachable: split_reachable.as_ref().unwrap_or(&reachable), + }; if let Some((id, ref_map, pending_refs)) = clone_unit( compilation, module, &unit, - resolved_unit.as_ref(), + split_unit.as_ref(), split_dwarf.as_ref(), &context, &addr_tr,