1
1
use crate :: debug:: Reader ;
2
2
use core:: fmt;
3
- use gimli:: { write, AttributeValue , DebuggingInformationEntry , Dwarf , LittleEndian , Unit } ;
3
+ use gimli:: {
4
+ write, AttributeValue , DebuggingInformationEntry , Dwarf , LittleEndian , Unit , UnitSectionOffset ,
5
+ } ;
4
6
5
7
macro_rules! dbi_log {
6
8
( $( $tt: tt) * ) => {
@@ -18,7 +20,7 @@ pub struct CompileUnitSummary<'a> {
18
20
impl < ' a > fmt:: Debug for CompileUnitSummary < ' a > {
19
21
fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
20
22
let unit = self . unit ;
21
- let offs: usize = unit. header . offset ( ) . as_debug_info_offset ( ) . unwrap ( ) . 0 ;
23
+ let offs = get_offset_value ( unit. header . offset ( ) ) ;
22
24
write ! ( f, "0x{offs:08x} [" ) ?;
23
25
let comp_dir = match unit. comp_dir {
24
26
Some ( dir) => & dir. to_string_lossy ( ) ,
@@ -51,7 +53,7 @@ pub fn log_begin_input_die(
51
53
) {
52
54
dbi_log ! (
53
55
"=== Begin DIE at 0x{:08x} (depth = {}):\n {:?}" ,
54
- die. offset( ) . 0 ,
56
+ get_offset_value ( die. offset( ) . to_unit_section_offset ( unit ) ) ,
55
57
depth,
56
58
DieDetailedSummary { dwarf, unit, die }
57
59
) ;
@@ -210,14 +212,15 @@ impl<'a> fmt::Debug for OutDieDetailedSummary<'a> {
210
212
211
213
pub fn log_end_output_die (
212
214
input_die : & DebuggingInformationEntry < Reader < ' _ > > ,
215
+ input_unit : & Unit < Reader < ' _ > , usize > ,
213
216
die_id : write:: UnitEntryId ,
214
217
unit : & write:: Unit ,
215
218
strings : & write:: StringTable ,
216
219
depth : isize ,
217
220
) {
218
221
dbi_log ! (
219
222
"=== End DIE at 0x{:08x} (depth = {}):\n {:?}" ,
220
- input_die. offset( ) . 0 ,
223
+ get_offset_value ( input_die. offset( ) . to_unit_section_offset ( input_unit ) ) ,
221
224
depth,
222
225
OutDieDetailedSummary {
223
226
die_id,
@@ -229,13 +232,21 @@ pub fn log_end_output_die(
229
232
230
233
pub fn log_end_output_die_skipped (
231
234
input_die : & DebuggingInformationEntry < Reader < ' _ > > ,
235
+ input_unit : & Unit < Reader < ' _ > , usize > ,
232
236
reason : & str ,
233
237
depth : isize ,
234
238
) {
235
239
dbi_log ! (
236
240
"=== End DIE at 0x{:08x} (depth = {}):\n Skipped as {}\n " ,
237
- input_die. offset( ) . 0 ,
241
+ get_offset_value ( input_die. offset( ) . to_unit_section_offset ( input_unit ) ) ,
238
242
depth,
239
243
reason
240
244
) ;
241
245
}
246
+
247
+ fn get_offset_value ( offset : UnitSectionOffset ) -> usize {
248
+ match offset {
249
+ UnitSectionOffset :: DebugInfoOffset ( offs) => offs. 0 ,
250
+ UnitSectionOffset :: DebugTypesOffset ( offs) => offs. 0 ,
251
+ }
252
+ }
0 commit comments