]> git.lizzy.rs Git - rust.git/blob - src/librustc_codegen_llvm/interfaces/debuginfo.rs
4e24e12bc6861e27eca89e0d8b574b6b25461716
[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     fn debuginfo_finalize(&self);
51 }
52
53 pub trait DebugInfoBuilderMethods<'tcx>: HasCodegen<'tcx> {
54     fn declare_local(
55         &self,
56         dbg_context: &FunctionDebugContext<Self::DIScope>,
57         variable_name: Name,
58         variable_type: Ty<'tcx>,
59         scope_metadata: Self::DIScope,
60         variable_access: VariableAccess<'_, Self::Value>,
61         variable_kind: VariableKind,
62         span: Span,
63     );
64     fn set_source_location(
65         &self,
66         debug_context: &FunctionDebugContext<Self::DIScope>,
67         scope: Option<Self::DIScope>,
68         span: Span,
69     );
70     fn insert_reference_to_gdb_debug_scripts_section_global(&self);
71 }