rudy_dwarf/
lib.rs

1//! DWARF debug information parsing and querying
2//!
3//! This crate provides functionality for parsing DWARF debug information
4//! from object files and querying it through a salsa database.
5
6// Public modules - clean API for users
7pub mod address;
8pub mod die;
9pub mod error;
10pub mod expressions;
11pub mod file;
12pub mod function;
13pub mod modules;
14pub mod parser;
15pub mod symbols;
16pub mod types;
17pub mod visitor;
18
19// Test utilities
20#[cfg(test)]
21pub mod test_utils;
22
23// Essential re-exports for convenience
24use std::path::{Path, PathBuf};
25
26// Core types that most users will need
27pub use die::Die;
28pub use error::Error;
29pub use file::{Binary, DebugFile, SourceFile};
30pub use gimli;
31pub use symbols::{SymbolName, TypeName};
32pub use types::{find_type_by_name, get_die_typename};
33
34// Database trait that this crate requires
35#[salsa::db]
36pub trait DwarfDb: salsa::Database {
37    /// Get source path remapping
38    fn remap_path(&self, path: &Path) -> PathBuf {
39        let mut path = path.to_path_buf();
40        for (source, target) in self.get_source_map() {
41            if source == target {
42                continue; // No remapping needed
43            }
44            if let Ok(stripped) = path.strip_prefix(source) {
45                tracing::debug!(
46                    "Remapping {} from {} to {}",
47                    path.display(),
48                    source.display(),
49                    target.display()
50                );
51                path = target.join(stripped);
52            }
53        }
54        path
55    }
56
57    /// Get the source map for path remapping
58    fn get_source_map(&self) -> &[(PathBuf, PathBuf)];
59}