]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_ssa/src/traits/debuginfo.rs
Merge branch 'master' into patch-2
[rust.git] / compiler / rustc_codegen_ssa / src / traits / debuginfo.rs
1 use super::BackendTypes;
2 use crate::mir::debuginfo::{FunctionDebugContext, VariableKind};
3 use rustc_middle::mir;
4 use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty};
5 use rustc_span::{SourceFile, Span, Symbol};
6 use rustc_target::abi::call::FnAbi;
7 use rustc_target::abi::Size;
8
9 pub trait DebugInfoMethods<'tcx>: BackendTypes {
10     fn create_vtable_debuginfo(
11         &self,
12         ty: Ty<'tcx>,
13         trait_ref: Option<PolyExistentialTraitRef<'tcx>>,
14         vtable: Self::Value,
15     );
16
17     /// Creates the function-specific debug context.
18     ///
19     /// Returns the FunctionDebugContext for the function which holds state needed
20     /// for debug info creation, if it is enabled.
21     fn create_function_debug_context(
22         &self,
23         instance: Instance<'tcx>,
24         fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
25         llfn: Self::Function,
26         mir: &mir::Body<'tcx>,
27     ) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>>;
28
29     // FIXME(eddyb) find a common convention for all of the debuginfo-related
30     // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
31     fn dbg_scope_fn(
32         &self,
33         instance: Instance<'tcx>,
34         fn_abi: &FnAbi<'tcx, Ty<'tcx>>,
35         maybe_definition_llfn: Option<Self::Function>,
36     ) -> Self::DIScope;
37
38     fn dbg_loc(
39         &self,
40         scope: Self::DIScope,
41         inlined_at: Option<Self::DILocation>,
42         span: Span,
43     ) -> Self::DILocation;
44
45     fn extend_scope_to_file(
46         &self,
47         scope_metadata: Self::DIScope,
48         file: &SourceFile,
49     ) -> Self::DIScope;
50     fn debuginfo_finalize(&self);
51
52     // FIXME(eddyb) find a common convention for all of the debuginfo-related
53     // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
54     fn create_dbg_var(
55         &self,
56         variable_name: Symbol,
57         variable_type: Ty<'tcx>,
58         scope_metadata: Self::DIScope,
59         variable_kind: VariableKind,
60         span: Span,
61     ) -> Self::DIVariable;
62 }
63
64 pub trait DebugInfoBuilderMethods: BackendTypes {
65     // FIXME(eddyb) find a common convention for all of the debuginfo-related
66     // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
67     fn dbg_var_addr(
68         &mut self,
69         dbg_var: Self::DIVariable,
70         dbg_loc: Self::DILocation,
71         variable_alloca: Self::Value,
72         direct_offset: Size,
73         // NB: each offset implies a deref (i.e. they're steps in a pointer chain).
74         indirect_offsets: &[Size],
75     );
76     fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
77     fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
78     fn set_var_name(&mut self, value: Self::Value, name: &str);
79 }