pub mod cuda;
pub mod cxx;
pub mod dotnet;
pub mod go;
pub mod python;
#[derive(Clone, Debug, Eq, PartialEq, Hash)]
pub struct CanonicalSymbol {
pub lang: &'static str,
pub fqn: String,
pub file: Option<String>,
pub line: Option<u32>,
pub demangled: Option<String>,
pub raw: String,
pub is_synthetic: bool,
}
impl CanonicalSymbol {
pub fn key(&self) -> (&'static str, &str) {
(self.lang, &self.fqn)
}
}
pub trait Canonicalizer: Send + Sync {
fn lang(&self) -> &'static str;
fn canonicalize(&self, raw: &str) -> CanonicalSymbol;
fn canonicalize_structured(
&self,
module: &str,
class: &str,
method: &str,
_sig: &str,
) -> CanonicalSymbol {
let parts: Vec<&str> = [module, class, method]
.into_iter()
.filter(|s| !s.is_empty())
.collect();
self.canonicalize(&parts.join("."))
}
fn resolve_async_frame(&self, _raw: &str) -> Option<String> {
None
}
}
pub fn for_lang(lang: &str) -> Option<Box<dyn Canonicalizer>> {
Some(match lang {
"cpp" | "rust" | "c" | "zig" | "d" | "nim" => Box::new(cxx::CxxCanonicalizer::new(lang)),
"dotnet" => Box::new(dotnet::DotnetCanonicalizer),
"python" => Box::new(python::PythonCanonicalizer),
"go" => Box::new(go::GoCanonicalizer),
"cuda" => Box::new(cuda::CudaCanonicalizer),
_ => return None,
})
}