]> git.proxmox.com Git - rustc.git/blob - src/librustc_codegen_ssa/traits/debuginfo.rs
New upstream version 1.44.1+dfsg1
[rustc.git] / src / librustc_codegen_ssa / traits / debuginfo.rs
1 use super::BackendTypes;
2 use crate::mir::debuginfo::{FunctionDebugContext, VariableKind};
3 use rustc_ast::ast::Name;
4 use rustc_hir::def_id::CrateNum;
5 use rustc_middle::mir;
6 use rustc_middle::ty::{Instance, Ty};
7 use rustc_span::{SourceFile, Span};
8 use rustc_target::abi::call::FnAbi;
9 use rustc_target::abi::Size;
10
11 pub trait DebugInfoMethods<'tcx>: BackendTypes {
12 fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value);
13
14 /// Creates the function-specific debug context.
15 ///
16 /// Returns the FunctionDebugContext for the function which holds state needed
17 /// for debug info creation, if it is enabled.
18 fn create_function_debug_context(
19 &self,
20 instance: Instance<'tcx>,
21 fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
22 llfn: Self::Function,
23 mir: &mir::Body<'_>,
24 ) -> Option<FunctionDebugContext<Self::DIScope>>;
25
26 fn extend_scope_to_file(
27 &self,
28 scope_metadata: Self::DIScope,
29 file: &SourceFile,
30 defining_crate: CrateNum,
31 ) -> Self::DIScope;
32 fn debuginfo_finalize(&self);
33
34 // FIXME(eddyb) find a common convention for all of the debuginfo-related
35 // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
36 fn create_dbg_var(
37 &self,
38 dbg_context: &FunctionDebugContext<Self::DIScope>,
39 variable_name: Name,
40 variable_type: Ty<'tcx>,
41 scope_metadata: Self::DIScope,
42 variable_kind: VariableKind,
43 span: Span,
44 ) -> Self::DIVariable;
45 }
46
47 pub trait DebugInfoBuilderMethods: BackendTypes {
48 // FIXME(eddyb) find a common convention for all of the debuginfo-related
49 // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
50 fn dbg_var_addr(
51 &mut self,
52 dbg_var: Self::DIVariable,
53 scope_metadata: Self::DIScope,
54 variable_alloca: Self::Value,
55 direct_offset: Size,
56 // NB: each offset implies a deref (i.e. they're steps in a pointer chain).
57 indirect_offsets: &[Size],
58 span: Span,
59 );
60 fn set_source_location(&mut self, scope: Self::DIScope, span: Span);
61 fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
62 fn set_var_name(&mut self, value: Self::Value, name: &str);
63 }