Find matching symbols between each object.
(
left: Option<&Object>,
right: Option<&Object>,
prev: Option<&Object>,
mappings: &MappingConfig,
)
| 573 | |
| 574 | /// Find matching symbols between each object. |
| 575 | fn matching_symbols( |
| 576 | left: Option<&Object>, |
| 577 | right: Option<&Object>, |
| 578 | prev: Option<&Object>, |
| 579 | mappings: &MappingConfig, |
| 580 | ) -> Result<Vec<SymbolMatch>> { |
| 581 | let mut matches = Vec::new(); |
| 582 | let mut left_used = BTreeSet::new(); |
| 583 | let mut right_used = BTreeSet::new(); |
| 584 | if let Some(left) = left { |
| 585 | if let Some(right) = right { |
| 586 | apply_symbol_mappings( |
| 587 | left, |
| 588 | right, |
| 589 | mappings, |
| 590 | &mut left_used, |
| 591 | &mut right_used, |
| 592 | &mut matches, |
| 593 | )?; |
| 594 | } |
| 595 | // Do two passes for nameless literals. The first only pairs up perfect matches to ensure |
| 596 | // those are correct first, while the second pass catches near matches. |
| 597 | for fuzzy_literals in [false, true] { |
| 598 | for (symbol_idx, symbol) in left.symbols.iter().enumerate() { |
| 599 | if symbol.size == 0 || symbol.flags.contains(SymbolFlag::Ignored) { |
| 600 | continue; |
| 601 | } |
| 602 | let section_kind = symbol_section_kind(left, symbol); |
| 603 | if section_kind == SectionKind::Unknown { |
| 604 | continue; |
| 605 | } |
| 606 | if left_used.contains(&symbol_idx) { |
| 607 | continue; |
| 608 | } |
| 609 | let symbol_match = SymbolMatch { |
| 610 | left: Some(symbol_idx), |
| 611 | right: find_symbol(right, left, symbol_idx, Some(&right_used), fuzzy_literals), |
| 612 | prev: find_symbol(prev, left, symbol_idx, None, fuzzy_literals), |
| 613 | section_kind, |
| 614 | }; |
| 615 | matches.push(symbol_match); |
| 616 | if let Some(right) = symbol_match.right { |
| 617 | left_used.insert(symbol_idx); |
| 618 | right_used.insert(right); |
| 619 | } |
| 620 | } |
| 621 | } |
| 622 | } |
| 623 | if let Some(right) = right { |
| 624 | // Do two passes for nameless literals. The first only pairs up perfect matches to ensure |
| 625 | // those are correct first, while the second pass catches near matches. |
| 626 | for fuzzy_literals in [false, true] { |
| 627 | for (symbol_idx, symbol) in right.symbols.iter().enumerate() { |
| 628 | if symbol.size == 0 || symbol.flags.contains(SymbolFlag::Ignored) { |
| 629 | continue; |
| 630 | } |
| 631 | let section_kind = symbol_section_kind(right, symbol); |
| 632 | if section_kind == SectionKind::Unknown { |
no test coverage detected