Skip to main content

ghostscope_dwarf/core/
ids.rs

1//! Stable semantic identifiers used by higher-level DWARF queries.
2
3/// Stable identifier for a loaded module within one `DwarfAnalyzer`.
4#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
5pub struct ModuleId(pub u32);
6
7/// Stable identifier for a compilation unit within a loaded module.
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
9pub struct CuId(pub u32);
10
11/// Stable reference to a DIE within a loaded module.
12#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
13pub struct DieRef {
14    pub module: ModuleId,
15    pub cu: CuId,
16    /// Unit-relative or absolute offset normalized by the producer of the id.
17    pub offset: u64,
18}
19
20/// Stable identifier for a type DIE.
21#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
22pub struct TypeId {
23    pub module: ModuleId,
24    pub cu: CuId,
25    pub die: DieRef,
26}
27
28/// Stable identifier for a variable declaration DIE.
29#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
30pub struct VariableId {
31    pub declaration: DieRef,
32}
33
34/// Stable identifier for a function DIE.
35#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
36pub struct FunctionId {
37    pub declaration: DieRef,
38}
39
40/// Stable identifier for a lexical scope DIE.
41#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
42pub struct ScopeId {
43    pub die: DieRef,
44}
45
46/// Stable identifier for an inline context inside a concrete function.
47#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, PartialOrd, Ord)]
48pub struct InlineContextId {
49    pub die: DieRef,
50}