File tree Expand file tree Collapse file tree 4 files changed +23
-17
lines changed
rustc_codegen_llvm/src/debuginfo Expand file tree Collapse file tree 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;
77use crate :: value:: Value ;
88use rustc_codegen_ssa:: traits:: * ;
99use rustc_middle:: bug;
10- use rustc_session:: config:: DebugInfo ;
11-
12- use rustc_span:: symbol:: sym;
10+ use rustc_span:: def_id:: LOCAL_CRATE ;
1311
1412/// Inserts a side-effect free instruction sequence that makes sure that the
1513/// .debug_gdb_scripts global is referenced, so it isn't removed by the linker.
1614pub 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 ) {
1816 let gdb_debug_scripts_section = get_or_insert_gdb_debug_scripts_section_global ( bx) ;
1917 // Load just the first byte as that's all that's necessary to force
2018 // 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, '_>) -
5856 }
5957 } )
6058}
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<'_, '_>) {
106106
107107 debug ! ( "finalize" ) ;
108108
109- if gdb :: needs_gdb_debug_scripts_section ( cx ) {
109+ if cx . tcx . needs_gdb_debug_scripts_section ( LOCAL_CRATE ) {
110110 // Add a .debug_gdb_scripts section to this compile-unit. This will
111111 // cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
112112 // 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};
2828use rustc_middle:: ty:: query:: Providers ;
2929use rustc_middle:: ty:: { self , Instance , Ty , TyCtxt } ;
3030use rustc_session:: cgu_reuse_tracker:: CguReuse ;
31- use rustc_session:: config:: { self , EntryFnType } ;
31+ use rustc_session:: config:: { self , DebugInfo , EntryFnType } ;
3232use rustc_session:: Session ;
33+ use rustc_span:: sym;
3334use rustc_target:: abi:: { Align , LayoutOf , VariantIdx } ;
3435
3536use std:: cmp;
@@ -828,6 +829,17 @@ pub fn provide(providers: &mut Providers) {
828829 }
829830 tcx. sess . opts . optimize
830831 } ;
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+ } ;
831843}
832844
833845fn 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! {
12141214 desc { "looking up the paths for extern crates" }
12151215 }
12161216
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+
12171224 /// Given a crate and a trait, look up all impls of that trait in the crate.
12181225 /// Return `(impl_id, self_ty)`.
12191226 query implementations_of_trait( _: ( CrateNum , DefId ) )
You can’t perform that action at this time.
0 commit comments