tracetool 0.3.0 → 0.4.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 24b271eb9816bfe2c8c9cf44af633851dfd06497
4
- data.tar.gz: f1c65ec08ac3aeedc355ec8160d8507cf1e1b73e
3
+ metadata.gz: 28053aff3e16e9baee1198e08bdbeffdefeef2f0
4
+ data.tar.gz: 894ac01ee7333ee6b02dc5fb422114f6269a0a72
5
5
  SHA512:
6
- metadata.gz: a2008ddb93477871d23e215cd4b7771e15b51942782f3e0a05b292d73e2c3e8b169f95fb4d2b3ce4a1c3c8bf7f007aeda8d68cf529a171999cb21ad9fdb187a2
7
- data.tar.gz: 4509d9dd674ef506f88930e178a851da1af1167fe2985d490ecf0a5c3c083bc64d1c3b3f9699753b9492054875dda78a073b1600adc1040790aac82ff353b0ed
6
+ metadata.gz: 3fa1e1578d5c6802e508cea8b7c1af90ff2ef4f83f3574b7cf0b218afbcc48c47783706bec06273a1a6887470ebddd0ccbd15fb0448d921296033ce174b064d1
7
+ data.tar.gz: 338ed267bce0c0d91ecdb47cdfe6d1f8eeed36179717bc16a6c5362c84fb15d5f3099906e35ad0eaa90af7368c7e8fd2bd1c5bcb1d66b69bcb00265c4330874d
data/bin/tracetool CHANGED
@@ -1,2 +1,2 @@
1
1
  #!/usr/bin/env ruby
2
- require_relative '../lib/tracetool'
2
+ require_relative '../lib/tracetool_cli'
data/lib/tracetool.rb CHANGED
@@ -1,29 +1,7 @@
1
1
  require 'ostruct'
2
2
  require 'powerpack/string'
3
3
 
4
- require_relative 'version'
5
-
6
4
  require_relative 'tracetool/android'
7
5
  require_relative 'tracetool/ios'
8
- require_relative 'tracetool/utils/cli'
9
6
  require_relative 'tracetool/utils/env'
10
7
  require_relative 'tracetool/utils/pipe'
11
-
12
- opts = Tracetool::ParseArgs.parse(ARGV)
13
-
14
- case opts.platform
15
- when :android
16
- stack = ARGF.read
17
- puts Tracetool::Android.scan(stack,
18
- symbols: opts.sym_dir,
19
- arch: opts.arch.to_s)
20
- when :ios
21
- stack = ARGF.read
22
- puts Tracetool::IOS.scan(stack,
23
- arch: opts.arch.to_s,
24
- xarchive: opts.sym_dir,
25
- module_name: opts.modulename,
26
- load_address: opts.address)
27
- else
28
- raise "Unknown(#{opts.platform})"
29
- end
@@ -13,17 +13,26 @@ module Tracetool
13
13
  # Launches process of trace desymbolication
14
14
  # @param [String] trace trace body
15
15
  def process(trace, context)
16
- # Find scanner which maches trace format
17
- scanner = SCANNERS.map { |s| s[trace] }.compact.first
18
- raise(ArgumentError, "#{trace}\n not android trace?") unless scanner
19
- scanner.process(context)
16
+ # Find scanner which matches trace format
17
+ @scanner = SCANNERS.map { |s| s[trace] }.compact.first
18
+ raise(ArgumentError, "#{trace}\n not android trace?") unless @scanner
19
+ @scanner.process(context)
20
+ end
21
+
22
+ # Creates parser for last unpacked trace
23
+ # @param [Array] files list of source files used in build
24
+ # @return [Tracetool::BaseTraceParser] parser that matches trace format.
25
+ # Or `nil`. If there was no scanning.
26
+ def parser(files)
27
+ return unless @scanner
28
+ @scanner.parser(files)
20
29
  end
21
30
  end
22
31
 
