@@ -11,7 +11,7 @@ use gimli::write::{
11
11
RangeList , RangeListTable , Result , SectionId , StringTable , UnitEntryId , UnitId , UnitTable ,
12
12
Writer , FileId ,
13
13
} ;
14
- use gimli:: { Endianity , Format , RunTimeEndian } ;
14
+ use gimli:: { Encoding , Format , RunTimeEndian } ;
15
15
16
16
use faerie:: * ;
17
17
@@ -43,10 +43,8 @@ struct DebugReloc {
43
43
}
44
44
45
45
pub struct DebugContext < ' tcx > {
46
+ encoding : Encoding ,
46
47
endian : RunTimeEndian ,
47
- format : Format ,
48
- version : u16 ,
49
- address_size : u8 ,
50
48
51
49
symbols : indexmap:: IndexSet < String > ,
52
50
@@ -64,9 +62,13 @@ pub struct DebugContext<'tcx> {
64
62
65
63
impl < ' a , ' tcx : ' a > DebugContext < ' tcx > {
66
64
pub fn new ( tcx : TyCtxt , address_size : u8 ) -> Self {
67
- // TODO: this should be configurable
68
- let version = 3 ; // macOS doesn't seem to support DWARF > 3
69
- let format = Format :: Dwarf32 ;
65
+ let encoding = Encoding {
66
+ format : Format :: Dwarf32 ,
67
+ // TODO: this should be configurable
68
+ // macOS doesn't seem to support DWARF > 3
69
+ version : 3 ,
70
+ address_size,
71
+ } ;
70
72
71
73
// FIXME: how to get version when building out of tree?
72
74
// Normally this would use option_env!("CFG_VERSION").
@@ -83,9 +85,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> {
83
85
let range_lists = RangeListTable :: default ( ) ;
84
86
85
87
let global_line_program = line_programs. add ( LineProgram :: new (
86
- version,
87
- address_size,
88
- format,
88
+ encoding,
89
89
1 ,
90
90
1 ,
91
91
-5 ,
@@ -95,7 +95,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> {
95
95
None ,
96
96
) ) ;
97
97
98
- let unit_id = units. add ( CompilationUnit :: new ( version , address_size , format ) ) ;
98
+ let unit_id = units. add ( CompilationUnit :: new ( encoding ) ) ;
99
99
{
100
100
let name = strings. add ( & * name) ;
101
101
let comp_dir = strings. add ( & * comp_dir) ;
@@ -124,10 +124,8 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> {
124
124
}
125
125
126
126
DebugContext {
127
+ encoding,
127
128
endian : target_endian ( tcx) ,
128
- format,
129
- version,
130
- address_size,
131
129
132
130
symbols : indexmap:: IndexSet :: new ( ) ,
133
131
@@ -189,9 +187,7 @@ impl<'a, 'tcx: 'a> DebugContext<'tcx> {
189
187
. write (
190
188
& mut debug_ranges,
191
189
& mut debug_rnglists,
192
- self . format ,
193
- self . version ,
194
- self . address_size ,
190
+ self . encoding
195
191
)
196
192
. unwrap ( ) ;
197
193
self . units
@@ -417,9 +413,7 @@ impl<'a, 'b, 'tcx: 'b> FunctionDebugContext<'a, 'tcx> {
417
413
let unit = self . debug_context . units . get_mut ( self . debug_context . unit_id ) ;
418
414
// FIXME: add to appropriate scope intead of root
419
415
let entry = unit. get_mut ( self . entry_id ) ;
420
- let mut size_array = [ 0 ; 8 ] ;
421
- target_endian ( tcx) . write_u64 ( & mut size_array, code_size as u64 ) ;
422
- entry. set ( gimli:: DW_AT_high_pc , AttributeValue :: Data8 ( size_array) ) ;
416
+ entry. set ( gimli:: DW_AT_high_pc , AttributeValue :: Data8 ( code_size as u64 ) ) ;
423
417
424
418
self . debug_context . unit_range_list . 0 . push ( Range {
425
419
begin : Address :: Relative {
0 commit comments