Class: Squash::Symbolicator::Lines

Inherits:
Object
  • Object
show all
Includes:
Enumerable, SerialBox
Defined in:
lib/squash/symbolicator/lines.rb

Overview

An aggregation of the ‘Symbolicator::Line`s of a binary class. This class is enumerable.

Instance Method Summary collapse

Constructor Details

#initializeLines

Creates a new empty aggregation.



48
49
50
# File 'lib/squash/symbolicator/lines.rb', line 48

def initialize
  @lines = Array.new
end

Instance Method Details

#[](*args) ⇒ Object

Delegated to ‘Array`.



87
# File 'lib/squash/symbolicator/lines.rb', line 87

def [](*args) @lines[*args] end

#add(start_address, file, lineno, col) ⇒ Object

Adds a line definition to the aggregation.

Parameters:

  • start_address (Fixnum)

    The lowest program counter address corresponding to this method or function.

  • file (String)

    The path to the file where this line is found.

  • lineno (Fixnum)

    The line number in ‘file`.

  • col (Fixnum)

    The column number in ‘file`.



60
61
62
63
64
65
66
67
68
69
# File 'lib/squash/symbolicator/lines.rb', line 60

def add(start_address, file, lineno, col)
  index   = @lines.find_index { |line| line.start_address > start_address }
  new_line = Squash::Symbolicator::Line.new(start_address, file, lineno, col)

  if index
    @lines.insert index, new_line
  else
    @lines << new_line
  end
end

#clear(*args) ⇒ Object

Delegated to ‘Array`.



89
# File 'lib/squash/symbolicator/lines.rb', line 89

def clear(*args) @lines.clear(*args) end

#each(*args) ⇒ Object

Delegated to ‘Array`.



85
# File 'lib/squash/symbolicator/lines.rb', line 85

def each(*args) @lines.each(*args) end

#for(address) ⇒ Symbol?

Returns the nearest ‘Symbolicator::Line` to a given program counter address.

Parameters:

  • address (Fixnum)

    A program counter address.

Returns:

  • (Symbol, nil)

    The line corresponding to that address, or ‘nil` if the address is not symbolicated.



77
78
79
80
81
82
# File 'lib/squash/symbolicator/lines.rb', line 77

def for(address)
  return @lines.last if @lines.last && @lines.last.start_address == address
  idx = @lines.find_index { |line| address < line.start_address }
  return nil unless idx
  return @lines[idx - 1]
end

#inspectObject



94
# File 'lib/squash/symbolicator/lines.rb', line 94

def inspect() "#<#{self.class} [#{size} lines]>" end

#size(*args) ⇒ Object

Delegated to ‘Array`.



91
# File 'lib/squash/symbolicator/lines.rb', line 91

def size(*args) @lines.size(*args) end