symbolic_symcache/transform/
il2cpp.rs1use symbolic_il2cpp::LineMapping;
5
6use super::{File, Function, SourceLocation, Transformer};
7
8fn full_path(file: &File<'_>) -> String {
9    let comp_dir = file.comp_dir.as_deref().unwrap_or_default();
10    let directory = file.directory.as_deref().unwrap_or_default();
11    let path_name = &file.name;
12
13    let prefix = symbolic_common::join_path(comp_dir, directory);
14    let full_path = symbolic_common::join_path(&prefix, path_name);
15    symbolic_common::clean_path(&full_path).into_owned()
16}
17
18impl Transformer for LineMapping {
19    fn transform_function<'f>(&'f mut self, f: Function<'f>) -> Function<'f> {
20        f
21    }
22
23    fn transform_source_location<'f>(
24        &'f mut self,
25        mut sl: SourceLocation<'f>,
26    ) -> SourceLocation<'f> {
27        let full_path = full_path(&sl.file);
30        if let Some((mapped_file, mapped_line)) = self.lookup(&full_path, sl.line) {
31            sl.file.name = mapped_file.into();
32            sl.file.comp_dir = None;
33            sl.file.directory = None;
34            sl.line = mapped_line;
35        }
36
37        sl
38    }
39}