class WORF::DebugInfo
Constants
- NO_CHILDREN
Public Class Methods
new(io, section, head_pos)
click to toggle source
# File lib/worf.rb, line 421 def initialize io, section, head_pos @io = io @section = section @head_pos = head_pos end
Public Instance Methods
compile_units(tags)
click to toggle source
# 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
Private Instance Methods
decode(tag, address_size, io)
click to toggle source
# File lib/worf.rb, line 485 def decode tag, address_size, io tag.decode io, address_size end
parse_die(io, tags, tag, offset, address_size)
click to toggle source
# File lib/worf.rb, line 474 def parse_die io, tags, tag, offset, address_size attributes = decode tag, address_size, io children = if tag.has_children? read_children io, tags, address_size else NO_CHILDREN end DIE.new tag, offset - @head_pos, attributes, children end
read_children(io, tags, address_size)
click to toggle source
# File lib/worf.rb, line 458 def read_children io, tags, address_size children = [] loop do offset = io.pos - @section.offset abbrev_code = WORF.unpackULEB128 io return children if abbrev_code == 0 tag = tags.fetch(abbrev_code - 1) die = parse_die io, tags, tag, offset, address_size children << die end end