23
32
  class << self
24
33
  # Desymbolicate android stack trace
25
34
  def scan(string, opts = {})
26
- AndroidTraceScanner.new .process(string, OpenStruct.new(opts))
35
+ AndroidTraceScanner.new.process(string, OpenStruct.new(opts))
27
36
  end
28
37
  end
29
38
  end
@@ -26,6 +26,14 @@ module Tracetool
26
26
  @trace
27
27
  end
28
28
 
29
+ # Create parser for current trace format
30
+ # @param [Array] files list of files used in build. This files are
31
+ # used to match file entries from stack trace to real files
32
+ # @return [Tracetool::BaseTraceParser] parser that matches trace format
33
+ def parser(files)
34
+ JavaTraceParser.new(files)
35
+ end
36
+
29
37
  class << self
30
38
  def match(string)
31
39
  # Split into lines
@@ -105,16 +105,17 @@ module Tracetool
105
105
  Pipe['ndk-stack', '-sym', symbols] << @trace
106
106
  end
107
107
 
108
+ # Create parser for current trace format
109
+ # @param [Array] files list of files used in build. This files are
110
+ # used to match file entries from stack trace to real files
111
+ # @return [Tracetool::BaseTraceParser] parser that matches trace format
112
+ def parser(files)
113
+ NativeTraceParser.new(files)
114
+ end
115
+
108
116
  class << self
109
117
  # Add methods for trace normalization
110
118
  include Tracetool::Android::NativeTraceEnhancer
111
- # Tells if provided string is a ndk trace
112
- # @return truthy or falsey value
113
- def match(string)
114
- return false if string.empty?
115
- packed?(string) || with_header?(string) || without_header?(string)
116
- end
117
-
118
119
  def packed?(string)
119
120
  RX_PACKED_FORMAT.match(string)
120
121
  end
@@ -60,6 +60,14 @@ module Tracetool
60
60
  Pipe['atos', *AtosContext.new(context).to_args] << trace
61
61
  end
62
62
 
63
+ # Create parser for current trace format
64
+ # @param [Array] files list of files used in build. This files are
65
+ # used to match file entries from stack trace to real files
66
+ # @return [Tracetool::BaseTraceParser] parser that matches trace format
67
+ def parser(files)
68
+ IOSTraceParser.new(files)
69
+ end
70
+
63
71
  private
64
72
 
65
73
  def mix(trace, symbolicated)
@@ -1,7 +1,8 @@
1
1
  require 'optparse'
2
- require 'optparse/time'
3
2
  require 'ostruct'
4
3
 
4
+ require_relative '../../version'
5
+
5
6
  module Tracetool
6
7
  # Tracetool cli args parser
7
8
  class ParseArgs
@@ -10,24 +11,25 @@ module Tracetool
10
11
  #
11
12
  # Return a structure describing the options.
12
13
  #
13
- def self.parse(args)
14
+ def self.parse(args, io = $stdout)
14
15
  # The options specified on the command line will be collected in *options*.
15
16
  # We set default values here.
16
- opt_parser = ParseArgs.new(OpenStruct.new(sym_dir: Dir.pwd))
17
+ opt_parser = ParseArgs.new(OpenStruct.new(sym_dir: Dir.pwd), io)
17
18
  options = opt_parser.parse(args)
18
19
  check(options)
19
20
  check_ios(options)
20
21
  options
21
22
  rescue OptionParser::MissingArgument => x
22
- puts ["Error occurred: #{x.message}", '', opt_parser.help].join("\n")
23
- exit 2
23
+ io.write ["Error occurred: #{x.message}", '', opt_parser.help].join("\n")
24
+ io.write "\n"
25
+ raise(x)
24
26
  end
25
27
 
26
28
  def self.check_ios(options)
27
29
  return unless options.platform == :ios
