rustc_codegen_ssa/traits/
debuginfo.rs1use std::ops::Range;
2
3use rustc_abi::Size;
4use rustc_middle::mir;
5use rustc_middle::ty::{ExistentialTraitRef, Instance, Ty};
6use rustc_span::{SourceFile, Span, Symbol};
7use rustc_target::callconv::FnAbi;
8
9use super::BackendTypes;
10use crate::mir::debuginfo::{FunctionDebugContext, VariableKind};
11
12pub trait DebugInfoCodegenMethods<'tcx>: BackendTypes {
13 fn create_vtable_debuginfo(
14 &self,
15 ty: Ty<'tcx>,
16 trait_ref: Option<ExistentialTraitRef<'tcx>>,
17 vtable: Self::Value,
18 );
19
20 fn create_function_debug_context(
25 &self,
26 instance: Instance<'tcx>,
27 fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
28 llfn: Self::Function,
29 mir: &mir::Body<'tcx>,
30 ) -> Option<FunctionDebugContext<'tcx, Self::DIScope, Self::DILocation>>;
31
32 fn dbg_scope_fn(
35 &self,
36 instance: Instance<'tcx>,
37 fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
38 maybe_definition_llfn: Option<Self::Function>,
39 ) -> Self::DIScope;
40
41 fn dbg_loc(
42 &self,
43 scope: Self::DIScope,
44 inlined_at: Option<Self::DILocation>,
45 span: Span,
46 ) -> Self::DILocation;
47
48 fn extend_scope_to_file(
49 &self,
50 scope_metadata: Self::DIScope,
51 file: &SourceFile,
52 ) -> Self::DIScope;
53 fn debuginfo_finalize(&self);
54
55 fn create_dbg_var(
58 &self,
59 variable_name: Symbol,
60 variable_type: Ty<'tcx>,
61 scope_metadata: Self::DIScope,
62 variable_kind: VariableKind,
63 span: Span,
64 ) -> Self::DIVariable;
65}
66
67pub trait DebugInfoBuilderMethods: BackendTypes {
68 fn dbg_var_addr(
71 &mut self,
72 dbg_var: Self::DIVariable,
73 dbg_loc: Self::DILocation,
74 variable_alloca: Self::Value,
75 direct_offset: Size,
76 indirect_offsets: &[Size],
78 fragment: Option<Range<Size>>,
81 );
82 fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
83 fn clear_dbg_loc(&mut self);
84 fn get_dbg_loc(&self) -> Option<Self::DILocation>;
85 fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
86 fn set_var_name(&mut self, value: Self::Value, name: &str);
87}