@@ -5,7 +5,6 @@ use rustc_codegen_ssa::mir::debuginfo::VariableKind::*;
55
66use self :: metadata:: { file_metadata, type_metadata, TypeMap } ;
77use self :: namespace:: mangled_name_of_instance;
8- use self :: source_loc:: InternalDebugLocation :: { self , UnknownLocation } ;
98use self :: type_names:: compute_debuginfo_type_name;
109use self :: utils:: { create_DIArray, is_node_local_to_unit, span_start, DIB } ;
1110
@@ -38,7 +37,7 @@ use std::ffi::CString;
3837use rustc:: ty:: layout:: { self , HasTyCtxt , LayoutOf , Size } ;
3938use rustc_codegen_ssa:: traits:: * ;
4039use rustc_span:: symbol:: Symbol ;
41- use rustc_span:: { self , BytePos , Pos , Span } ;
40+ use rustc_span:: { self , BytePos , Span } ;
4241use smallvec:: SmallVec ;
4342use syntax:: ast;
4443
@@ -52,7 +51,6 @@ mod utils;
5251pub use self :: create_scope_map:: compute_mir_scopes;
5352pub use self :: metadata:: create_global_var_metadata;
5453pub use self :: metadata:: extend_scope_to_file;
55- pub use self :: source_loc:: set_source_location;
5654
5755#[ allow( non_upper_case_globals) ]
5856const DW_TAG_auto_variable : c_uint = 0x100 ;
@@ -148,20 +146,18 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
148146 // names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
149147 fn dbg_var_addr (
150148 & mut self ,
151- dbg_context : & FunctionDebugContext < & ' ll DIScope > ,
152149 dbg_var : & ' ll DIVariable ,
153150 scope_metadata : & ' ll DIScope ,
154151 variable_alloca : Self :: Value ,
155152 direct_offset : Size ,
156153 indirect_offsets : & [ Size ] ,
157154 span : Span ,
158155 ) {
159- assert ! ( !dbg_context. source_locations_enabled) ;
160156 let cx = self . cx ( ) ;
161157
162- let loc = span_start ( cx, span) ;
163-
164158 // Convert the direct and indirect offsets to address ops.
159+ // FIXME(eddyb) use `const`s instead of getting the values via FFI,
160+ // the values should match the ones in the DWARF standard anyway.
165161 let op_deref = || unsafe { llvm:: LLVMRustDIBuilderCreateOpDeref ( ) } ;
166162 let op_plus_uconst = || unsafe { llvm:: LLVMRustDIBuilderCreateOpPlusUconst ( ) } ;
167163 let mut addr_ops = SmallVec :: < [ _ ; 8 ] > :: new ( ) ;
@@ -178,37 +174,32 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
178174 }
179175 }
180176
181- // FIXME(eddyb) maybe this information could be extracted from `var `,
177+ // FIXME(eddyb) maybe this information could be extracted from `dbg_var `,
182178 // to avoid having to pass it down in both places?
183- source_loc:: set_debug_location (
184- self ,
185- InternalDebugLocation :: new ( scope_metadata, loc. line , loc. col . to_usize ( ) ) ,
186- ) ;
179+ // NB: `var` doesn't seem to know about the column, so that's a limitation.
180+ let dbg_loc = cx. create_debug_loc ( scope_metadata, span) ;
187181 unsafe {
188- let debug_loc = llvm:: LLVMGetCurrentDebugLocation ( self . llbuilder ) ;
189182 // FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
190- let instr = llvm:: LLVMRustDIBuilderInsertDeclareAtEnd (
183+ llvm:: LLVMRustDIBuilderInsertDeclareAtEnd (
191184 DIB ( cx) ,
192185 variable_alloca,
193186 dbg_var,
194187 addr_ops. as_ptr ( ) ,
195188 addr_ops. len ( ) as c_uint ,
196- debug_loc ,
189+ dbg_loc ,
197190 self . llbb ( ) ,
198191 ) ;
199-
200- llvm:: LLVMSetInstDebugLocation ( self . llbuilder , instr) ;
201192 }
202- source_loc:: set_debug_location ( self , UnknownLocation ) ;
203193 }
204194
205- fn set_source_location (
206- & mut self ,
207- debug_context : & mut FunctionDebugContext < & ' ll DIScope > ,
208- scope : & ' ll DIScope ,
209- span : Span ,
210- ) {
211- set_source_location ( debug_context, & self , scope, span)
195+ fn set_source_location ( & mut self , scope : & ' ll DIScope , span : Span ) {
196+ debug ! ( "set_source_location: {}" , self . sess( ) . source_map( ) . span_to_string( span) ) ;
197+
198+ let dbg_loc = self . cx ( ) . create_debug_loc ( scope, span) ;
199+
200+ unsafe {
201+ llvm:: LLVMSetCurrentDebugLocation ( self . llbuilder , dbg_loc) ;
202+ }
212203 }
213204 fn insert_reference_to_gdb_debug_scripts_section_global ( & mut self ) {
214205 gdb:: insert_reference_to_gdb_debug_scripts_section_global ( self )
@@ -342,7 +333,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
342333 } ;
343334 let mut fn_debug_context = FunctionDebugContext {
344335 scopes : IndexVec :: from_elem ( null_scope, & mir. source_scopes ) ,
345- source_locations_enabled : false ,
346336 defining_crate : def_id. krate ,
347337 } ;
348338
0 commit comments