Class: ElfUtils::Section::DebugLine::LineNumberProgram

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

Defined Under Namespace

Classes: Header, StateMachine

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(file:, offset:, header:, body:) ⇒ LineNumberProgram

Returns a new instance of LineNumberProgram.



5
6
7
8
9
10
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 5

def initialize(file:, offset:, header:, body:)
  @file = file
  @offset = offset
  @header = header
  @body = body
end

Instance Attribute Details

#bodyObject (readonly)

Returns the value of attribute body.



11
12
13
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 11

def body
  @body
end

#fileObject (readonly)

Returns the value of attribute file.



11
12
13
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 11

def file
  @file
end

#headerObject (readonly)

Returns the value of attribute header.



11
12
13
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 11

def header
  @header
end

Instance Method Details

#addr_typeObject



13
14
15
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 13

def addr_type
  @header.addr_type
end

#address_tableObject



38
39
40
41
42
43
44
45
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 38

def address_table
  @address_table ||= begin
    state = StateMachine.new(self)
    state.process(body).each_with_object({}) do |entry, o|
      o[entry.address] = entry.freeze
    end.freeze
  end
end

#directoriesObject



22
23
24
25
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 22

def directories
  unpack_header_tail unless @directories
  @directories
end

#file_name(index) ⇒ Object



32
33
34
35
36
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 32

def file_name(index)
  file_name = file_names[index]
  dir = directories[file_name[:directory_index]]
  File.join(dir[:path], file_name[:path])
end

#file_namesObject



27
28
29
30
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 27

def file_names
  unpack_header_tail unless @file_names
  @file_names
end

#source_location(addr) ⇒ Object



47
48
49
50
51
52
53
54
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 47

def source_location(addr)
  entry = address_table[addr] || return
  {
    file: file_name(entry.file),
    line: entry.line,
    column: entry.column
  }
end

#standard_opcode_lengthsObject



17
18
19
20
# File 'lib/elf_utils/section/debug_line/line_number_program.rb', line 17

def standard_opcode_lengths
  unpack_header_tail unless @standard_opcode_lengths
  @standard_opcode_lengths
end