tracetool 0.4.2 → 0.5.4

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
  SHA256:
3
- metadata.gz: 8472dc65529d01a91acb750d319896a662a39e387b78b624cab705759a082325
4
- data.tar.gz: 6933e16c48afbfbe1d7d79a26644dfc6b36023a689defaaae08c4549d29e6497
3
+ metadata.gz: 3e0743d5a4d5120b011f4e6f564fce88f30d371db0bf0a1dceedd8036dc902d8
4
+ data.tar.gz: 482da334fdbf304d13f8f5c008fbac931d4d471bf225d5c6c5e2526e346403c5
5
5
  SHA512:
6
- metadata.gz: a42194c3b26c71ece0ae466c4e82c1b1e2fbec7468b24a795c1c21075492378e20f991152ce4fdb3e1db535ecca3fd45fa4f059e37e7691bc5e4629ea16f1d77
7
- data.tar.gz: 7e2f747f6de6a6865a207f0670ea3c406e3b42f76bd2528b6cb9795d1aaf214ec2295bb5626601d5690e84a5f35e0c0b971b47f2e9036c98254a6e36dc5e93c4
6
+ metadata.gz: 5b088f68484f5b281256c49e9d27547e66d7e8410f29e35e60562c0521e2e62b33e6d3e330b9f7b827237729422dea288a105365c799e7413cca73424d34ad68
7
+ data.tar.gz: fc08022e268e4e4e8e25c4f294bc382ce0f2986d443f0502e68278d0a0adbf2f57d8e4cc30316eb27ac9e210bd33cb0820d01d67b017ea30fbc6b614cc604ad8
@@ -105,13 +105,7 @@ module Tracetool
105
105
  # path to symbols dir
106
106
  # @return [String] desymbolicated stack trace
107
107
  def process(ctx)
108
- symbols = File.join(ctx.symbols, 'local')
109
- symbols = if ctx.arch
110
- File.join(symbols, ctx.arch)
111
- else
112
- Dir[File.join(symbols, '*')].first || symbols
113
- end
114
- Pipe['ndk-stack', '-sym', symbols] << @trace
108
+ Pipe['ndk-stack', '-sym', ctx.symbols] << @trace
115
109
  end
116
110
 
117
111
  # Create parser for current trace format
@@ -1,3 +1,4 @@
1
+ require_relative 'ios/atos_context'
1
2
  require_relative 'ios/scanner'
2
3
  require_relative 'ios/parser'
3
4
 
@@ -0,0 +1,35 @@
1
+ module Tracetool
2
+ module IOS
3
+ # Converts context to atos arguments
4
+ class AtosContext
5
+ # If no arch specified will use `arm64`
6
+ DEFAULT_ARCH = 'arm64'.freeze
7
+
8
+ # List of required argument names
9
+ REQUIRED_ARGUMENTS = %i[load_address xarchive module_name].freeze
10
+
11
+ def initialize(ctx)
12
+ check_arguments(ctx)
13
+ @load_address = ctx.load_address
14
+ @binary_path = module_binary(ctx.xarchive, ctx.module_name)
15
+ @arch = ctx.arch || 'arm64'
16
+ end
17
+
18
+ def to_args
19
+ %w[-o -l -arch].zip([@binary_path, @load_address, @arch]).flatten
20
+ end
21
+
22
+ private
23
+
24
+ def module_binary(xarchive, module_name)
25
+ File.join(xarchive, 'dSYMs', "#{module_name}.app.dSYM", 'Contents', 'Resources', 'DWARF', module_name)
26
+ end
27
+
28
+ def check_arguments(ctx)
29
+ REQUIRED_ARGUMENTS.each do |a|
30
+ ctx[a] || raise(ArgumentError, "Missing `#{a}` value")
31
+ end
32
+ end
33
+ end
34
+ end
35
+ end
@@ -5,7 +5,7 @@ module Tracetool
5
5
  # IOS traces scanner and source mapper
6
6
  class IOSTraceParser < Tracetool::BaseTraceParser
7
7
  # Describes IOS stack entry
8
- STACK_ENTRY_PATTERN = /^(?<frame>\d+) (?<binary>[^ ]+) (?<call_description>.+)$/.freeze
8
+ STACK_ENTRY_PATTERN = /^(?<frame>\d+)\t(?<binary>.+)\t(?<call_description>.+)$/.freeze
9
9
  # Describes source block
10
10
  SOURCE_PATTERN =
11
11
  /^((-?\[(?<class>[^ ]+) (?<method>.+)\])|(?<method>.+)) \(in (?<module>.+)\) \((?<file>.+):(?<line>\d+)\)$/
@@ -1,37 +1,5 @@
1
1
  module Tracetool
2
2
  module IOS
3
- # Converts context to atos arguments
4
- class AtosContext
5
- # If no arch specified will use `arm64`
6
- DEFAULT_ARCH = 'arm64'.freeze
7
-
8
- # List of required argument names
9
- REQUIRED_ARGUMENTS = %i[load_address xarchive module_name].freeze
10
-
11
- def initialize(ctx)
12
- check_arguments(ctx)
13
- @load_address = ctx.load_address
14
- @binary_path = module_binary(ctx.xarchive, ctx.module_name)
15
- @arch = ctx.arch || 'arm64'
16
- end
17
-
18
- def to_args
19
- %w[-o -l -arch].zip([@binary_path, @load_address, @arch]).flatten
20
- end
21
-
22
- private
23
-
24
- def module_binary(xarchive, module_name)
25
- File.join(xarchive, 'dSYMs', "#{module_name}.app.dSYM", 'Contents', 'Resources', 'DWARF', module_name)
26
- end
27
-
28
- def check_arguments(ctx)
29
- REQUIRED_ARGUMENTS.each do |a|
30
- ctx[a] || raise(ArgumentError, "Missing `#{a}` value")
31
- end
32
- end
33
- end
34
-
35
3
  # launches atos
