rustc_codegen_ssa/traits/
debuginfo.rs1use std::ops::Range;
2
3use rustc_abi::Size;
4use rustc_middle::ty::{ExistentialTraitRef, Instance, Ty};
5use rustc_span::{BytePos, SourceFile, Span, Symbol};
6use rustc_target::callconv::FnAbi;
7
8use super::BackendTypes;
9use crate::mir::debuginfo::VariableKind;
10
11pub trait DebugInfoCodegenMethods<'tcx>: BackendTypes {
12 fn create_vtable_debuginfo(
13 &self,
14 ty: Ty<'tcx>,
15 trait_ref: Option<ExistentialTraitRef<'tcx>>,
16 vtable: Self::Value,
17 );
18
19 fn dbg_create_lexical_block(&self, pos: BytePos, parent_scope: Self::DIScope) -> Self::DIScope;
20
21 fn dbg_location_clone_with_discriminator(
22 &self,
23 loc: Self::DILocation,
24 discriminator: u32,
25 ) -> Option<Self::DILocation>;
26
27 fn dbg_scope_fn(
30 &self,
31 instance: Instance<'tcx>,
32 fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
33 maybe_definition_llfn: Option<Self::Function>,
34 ) -> Self::DIScope;
35
36 fn dbg_loc(
37 &self,
38 scope: Self::DIScope,
39 inlined_at: Option<Self::DILocation>,
40 span: Span,
41 ) -> Self::DILocation;
42
43 fn extend_scope_to_file(
44 &self,
45 scope_metadata: Self::DIScope,
46 file: &SourceFile,
47 ) -> Self::DIScope;
48 fn debuginfo_finalize(&self);
49
50 fn create_dbg_var(
53 &self,
54 variable_name: Symbol,
55 variable_type: Ty<'tcx>,
56 scope_metadata: Self::DIScope,
57 variable_kind: VariableKind,
58 span: Span,
59 ) -> Self::DIVariable;
60}
61
62pub trait DebugInfoBuilderMethods<'tcx>: BackendTypes {
63 fn dbg_var_addr(
66 &mut self,
67 dbg_var: Self::DIVariable,
68 dbg_loc: Self::DILocation,
69 variable_alloca: Self::Value,
70 direct_offset: Size,
71 indirect_offsets: &[Size],
73 fragment: &Option<Range<Size>>,
76 );
77 fn dbg_var_value(
78 &mut self,
79 dbg_var: Self::DIVariable,
80 dbg_loc: Self::DILocation,
81 value: Self::Value,
82 direct_offset: Size,
83 indirect_offsets: &[Size],
85 fragment: &Option<Range<Size>>,
88 );
89 fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
90 fn clear_dbg_loc(&mut self);
91 fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
92 fn set_var_name(&mut self, value: Self::Value, name: &str);
93
94 fn with_move_annotation<R>(
101 &mut self,
102 _instance: Instance<'tcx>,
103 f: impl FnOnce(&mut Self) -> R,
104 ) -> R {
105 f(self)
106 }
107}