File tree 4 files changed +23
-17
lines changed
rustc_codegen_llvm/src/debuginfo
4 files changed +23
-17
lines changed Original file line number Diff line number Diff line change @@ -7,14 +7,12 @@ use crate::common::CodegenCx;
7
7
use crate :: value:: Value ;
8
8
use rustc_codegen_ssa:: traits:: * ;
9
9
use rustc_middle:: bug;
10
- use rustc_session:: config:: DebugInfo ;
11
-
12
- use rustc_span:: symbol:: sym;
10
+ use rustc_span:: def_id:: LOCAL_CRATE ;
13
11
14
12
/// Inserts a side-effect free instruction sequence that makes sure that the
15
13
/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
16
14
pub fn insert_reference_to_gdb_debug_scripts_section_global ( bx : & mut Builder < ' _ , ' _ , ' _ > ) {
17
- if needs_gdb_debug_scripts_section ( bx ) {
15
+ if bx . tcx . needs_gdb_debug_scripts_section ( LOCAL_CRATE ) {
18
16
let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global ( bx) ;
19
17
// Load just the first byte as that's all that's necessary to force
20
18
// LLVM to keep around the reference to the global.
@@ -58,14 +56,3 @@ pub fn get_or_insert_gdb_debug_scripts_section_global(cx: &CodegenCx<'ll, '_>) -
58
56
}
59
57
} )
60
58
}
61
-
62
- pub fn needs_gdb_debug_scripts_section ( cx : & CodegenCx < ' _ , ' _ > ) -> bool {
63
- let omit_gdb_pretty_printer_section = cx
64
- . tcx
65
- . sess
66
- . contains_name ( & cx. tcx . hir ( ) . krate_attrs ( ) , sym:: omit_gdb_pretty_printer_section) ;
67
-
68
- !omit_gdb_pretty_printer_section
69
- && cx. sess ( ) . opts . debuginfo != DebugInfo :: None
70
- && cx. sess ( ) . target . emit_debug_gdb_scripts
71
- }
Original file line number Diff line number Diff line change @@ -106,7 +106,7 @@ pub fn finalize(cx: &CodegenCx<'_, '_>) {
106
106
107
107
debug ! ( "finalize" ) ;
108
108
109
- if gdb :: needs_gdb_debug_scripts_section ( cx ) {
109
+ if cx . tcx . needs_gdb_debug_scripts_section ( LOCAL_CRATE ) {
110
110
// Add a .debug_gdb_scripts section to this compile-unit. This will
111
111
// cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
112
112
// which activates the Rust pretty printers for binary this section is
Original file line number Diff line number Diff line change @@ -28,8 +28,9 @@ use rustc_middle::ty::layout::{FAT_PTR_ADDR, FAT_PTR_EXTRA};
28
28
use rustc_middle:: ty:: query:: Providers ;
29
29
use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt } ;
30
30
use rustc_session:: cgu_reuse_tracker:: CguReuse ;
31
- use rustc_session:: config:: { self , EntryFnType } ;
31
+ use rustc_session:: config:: { self , DebugInfo , EntryFnType } ;
32
32
use rustc_session:: Session ;
33
+ use rustc_span:: sym;
33
34
use rustc_target:: abi:: { Align , LayoutOf , VariantIdx } ;
34
35
35
36
use std:: cmp;
@@ -828,6 +829,17 @@ pub fn provide(providers: &mut Providers) {
828
829
}
829
830
tcx. sess . opts . optimize
830
831
} ;
832
+
833
+ providers. needs_gdb_debug_scripts_section = |tcx, cnum| {
834
+ assert_eq ! ( cnum, LOCAL_CRATE ) ;
835
+
836
+ let omit_gdb_pretty_printer_section =
837
+ tcx. sess . contains_name ( & tcx. hir ( ) . krate_attrs ( ) , sym:: omit_gdb_pretty_printer_section) ;
838
+
839
+ !omit_gdb_pretty_printer_section
840
+ && tcx. sess . opts . debuginfo != DebugInfo :: None
841
+ && tcx. sess . target . emit_debug_gdb_scripts
842
+ } ;
831
843
}
832
844
833
845
fn determine_cgu_reuse < ' tcx > ( tcx : TyCtxt < ' tcx > , cgu : & CodegenUnit < ' tcx > ) -> CguReuse {
Original file line number Diff line number Diff line change @@ -1214,6 +1214,13 @@ rustc_queries! {
1214
1214
desc { "looking up the paths for extern crates" }
1215
1215
}
1216
1216
1217
+ /// Determines if we need to emit a GDB debug script section
1218
+ /// during codegen for the current crate. The CrateNum
1219
+ /// should always be LOCAL_CRATE
1220
+ query needs_gdb_debug_scripts_section( _: CrateNum ) -> bool {
1221
+ desc { "determine if the current crate needs a gdb debug scripts section" }
1222
+ }
1223
+
1217
1224
/// Given a crate and a trait, look up all impls of that trait in the crate.
1218
1225
/// Return `(impl_id, self_ty)`.
1219
1226
query implementations_of_trait( _: ( CrateNum , DefId ) )
You can’t perform that action at this time.
0 commit comments