]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_ssa/src/traits/debuginfo.rs
Introduce composite debuginfo.
[rust.git] / compiler / rustc_codegen_ssa / src / traits / debuginfo.rs
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 {
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.
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.).
33     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
40     fn dbg_loc(
41         &self,
42         scope: Self::DIScope,
43         inlined_at: Option<Self::DILocation>,
44         span: Span,
45     ) -> Self::DILocation;
46
47     fn extend_scope_to_file(
48         &self,
49         scope_metadata: Self::DIScope,
50         file: &SourceFile,
51     ) -> Self::DIScope;
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.).
56     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.).
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     );
81     fn set_dbg_loc(&mut self, dbg_loc: Self::DILocation);
82     fn insert_reference_to_gdb_debug_scripts_section_global(&mut self);
83     fn set_var_name(&mut self, value: Self::Value, name: &str);
84 }