node/lib/metasm/metasm/exe_format/elf_decode.rb
def decode(elf, info, abbrev, str)
			super(elf, info)
			len = @cu_len-7	# @cu_len is size from end of @cu_len field, so we substract ptsz/tag/abroff
			info.ptr += len	# advance for caller
			info = info[info.ptr-len, len]	# we'll work on our segment
			abbrev.ptr = @abbrev_off

			return if abbrev.ptr >= abbrev.length or info.ptr >= info.length

			idx_abbroff = {}

			# returns a list of siblings at current abbrev.ptr
			decode_tree = lambda { |parent|
				siblings = []
				loop {
					info_idx = elf.decode_leb(info)
					break siblings if info_idx == 0
					abbrev.ptr = idx_abbroff[info_idx] if idx_abbroff[info_idx]
					idx_abbroff[info_idx] ||= abbrev.ptr
					n = DwarfDebug::Node.decode(elf, info, abbrev, str, idx_abbroff)
					idx_abbroff[info_idx+1] ||= abbrev.ptr
					siblings << n
					n.children = decode_tree[n] if n.has_child == 1
					n.parent = parent
					break n if not parent
				}
			}
			@tree = decode_tree[nil]
		end
# decode a DWARF2 'compilation unit'
decode a DWARF2 'compilation unit'
decode a DWARF2 ' compilation unit '
def decode(elf, info, abbrev, str)
			super(elf, info)
			len = @cu_len-7	
			info.ptr += len	
			info = info[info.ptr-len, len]	
			abbrev.ptr = @abbrev_off
			return if abbrev.ptr >= abbrev.length or info.ptr >= info.length
			idx_abbroff = {}
			decode_tree = lambda { |parent|
				siblings = []
				loop {
					info_idx = elf.decode_leb(info)
					break siblings if info_idx == 0
					abbrev.ptr = idx_abbroff[info_idx] if idx_abbroff[info_idx]
					idx_abbroff[info_idx] ||= abbrev.ptr
					n = DwarfDebug::Node.decode(elf, info, abbrev, str, idx_abbroff)
					idx_abbroff[info_idx+1] ||= abbrev.ptr
					siblings << n
					n.children = decode_tree[n] if n.has_child == 1
					n.parent = parent
					break n if not parent
				}
			}
			@tree = decode_tree[nil]
		end
def decode ( elf , info , abbrev , str ) super ( elf , info ) len = @cu_len - 7 info . ptr += len info = info [ info . ptr - len , len ] abbrev . ptr = @abbrev_off return if abbrev . ptr >= abbrev . length or info . ptr >= info . length idx_abbroff = { } decode_tree = lambda { | parent | siblings = [ ] loop { info_idx = elf . decode_leb ( info ) break siblings if info_idx == 0 abbrev . ptr = idx_abbroff [ info_idx ] if idx_abbroff [ info_idx ] idx_abbroff [ info_idx ] ||= abbrev . ptr n = DwarfDebug :: Node . decode ( elf , info , abbrev , str , idx_abbroff ) idx_abbroff [ info_idx + 1 ] ||= abbrev . ptr siblings << n n . children = decode_tree [ n ] if n . has_child == 1 n . parent = parent break n if not parent } } @tree = decode_tree [ nil ] end
decode a DWARF2 'compilation unit'
decode a DWARF2 ' compilation unit '
# @cu_len is size from end of @cu_len field, so we substract ptsz/tag/abroff # advance for caller # we'll work on our segment # returns a list of siblings at current abbrev.ptr
elf
info
abbrev
str