@@ -5,7 +5,6 @@ use rustc_codegen_ssa::mir::debuginfo::VariableKind::*;
5
5
6
6
use self :: metadata:: { file_metadata, type_metadata, TypeMap } ;
7
7
use self :: namespace:: mangled_name_of_instance;
8
- use self :: source_loc:: InternalDebugLocation :: { self , UnknownLocation } ;
9
8
use self :: type_names:: compute_debuginfo_type_name;
10
9
use self :: utils:: { create_DIArray, is_node_local_to_unit, span_start, DIB } ;
11
10
@@ -38,7 +37,7 @@ use std::ffi::CString;
38
37
use rustc:: ty:: layout:: { self , HasTyCtxt , LayoutOf , Size } ;
39
38
use rustc_codegen_ssa:: traits:: * ;
40
39
use rustc_span:: symbol:: Symbol ;
41
- use rustc_span:: { self , BytePos , Pos , Span } ;
40
+ use rustc_span:: { self , BytePos , Span } ;
42
41
use smallvec:: SmallVec ;
43
42
use syntax:: ast;
44
43
@@ -52,7 +51,6 @@ mod utils;
52
51
pub use self :: create_scope_map:: compute_mir_scopes;
53
52
pub use self :: metadata:: create_global_var_metadata;
54
53
pub use self :: metadata:: extend_scope_to_file;
55
- pub use self :: source_loc:: set_source_location;
56
54
57
55
#[ allow( non_upper_case_globals) ]
58
56
const DW_TAG_auto_variable : c_uint = 0x100 ;
@@ -148,20 +146,18 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
148
146
// names (choose between `dbg`, `debug`, `debuginfo`, `debug_info` etc.).
149
147
fn dbg_var_addr (
150
148
& mut self ,
151
- dbg_context : & FunctionDebugContext < & ' ll DIScope > ,
152
149
dbg_var : & ' ll DIVariable ,
153
150
scope_metadata : & ' ll DIScope ,
154
151
variable_alloca : Self :: Value ,
155
152
direct_offset : Size ,
156
153
indirect_offsets : & [ Size ] ,
157
154
span : Span ,
158
155
) {
159
- assert ! ( !dbg_context. source_locations_enabled) ;
160
156
let cx = self . cx ( ) ;
161
157
162
- let loc = span_start ( cx, span) ;
163
-
164
158
// 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.
165
161
let op_deref = || unsafe { llvm:: LLVMRustDIBuilderCreateOpDeref ( ) } ;
166
162
let op_plus_uconst = || unsafe { llvm:: LLVMRustDIBuilderCreateOpPlusUconst ( ) } ;
167
163
let mut addr_ops = SmallVec :: < [ _ ; 8 ] > :: new ( ) ;
@@ -178,37 +174,32 @@ impl DebugInfoBuilderMethods for Builder<'a, 'll, 'tcx> {
178
174
}
179
175
}
180
176
181
- // FIXME(eddyb) maybe this information could be extracted from `var `,
177
+ // FIXME(eddyb) maybe this information could be extracted from `dbg_var `,
182
178
// 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) ;
187
181
unsafe {
188
- let debug_loc = llvm:: LLVMGetCurrentDebugLocation ( self . llbuilder ) ;
189
182
// FIXME(eddyb) replace `llvm.dbg.declare` with `llvm.dbg.addr`.
190
- let instr = llvm:: LLVMRustDIBuilderInsertDeclareAtEnd (
183
+ llvm:: LLVMRustDIBuilderInsertDeclareAtEnd (
191
184
DIB ( cx) ,
192
185
variable_alloca,
193
186
dbg_var,
194
187
addr_ops. as_ptr ( ) ,
195
188
addr_ops. len ( ) as c_uint ,
196
- debug_loc ,
189
+ dbg_loc ,
197
190
self . llbb ( ) ,
198
191
) ;
199
-
200
- llvm:: LLVMSetInstDebugLocation ( self . llbuilder , instr) ;
201
192
}
202
- source_loc:: set_debug_location ( self , UnknownLocation ) ;
203
193
}
204
194
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
+ }
212
203
}
213
204
fn insert_reference_to_gdb_debug_scripts_section_global ( & mut self ) {
214
205
gdb:: insert_reference_to_gdb_debug_scripts_section_global ( self )
@@ -342,7 +333,6 @@ impl DebugInfoMethods<'tcx> for CodegenCx<'ll, 'tcx> {
342
333
} ;
343
334
let mut fn_debug_context = FunctionDebugContext {
344
335
scopes : IndexVec :: from_elem ( null_scope, & mir. source_scopes ) ,
345
- source_locations_enabled : false ,
346
336
defining_crate : def_id. krate ,
347
337
} ;
348
338
0 commit comments