@@ -9,8 +9,8 @@ use cranelift_codegen::isa::TargetIsa;
9
9
use cranelift_codegen:: ValueLocRange ;
10
10
11
11
use gimli:: write:: {
12
- self , Address , AttributeValue , DwarfUnit , Expression , LineProgram ,
13
- LineString , Location , LocationList , Range , RangeList , UnitEntryId , Writer ,
12
+ Address , AttributeValue , DwarfUnit , Expression , LineProgram ,
13
+ LineString , Location , LocationList , Range , RangeList , UnitEntryId ,
14
14
} ;
15
15
use gimli:: { Encoding , Format , LineEncoding , RunTimeEndian , X86_64 } ;
16
16
@@ -187,7 +187,7 @@ impl<'tcx> DebugContext<'tcx> {
187
187
let type_entry = self . dwarf . unit . get_mut ( type_id) ;
188
188
189
189
//type_entry.set(gimli::DW_AT_mutable, AttributeValue::Flag(mutbl == rustc_hir::Mutability::Mut));
190
- type_entry. set ( gimli:: DW_AT_type , AttributeValue :: ThisUnitEntryRef ( pointee) ) ;
190
+ type_entry. set ( gimli:: DW_AT_type , AttributeValue :: UnitRef ( pointee) ) ;
191
191
192
192
type_id
193
193
}
@@ -213,7 +213,7 @@ impl<'tcx> DebugContext<'tcx> {
213
213
214
214
field_entry. set ( gimli:: DW_AT_name , AttributeValue :: String ( field_def. ident . as_str ( ) . to_string ( ) . into_bytes ( ) ) ) ;
215
215
field_entry. set ( gimli:: DW_AT_data_member_location , AttributeValue :: Udata ( field_offset. bytes ( ) ) ) ;
216
- field_entry. set ( gimli:: DW_AT_type , AttributeValue :: ThisUnitEntryRef ( field_type) ) ;
216
+ field_entry. set ( gimli:: DW_AT_type , AttributeValue :: UnitRef ( field_type) ) ;
217
217
}
218
218
219
219
type_id
@@ -291,7 +291,7 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
291
291
let var_entry = self . debug_context . dwarf . unit . get_mut ( var_id) ;
292
292
293
293
var_entry. set ( gimli:: DW_AT_name , AttributeValue :: String ( name. into_bytes ( ) ) ) ;
294
- var_entry. set ( gimli:: DW_AT_type , AttributeValue :: ThisUnitEntryRef ( dw_ty) ) ;
294
+ var_entry. set ( gimli:: DW_AT_type , AttributeValue :: UnitRef ( dw_ty) ) ;
295
295
296
296
var_id
297
297
}
@@ -341,15 +341,13 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
341
341
let name = format ! ( "{}{}" , base_name, i) ;
342
342
343
343
let dw_ty = self . debug_context . dwarf_ty_for_clif_ty ( param. value_type ) ;
344
- let loc = Expression (
345
- translate_loc ( isa, context. func . locations [ val] , & context. func . stack_slots ) . unwrap ( ) ,
346
- ) ;
344
+ let loc = translate_loc ( isa, context. func . locations [ val] , & context. func . stack_slots ) . unwrap ( ) ;
347
345
348
346
let arg_id = self . debug_context . dwarf . unit . add ( self . entry_id , gimli:: DW_TAG_formal_parameter ) ;
349
347
let var_entry = self . debug_context . dwarf . unit . get_mut ( arg_id) ;
350
348
351
349
var_entry. set ( gimli:: DW_AT_name , AttributeValue :: String ( name. into_bytes ( ) ) ) ;
352
- var_entry. set ( gimli:: DW_AT_type , AttributeValue :: ThisUnitEntryRef ( dw_ty) ) ;
350
+ var_entry. set ( gimli:: DW_AT_type , AttributeValue :: UnitRef ( dw_ty) ) ;
353
351
var_entry. set ( gimli:: DW_AT_location , AttributeValue :: Exprloc ( loc) ) ;
354
352
}
355
353
@@ -413,9 +411,7 @@ fn place_location<'a, 'tcx>(
413
411
symbol : func_debug_ctx. symbol ,
414
412
addend : i64:: from ( value_loc_range. end ) ,
415
413
} ,
416
- data : Expression (
417
- translate_loc ( isa, value_loc_range. loc , & context. func . stack_slots ) . unwrap ( ) ,
418
- ) ,
414
+ data : translate_loc ( isa, value_loc_range. loc , & context. func . stack_slots ) . unwrap ( ) ,
419
415
} )
420
416
. collect ( ) ,
421
417
) ;
@@ -425,40 +421,37 @@ fn place_location<'a, 'tcx>(
425
421
} else {
426
422
// FIXME set value labels for unused locals
427
423
428
- AttributeValue :: Exprloc ( Expression ( vec ! [ ] ) )
424
+ AttributeValue :: Exprloc ( Expression :: new ( ) )
429
425
}
430
426
}
431
427
CPlaceInner :: Addr ( _, _) => {
432
428
// FIXME implement this (used by arguments and returns)
433
429
434
- AttributeValue :: Exprloc ( Expression ( vec ! [ ] ) )
430
+ AttributeValue :: Exprloc ( Expression :: new ( ) )
435
431
436
432
// For PointerBase::Stack:
437
- //AttributeValue::Exprloc(Expression( translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap() ))
433
+ //AttributeValue::Exprloc(translate_loc(ValueLoc::Stack(*stack_slot), &context.func.stack_slots).unwrap())
438
434
}
439
435
}
440
436
}
441
437
442
438
// Adapted from https://github.com/CraneStation/wasmtime/blob/5a1845b4caf7a5dba8eda1fef05213a532ed4259/crates/debug/src/transform/expression.rs#L59-L137
443
- fn translate_loc ( isa : & dyn TargetIsa , loc : ValueLoc , stack_slots : & StackSlots ) -> Option < Vec < u8 > > {
439
+ fn translate_loc ( isa : & dyn TargetIsa , loc : ValueLoc , stack_slots : & StackSlots ) -> Option < Expression > {
444
440
match loc {
445
441
ValueLoc :: Reg ( reg) => {
446
442
let machine_reg = isa. map_dwarf_register ( reg) . unwrap ( ) ;
447
- assert ! ( machine_reg <= 32 ) ; // FIXME
448
- Some ( vec ! [ gimli:: constants:: DW_OP_reg0 . 0 + machine_reg as u8 ] )
443
+ let mut expr = Expression :: new ( ) ;
444
+ expr. op_reg ( gimli:: Register ( machine_reg) ) ;
445
+ Some ( expr)
449
446
}
450
447
ValueLoc :: Stack ( ss) => {
451
448
if let Some ( ss_offset) = stack_slots[ ss] . offset {
452
- let endian = gimli:: RunTimeEndian :: Little ;
453
- let mut writer = write:: EndianVec :: new ( endian) ;
454
- writer
455
- . write_u8 ( gimli:: constants:: DW_OP_breg0 . 0 + X86_64 :: RBP . 0 as u8 )
456
- . expect ( "bp wr" ) ;
457
- writer. write_sleb128 ( ss_offset as i64 + 16 ) . expect ( "ss wr" ) ;
458
- let buf = writer. into_vec ( ) ;
459
- return Some ( buf) ;
449
+ let mut expr = Expression :: new ( ) ;
450
+ expr. op_breg ( X86_64 :: RBP , ss_offset as i64 + 16 ) ;
451
+ Some ( expr)
452
+ } else {
453
+ None
460
454
}
461
- None
462
455
}
463
456
_ => None ,
464
457
}
0 commit comments