about summary refs log tree commit diff
path: root/compiler/rustc_codegen_gcc/src/debuginfo.rs
blob: 8661532a3595e6e2d4a659a3bd763fffbe3c2c75 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
use gccjit::{FunctionType, RValue};
use rustc_codegen_ssa::mir::debuginfo::{FunctionDebugContext, VariableKind};
use rustc_codegen_ssa::traits::{BuilderMethods, DebugInfoBuilderMethods, DebugInfoMethods};
use rustc_middle::middle::cstore::CrateDepKind;
use rustc_middle::mir;
use rustc_middle::ty::{Instance, Ty};
use rustc_span::{SourceFile, Span, Symbol};
use rustc_span::def_id::LOCAL_CRATE;
use rustc_target::abi::Size;
use rustc_target::abi::call::FnAbi;

use crate::builder::Builder;
use crate::context::CodegenCx;

impl<'a, 'gcc, 'tcx> DebugInfoBuilderMethods for Builder<'a, 'gcc, 'tcx> {
    // FIXME(eddyb) find a common convention for all of the debuginfo-related
    // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
    fn dbg_var_addr(&mut self, _dbg_var: Self::DIVariable, _scope_metadata: Self::DIScope, _variable_alloca: Self::Value, _direct_offset: Size, _indirect_offsets: &[Size]) {
        unimplemented!();
    }

    fn insert_reference_to_gdb_debug_scripts_section_global(&mut self) {
        // TODO(antoyo): replace with gcc_jit_context_new_global_with_initializer() if it's added:
        // https://gcc.gnu.org/pipermail/jit/2020q3/001225.html
        //
        // Call the function to initialize global values here.
        // We assume this is only called for the main function.
        use std::iter;

        for crate_num in self.cx.tcx.crates(()).iter().copied().chain(iter::once(LOCAL_CRATE)) {
            // FIXME(antoyo): better way to find if a crate is of proc-macro type?
            if crate_num == LOCAL_CRATE || self.cx.tcx.dep_kind(crate_num) != CrateDepKind::MacrosOnly {
                // NOTE: proc-macro crates are not included in the executable, so don't call their
                // initialization routine.
                let initializer_name = format!("__gccGlobalCrateInit{}", self.cx.tcx.crate_name(crate_num));
                let codegen_init_func = self.context.new_function(None, FunctionType::Extern, self.context.new_type::<()>(), &[],
                initializer_name, false);
                self.llbb().add_eval(None, self.context.new_call(None, codegen_init_func, &[]));
            }
        }

        // TODO(antoyo): insert reference to gdb debug scripts section global.
    }

    fn set_var_name(&mut self, _value: RValue<'gcc>, _name: &str) {
        unimplemented!();
    }

    fn set_dbg_loc(&mut self, _dbg_loc: Self::DILocation) {
        unimplemented!();
    }
}

impl<'gcc, 'tcx> DebugInfoMethods<'tcx> for CodegenCx<'gcc, 'tcx> {
    fn create_vtable_metadata(&self, _ty: Ty<'tcx>, _vtable: Self::Value) {
        // TODO(antoyo)
    }

    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>> {
        // TODO(antoyo)
        None
    }

    fn extend_scope_to_file(&self, _scope_metadata: Self::DIScope, _file: &SourceFile) -> Self::DIScope {
        unimplemented!();
    }

    fn debuginfo_finalize(&self) {
        // TODO(antoyo)
    }

    fn create_dbg_var(&self, _variable_name: Symbol, _variable_type: Ty<'tcx>, _scope_metadata: Self::DIScope, _variable_kind: VariableKind, _span: Span) -> Self::DIVariable {
        unimplemented!();
    }

    fn dbg_scope_fn(&self, _instance: Instance<'tcx>, _fn_abi: &FnAbi<'tcx, Ty<'tcx>>, _maybe_definition_llfn: Option<RValue<'gcc>>) -> Self::DIScope {
        unimplemented!();
    }

    fn dbg_loc(&self, _scope: Self::DIScope, _inlined_at: Option<Self::DILocation>, _span: Span) -> Self::DILocation {
        unimplemented!();
    }
}