36
4
  class IOSTraceScanner
37
5
  # Stack trace line consists of numerous whitespace separated
@@ -44,13 +12,32 @@ module Tracetool
44
12
  # @return [Array] containing (%binary_name%, %address%) pairs
45
13
  def parse(trace)
46
14
  trace.split("\n").map do |line|
47
- line.split(' ')[1..2] # Fetch binary name and address
15
+ parse_line(line)
48
16
  end
49
17
  end
50
18
 
19
+ # Parse trace line from trace. Which usualy looks like this:
20
+ # 3 My Module Name 0x0000000102d6e9f4 My Module Name + 5859828
21
+ # We need to fetch two values: 'My Module Name' and '0x0000000102d6e9f4'.
22
+ def parse_line(line)
23
+ parts = line.split(' ')
24
+ parts.shift # Frame number, not needed
25
+
26
+ module_name = ''
27
+
28
+ until parts.first.start_with?('0x')
29
+ module_name += parts.shift
30
+ module_name += ' '
31
+ end
32
+
33
+ address = parts.shift
34
+
35
+ [module_name.chop, address]
36
+ end
37
+
51
38
  def process(trace, context)
52
39
  trace = parse(trace)
53
- desym = run_atos(context, trace.map(&:last))
40
+ desym = run_atos(context, trace.map(&:last).join(' '))
54
41
  # Add useful columns to unpacked trace
55
42
  mix(trace, desym.split("\n")).join("\n")
56
43
  end
@@ -72,12 +59,7 @@ module Tracetool
72
59
  def mix(trace, symbolicated)
73
60
  trace.zip(symbolicated).map.with_index do |pair, i|
74
61
  t, desym = pair
75
- line = []
76
- line << i
77
- line << t.first
78
- line << desym
79
-
80
- line.join(' ')
62
+ "#{i}\t#{t.first}\t#{desym}"
81
63
  end
82
64
  end
83
65
  end
@@ -6,8 +6,8 @@ require_relative '../../version'
6
6
  module Tracetool
7
7
  # Tracetool cli args parser
8
8
  class ParseArgs
9
- # List of supported abis
10
- ARCH_LIST = %i[armeabi-v7a armeabi x86 arm64 arm64-v8a x86_64].freeze
9
+ # List of supported abis. Only needed for iOS unpacking
10
+ ARCH_LIST = %i[arm arm64].freeze
11
11
  #
12
12
  # Return a structure describing the options.
13
13
  #
@@ -30,14 +30,14 @@ module Tracetool
30
30
 
31
31
  {
32
32
  'address' => options.address,
33
- 'module' => options.modulename
33
+ 'module' => options.modulename,
34
+ 'arch' => options.arch
34
35
  }.each { |arg, check| raise(OptionParser::MissingArgument, arg) unless check }
35
36
  end
36
37
 
37
38
  def self.check(options)
38
39
  {
39
- 'platform' => options.platform,
40
- 'arch' => options.arch
40
+ 'platform' => options.platform
41
41
  }.each { |arg, check| raise(OptionParser::MissingArgument, arg) unless check }
42
42
  end
43
43
 
@@ -1,6 +1,7 @@
1
1
  require 'open3'
2
+
2
3
  module Tracetool
3
- # helper module for launching commands
4
+ # Helper module for launching commands
4
5
  module Pipe
5
6
  # Executes shell command
6
7
  class Executor
@@ -14,12 +15,10 @@ module Tracetool
14
15
  end
15
16
 
16
17
  def <<(args)
17
- args = args.join("\n") if args.is_a? Array
18
- IO.popen(cmd, 'r+') do |io|
19
- io.write(args)
20
- io.close_write
21
- io.read.chomp
22
- end
18
+ out, err, status = Open3.capture3({}, *cmd, stdin_data: args)
19
+ raise "#{cmd.join(' ')} (exit: #{status.exitstatus}) #{err.chomp}" unless status.success?
20
+
21
+ out.chomp
23
22
  end
24
23
  end
25
24
 
@@ -1,7 +1,7 @@
1
1
  module Tracetool
2
2
  # Version constant
3
3
  module Version
4
- VERSION = [0, 4, 2].freeze
4
+ VERSION = [0, 5, 4].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.4.2
4
+ version: 0.5.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - ilya.arkhanhelsky
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-16 00:00:00.000000000 Z
11
+ date: 2020-10-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: powerpack
@@ -37,6 +37,7 @@ files:
37
37
  - lib/tracetool/android/java.rb
38
38
  - lib/tracetool/android/native.rb
39
39
  - lib/tracetool/ios.rb
40
+ - lib/tracetool/ios/atos_context.rb
40
41
  - lib/tracetool/ios/parser.rb
41
42
  - lib/tracetool/ios/scanner.rb
42
43
  - lib/tracetool/utils/cli.rb
@@ -65,7 +66,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
65
66
  - !ruby/object:Gem::Version
66
67
  version: '0'
67
68
  requirements: []
68
- rubygems_version: 3.0.3
69
+ rubygems_version: 3.1.2
69
70
  signing_key:
70
71
  specification_version: 4
71
72
  summary: Tracetool