]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_llvm/interfaces/debuginfo.rs
eca60e9c9cee1c1ef48de55e4a1ae3317a8cb98c
[rust.git] / src / librustc_codegen_llvm / interfaces / debuginfo.rs
1 // Copyright 2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution and at
3 // http://rust-lang.org/COPYRIGHT.
4 //
5 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8 // option. This file may not be copied, modified, or distributed
9 // except according to those terms.
10
11 use super::backend::Backend;
12 use super::HasCodegen;
13 use debuginfo::{FunctionDebugContext, MirDebugScope, VariableAccess, VariableKind};
14 use monomorphize::Instance;
15 use rustc::hir::def_id::CrateNum;
16 use rustc::mir;
17 use rustc::ty::{self, Ty};
18 use rustc_data_structures::indexed_vec::IndexVec;
19 use syntax::ast::Name;
20 use syntax_pos::{SourceFile, Span};
21
22 pub trait DebugInfoMethods<'tcx>: Backend<'tcx> {
23     fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value);
24
25     /// Creates the function-specific debug context.
26     ///
27     /// Returns the FunctionDebugContext for the function which holds state needed
28     /// for debug info creation. The function may also return another variant of the
29     /// FunctionDebugContext enum which indicates why no debuginfo should be created
30     /// for the function.
31     fn create_function_debug_context(
32         &self,
33         instance: Instance<'tcx>,
34         sig: ty::FnSig<'tcx>,
35         llfn: Self::Value,
36         mir: &mir::Mir,
37     ) -> FunctionDebugContext<Self::DIScope>;
38
39     fn create_mir_scopes(
40         &self,
41         mir: &mir::Mir,
42         debug_context: &FunctionDebugContext<Self::DIScope>,
43     ) -> IndexVec<mir::SourceScope, MirDebugScope<Self::DIScope>>;
44     fn extend_scope_to_file(
45         &self,
46         scope_metadata: Self::DIScope,
47         file: &SourceFile,
48         defining_crate: CrateNum,
49     ) -> Self::DIScope;
50 }
51
52 pub trait DebugInfoBuilderMethods<'tcx>: HasCodegen<'tcx> {
53     fn declare_local(
54         &self,
55         dbg_context: &FunctionDebugContext<Self::DIScope>,
56         variable_name: Name,
57         variable_type: Ty<'tcx>,
58         scope_metadata: Self::DIScope,
59         variable_access: VariableAccess<'_, Self::Value>,
60         variable_kind: VariableKind,
61         span: Span,
62     );
63     fn set_source_location(
64         &self,
65         debug_context: &FunctionDebugContext<Self::DIScope>,
66         scope: Option<Self::DIScope>,
67         span: Span,
68     );
69     fn insert_reference_to_gdb_debug_scripts_section_global(&self);
70 }