(
isa: &dyn TargetIsa,
compilation: &mut Compilation<'_>,
)
| 128 | } |
| 129 | |
| 130 | pub fn transform_dwarf( |
| 131 | isa: &dyn TargetIsa, |
| 132 | compilation: &mut Compilation<'_>, |
| 133 | ) -> Result<write::Dwarf, Error> { |
| 134 | dbi_log!("Commencing DWARF transform for {:?}", compilation); |
| 135 | |
| 136 | let mut transforms = PrimaryMap::new(); |
| 137 | for (i, _) in compilation.translations.iter() { |
| 138 | transforms.push(AddressTransform::new(compilation, i)); |
| 139 | } |
| 140 | |
| 141 | let buffer = Vec::new(); |
| 142 | |
| 143 | let dwarf_package = compilation |
| 144 | .dwarf_package_bytes |
| 145 | .map( |
| 146 | |bytes| -> Option<DwarfPackage<gimli::EndianSlice<'_, gimli::LittleEndian>>> { |
| 147 | read_dwarf_package_from_bytes(bytes, &buffer, compilation.tunables) |
| 148 | }, |
| 149 | ) |
| 150 | .flatten(); |
| 151 | |
| 152 | let out_encoding = gimli::Encoding { |
| 153 | format: gimli::Format::Dwarf32, |
| 154 | version: 4, // TODO: this should be configurable |
| 155 | address_size: isa.pointer_bytes(), |
| 156 | }; |
| 157 | let mut out_dwarf = write::Dwarf::default(); |
| 158 | |
| 159 | let mut vmctx_ptr_die_refs = PrimaryMap::new(); |
| 160 | |
| 161 | let mut translated = HashSet::new(); |
| 162 | |
| 163 | for (module, translation) in compilation.translations.iter() { |
| 164 | dbi_log!("[== Transforming CUs for module #{} ==]", module.as_u32()); |
| 165 | |
| 166 | let addr_tr = &transforms[module]; |
| 167 | let di = &translation.debuginfo; |
| 168 | |
| 169 | let out_module_synthetic_unit = ModuleSyntheticUnit::new( |
| 170 | module, |
| 171 | compilation, |
| 172 | out_encoding, |
| 173 | &mut out_dwarf.units, |
| 174 | &mut out_dwarf.strings, |
| 175 | ); |
| 176 | // TODO-DebugInfo-Cleanup: move the simulation code to be per-module and delete this map. |
| 177 | vmctx_ptr_die_refs.push(out_module_synthetic_unit.vmctx_ptr_die_ref()); |
| 178 | |
| 179 | let mut filter = write::FilterUnitSection::new(&di.dwarf)?; |
| 180 | build_dependencies(&mut filter, addr_tr)?; |
| 181 | let mut convert = out_dwarf.convert_with_filter(filter)?; |
| 182 | while let Some((mut unit, root_entry)) = convert.read_unit()? { |
| 183 | if let Some(dwp) = dwarf_package.as_ref() |
| 184 | && let Some(dwo_id) = unit.read_unit.dwo_id |
| 185 | && let Ok(Some(split_dwarf)) = dwp.find_cu(dwo_id, unit.read_unit.dwarf) |
| 186 | { |
| 187 | let mut split_filter = |
no test coverage detected