@@ -30,7 +30,7 @@ use tracing::debug;
30
30
31
31
use self :: metadata:: { UNKNOWN_COLUMN_NUMBER , UNKNOWN_LINE_NUMBER , file_metadata, type_di_node} ;
32
32
use self :: namespace:: mangled_name_of_instance;
33
- use self :: utils:: { DIB , create_DIArray, is_node_local_to_unit} ;
33
+ use self :: utils:: { DIB , create_DIArray, debug_context , is_node_local_to_unit} ;
34
34
use crate :: builder:: Builder ;
35
35
use crate :: common:: { AsCCharPtr , CodegenCx } ;
36
36
use crate :: llvm;
@@ -131,20 +131,22 @@ impl<'ll, 'tcx> CodegenUnitDebugContext<'ll, 'tcx> {
131
131
}
132
132
133
133
/// Creates any deferred debug metadata nodes
134
- pub ( crate ) fn finalize ( cx : & CodegenCx < ' _ , ' _ > ) {
135
- if let Some ( dbg_cx) = & cx. dbg_cx {
136
- debug ! ( "finalize" ) ;
137
-
138
- if gdb:: needs_gdb_debug_scripts_section ( cx) {
139
- // Add a .debug_gdb_scripts section to this compile-unit. This will
140
- // cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
141
- // which activates the Rust pretty printers for binary this section is
142
- // contained in.
143
- gdb:: get_or_insert_gdb_debug_scripts_section_global ( cx) ;
144
- }
134
+ pub ( crate ) fn finalize ( cx : & mut CodegenCx < ' _ , ' _ > ) {
135
+ if cx. dbg_cx . is_none ( ) {
136
+ return ;
137
+ }
138
+
139
+ debug ! ( "finalize" ) ;
145
140
146
- dbg_cx. finalize ( cx. sess ( ) ) ;
141
+ if gdb:: needs_gdb_debug_scripts_section ( cx) {
142
+ // Add a .debug_gdb_scripts section to this compile-unit. This will
143
+ // cause GDB to try and load the gdb_load_rust_pretty_printers.py file,
144
+ // which activates the Rust pretty printers for binary this section is
145
+ // contained in.
146
+ gdb:: get_or_insert_gdb_debug_scripts_section_global ( cx) ;
147
147
}
148
+
149
+ debug_context ( cx) . finalize ( cx. sess ( ) ) ;
148
150
}
149
151
150
152
impl < ' ll > Builder < ' _ , ' ll , ' _ > {
@@ -215,10 +217,6 @@ impl<'ll> DebugInfoBuilderMethods for Builder<'_, 'll, '_> {
215
217
}
216
218
}
217
219
218
- fn insert_reference_to_gdb_debug_scripts_section_global ( & mut self ) {
219
- gdb:: insert_reference_to_gdb_debug_scripts_section_global ( self )
220
- }
221
-
222
220
fn set_var_name ( & mut self , value : & ' ll Value , name : & str ) {
223
221
// Avoid wasting time if LLVM value names aren't even enabled.
224
222
if self . sess ( ) . fewer_names ( ) {
@@ -614,7 +612,7 @@ impl<'ll, 'tcx> DebugInfoCodegenMethods<'tcx> for CodegenCx<'ll, 'tcx> {
614
612
metadata:: extend_scope_to_file ( self , scope_metadata, file)
615
613
}
616
614
617
- fn debuginfo_finalize ( & self ) {
615
+ fn debuginfo_finalize ( & mut self ) {
618
616
finalize ( self )
619
617
}
620
618
0 commit comments