]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/traits/debuginfo.rs
Rollup merge of #61273 - RalfJung:maybe-uninit, r=Centril
[rust.git] / src / librustc_codegen_ssa / traits / debuginfo.rs
1 use super::BackendTypes;
2 use crate::debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess, VariableKind};
3 use rustc::hir::def_id::CrateNum;
4 use rustc::mir;
5 use rustc::ty::{self, Ty};
6 use rustc_data_structures::indexed_vec::IndexVec;
7 use rustc_mir::monomorphize::Instance;
8 use syntax::ast::Name;
9 use syntax_pos::{SourceFile, Span};
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. The function may also return another variant of the
18     /// FunctionDebugContext enum which indicates why no debuginfo should be created
19     /// for the function.
20     fn create_function_debug_context(
21         &self,
22         instance: Instance<'tcx>,
23         sig: ty::FnSig<'tcx>,
24         llfn: Self::Value,
25         mir: &mir::Body<'_>,
26     ) -> FunctionDebugContext<Self::DIScope>;
27
28     fn create_mir_scopes(
29         &self,
30         mir: &mir::Body<'_>,
31         debug_context: &mut FunctionDebugContext<Self::DIScope>,
32     ) -> IndexVec<mir::SourceScope, MirDebugScope<Self::DIScope>>;
33     fn extend_scope_to_file(
34         &self,
35         scope_metadata: Self::DIScope,
36         file: &SourceFile,
37         defining_crate: CrateNum,
38     ) -> Self::DIScope;
39     fn debuginfo_finalize(&self);
40     fn debuginfo_upvar_ops_sequence(&self, byte_offset_of_var_in_env: u64) -> [i64; 4];
41 }
42
43 pub trait DebugInfoBuilderMethods<'tcx>: BackendTypes {
44     fn declare_local(
45         &mut self,
46         dbg_context: &FunctionDebugContext<Self::DIScope>,
47         variable_name: Name,
48         variable_type: Ty<'tcx>,
49         scope_metadata: Self::DIScope,
50         variable_access: VariableAccess<'_, Self::Value>,
51         variable_kind: VariableKind,
52         span: Span,
53     );
54     fn set_source_location(
55         &mut self,
56         debug_context: &mut FunctionDebugContext<Self::DIScope>,
57         scope: Option<Self::DIScope>,
58         span: Span,
59     );
60     fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
61     fn set_value_name(&mut self, value: Self::Value, name: &str);
62 }