seafoam 0.8 → 0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bgv2isabelle +1 -5
  3. data/bin/bgv2json +1 -5
  4. data/bin/seafoam +1 -5
  5. data/lib/seafoam/bgv/bgv_parser.rb +1 -2
  6. data/lib/seafoam/commands.rb +135 -101
  7. data/lib/seafoam/formatters/base.rb +88 -0
  8. data/lib/seafoam/formatters/formatters.rb +8 -0
  9. data/lib/seafoam/formatters/json.rb +82 -0
  10. data/lib/seafoam/formatters/text.rb +70 -0
  11. data/lib/seafoam/graal/graph_description.rb +22 -0
  12. data/lib/seafoam/graal/pi.rb +18 -0
  13. data/lib/seafoam/graal/source.rb +5 -9
  14. data/lib/seafoam/graph.rb +9 -1
  15. data/lib/seafoam/graphviz_writer.rb +3 -0
  16. data/lib/seafoam/json_writer.rb +1 -3
  17. data/lib/seafoam/{annotators → passes}/fallback.rb +4 -4
  18. data/lib/seafoam/{annotators → passes}/graal.rb +43 -15
  19. data/lib/seafoam/passes/truffle.rb +58 -0
  20. data/lib/seafoam/passes.rb +61 -0
  21. data/lib/seafoam/version.rb +1 -1
  22. data/lib/seafoam.rb +7 -6
  23. metadata +17 -81
  24. data/.github/probots.yml +0 -2
  25. data/.github/workflows/workflows.yml +0 -40
  26. data/.gitignore +0 -6
  27. data/.rubocop.yml +0 -37
  28. data/.ruby-version +0 -1
  29. data/.seafoam/config +0 -1
  30. data/CODE_OF_CONDUCT.md +0 -128
  31. data/CONTRIBUTING.md +0 -5
  32. data/Gemfile +0 -2
  33. data/Gemfile.lock +0 -59
  34. data/LICENSE.md +0 -7
  35. data/README.md +0 -378
  36. data/bin/cfg2asm +0 -24
  37. data/demos/box-unbox-stats +0 -65
  38. data/docs/annotators.md +0 -43
  39. data/docs/bgv.md +0 -294
  40. data/docs/getting-graphs.md +0 -63
  41. data/docs/images/igv.png +0 -0
  42. data/docs/images/seafoam.png +0 -0
  43. data/docs/images/spotlight-igv.png +0 -0
  44. data/docs/images/spotlight-seafoam.png +0 -0
  45. data/docs/json.md +0 -35
  46. data/examples/Fib.java +0 -24
  47. data/examples/MatMult.java +0 -39
  48. data/examples/fib-java.bgv.gz +0 -0
  49. data/examples/fib.js +0 -15
  50. data/examples/fib.rb +0 -15
  51. data/examples/identity.rb +0 -13
  52. data/examples/java/Irreducible.class +0 -0
  53. data/examples/java/Irreducible.j +0 -35
  54. data/examples/java/IrreducibleDecompiled.java +0 -21
  55. data/examples/java/JavaExamples.java +0 -418
  56. data/examples/matmult.rb +0 -29
  57. data/examples/overflow.rb +0 -13
  58. data/examples/ruby/clamps.rb +0 -20
  59. data/examples/ruby/graal.patch +0 -15
  60. data/examples/ruby/ruby_examples.rb +0 -278
  61. data/lib/seafoam/annotators.rb +0 -54
  62. data/lib/seafoam/cfg/cfg_parser.rb +0 -93
  63. data/lib/seafoam/cfg/disassembler.rb +0 -70
  64. data/lib/seafoam/config.rb +0 -34
  65. data/seafoam.gemspec +0 -22
  66. data/spec/seafoam/annotators/fallback_spec.rb +0 -69
  67. data/spec/seafoam/annotators/graal_spec.rb +0 -96
  68. data/spec/seafoam/annotators_spec.rb +0 -61
  69. data/spec/seafoam/bgv/bgv_parser_spec.rb +0 -167
  70. data/spec/seafoam/binary/io_binary_reader_spec.rb +0 -176
  71. data/spec/seafoam/cfg/cfg_parser_spec.rb +0 -21
  72. data/spec/seafoam/cfg/disassembler_spec.rb +0 -32
  73. data/spec/seafoam/command_spec.rb +0 -314
  74. data/spec/seafoam/graph_spec.rb +0 -172
  75. data/spec/seafoam/graphviz_writer_spec.rb +0 -63
  76. data/spec/seafoam/json_writer_spec.rb +0 -14
  77. data/spec/seafoam/spec_helpers.rb +0 -34
  78. data/spec/seafoam/spotlight_spec.rb +0 -38
  79. data/tools/render-all +0 -36
