@@ -7,8 +7,8 @@ use cranelift::codegen::ir::{StackSlots, ValueLoc};
7
7
use cranelift:: codegen:: isa:: RegUnit ;
8
8
9
9
use gimli:: write:: {
10
- self , Address , AttributeValue , DwarfUnit , Expression , LineProgram , LineString ,
11
- Location , LocationList , Range , RangeList , UnitEntryId , Writer ,
10
+ self , Address , AttributeValue , DwarfUnit , Expression , LineProgram , LineString , Location ,
11
+ LocationList , Range , RangeList , UnitEntryId , Writer ,
12
12
} ;
13
13
use gimli:: { Encoding , Format , LineEncoding , Register , RunTimeEndian , X86_64 } ;
14
14
@@ -105,9 +105,7 @@ impl<'tcx> DebugContext<'tcx> {
105
105
return * type_id;
106
106
}
107
107
108
- let new_entry = |dwarf : & mut DwarfUnit , tag| {
109
- dwarf. unit . add ( dwarf. unit . root ( ) , tag)
110
- } ;
108
+ let new_entry = |dwarf : & mut DwarfUnit , tag| dwarf. unit . add ( dwarf. unit . root ( ) , tag) ;
111
109
112
110
let primtive = |dwarf : & mut DwarfUnit , ate| {
113
111
let type_id = new_entry ( dwarf, gimli:: DW_TAG_base_type ) ;
@@ -122,7 +120,11 @@ impl<'tcx> DebugContext<'tcx> {
122
120
ty:: Uint ( _) => primtive ( & mut self . dwarf , gimli:: DW_ATE_unsigned ) ,
123
121
ty:: Int ( _) => primtive ( & mut self . dwarf , gimli:: DW_ATE_signed ) ,
124
122
ty:: Float ( _) => primtive ( & mut self . dwarf , gimli:: DW_ATE_float ) ,
125
- ty:: Ref ( _, pointee_ty, mutbl) | ty:: RawPtr ( ty:: TypeAndMut { ty : pointee_ty, mutbl } ) => {
123
+ ty:: Ref ( _, pointee_ty, mutbl)
124
+ | ty:: RawPtr ( ty:: TypeAndMut {
125
+ ty : pointee_ty,
126
+ mutbl,
127
+ } ) => {
126
128
let type_id = new_entry ( & mut self . dwarf , gimli:: DW_TAG_pointer_type ) ;
127
129
128
130
// Ensure that type is inserted before recursing to avoid duplicates
@@ -145,7 +147,10 @@ impl<'tcx> DebugContext<'tcx> {
145
147
let type_entry = self . dwarf . unit . get_mut ( type_id) ;
146
148
147
149
type_entry. set ( gimli:: DW_AT_name , AttributeValue :: String ( name. into_bytes ( ) ) ) ;
148
- type_entry. set ( gimli:: DW_AT_byte_size , AttributeValue :: Udata ( layout. size . bytes ( ) ) ) ;
150
+ type_entry. set (
151
+ gimli:: DW_AT_byte_size ,
152
+ AttributeValue :: Udata ( layout. size . bytes ( ) ) ,
153
+ ) ;
149
154
150
155
self . types . insert ( ty, type_id) ;
151
156
@@ -219,14 +224,8 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
219
224
. add ( self . entry_id , gimli:: DW_TAG_variable ) ;
220
225
let var_entry = self . debug_context . dwarf . unit . get_mut ( var_id) ;
221
226
222
- var_entry. set (
223
- gimli:: DW_AT_name ,
224
- AttributeValue :: String ( name. into_bytes ( ) ) ,
225
- ) ;
226
- var_entry. set (
227
- gimli:: DW_AT_type ,
228
- AttributeValue :: ThisUnitEntryRef ( dw_ty) ,
229
- ) ;
227
+ var_entry. set ( gimli:: DW_AT_name , AttributeValue :: String ( name. into_bytes ( ) ) ) ;
228
+ var_entry. set ( gimli:: DW_AT_type , AttributeValue :: ThisUnitEntryRef ( dw_ty) ) ;
230
229
231
230
var_id
232
231
}
@@ -250,38 +249,36 @@ impl<'a, 'tcx> FunctionDebugContext<'a, 'tcx> {
250
249
length : end as u64 ,
251
250
} ) ;
252
251
253
- {
254
- let value_labels_ranges = context. build_value_labels_ranges ( isa) . unwrap ( ) ;
255
-
256
- for ( value_label, value_loc_ranges) in value_labels_ranges. iter ( ) {
257
- let var_id = self . define_local ( mir:: Local :: from_u32 ( value_label. as_u32 ( ) ) ) ;
258
-
259
- let loc_list = LocationList (
260
- value_loc_ranges
261
- . iter ( )
262
- . map ( |value_loc_range| {
263
- Location :: StartEnd {
264
- begin : Address :: Symbol {
265
- symbol : self . symbol ,
266
- addend : i64:: from ( value_loc_range. start ) ,
267
- } ,
268
- end : Address :: Symbol {
269
- symbol : self . symbol ,
270
- addend : i64:: from ( value_loc_range. end ) ,
271
- } ,
272
- data : Expression ( translate_loc ( value_loc_range. loc , & context. func . stack_slots ) . unwrap ( ) ) ,
273
- }
274
- } )
275
- . collect ( ) ,
276
- ) ;
277
- let loc_list_id = self . debug_context . dwarf . unit . locations . add ( loc_list) ;
278
-
279
- let var_entry = self . debug_context . dwarf . unit . get_mut ( var_id) ;
280
- var_entry. set (
281
- gimli:: DW_AT_location ,
282
- AttributeValue :: LocationListRef ( loc_list_id) ,
283
- ) ;
284
- }
252
+ let value_labels_ranges = context. build_value_labels_ranges ( isa) . unwrap ( ) ;
253
+
254
+ for ( value_label, value_loc_ranges) in value_labels_ranges. iter ( ) {
255
+ let var_id = self . define_local ( mir:: Local :: from_u32 ( value_label. as_u32 ( ) ) ) ;
256
+
257
+ let loc_list = LocationList (
258
+ value_loc_ranges
259
+ . iter ( )
260
+ . map ( |value_loc_range| Location :: StartEnd {
261
+ begin : Address :: Symbol {
262
+ symbol : self . symbol ,
263
+ addend : i64:: from ( value_loc_range. start ) ,
264
+ } ,
265
+ end : Address :: Symbol {
266
+ symbol : self . symbol ,
267
+ addend : i64:: from ( value_loc_range. end ) ,
268
+ } ,
269
+ data : Expression (
270
+ translate_loc ( value_loc_range. loc , & context. func . stack_slots ) . unwrap ( ) ,
271
+ ) ,
272
+ } )
273
+ . collect ( ) ,
274
+ ) ;
275
+ let loc_list_id = self . debug_context . dwarf . unit . locations . add ( loc_list) ;
276
+
277
+ let var_entry = self . debug_context . dwarf . unit . get_mut ( var_id) ;
278
+ var_entry. set (
279
+ gimli:: DW_AT_location ,
280
+ AttributeValue :: LocationListRef ( loc_list_id) ,
281
+ ) ;
285
282
}
286
283
}
287
284
}
0 commit comments