28
30
  {
29
31
  'address' => options.address,
30
- 'modulename' => options.modulename
32
+ 'module' => options.modulename
31
33
  }.each { |arg, check| raise(OptionParser::MissingArgument, arg) unless check }
32
34
  end
33
35
 
@@ -38,17 +40,10 @@ module Tracetool
38
40
  }.each { |arg, check| raise(OptionParser::MissingArgument, arg) unless check }
39
41
  end
40
42
 
41
- def initialize(defaults)
43
+ def initialize(defaults, io)
44
+ @io = io
42
45
  @options = defaults
43
- @opt_parser = OptionParser.new do |opts|
44
- opt_banner(opts)
45
- opts.separator ''
46
- opt_common(opts)
47
- opts.separator ''
48
- opt_ios(opts)
49
- opts.separator ''
50
- opt_default(opts)
51
- end
46
+ @opt_parser = gen_opt_parser
52
47
  end
53
48
 
54
49
  def parse(args)
@@ -60,6 +55,20 @@ module Tracetool
60
55
  @opt_parser.help
61
56
  end
62
57
 
58
+ private
59
+
60
+ def gen_opt_parser
61
+ OptionParser.new do |opts|
62
+ opt_banner(opts)
63
+ opts.separator ''
64
+ opt_common(opts)
65
+ opts.separator ''
66
+ opt_ios(opts)
67
+ opts.separator ''
68
+ opt_default(opts)
69
+ end
70
+ end
71
+
63
72
  def opt_banner(opts)
64
73
  opts.banner = 'Usage: tracetool OPTION... [FILE]...'
65
74
  opts.separator ''
@@ -104,13 +113,14 @@ module Tracetool
104
113
  # No argument, shows at tail. This will print an options summary.
105
114
  # Try it and see!
106
115
  opts.on_tail('-h', '--help', 'Show this message') do
107
- puts opts
116
+ @io.write opts
117
+ @io.write "\n"
108
118
  exit
109
119
  end
110
120
 
111
121
  # Another typical switch to print the version.
112
122
  opts.on_tail('--version', 'Show version') do
113
- puts 'tracetool ' + Tracetool::Version.to_s
123
+ @io.write 'tracetool ' + Tracetool::Version.to_s
114
124
  exit
115
125
  end
116
126
  end
@@ -0,0 +1,20 @@
1
+ require_relative 'tracetool'
2
+ require_relative 'tracetool/utils/cli'
3
+
4
+ opts = Tracetool::ParseArgs.parse(ARGV)
5
+ case opts.platform
6
+ when :android
7
+ stack = ARGF.read
8
+ puts Tracetool::Android.scan(stack,
9
+ symbols: opts.sym_dir,
10
+ arch: opts.arch.to_s)
11
+ when :ios
12
+ stack = ARGF.read
13
+ puts Tracetool::IOS.scan(stack,
14
+ arch: opts.arch.to_s,
15
+ xarchive: opts.sym_dir,
16
+ module_name: opts.modulename,
17
+ load_address: opts.address)
18
+ else
19
+ raise "Unknown(#{opts.platform})"
20
+ end
data/lib/version.rb CHANGED
@@ -1,7 +1,7 @@
1
1
  module Tracetool
2
2
  # Version constant
3
3
  module Version
4
- VERSION = [0, 3, 0].freeze
4
+ VERSION = [0, 4, 0].freeze
5
5
 
6
6
  class << self
7
7
  # @return [String] version string
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tracetool
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - ilya.arkhanhelsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-11-12 00:00:00.000000000 Z
11
+ date: 2017-11-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: powerpack
@@ -43,6 +43,7 @@ files:
43
43
  - lib/tracetool/utils/env.rb
44
44
  - lib/tracetool/utils/parser.rb
45
45
  - lib/tracetool/utils/pipe.rb
46
+ - lib/tracetool_cli.rb
46
47
  - lib/version.rb
47
48
  homepage: https://github.com/vizor-games/tracetool
48
49
  licenses: