]> git.lizzy.rs Git - rust.git/blob - compiler/rustc_codegen_gcc/src/debuginfo.rs
Merge commit 'e228f0c16ea8c34794a6285bf57aab627c26b147' into libgccjit-codegen
[rust.git] / compiler / rustc_codegen_gcc / src / debuginfo.rs
1 use gccjit::{FunctionType, RValue};
2 use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, VariableKind};
3 use rustc_codegen_ssa::traits::{BuilderMethods, DebugInfoBuilderMethods, DebugInfoMethods};
4 use rustc_middle::middle::cstore::CrateDepKind;
5 use rustc_middle::mir;
6 use rustc_middle::ty::{Instance, Ty};
7 use rustc_span::{SourceFile, Span, Symbol};
8 use rustc_span::def_id::LOCAL_CRATE;
9 use rustc_target::abi::Size;
10 use rustc_target::abi::call::FnAbi;
11
12 use crate::builder::Builder;
13 use crate::context::CodegenCx;
14
15 impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
16     // FIXME(eddyb) find a common convention for all of the debuginfo-related
17     // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
18     fn dbg_var_addr(&mut self, _dbg_var: Self::DIVariable, _scope_metadata: Self::DIScope, _variable_alloca: Self::Value, _direct_offset: Size, _indirect_offsets: &[Size]) {
19         unimplemented!();
20     }
21
22     fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
23         // TODO(antoyo): replace with gcc_jit_context_new_global_with_initializer() if it's added:
24         // https://gcc.gnu.org/pipermail/jit/2020q3/001225.html
25         //
26         // Call the function to initialize global values here.
27         // We assume this is only called for the main function.
28         use std::iter;
29
30         for crate_num in self.cx.tcx.crates(()).iter().copied().chain(iter::once(LOCAL_CRATE)) {
31             // FIXME(antoyo): better way to find if a crate is of proc-macro type?
32             if crate_num == LOCAL_CRATE || self.cx.tcx.dep_kind(crate_num) != CrateDepKind::MacrosOnly {
33                 // NOTE: proc-macro crates are not included in the executable, so don't call their
34                 // initialization routine.
35                 let initializer_name = format!("__gccGlobalCrateInit{}", self.cx.tcx.crate_name(crate_num));
36                 let codegen_init_func = self.context.new_function(None, FunctionType::Extern, self.context.new_type::<()>(), &[],
37                 initializer_name, false);
38                 self.llbb().add_eval(None, self.context.new_call(None, codegen_init_func, &[]));
39             }
40         }
41
42         // TODO(antoyo): insert reference to gdb debug scripts section global.
43     }
44
45     fn set_var_name(&mut self, _value: RValue<'gcc>, _name: &str) {
46         unimplemented!();
47     }
48
49     fn set_dbg_loc(&mut self, _dbg_loc: Self::DILocation) {
50         unimplemented!();
51     }
52 }
53
54 impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
55     fn create_vtable_metadata(&self, _ty: Ty<'tcx>, _vtable: Self::Value) {
56         // TODO(antoyo)
57     }
58
59     fn create_function_debug_context(&self, _instance: Instance<'tcx>, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _llfn: RValue<'gcc>, _mir: &mir::Body<'tcx>) -> Option<FunctionDebugContext<Self::DIScope, Self::DILocation>> {
60         // TODO(antoyo)
61         None
62     }
63
64     fn extend_scope_to_file(&self, _scope_metadata: Self::DIScope, _file: &SourceFile) -> Self::DIScope {
65         unimplemented!();
66     }
67
68     fn debuginfo_finalize(&self) {
69         // TODO(antoyo)
70     }
71
72     fn create_dbg_var(&self, _variable_name: Symbol, _variable_type: Ty<'tcx>, _scope_metadata: Self::DIScope, _variable_kind: VariableKind, _span: Span) -> Self::DIVariable {
73         unimplemented!();
74     }
75
76     fn dbg_scope_fn(&self, _instance: Instance<'tcx>, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _maybe_definition_llfn: Option<RValue<'gcc>>) -> Self::DIScope {
77         unimplemented!();
78     }
79
80     fn dbg_loc(&self, _scope: Self::DIScope, _inlined_at: Option<Self::DILocation>, _span: Span) -> Self::DILocation {
81         unimplemented!();
82     }
83 }