Class: WORF::DebugInfo

Inherits:
Object
  • Object
show all
Defined in:
lib/worf.rb

Instance Method Summary collapse

Constructor Details

#initialize(io, section, head_pos) ⇒ DebugInfo

Returns a new instance of DebugInfo.



421
422
423
424
425
# File 'lib/worf.rb', line 421

def initialize io, section, head_pos
  @io           = io
  @section      = section
  @head_pos     = head_pos
end

Instance Method Details

#compile_units(tags) ⇒ Object



427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
# File 'lib/worf.rb', line 427

def compile_units tags
  cus = []
  @io.seek @head_pos + @section.offset, IO::SEEK_SET
  while @io.pos < @head_pos + @section.offset + @section.size
    unit_length, dwarf_version = @io.read(6).unpack("LS")
    if dwarf_version != 4
      raise NotImplementedError, "Only DWARF4 rn #{dwarf_version}"
    end

    debug_abbrev_offset = @io.read(4).unpack1("L")
    address_size = @io.readbyte
    if address_size != 8
      raise NotImplementedError, "only 8 bytes address size supported rn"
    end
    offset = @io.pos - @section.offset
    abbrev_code = WORF.unpackULEB128 @io
    tag = tags[abbrev_code - 1]
    cu = CompilationUnit.new(unit_length,
                               dwarf_version,
                               debug_abbrev_offset,
                               address_size,
                               parse_die(@io, tags, tag, offset, address_size))
    cus << cu
  end
  cus
ensure
  @io.seek @head_pos, IO::SEEK_SET
end