Class: ElfUtils::Section::DebugArange

Inherits:
Base
  • Object
show all
Extended by:
CTypes::Helpers
Defined in:
lib/elf_utils/section/debug_arange.rb

Defined Under Namespace

Classes: Entry

Constant Summary collapse

Tuple32 =
struct(addr: uint32, size: uint32)
Tuple64 =
struct(addr: uint64, size: uint64)

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

#cu_offset(addr) ⇒ Object



49
50
51
52
# File 'lib/elf_utils/section/debug_arange.rb', line 49

def cu_offset(addr)
  ranges.each { |range, offset| return offset if range.include?(addr) }
  nil
end

#entriesObject



28
29
30
# File 'lib/elf_utils/section/debug_arange.rb', line 28

def entries
  @entries ||= Entry.unpack_all(bytes, endian: @file.endian)
end

#rangesObject



32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# File 'lib/elf_utils/section/debug_arange.rb', line 32

def ranges
  @ranges ||= begin
    ranges = []
    entries.each do |entry|
      tuple_type = (entry.addr_size == 4) ? Tuple32 : Tuple64
      tuple_type
        .unpack_all(entry.tuple_bytes, endian: @file.endian)
        .each do |tuple|
          next if tuple.addr == 0 && tuple.size == 0
          range = tuple.addr...(tuple.addr + tuple.size)
          ranges << [range, entry.debug_info_offset]
        end
    end
    ranges
  end
end