class Tracetool::Android::NativeTraceScanner
Processes native traces
Constants
- RX_INITIAL_ASTERISKS
- 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.
-
- RX_PC_ADDRESS
Contains address line like
“` pc 00000000004321ec libfoo.so “`
- TRACE_DELIMETER
Initial sequence of asterisks which marks begining of trace body
Public Class Methods
With given potential stack trace string create scanner if possible @param [String] string trace @return [NativeTraceScanner] or nil
# 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
# File lib/tracetool/android/native.rb, line 134 def address_lines?(lines) lines.all? do |line| RX_PC_ADDRESS.match(line) end end
@param [String] string well formed native android stack trace @see developer.android.com/ndk/guides/ndk-stack.html
# File lib/tracetool/android/native.rb, line 100 def initialize(string) @trace = string end
# File lib/tracetool/android/native.rb, line 122 def packed?(string) RX_PACKED_FORMAT.match(string) end
# File lib/tracetool/android/native.rb, line 140 def with_header?(string) RX_INITIAL_ASTERISKS.match(string) end
# 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
Public Instance Methods
Create parser for current trace format @param [Array] files list of files used in build. This files are
used to match file entries from stack trace to real files
@return [Tracetool::BaseTraceParser] parser that matches trace format
# File lib/tracetool/android/native.rb, line 115 def parser(files) NativeTraceParser.new(files) end
@param [OpenStruct] ctx context object containing `symbols` field with
path to symbols dir
@return [String] desymbolicated stack trace
# File lib/tracetool/android/native.rb, line 107 def process(ctx) Pipe['ndk-stack', '-sym', ctx.symbols] << @trace end