@@ -1,96 +0,0 @@
1
- require 'seafoam'
2
-
3
- require 'rspec'
4
-
5
- require_relative '../spec_helpers'
6
-
7
- describe Seafoam::Annotators::GraalAnnotator do
8
- it 'applies to Graal graphs' do
9
- expect(Seafoam::Annotators::GraalAnnotator.applies?(Seafoam::SpecHelpers.example_graph('fib-java', 0))).to be true
10
- end
11
-
12
- it 'does not apply to Truffle trees' do
13
- expect(Seafoam::Annotators::GraalAnnotator.applies?(Seafoam::SpecHelpers.example_graph('fib-js', 0))).to be false
14
- end
15
-
16
- it 'applies to Truffle graphs' do
17
- expect(Seafoam::Annotators::GraalAnnotator.applies?(Seafoam::SpecHelpers.example_graph('fib-js', 2))).to be true
18
- end
19
-
20
- describe 'when run' do
21
- describe 'without options' do
22
- before :all do
23
- @graph = Seafoam::SpecHelpers.example_graph('matmult-ruby', 8)
24
- annotator = Seafoam::Annotators::GraalAnnotator.new({})
25
- annotator.annotate @graph
26
- end
27
-
28
- it 'annotates all nodes with a kind' do
29
- expect(@graph.nodes.values.any? { |n| n.props[:kind].nil? }).to be_falsey
30
- end
31
-
32
- it 'annotates all nodes with a label' do
33
- expect(@graph.nodes.values.any? { |n| n.props[:label].nil? }).to be_falsey
34
- end
35
-
36
- it 'annotates all edges with a kind' do
37
- expect(@graph.edges.any? { |e| e.props[:kind].nil? }).to be_falsey
38
- end
39
-
40
- it 'annotates not negated GuardNodes with "Guard, else ..."' do
41
- expect(@graph.nodes[7101].props['negated']).to be false
42
- expect(@graph.nodes[7101].props[:label]).to start_with 'Guard, else'
43
- end
44
-
45
- it 'annotates negated GuardNodes with "Guard not, else ..."' do
46
- expect(@graph.nodes[7102].props['negated']).to be true
47
- expect(@graph.nodes[7102].props[:label]).to start_with 'Guard not, else'
48
- end
49
- end
50
-
51
- describe 'with :hide_frame_state' do
52
- before :all do
53
- @graph = Seafoam::SpecHelpers.example_graph('matmult-ruby', 2)
54
- annotator = Seafoam::Annotators::GraalAnnotator.new(hide_frame_state: true)
55
- annotator.annotate @graph
56
- end
57
-
58
- it 'sets the hidden property on all frame state nodes' do
59
- frame_state_nodes = @graph.nodes.values.select do |n|
60
- Seafoam::Annotators::GraalAnnotator::FRAME_STATE_NODES.include?(n.props.dig(:node_class, :node_class))
61
- end
62
- expect(frame_state_nodes.all? { |n| n.props[:hidden] }).to be_truthy
63
- end
64
- end
65
-
66
- describe 'with :hide_floating' do
67
- before :all do
68
- @graph = Seafoam::SpecHelpers.example_graph('matmult-ruby', 2)
69
- annotator = Seafoam::Annotators::GraalAnnotator.new(hide_floating: true)
70
- annotator.annotate @graph
71
- end
72
-
73
- it 'sets the hidden property on all nodes without a control edge' do
74
- nodes_without_control_edge = @graph.nodes.values.select do |n|
75
- n.edges.none? { |e| e.props[:kind] == 'control' }
76
- end
77
- expect(nodes_without_control_edge.all? { |n| n.props[:hidden] }).to be_truthy
78
- end
79
- end
80
-
81
- describe 'with :reduce_edges' do
82
- before :all do
83
- @graph = Seafoam::SpecHelpers.example_graph('matmult-ruby', 2)
84
- annotator = Seafoam::Annotators::GraalAnnotator.new(reduce_edges: true)
85
- annotator.annotate @graph
86
- end
87
-
88
- it 'inlines all constant nodes' do
89
- constant_nodes = @graph.nodes.values.select do |n|
90
- Seafoam::Annotators::GraalAnnotator::SIMPLE_INPUTS.include?(n.props.dig(:node_class, :node_class))
91
- end
92
- expect(constant_nodes.all? { |n| n.props[:inlined] }).to be_truthy
93
- end
94
- end
95
- end
96
- end
@@ -1,61 +0,0 @@
1
- require 'seafoam'
2
-
3
- require 'rspec'
4
-
5
- describe Seafoam::Annotators do
6
- describe '#annotate' do
7
- it 'asks annotators if they apply' do
8
- check_applied = false
9
-
10
- Class.new(Seafoam::Annotator) do
11
- singleton_class.define_method(:applies?) do |_graph|
12
- check_applied = true
13
- false
14
- end
15
- end
16
-
17
- Seafoam::Annotators.apply(Seafoam::Graph.new)
18
- expect(check_applied).to be true
19
- end
20
-
21
- it 'runs annotators that apply' do
22
- check_annotated = false
23
-
24
- Class.new(Seafoam::Annotator) do
25
- singleton_class.define_method(:applies?) do |_graph|
26
- true
27
- end
28
-
29
- define_method(:annotate) do |_graph|
30
- check_annotated = true
31
- end
32
- end
33
-
34
- Seafoam::Annotators.apply(Seafoam::Graph.new)
35
- expect(check_annotated).to be true
36
- end
37
- end
38
-
39
- describe '#annotators' do
40
- it 'returns the standard annotators' do
41
- annotators = Seafoam::Annotators.annotators
42
- expect(annotators).to include Seafoam::Annotators::FallbackAnnotator
43
- expect(annotators).to include Seafoam::Annotators::GraalAnnotator
44
- end
45
-
46
- it 'returns custom annotators' do
47
- custom_annotator = Class.new(Seafoam::Annotator) do
48
- def self.applies?(_graph)
49
- false
50
- end
51
- end
52
- annotators = Seafoam::Annotators.annotators
53
- expect(annotators).to include custom_annotator
54
- end
55
-
56
- it 'returns the FallbackAnnotator annotator last' do
57
- annotators = Seafoam::Annotators.annotators
58
- expect(annotators.last).to eq Seafoam::Annotators::FallbackAnnotator
59
- end
60
- end
61
- end
@@ -1,167 +0,0 @@
1
- require 'seafoam'
2
-
3
- require 'rspec'
4
-
5
- require_relative '../spec_helpers'
6
-
7
- describe Seafoam::BGV::BGVParser do
8
- before :all do
9
- @fib_java_bgv = File.expand_path('../../../examples/fib-java.bgv', __dir__)
10
- end
11
-
12
- it 'can read full files' do
13
- Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
14
- parser = Seafoam::BGV::BGVParser.new(file)
15
- parser.read_file_header
16
- parser.skip_document_props
17
- loop do
18
- index, = parser.read_graph_preheader
19
- break unless index
20
-
21
- parser.read_graph_header
22
- parser.read_graph
23
- end
24
- end
25
- end
26
-
27
- it 'can read full gzipped files' do
28
- parser = Seafoam::BGV::BGVParser.new(File.expand_path('../../../examples/fib-java.bgv.gz', __dir__))
29
- parser.read_file_header
30
- parser.skip_document_props
31
- loop do
32
- index, = parser.read_graph_preheader
33
- break unless index
34
-
35
- parser.read_graph_header
36
- parser.read_graph
37
- end
38
- end
39
-
40
- it 'can skip full files' do
41
- Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
42
- parser = Seafoam::BGV::BGVParser.new(file)
43
- parser.read_file_header
44
- parser.skip_document_props
45
- loop do
46
- index, = parser.read_graph_preheader
47
- break unless index
48
-
49
- parser.skip_graph_header
50
- parser.skip_graph
51
- end
52
- end
53
- end
54
-
55
- it 'can read basic blocks' do
56
- parser = Seafoam::BGV::BGVParser.new(File.expand_path('../../../examples/fib-java.bgv', __dir__))
57
- parser.read_file_header
58
- parser.skip_document_props
59
- parser.read_graph_preheader
60
- parser.skip_graph_header
61
- graph = parser.read_graph
62
- expect(graph.blocks.size).to eq 3
63
- end
64
-
65
- it 'can alternate skipping and reading full files' do
66
- Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
67
- parser = Seafoam::BGV::BGVParser.new(file)
68
- parser.read_file_header
69
- parser.skip_document_props
70
- skip = false
71
- loop do
72
- index, = parser.read_graph_preheader
73
- break unless index
74
-
75
- if skip
76
- parser.skip_graph_header
77
- parser.skip_graph
78
- else
79
- parser.read_graph_header
80
- parser.read_graph
81
- end
82
- skip = !skip
83
- end
84
- end
85
- end
86
-
87
- describe '#read_file_header' do
88
- it 'produces a version' do
89
- parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
90
- expect(parser.read_file_header).to eq [7, 0]
91
- end
92
-
93
- it 'raises an error for files which are not BGV' do
94
- parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/not.bgv', __dir__))
95
- expect { parser.read_file_header }.to raise_error(EncodingError)
96
- end
97
-
98
- it 'raises an error for files which are an unsupported version of BGV' do
99
- parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
100
- expect { parser.read_file_header }.to raise_error(NotImplementedError)
101
- end
102
-
103
- it 'does not raise an error for an unsupported version of BGV if version_check is disabled' do
104
- parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
105
- expect(parser.read_file_header(version_check: false)).to eq [7, 2]
106
- end
107
- end
108
-
109
- describe '#read_graph_preheader' do
110
- it 'produces an index and id' do
111
- parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
112
- parser.read_file_header
113
- parser.skip_document_props
114
- expect(parser.read_graph_preheader).to eq [0, 0]
115
- end
116
-
117
- it 'returns nil for end of file' do
118
- parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
119
- parser.read_file_header
120
- parser.skip_document_props
121
- 56.times do
122
- expect(parser.read_graph_preheader).to_not be_nil
123
- parser.skip_graph_header
124
- parser.skip_graph
125
- end
126
- expect(parser.read_graph_preheader).to be_nil
127
- end
128
-
129
- it 'returns unique indicies' do
130
- parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
131
- parser.read_file_header
132
- parser.skip_document_props
133
- indicies = []
134
- 5.times do
135
- index, = parser.read_graph_preheader
136
- expect(indicies).to_not include index
137
- indicies.push index
138
- parser.skip_graph_header
139
- parser.skip_graph
140
- end
141
- end
142
- end
143
-
144
- describe '#read_graph_header' do
145
- it 'produces an expected header' do
146
- parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
147
- parser.read_file_header
148
- parser.skip_document_props
149
- parser.read_graph_preheader
150
- header = parser.read_graph_header
151
- expect(header[:props]['scope']).to eq 'main.Compiling.GraalCompiler.FrontEnd.PhaseSuite.GraphBuilderPhase'
152
- end
153
- end
154
-
155
- describe '#read_graph' do
156
- it 'produces an expected graph' do
157
- parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
158
- parser.read_file_header
159
- parser.skip_document_props
160
- parser.read_graph_preheader
161
- parser.read_graph_header
162
- graph = parser.read_graph
163
- expect(graph.nodes.size).to eq 21
164
- expect(graph.edges.size).to eq 30
165
- end
166
- end
167
- end
@@ -1,176 +0,0 @@
1
- require 'stringio'
2
-
3
- require 'seafoam'
4
-
5
- require 'rspec'
6
-
7
- describe Seafoam::Binary::IOBinaryReader do
8
- describe '#read_utf8' do
9
- it 'reads a UTF-8 string' do
10
- string = 'abc😀'
11
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new(string))
12
- expect(reader.read_utf8(string.bytesize)).to eq string
13
- end
14
- end
15
-
16
- describe '#read_bytes' do
17
- it 'reads bytes' do
18
- string = 'abc😀'
19
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new(string))
20
- expect(reader.read_bytes(string.bytesize)).to eq "abc\xF0\x9F\x98\x80".force_encoding(Encoding::ASCII_8BIT)
21
- end
22
- end
23
-
24
- describe '#read_float64' do
25
- it 'reads a double-precision float' do
26
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1.5].pack('G')}hello"))
27
- expect(reader.read_float64).to eq 1.5
28
- end
29
- end
30
-
31
- describe '#read_float32' do
32
- it 'reads a single-precision float' do
33
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1.5].pack('g')}hello"))
34
- expect(reader.read_float32).to eq 1.5
35
- end
36
- end
37
-
38
- describe '#read_sint64' do
39
- it 'reads a signed 64-bit network-endian integer' do
40
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1234].pack('q>')}hello"))
41
- expect(reader.read_sint64).to eq 1234
42
- end
43
- end
44
-
45
- describe '#read_sint32' do
46
- it 'reads a signed 32-bit network-endian integer' do
47
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1234].pack('l>')}hello"))
48
- expect(reader.read_sint32).to eq 1234
49
- end
50
- end
51
-
52
- describe '#read_sint16' do
53
- it 'reads a signed 16-bit network-endian integer' do
54
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1234].pack('s>')}hello"))
55
- expect(reader.read_sint16).to eq 1234
56
- end
57
- end
58
-
59
- describe '#read_sint8' do
60
- it 'reads a signed 8-bit integer' do
61
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[-123].pack('c')}hello"))
62
- expect(reader.read_sint8).to eq(-123)
63
- end
64
- end
65
-
66
- describe '#read_uint8' do
67
- it 'reads an unsigned 8-bit integer' do
68
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[212].pack('C')}hello"))
69
- expect(reader.read_uint8).to eq 212
70
- end
71
- end
72
-
73
- describe '#skip_float64' do
74
- it 'skips 8 bytes' do
75
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12345678x'))
76
- reader.skip_float64
77
- expect(reader.read_uint8).to eq 'x'.ord
78
- end
79
-
80
- it 'accepts a count' do
81
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234567812345678x'))
82
- reader.skip_float64 2
83
- expect(reader.read_uint8).to eq 'x'.ord
84
- end
85
- end
86
-
87
- describe '#skip_float32' do
88
- it 'skips 4 bytes' do
89
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234x'))
90
- reader.skip_float32
91
- expect(reader.read_uint8).to eq 'x'.ord
92
- end
93
-
94
- it 'accepts a count' do
95
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12341234x'))
96
- reader.skip_float32 2
97
- expect(reader.read_uint8).to eq 'x'.ord
98
- end
99
-
100
- describe '#skip_int64' do
101
- it 'skips 8 bytes' do
102
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12345678x'))
103
- reader.skip_int64
104
- expect(reader.read_uint8).to eq 'x'.ord
105
- end
106
-
107
- it 'accepts a count' do
108
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234567812345678x'))
109
- reader.skip_int64 2
110
- expect(reader.read_uint8).to eq 'x'.ord
111
- end
112
- end
113
-
114
- describe '#skip_int32' do
115
- it 'skips 4 bytes' do
116
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234x'))
117
- reader.skip_int32
118
- expect(reader.read_uint8).to eq 'x'.ord
119
- end
120
-
121
- it 'accepts a count' do
122
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12341234x'))
123
- reader.skip_int32 2
124
- expect(reader.read_uint8).to eq 'x'.ord
125
- end
126
- end
127
-
128
- describe '#skip_int16' do
129
- it 'skips 2 bytes' do
130
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12x'))
131
- reader.skip_int16
132
- expect(reader.read_uint8).to eq 'x'.ord
133
- end
134
-
135
- it 'accepts a count' do
136
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1212x'))
137
- reader.skip_int16 2
138
- expect(reader.read_uint8).to eq 'x'.ord
139
- end
140
- end
141
-
142
- describe '#skip_int8' do
143
- it 'skips 1 byte' do
144
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1x'))
145
- reader.skip_int8
146
- expect(reader.read_uint8).to eq 'x'.ord
147
- end
148
-
149
- it 'accepts a count' do
150
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('11x'))
151
- reader.skip_int8 2
152
- expect(reader.read_uint8).to eq 'x'.ord
153
- end
154
- end
155
-
156
- describe '#skip' do
157
- it 'skips n bytes' do
158
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('123x'))
159
- reader.skip 3
160
- expect(reader.read_uint8).to eq 'x'.ord
161
- end
162
- end
163
-
164
- describe '#eof?' do
165
- it 'returns false when not at the end of file' do
166
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('123'))
167
- expect(reader.eof?).to be false
168
- end
169
-
170
- it 'returns true when at the end of file' do
171
- reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new(''))
172
- expect(reader.eof?).to be true
173
- end
174
- end
175
- end
176
- end
@@ -1,21 +0,0 @@
1
- require 'seafoam'
2
-
3
- require 'rspec'
4
-
5
- require_relative '../spec_helpers'
6
-
7
- describe Seafoam::CFG::CFGParser do
8
- before :all do
9
- @example_cfg = File.expand_path('../../../examples/java/exampleIf.cfg', __dir__)
10
- end
11
-
12
- it 'correctly parses information from an nmethod' do
13
- parser = Seafoam::CFG::CFGParser.new($stdout, @example_cfg)
14
- parser.skip_over_cfg 'After code installation'
15
- nmethod = parser.read_nmethod
16
- expect(nmethod.code.arch).to eq 'AMD64'
17
- expect(nmethod.code.arch_width).to eq '64'
18
- expect(nmethod.code.base).to eq 0x1183037a0
19
- expect(nmethod.comments.size).to eq 25
20
- end
21
- end
@@ -1,32 +0,0 @@
1
- require 'seafoam'
2
-
3
- require 'rspec'
4
-
5
- require_relative '../spec_helpers'
6
-
7
- describe Seafoam::CFG::Disassembler do
8
- if Seafoam::SpecHelpers.dependencies_installed?
9
- it 'can start Capstone Disassembler disassemble an nmethod with and without comments' do
10
- @example_cfg = File.expand_path('../../../examples/java/exampleIf.cfg', __dir__)
11
- @file = File.open('tempfile_disassembler_spec.txt', 'w')
12
- parser = Seafoam::CFG::CFGParser.new(@file, @example_cfg)
13
- parser.skip_over_cfg 'After code installation'
14
- @nmethod = parser.read_nmethod
15
-
16
- disassembler = Seafoam::CFG::Disassembler.new(@file)
17
- disassembler.disassemble(@nmethod, 0)
18
- @file.close
19
-
20
- expect(`wc -l 'tempfile_disassembler_spec.txt'`.to_i).to eq 46
21
-
22
- @file = File.open('tempfile_disassembler_spec.txt', 'w')
23
- disassembler = Seafoam::CFG::Disassembler.new(@file)
24
- disassembler.disassemble(@nmethod, 2)
25
- @file.close
26
-
27
- expect(`wc -l 'tempfile_disassembler_spec.txt'`.to_i).to eq 46
28
-
29
- File.delete(@file)
30
- end
31
- end
32
- end