1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
#![cfg_attr(coverage_nightly, coverage(off))]
//! Correlation Engine
//!
//! Creates bidirectional mappings between source locations and WASM offsets.
//! Uses DWARF as primary source, source maps as fallback.
//!
//! Implements DWASM-010: Source-to-WASM correlation with:
//! - Bidirectional mapping (source <-> WASM)
//! - DWARF as primary source
//! - Source maps as fallback
//! - Confidence scoring for each mapping
use crate::services::deep_wasm::{
DeepWasmResult, DwarfDebugEntry, Location, SourceMapEntry, SourceToWasmMapping,
};
use std::collections::HashMap;
use std::path::PathBuf;
/// Estimate WASM function index from DWARF offset
/// This is a heuristic until we have full WASM module analysis
fn estimate_function_index(die_offset: u64) -> u32 {
// Simple heuristic: assume functions are roughly 100 bytes apart in DWARF
// This will be replaced with accurate mapping from WASM module analysis
(die_offset / 100) as u32
}
/// Correlation engine for multi-layer mapping
pub struct CorrelationEngine {
/// Confidence threshold for mappings (0.0-1.0)
confidence_threshold: f64,
}
impl CorrelationEngine {
pub fn new() -> Self {
Self {
confidence_threshold: 0.7, // 70% confidence minimum
}
}
/// Create correlation engine with custom confidence threshold
pub fn with_confidence_threshold(threshold: f64) -> Self {
Self {
confidence_threshold: threshold.clamp(0.0, 1.0),
}
}
}
impl Default for CorrelationEngine {
fn default() -> Self {
Self::new()
}
}
// --- Submodule includes (semantic split) ---
include!("correlation_engine_correlate.rs");
include!("correlation_engine_line_programs.rs");
include!("correlation_engine_lookups.rs");
include!("correlation_engine_unit_tests.rs");