MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / loaded_modules_from_mappings

Function loaded_modules_from_mappings

src/executor/memory/module_artifacts.rs:177–267  ·  view source on GitHub ↗
(mappings: &[ProcessMapping])

Source from the content-addressed store, hash-verified

175}
176
177fn loaded_modules_from_mappings(mappings: &[ProcessMapping]) -> HashMap<PathBuf, LoadedModule> {
178 let mut loaded_modules = HashMap::<PathBuf, LoadedModule>::new();
179 // Open each path once and parse every artifact from that one mapping, so
180 // the identity check and the parsed bytes always refer to the same inode,
181 // even if the path is replaced during extraction.
182 let mut mapped_modules = HashMap::<PathBuf, Option<MappedModule>>::new();
183
184 for mapping in mappings {
185 let path = PathBuf::from(&mapping.path);
186 let module = mapped_modules.entry(path.clone()).or_insert_with(|| {
187 MappedModule::open(&path)
188 .inspect_err(|e| debug!("{} is no longer mappable: {e}", mapping.path))
189 .ok()
190 });
191 let Some(module) = module else {
192 continue;
193 };
194 if !names_mapped_file(mapping, module.identity) {
195 continue;
196 }
197 let object = match object::File::parse(&module.mmap[..]) {
198 Ok(object) => object,
199 Err(e) => {
200 debug!("Failed to parse {}: {e}", mapping.path);
201 continue;
202 }
203 };
204
205 let load_bias = match elf_helper::compute_load_bias(
206 &object,
207 mapping.avma_range.start,
208 mapping.avma_range.end,
209 mapping.file_offset,
210 ) {
211 Ok(load_bias) => load_bias,
212 Err(e) => {
213 debug!("Failed to compute load bias for {}: {e}", mapping.path);
214 continue;
215 }
216 };
217
218 let loaded_module = loaded_modules.entry(path.clone()).or_default();
219
220 if loaded_module.module_symbols.is_none() {
221 match ModuleSymbols::from_object(&object, &path) {
222 Ok(symbols) => loaded_module.module_symbols = Some(symbols),
223 Err(e) => debug!("Failed to load symbols for {}: {e}", mapping.path),
224 }
225 }
226
227 let process_unwind_data = if let Some(unwind_data) = &loaded_module.unwind_data {
228 Some(ProcessUnwindData {
229 timestamp: Some(mapping.timestamp),
230 avma_range: mapping.avma_range.clone(),
231 base_avma: unwind_data.base_svma.wrapping_add(load_bias),
232 })
233 } else {
234 match unwind_data_from_object(

Callers 1

save_module_artifactsFunction · 0.85

Calls 4

names_mapped_fileFunction · 0.85
compute_load_biasFunction · 0.85
unwind_data_from_objectFunction · 0.85
add_load_biasMethod · 0.80

Tested by

no test coverage detected