1 use super::BackendTypes; 2 use crate::mir::debuginfo::{FunctionDebugContext, VariableKind}; 3 use rustc_middle::mir; 4 use rustc_middle::ty::{Instance, PolyExistentialTraitRef, Ty}; 5 use rustc_span::{SourceFile, Span, Symbol}; 6 use rustc_target::abi::call::FnAbi; 7 use rustc_target::abi::Size; 8 9 use std::ops::Range; 10 11 pub trait DebugInfoMethods<'tcx>: BackendTypes { create_vtable_debuginfo( &self, ty: Ty<'tcx>, trait_ref: Option<PolyExistentialTraitRef<'tcx>>, vtable: Self::Value, )12 fn create_vtable_debuginfo( 13 &self, 14 ty: Ty<'tcx>, 15 trait_ref: Option<PolyExistentialTraitRef<'tcx>>, 16 vtable: Self::Value, 17 ); 18 19 /// Creates the function-specific debug context. 20 /// 21 /// Returns the FunctionDebugContext for the function which holds state needed 22 /// for debug info creation, if it is enabled. create_function_debug_context( &self, instance: Instance<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, llfn: Self::Function, mir: &mir::Body<'tcx>, ) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>>23 fn create_function_debug_context( 24 &self, 25 instance: Instance<'tcx>, 26 fn_abi: &FnAbi<'tcx, Ty<'tcx>>, 27 llfn: Self::Function, 28 mir: &mir::Body<'tcx>, 29 ) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>>; 30 31 // FIXME(eddyb) find a common convention for all of the debuginfo-related 32 // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.). dbg_scope_fn( &self, instance: Instance<'tcx>, fn_abi: &FnAbi<'tcx, Ty<'tcx>>, maybe_definition_llfn: Option<Self::Function>, ) -> Self::DIScope33 fn dbg_scope_fn( 34 &self, 35 instance: Instance<'tcx>, 36 fn_abi: &FnAbi<'tcx, Ty<'tcx>>, 37 maybe_definition_llfn: Option<Self::Function>, 38 ) -> Self::DIScope; 39 dbg_loc( &self, scope: Self::DIScope, inlined_at: Option<Self::DILocation>, span: Span, ) -> Self::DILocation40 fn dbg_loc( 41 &self, 42 scope: Self::DIScope, 43 inlined_at: Option<Self::DILocation>, 44 span: Span, 45 ) -> Self::DILocation; 46 extend_scope_to_file( &self, scope_metadata: Self::DIScope, file: &SourceFile, ) -> Self::DIScope47 fn extend_scope_to_file( 48 &self, 49 scope_metadata: Self::DIScope, 50 file: &SourceFile, 51 ) -> Self::DIScope; debuginfo_finalize(&self)52 fn debuginfo_finalize(&self); 53 54 // FIXME(eddyb) find a common convention for all of the debuginfo-related 55 // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.). create_dbg_var( &self, variable_name: Symbol, variable_type: Ty<'tcx>, scope_metadata: Self::DIScope, variable_kind: VariableKind, span: Span, ) -> Self::DIVariable56 fn create_dbg_var( 57 &self, 58 variable_name: Symbol, 59 variable_type: Ty<'tcx>, 60 scope_metadata: Self::DIScope, 61 variable_kind: VariableKind, 62 span: Span, 63 ) -> Self::DIVariable; 64 } 65 66 pub trait DebugInfoBuilderMethods: BackendTypes { 67 // FIXME(eddyb) find a common convention for all of the debuginfo-related 68 // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.). dbg_var_addr( &mut self, dbg_var: Self::DIVariable, dbg_loc: Self::DILocation, variable_alloca: Self::Value, direct_offset: Size, indirect_offsets: &[Size], fragment: Option<Range<Size>>, )69 fn dbg_var_addr( 70 &mut self, 71 dbg_var: Self::DIVariable, 72 dbg_loc: Self::DILocation, 73 variable_alloca: Self::Value, 74 direct_offset: Size, 75 // NB: each offset implies a deref (i.e. they're steps in a pointer chain). 76 indirect_offsets: &[Size], 77 // Byte range in the `dbg_var` covered by this fragment, 78 // if this is a fragment of a composite `DIVariable`. 79 fragment: Option<Range<Size>>, 80 ); set_dbg_loc(&mut self, dbg_loc: Self::DILocation)81 fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation); insert_reference_to_gdb_debug_scripts_section_global(&mut self)82 fn insert_reference_to_gdb_debug_scripts_section_global(&mut self); set_var_name(&mut self, value: Self::Value, name: &str)83 fn set_var_name(&mut self, value: Self::Value, name: &str); 84 } 85