@@ -9,7 +9,7 @@ use crate::prelude::*;
9
9
use rustc_index:: vec:: IndexVec ;
10
10
11
11
use cranelift_codegen:: entity:: EntityRef ;
12
- use cranelift_codegen:: ir:: { StackSlots , ValueLabel , ValueLoc } ;
12
+ use cranelift_codegen:: ir:: { LabelValueLoc , StackSlots , ValueLabel , ValueLoc } ;
13
13
use cranelift_codegen:: isa:: TargetIsa ;
14
14
use cranelift_codegen:: ValueLocRange ;
15
15
@@ -39,7 +39,6 @@ pub(crate) struct DebugContext<'tcx> {
39
39
dwarf : DwarfUnit ,
40
40
unit_range_list : RangeList ,
41
41
42
- clif_types : FxHashMap < Type , UnitEntryId > ,
43
42
types : FxHashMap < Ty < ' tcx > , UnitEntryId > ,
44
43
}
45
44
@@ -115,48 +114,10 @@ impl<'tcx> DebugContext<'tcx> {
115
114
dwarf,
116
115
unit_range_list : RangeList ( Vec :: new ( ) ) ,
117
116
118
- clif_types : FxHashMap :: default ( ) ,
119
117
types : FxHashMap :: default ( ) ,
120
118
}
121
119
}
122
120
123
- fn dwarf_ty_for_clif_ty ( & mut self , ty : Type ) -> UnitEntryId {
124
- if let Some ( type_id) = self . clif_types . get ( & ty) {
125
- return * type_id;
126
- }
127
-
128
- let new_entry = |dwarf : & mut DwarfUnit , tag| dwarf. unit . add ( dwarf. unit . root ( ) , tag) ;
129
-
130
- let primitive = |dwarf : & mut DwarfUnit , ate| {
131
- let type_id = new_entry ( dwarf, gimli:: DW_TAG_base_type ) ;
132
- let type_entry = dwarf. unit . get_mut ( type_id) ;
133
- type_entry. set ( gimli:: DW_AT_encoding , AttributeValue :: Encoding ( ate) ) ;
134
- type_id
135
- } ;
136
-
137
- let type_id = if ty. is_bool ( ) {
138
- primitive ( & mut self . dwarf , gimli:: DW_ATE_boolean )
139
- } else if ty. is_int ( ) {
140
- primitive ( & mut self . dwarf , gimli:: DW_ATE_address )
141
- } else if ty. is_float ( ) {
142
- primitive ( & mut self . dwarf , gimli:: DW_ATE_float )
143
- } else {
144
- new_entry ( & mut self . dwarf , gimli:: DW_TAG_structure_type )
145
- } ;
146
-
147
- let type_entry = self . dwarf . unit . get_mut ( type_id) ;
148
- type_entry. set (
149
- gimli:: DW_AT_name ,
150
- AttributeValue :: String ( format ! ( "{}" , ty) . replace ( 'i' , "u" ) . into_bytes ( ) ) ,
151
- ) ;
152
- type_entry. set (
153
- gimli:: DW_AT_byte_size ,
154
- AttributeValue :: Udata ( u64:: from ( ty. bytes ( ) ) ) ,
155
- ) ;
156
-
157
- type_id
158
- }
159
-
160
121
fn dwarf_ty ( & mut self , ty : Ty < ' tcx > ) -> UnitEntryId {
161
122
if let Some ( type_id) = self . types . get ( ty) {
162
123
return * type_id;
@@ -312,51 +273,6 @@ impl<'tcx> DebugContext<'tcx> {
312
273
// Using Udata for DW_AT_high_pc requires at least DWARF4
313
274
func_entry. set ( gimli:: DW_AT_high_pc , AttributeValue :: Udata ( u64:: from ( end) ) ) ;
314
275
315
- // FIXME Remove once actual debuginfo for locals works.
316
- for ( i, ( param, & val) ) in context
317
- . func
318
- . signature
319
- . params
320
- . iter ( )
321
- . zip (
322
- context
323
- . func
324
- . dfg
325
- . block_params ( context. func . layout . entry_block ( ) . unwrap ( ) ) ,
326
- )
327
- . enumerate ( )
328
- {
329
- use cranelift_codegen:: ir:: ArgumentPurpose ;
330
- let base_name = match param. purpose {
331
- ArgumentPurpose :: Normal => "arg" ,
332
- ArgumentPurpose :: StructArgument ( _) => "struct_arg" ,
333
- ArgumentPurpose :: StructReturn => "sret" ,
334
- ArgumentPurpose :: Link
335
- | ArgumentPurpose :: FramePointer
336
- | ArgumentPurpose :: CalleeSaved => continue ,
337
- ArgumentPurpose :: VMContext
338
- | ArgumentPurpose :: SignatureId
339
- | ArgumentPurpose :: CallerTLS
340
- | ArgumentPurpose :: CalleeTLS
341
- | ArgumentPurpose :: StackLimit => unreachable ! ( ) ,
342
- } ;
343
- let name = format ! ( "{}{}" , base_name, i) ;
344
-
345
- let dw_ty = self . dwarf_ty_for_clif_ty ( param. value_type ) ;
346
- let loc =
347
- translate_loc ( isa, context. func . locations [ val] , & context. func . stack_slots ) . unwrap ( ) ;
348
-
349
- let arg_id = self
350
- . dwarf
351
- . unit
352
- . add ( entry_id, gimli:: DW_TAG_formal_parameter ) ;
353
- let var_entry = self . dwarf . unit . get_mut ( arg_id) ;
354
-
355
- var_entry. set ( gimli:: DW_AT_name , AttributeValue :: String ( name. into_bytes ( ) ) ) ;
356
- var_entry. set ( gimli:: DW_AT_type , AttributeValue :: UnitRef ( dw_ty) ) ;
357
- var_entry. set ( gimli:: DW_AT_location , AttributeValue :: Exprloc ( loc) ) ;
358
- }
359
-
360
276
// FIXME make it more reliable and implement scopes before re-enabling this.
361
277
if false {
362
278
let value_labels_ranges = context. build_value_labels_ranges ( isa) . unwrap ( ) ;
@@ -463,17 +379,17 @@ fn place_location<'tcx>(
463
379
// Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137
464
380
fn translate_loc (
465
381
isa : & dyn TargetIsa ,
466
- loc : ValueLoc ,
382
+ loc : LabelValueLoc ,
467
383
stack_slots : & StackSlots ,
468
384
) -> Option < Expression > {
469
385
match loc {
470
- ValueLoc :: Reg ( reg) => {
386
+ LabelValueLoc :: ValueLoc ( ValueLoc :: Reg ( reg) ) => {
471
387
let machine_reg = isa. map_dwarf_register ( reg) . unwrap ( ) ;
472
388
let mut expr = Expression :: new ( ) ;
473
389
expr. op_reg ( gimli:: Register ( machine_reg) ) ;
474
390
Some ( expr)
475
391
}
476
- ValueLoc :: Stack ( ss) => {
392
+ LabelValueLoc :: ValueLoc ( ValueLoc :: Stack ( ss) ) => {
477
393
if let Some ( ss_offset) = stack_slots[ ss] . offset {
478
394
let mut expr = Expression :: new ( ) ;
479
395
expr. op_breg ( X86_64 :: RBP , i64:: from ( ss_offset) + 16 ) ;
@@ -482,6 +398,17 @@ fn translate_loc(
482
398
None
483
399
}
484
400
}
485
- _ => None ,
401
+ LabelValueLoc :: ValueLoc ( ValueLoc :: Unassigned ) => unreachable ! ( ) ,
402
+ LabelValueLoc :: Reg ( reg) => {
403
+ let machine_reg = isa. map_regalloc_reg_to_dwarf ( reg) . unwrap ( ) ;
404
+ let mut expr = Expression :: new ( ) ;
405
+ expr. op_reg ( gimli:: Register ( machine_reg) ) ;
406
+ Some ( expr)
407
+ }
408
+ LabelValueLoc :: SPOffset ( offset) => {
409
+ let mut expr = Expression :: new ( ) ;
410
+ expr. op_breg ( X86_64 :: RSP , offset) ;
411
+ Some ( expr)
412
+ }
486
413
}
487
414
}
0 commit comments