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.
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.
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;
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};
22 pub trait DebugInfoMethods<'tcx>: Backend<'tcx> {
23 fn create_vtable_metadata(&self, ty: Ty<'tcx>, vtable: Self::Value);
25 /// Creates the function-specific debug context.
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
31 fn create_function_debug_context(
33 instance: Instance<'tcx>,
37 ) -> FunctionDebugContext<Self::DIScope>;
42 debug_context: &FunctionDebugContext<Self::DIScope>,
43 ) -> IndexVec<mir::SourceScope, MirDebugScope<Self::DIScope>>;
44 fn extend_scope_to_file(
46 scope_metadata: Self::DIScope,
48 defining_crate: CrateNum,
50 fn debuginfo_finalize(&self);
53 pub trait DebugInfoBuilderMethods<'tcx>: HasCodegen<'tcx> {
56 dbg_context: &FunctionDebugContext<Self::DIScope>,
58 variable_type: Ty<'tcx>,
59 scope_metadata: Self::DIScope,
60 variable_access: VariableAccess<'_, Self::Value>,
61 variable_kind: VariableKind,
64 fn set_source_location(
66 debug_context: &FunctionDebugContext<Self::DIScope>,
67 scope: Option<Self::DIScope>,
70 fn insert_reference_to_gdb_debug_scripts_section_global(&self);