Class: Tracetool::BaseTraceParser

Inherits:
Object
  • Object
show all
Includes:
StringUtils
Defined in:
lib/tracetool/utils/parser.rb

Overview

Base trace parser logic

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(entry_pattern, call_pattern, build_files, convert_numbers = false) ⇒ BaseTraceParser

Returns a new instance of BaseTraceParser.



10
11
12
13
14
15
# File 'lib/tracetool/utils/parser.rb', line 10

def initialize(entry_pattern, call_pattern, build_files, convert_numbers = false)
  @build_files = build_files
  @entry_pattern = entry_pattern
  @call_pattern = call_pattern.is_a?(Array) ? call_pattern : [call_pattern]
  @convert_numbers = convert_numbers
end

Instance Attribute Details

#call_patternObject (readonly)

Returns the value of attribute call_pattern.



8
9
10
# File 'lib/tracetool/utils/parser.rb', line 8

def call_pattern
  @call_pattern
end

#entry_patternObject (readonly)

Returns the value of attribute entry_pattern.



8
9
10
# File 'lib/tracetool/utils/parser.rb', line 8

def entry_pattern
  @entry_pattern
end

Instance Method Details

#parse(lines) ⇒ Object

Parse crash dump Each line should be parsed in Hash which SHOULD or MAY contains following entries:

  • SHOULD contain ‘orig` entry – original trace entry

  • MAY contain following entries IF original entry matched pattern:

** ‘frame` - stack frame index ** `lib` - shared library name (android) or module name (ios) ** `call_description` - original call block ** MAY contain `call` entry if `call_description` was recognized: *** `method` - namespaced method name (with class and its namespace) *** `file` - file path relative to `symbols dir` *** `line` - line number in specified file



30
31
32
33
34
35
# File 'lib/tracetool/utils/parser.rb', line 30

def parse(lines)
  lines
    .split("\n")
    .select { |line| line_filter(line) }
    .map { |line| scan_call(scan_line(line)) }
end