]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_ssa/traits/debuginfo.rs
Rollup merge of #64996 - lzutao:inline-ptr-null, r=oli-obk
[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, Instance};
6 use rustc_index::vec::IndexVec;
7 use syntax::ast::Name;
8 use syntax_pos::{SourceFile, Span};
9
10 pub trait DebugInfoMethods<'tcx>: BackendTypes {
11     fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value);
12
13     /// Creates the function-specific debug context.
14     ///
15     /// Returns the FunctionDebugContext for the function which holds state needed
16     /// for debug info creation. The function may also return another variant of the
17     /// FunctionDebugContext enum which indicates why no debuginfo should be created
18     /// for the function.
19     fn create_function_debug_context(
20         &self,
21         instance: Instance<'tcx>,
22         sig: ty::FnSig<'tcx>,
23         llfn: Self::Function,
24         mir: &mir::Body<'_>,
25     ) -> FunctionDebugContext<Self::DIScope>;
26
27     fn create_mir_scopes(
28         &self,
29         mir: &mir::Body<'_>,
30         debug_context: &mut FunctionDebugContext<Self::DIScope>,
31     ) -> IndexVec<mir::SourceScope, MirDebugScope<Self::DIScope>>;
32     fn extend_scope_to_file(
33         &self,
34         scope_metadata: Self::DIScope,
35         file: &SourceFile,
36         defining_crate: CrateNum,
37     ) -> Self::DIScope;
38     fn debuginfo_finalize(&self);
39     fn debuginfo_upvar_ops_sequence(&self, byte_offset_of_var_in_env: u64) -> [i64; 4];
40 }
41
42 pub trait DebugInfoBuilderMethods<'tcx>: BackendTypes {
43     fn declare_local(
44         &mut self,
45         dbg_context: &FunctionDebugContext<Self::DIScope>,
46         variable_name: Name,
47         variable_type: Ty<'tcx>,
48         scope_metadata: Self::DIScope,
49         variable_access: VariableAccess<'_, Self::Value>,
50         variable_kind: VariableKind,
51         span: Span,
52     );
53     fn set_source_location(
54         &mut self,
55         debug_context: &mut FunctionDebugContext<Self::DIScope>,
56         scope: Option<Self::DIScope>,
57         span: Span,
58     );
59     fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
60     fn set_var_name(&mut self, value: Self::Value, name: impl ToString);
61 }