| ... | @@ -1377,9 +1377,13 @@ pub const DwarfInfo = struct { | ... | @@ -1377,9 +1377,13 @@ pub const DwarfInfo = struct { |
| 1377 | if (compile_unit.pc_range) |range| { | 1377 | if (compile_unit.pc_range) |range| { |
| 1378 | if (target_address >= range.start and target_address < range.end) return compile_unit; | 1378 | if (target_address >= range.start and target_address < range.end) return compile_unit; |
| 1379 | } | 1379 | } |
| 1380 | if (compile_unit.die.getAttrSecOffset(DW.AT_ranges)) |ranges_offset| { | 1380 | if (di.debug_ranges) |debug_ranges| { |
| 1381 | var base_address: usize = 0; | 1381 | if (compile_unit.die.getAttrSecOffset(DW.AT_ranges)) |ranges_offset| { |
| 1382 | if (di.debug_ranges) |debug_ranges| { | 1382 | // All the addresses in the list are relative to the value |
| | 1383 | // specified by DW_AT_low_pc or to some other value encoded |
| | 1384 | // in the list itself |
| | 1385 | var base_address = try compile_unit.die.getAttrAddr(DW.AT_low_pc); |
| | 1386 | |
| 1383 | try di.dwarf_seekable_stream.seekTo(debug_ranges.offset + ranges_offset); | 1387 | try di.dwarf_seekable_stream.seekTo(debug_ranges.offset + ranges_offset); |
| 1384 | while (true) { | 1388 | while (true) { |
| 1385 | const begin_addr = try di.dwarf_in_stream.readIntLittle(usize); | 1389 | const begin_addr = try di.dwarf_in_stream.readIntLittle(usize); |
| ... | @@ -1387,18 +1391,21 @@ pub const DwarfInfo = struct { | ... | @@ -1387,18 +1391,21 @@ pub const DwarfInfo = struct { |
| 1387 | if (begin_addr == 0 and end_addr == 0) { | 1391 | if (begin_addr == 0 and end_addr == 0) { |
| 1388 | break; | 1392 | break; |
| 1389 | } | 1393 | } |
| | 1394 | // This entry selects a new value for the base address |
| 1390 | if (begin_addr == maxInt(usize)) { | 1395 | if (begin_addr == maxInt(usize)) { |
| 1391 | base_address = begin_addr; | 1396 | base_address = end_addr; |
| 1392 | continue; | 1397 | continue; |
| 1393 | } | 1398 | } |
| 1394 | if (target_address >= begin_addr and target_address < end_addr) { | 1399 | if (target_address >= base_address + begin_addr and target_address < base_address + end_addr) { |
| 1395 | return compile_unit; | 1400 | return compile_unit; |
| 1396 | } | 1401 | } |
| 1397 | } | 1402 | } |
| | 1403 | |
| | 1404 | return error.InvalidDebugInfo; |
| | 1405 | } else |err| { |
| | 1406 | if (err != error.MissingDebugInfo) return err; |
| | 1407 | continue; |
| 1398 | } | 1408 | } |
| 1399 | } else |err| { | | |
| 1400 | if (err != error.MissingDebugInfo) return err; | | |
| 1401 | continue; | | |
| 1402 | } | 1409 | } |
| 1403 | } | 1410 | } |
| 1404 | return error.MissingDebugInfo; | 1411 | return error.MissingDebugInfo; |