Class: Tracetool::Android::NativeTraceScanner
- Inherits:
-
Object
- Object
- Tracetool::Android::NativeTraceScanner
- Extended by:
- NativeTraceEnhancer
- Defined in:
- lib/tracetool/android/native.rb
Overview
Processes native traces
Constant Summary collapse
- TRACE_DELIMETER =
Initial sequence of asterisks which marks begining of trace body
'*** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***'.freeze
- RX_INITIAL_ASTERISKS =
/#{TRACE_DELIMETER.gsub('*', '\*')}/.freeze
- RX_PC_ADDRESS =
Contains address line like
“‘ pc 00000000004321ec libfoo.so “`
/pc \d+/.freeze
- RX_PACKED_FORMAT =
Format of packed trace. Consists of one or more trace blocks.
-
Each block starts with ‘<<<` and ends with `>>>`.
-
Each block contains one or more lines
-
Lines delimited with ;
-
Line consists of
** pointer address ‘/d+/` ** library (so) name `/[^ ]+/` ** symbol name `/[^ ]+/`, if present ** symbol offset `/d+/`
Last two entries can be missing.
-
/^(<<<([-?\d]+ [^ ]+ (.+)?;)+>>>)+$/.freeze
Constants included from NativeTraceEnhancer
Tracetool::Android::NativeTraceEnhancer::NATIVE_DUMP_HEADER
Class Method Summary collapse
-
.[](string) ⇒ NativeTraceScanner
With given potential stack trace string create scanner if possible.
- .address_lines?(lines) ⇒ Boolean
- .packed?(string) ⇒ Boolean
- .with_header?(string) ⇒ Boolean
- .without_header?(string) ⇒ Boolean
Instance Method Summary collapse
-
#initialize(string) ⇒ NativeTraceScanner
constructor
A new instance of NativeTraceScanner.
-
#parser(files) ⇒ Tracetool::BaseTraceParser
Create parser for current trace format.
-
#process(ctx) ⇒ String
Desymbolicated stack trace.
Methods included from NativeTraceEnhancer
Constructor Details
#initialize(string) ⇒ NativeTraceScanner
Returns a new instance of NativeTraceScanner.
100 101 102 |
# File 'lib/tracetool/android/native.rb', line 100 def initialize(string) @trace = string end |
Class Method Details
.[](string) ⇒ NativeTraceScanner
With given potential stack trace string create scanner if possible
148 149 150 151 152 153 154 155 156 |
# File 'lib/tracetool/android/native.rb', line 148 def [](string) if packed? string new(unpack(string)) elsif with_header? string new(string) elsif without_header? string new(add_header(string)) end end |
.address_lines?(lines) ⇒ Boolean
134 135 136 137 138 |
# File 'lib/tracetool/android/native.rb', line 134 def address_lines?(lines) lines.all? do |line| RX_PC_ADDRESS.match(line) end end |
.packed?(string) ⇒ Boolean
122 123 124 |
# File 'lib/tracetool/android/native.rb', line 122 def packed?(string) RX_PACKED_FORMAT.match(string) end |
.with_header?(string) ⇒ Boolean
140 141 142 |
# File 'lib/tracetool/android/native.rb', line 140 def with_header?(string) RX_INITIAL_ASTERISKS.match(string) end |
.without_header?(string) ⇒ Boolean
126 127 128 129 130 131 132 |
# File 'lib/tracetool/android/native.rb', line 126 def without_header?(string) lines = string.split("\n") return true if address_lines?(lines) first, *rest = lines first.include?('backtrace:') && address_lines?(rest) end |
Instance Method Details
#parser(files) ⇒ Tracetool::BaseTraceParser
Create parser for current trace format
115 116 117 |
# File 'lib/tracetool/android/native.rb', line 115 def parser(files) NativeTraceParser.new(files) end |