Create and return the compiled function address map from the original source offset and length.
(&mut self, offset: u32, length: u32, with_instruction_addresses: bool)
| 163 | /// Create and return the compiled function address map from the original source offset |
| 164 | /// and length. |
| 165 | pub fn set_address_map(&mut self, offset: u32, length: u32, with_instruction_addresses: bool) { |
| 166 | assert!((offset + length) <= u32::max_value()); |
| 167 | let len = self.buffer.data().len(); |
| 168 | let srclocs = self |
| 169 | .buffer |
| 170 | .get_srclocs_sorted() |
| 171 | .into_iter() |
| 172 | .map(|&MachSrcLoc { start, end, loc }| (loc, start, (end - start))); |
| 173 | let instructions = if with_instruction_addresses { |
| 174 | collect_address_maps(len.try_into().unwrap(), srclocs) |
| 175 | } else { |
| 176 | Default::default() |
| 177 | }; |
| 178 | let start_srcloc = FilePos::new(offset); |
| 179 | let end_srcloc = FilePos::new(offset + length); |
| 180 | |
| 181 | let address_map = FunctionAddressMap { |
| 182 | instructions: instructions.into(), |
| 183 | start_srcloc, |
| 184 | end_srcloc, |
| 185 | body_offset: 0, |
| 186 | body_len: len.try_into().unwrap(), |
| 187 | }; |
| 188 | |
| 189 | self.metadata.address_map = address_map; |
| 190 | } |
| 191 | |
| 192 | /// Get a reference to the unwind information from the |
| 193 | /// function's metadata. |
no test coverage detected