Class: ElfUtils::Section::DebugRanges

Inherits:
Base
  • Object
show all
Includes:
CTypes::Helpers
Defined in:
lib/elf_utils/section/debug_ranges.rb

Instance Attribute Summary

Attributes inherited from Base

#header

Instance Method Summary collapse

Methods inherited from Base

#addr, #alloc?, #bytes, #flags, #initialize, #inspect, #load_segment, #name, #offset, #relocate, #relocation_offset, #size, #symbol, #symbols, #to_range

Constructor Details

This class inherits a constructor from ElfUtils::Section::Base

Instance Method Details

#get(offset:, base:) ⇒ Object

get the range list at a given offset



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
# File 'lib/elf_utils/section/debug_ranges.rb', line 6

def get(offset:, base:)
  array(array(@file.addr_type, 2), terminator: [0, 0])
    .unpack(bytes[offset..])
    .map do |first, last|
      if first == @file.addr_type.max
        # TODO figure out how to generate a test file that makes use of
        # DW_AT_ranges & has a base address range so we can add tests for
        # this.
        base = last
        nil
      else
        (first + base)..(last + base - 1)
      end
    end.compact
end