rbx-trepanning 0.0.1-universal-rubinius
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +376 -0
- data/LICENSE +25 -0
- data/NEWS +2 -0
- data/README.textile +28 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +218 -0
- data/app/breakpoint.rbc +3564 -0
- data/app/brkptmgr.rb +138 -0
- data/app/brkptmgr.rbc +2827 -0
- data/app/default.rb +61 -0
- data/app/default.rbc +1011 -0
- data/app/display.rb +35 -0
- data/app/display.rbc +968 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +112 -0
- data/app/irb.rbc +2111 -0
- data/app/iseq.rb +95 -0
- data/app/iseq.rbc +1801 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +123 -0
- data/app/options.rbc +2183 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1144 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +63 -0
- data/bin/trepanx.compiled.rbc +985 -0
- data/interface/base_intf.rb +95 -0
- data/interface/base_intf.rbc +1742 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/user.rb +91 -0
- data/interface/user.rbc +1418 -0
- data/io/base_io.rb +94 -0
- data/io/base_io.rbc +1404 -0
- data/io/input.rb +112 -0
- data/io/input.rbc +1979 -0
- data/io/null_output.rb +42 -0
- data/io/null_output.rbc +730 -0
- data/io/string_array.rb +156 -0
- data/io/string_array.rbc +2466 -0
- data/lib/trepanning.rb +398 -0
- data/lib/trepanning.rbc +6661 -0
- data/processor/breakpoint.rb +161 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +46 -0
- data/processor/command/base/cmd.rb +124 -0
- data/processor/command/base/subcmd.rb +213 -0
- data/processor/command/base/submgr.rb +179 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +184 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/continue.rb +82 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +43 -0
- data/processor/command/disassemble.rb +103 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +31 -0
- data/processor/command/exit.rb +58 -0
- data/processor/command/finish.rb +78 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +146 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +75 -0
- data/processor/command/info_subcmd/file.rb +153 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +59 -0
- data/processor/command/info_subcmd/variables.rb +40 -0
- data/processor/command/irb.rb +96 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +296 -0
- data/processor/command/next.rb +66 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/pr.rb +38 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +28 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
- data/processor/command/set_subcmd/basename.rb +26 -0
- data/processor/command/set_subcmd/debug.rb +27 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +60 -0
- data/processor/command/set_subcmd/hidelevel.rb +63 -0
- data/processor/command/set_subcmd/kernelstep.rb +61 -0
- data/processor/command/set_subcmd/max.rb +29 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +54 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/substitute.rb +25 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +27 -0
- data/processor/command/show_subcmd/alias.rb +43 -0
- data/processor/command/show_subcmd/args.rb +26 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +22 -0
- data/processor/command/show_subcmd/debug.rb +27 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +27 -0
- data/processor/command/show_subcmd/hidelevel.rb +42 -0
- data/processor/command/show_subcmd/kernelstep.rb +37 -0
- data/processor/command/show_subcmd/max.rb +30 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/trace.rb +29 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/source.rb +83 -0
- data/processor/command/step.rb +41 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/up.rb +87 -0
- data/processor/default.rb +56 -0
- data/processor/disassemble.rb +32 -0
- data/processor/eval.rb +96 -0
- data/processor/frame.rb +211 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +133 -0
- data/processor/load_cmds.rb +101 -0
- data/processor/location.rb +128 -0
- data/processor/main.rb +394 -0
- data/processor/mock.rb +137 -0
- data/processor/msg.rb +28 -0
- data/processor/running.rb +230 -0
- data/processor/stepping.rb +115 -0
- data/processor/subcmd.rb +160 -0
- data/processor/validate.rb +355 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +1 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +0 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-xx.rb +18 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/gcd1.rb +24 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +51 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +55 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +78 -0
- data/test/integration/test-fname-with-blank.rb +12 -0
- data/test/integration/test-quit.rb +25 -0
- data/test/unit/cmd-helper.rb +46 -0
- data/test/unit/test-app-brkpt.rb +30 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-iseq.rb +49 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +61 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +28 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +49 -0
- data/test/unit/test-cmd-break.rb +23 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +101 -0
- data/test/unit/test-cmd-kill.rb +48 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-proc-eval.rb +37 -0
- data/test/unit/test-proc-frame.rb +79 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +41 -0
- data/test/unit/test-proc-location.rb +48 -0
- data/test/unit/test-proc-main.rb +96 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +51 -0
- metadata +337 -0
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestBreak < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_line_only_break
|
11
|
+
# Check that we can set breakpoints in parent, sibling and children
|
12
|
+
# of sibling returns. We have one more 'continue' than we need
|
13
|
+
# just in case something goes wrong.
|
14
|
+
cmds_pat = ((['break %d'] * 4) + (%w(continue) * 4)).join("\n")
|
15
|
+
line = __LINE__
|
16
|
+
cmds = (cmds_pat % [line, line+6, line+11, line+14]).split(/\n/)
|
17
|
+
d = strarray_setup(cmds)
|
18
|
+
##############################
|
19
|
+
def foo # line + 4
|
20
|
+
a = 5 # line + 5
|
21
|
+
b = 6 # line + 6
|
22
|
+
end # line + 7
|
23
|
+
1.times do # line + 8
|
24
|
+
d.start # line + 9
|
25
|
+
1.times do # line + 10
|
26
|
+
x = 11 # line + 11
|
27
|
+
foo # line + 12
|
28
|
+
end # line + 13
|
29
|
+
c = 14 # line + 14
|
30
|
+
end
|
31
|
+
##############################
|
32
|
+
d.stop # ({:remove => true})
|
33
|
+
out = ["-- ",
|
34
|
+
'1.times do # line + 10',
|
35
|
+
'Set breakpoint 1: foo.rb:55 (@3)',
|
36
|
+
'Set breakpoint 2: foo.rb:55 (@3)',
|
37
|
+
'Set breakpoint 3: foo.rb:55 (@3)',
|
38
|
+
'Set breakpoint 4: foo.rb:55 (@3)',
|
39
|
+
'xx ',
|
40
|
+
'x = 11 # line + 11',
|
41
|
+
'xx ',
|
42
|
+
'b = 6 # line + 6',
|
43
|
+
'xx ',
|
44
|
+
'c = 14 # line + 14'
|
45
|
+
]
|
46
|
+
compare_output(out, d, cmds)
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
|
51
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestFinish < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_finish_between_fn
|
11
|
+
# "Finish" over a recursive function. We use a recursive function
|
12
|
+
# so that we check that the temporary breakpoint created in the
|
13
|
+
# implementation is specific to the frame. See Rubinius issue
|
14
|
+
# #558.
|
15
|
+
def fact(x)
|
16
|
+
return 1 if x <= 1
|
17
|
+
x = x * fact(x-1)
|
18
|
+
return x
|
19
|
+
end
|
20
|
+
# An extra 'continue' added in case something goes wrong.
|
21
|
+
cmds = %w(step finish) + ['pr x', 'continue', 'continue']
|
22
|
+
d = strarray_setup(cmds)
|
23
|
+
d.start
|
24
|
+
##############################
|
25
|
+
x = fact(4)
|
26
|
+
y = 5
|
27
|
+
##############################
|
28
|
+
d.stop # ({:remove => true})
|
29
|
+
out = ['-- ',
|
30
|
+
'x = fact(4)',
|
31
|
+
'-> ',
|
32
|
+
'return 1 if x <= 1',
|
33
|
+
'<- ',
|
34
|
+
'return x',
|
35
|
+
'24']
|
36
|
+
compare_output(out, d, cmds)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_finish_between_fn_simple
|
40
|
+
|
41
|
+
# Finish over functions
|
42
|
+
def five; 5 end
|
43
|
+
def something(x)
|
44
|
+
return 1 if x <= 1
|
45
|
+
x =
|
46
|
+
if five > 5
|
47
|
+
24
|
48
|
+
else
|
49
|
+
22
|
50
|
+
end
|
51
|
+
end
|
52
|
+
cmds = %w(step finish) + ['pr x', 'continue']
|
53
|
+
d = strarray_setup(cmds)
|
54
|
+
d.start
|
55
|
+
##############################
|
56
|
+
x = something(4)
|
57
|
+
y = 5
|
58
|
+
##############################
|
59
|
+
d.stop # ({:remove => true})
|
60
|
+
out = [
|
61
|
+
'-- ',
|
62
|
+
'x = something(4)',
|
63
|
+
'-> ',
|
64
|
+
'return 1 if x <= 1',
|
65
|
+
'<- ',
|
66
|
+
'22', '22']
|
67
|
+
compare_output(out, d, cmds)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestFnTestHelper < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_basic
|
11
|
+
assert_equal(__LINE__, get_lineno, 'get_lineno()')
|
12
|
+
assert_equal(0,
|
13
|
+
'-- (/tmp/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC)
|
14
|
+
assert_equal(0, '(trepanx): exit' =~ TREPAN_PROMPT)
|
15
|
+
|
16
|
+
output='
|
17
|
+
-- (/tmp/trepan/tmp/gcd.rb:4)
|
18
|
+
(trepanx): s
|
19
|
+
-- (/tmp/trepan/tmp/gcd.rb:18)
|
20
|
+
(trepanx): s
|
21
|
+
-- (/tmp/trepan/tmp/gcd.rb:19)
|
22
|
+
(trepanx): s
|
23
|
+
.. (/tmp/trepan/tmp/gcd.rb:0)
|
24
|
+
(trepanx): s
|
25
|
+
-> (/tmp/trepan/tmp/gcd.rb:4)
|
26
|
+
'.split(/\n/)
|
27
|
+
expect='
|
28
|
+
-- (/tmp/trepan/tmp/gcd.rb:4)
|
29
|
+
-- (/tmp/trepan/tmp/gcd.rb:18)
|
30
|
+
-- (/tmp/trepan/tmp/gcd.rb:19)
|
31
|
+
.. (/tmp/trepan/tmp/gcd.rb:0)
|
32
|
+
-> (/tmp/trepan/tmp/gcd.rb:4)
|
33
|
+
'.split(/\n/)
|
34
|
+
assert_equal(expect, filter_line_cmd(output))
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestBreak < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_list_frame_change
|
11
|
+
# Check that list update the frame position
|
12
|
+
# of sibling returns. We have one more 'continue' than we need
|
13
|
+
# just in case something goes wrong.
|
14
|
+
cmds_pat = [
|
15
|
+
'set max list 2',
|
16
|
+
'list',
|
17
|
+
"continue %d",
|
18
|
+
'list',
|
19
|
+
'up',
|
20
|
+
'list',
|
21
|
+
'continue'].join("\n")
|
22
|
+
line = __LINE__
|
23
|
+
cmds = (cmds_pat % (line+5)).split(/\n/)
|
24
|
+
d = strarray_setup(cmds)
|
25
|
+
##############################
|
26
|
+
def foo # line + 4
|
27
|
+
a = 5 # line + 5
|
28
|
+
b = 6 # line + 6
|
29
|
+
end # line + 7
|
30
|
+
d.start # line + 8
|
31
|
+
foo
|
32
|
+
##############################
|
33
|
+
d.stop # ({:remove => true})
|
34
|
+
out = [
|
35
|
+
"-- ",
|
36
|
+
"foo",
|
37
|
+
"max list is 2.",
|
38
|
+
" 30 \t d.start # line + 8",
|
39
|
+
" 31 ->\t foo",
|
40
|
+
"Set temporary breakpoint 1: foo.rb:55 (@3)",
|
41
|
+
"x1 ",
|
42
|
+
"a = 5 # line + 5",
|
43
|
+
" 26 \t def foo # line + 4 ",
|
44
|
+
" 27 ->\t a = 5 # line + 5",
|
45
|
+
" ",
|
46
|
+
"foo",
|
47
|
+
" 31 ->\t foo",
|
48
|
+
" 32 \t ##############################"
|
49
|
+
]
|
50
|
+
compare_output(out, d, cmds)
|
51
|
+
end
|
52
|
+
|
53
|
+
end
|
54
|
+
|
55
|
+
|
@@ -0,0 +1,49 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
def discontinuous(obj)
|
7
|
+
if klass = obj.class and klass.kind_of?(String)
|
8
|
+
return true
|
9
|
+
end
|
10
|
+
return nil
|
11
|
+
end
|
12
|
+
|
13
|
+
class TestNextBug < Test::Unit::TestCase
|
14
|
+
|
15
|
+
include FnTestHelper
|
16
|
+
|
17
|
+
# Sometimes a line may have a disconnected set of IP. For example
|
18
|
+
# Rubinius::VariableScope#method_visibility which has these
|
19
|
+
# offset/lines
|
20
|
+
#
|
21
|
+
# ... 0, 126, 22, 127, 29, 128, 43, 130, 48, 126, 50, ...
|
22
|
+
# ^^^ ^^^
|
23
|
+
#
|
24
|
+
# Make sure when can "next" when we are stopped at the 2nd part of
|
25
|
+
# line 126 (offset 50).
|
26
|
+
#
|
27
|
+
def test_next_on_line_with_discontinuous_ips
|
28
|
+
lines = method(:discontinuous).executable.lines
|
29
|
+
unless lines.at(3) == lines.at(7)
|
30
|
+
puts("Skipping #{__FILE__} test because code generated is not " +
|
31
|
+
"what we need to test here. Please fix.")
|
32
|
+
end
|
33
|
+
cmds = %w(step next continue)
|
34
|
+
d = strarray_setup(cmds)
|
35
|
+
d.start
|
36
|
+
discontinuous(4)
|
37
|
+
d.stop
|
38
|
+
out = ['-- ',
|
39
|
+
'discontinuous(4)',
|
40
|
+
'-> ',
|
41
|
+
'if klass = obj.class and klass.kind_of?(String)',
|
42
|
+
'-- ',
|
43
|
+
'return nil'
|
44
|
+
]
|
45
|
+
compare_output(out, d, cmds)
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestNext < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_next_same_level
|
11
|
+
|
12
|
+
# See that we can next with parameter which is the same as 'next 1'
|
13
|
+
cmds = %w(next next continue)
|
14
|
+
d = strarray_setup(cmds)
|
15
|
+
d.start
|
16
|
+
x = 5
|
17
|
+
y = 6
|
18
|
+
d.stop
|
19
|
+
out = ['-- ', 'x = 5', '-- ', 'y = 6', '-- ', 'd.stop']
|
20
|
+
compare_output(out, d, cmds)
|
21
|
+
|
22
|
+
# See that we can next with a computed count value
|
23
|
+
cmds = ['step', 'next 5-3', 'continue']
|
24
|
+
d = strarray_setup(cmds)
|
25
|
+
d.start
|
26
|
+
########### t1 ###############
|
27
|
+
x = 5
|
28
|
+
y = 6
|
29
|
+
z = 7
|
30
|
+
##############################
|
31
|
+
d.stop
|
32
|
+
out = ['-- ', 'x = 5', '-- ', 'y = 6', '-- ', 'd.stop']
|
33
|
+
compare_output(out, d, cmds)
|
34
|
+
end
|
35
|
+
|
36
|
+
def test_next_between_fn
|
37
|
+
|
38
|
+
# Next over functions
|
39
|
+
cmds = ['next 2', 'continue']
|
40
|
+
d = strarray_setup(cmds)
|
41
|
+
d.start
|
42
|
+
########### t2 ###############
|
43
|
+
def fact(x)
|
44
|
+
return 1 if x <= 1
|
45
|
+
return fact(x-1)
|
46
|
+
end
|
47
|
+
x = fact(4)
|
48
|
+
y = 5
|
49
|
+
##############################
|
50
|
+
d.stop # ({:remove => true})
|
51
|
+
out = ['-- ', 'def fact(x)', '-- ', 'y = 5']
|
52
|
+
compare_output(out, d, cmds)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_scoped_next
|
56
|
+
# "Next" over a recursive function. We use a recursive function so
|
57
|
+
# that we check that the temporary breakpoint created in the
|
58
|
+
# implementation is specific to the frame. See Rubinius issue
|
59
|
+
# #558.
|
60
|
+
def fact(x)
|
61
|
+
return 1 if x <= 1
|
62
|
+
x = x * fact(x-1)
|
63
|
+
return x
|
64
|
+
end
|
65
|
+
cmds = ['step', 'next 3', 'pr x', 'continue']
|
66
|
+
d = strarray_setup(cmds)
|
67
|
+
d.start
|
68
|
+
##############################
|
69
|
+
x = fact(4)
|
70
|
+
y = 5
|
71
|
+
##############################
|
72
|
+
d.stop # ({:remove => true})
|
73
|
+
out = ['-- ',
|
74
|
+
'x = fact(4)',
|
75
|
+
'-> ',
|
76
|
+
'return 1 if x <= 1',
|
77
|
+
'-- ',
|
78
|
+
'return x',
|
79
|
+
'24']
|
80
|
+
compare_output(out, d, cmds)
|
81
|
+
end
|
82
|
+
|
83
|
+
# def test_next_in_exception
|
84
|
+
# cmds = %w(next! continue)
|
85
|
+
# d = strarray_setup(cmds)
|
86
|
+
# d.start
|
87
|
+
# ########### t2 ###############
|
88
|
+
# begin
|
89
|
+
# got_boom = false
|
90
|
+
# x = 4/0
|
91
|
+
# rescue
|
92
|
+
# got_boom = true
|
93
|
+
# end
|
94
|
+
# ##############################
|
95
|
+
# d.stop # ({:remove => true})
|
96
|
+
# out = ['-- ', 'begin']
|
97
|
+
# compare_output(out, d, cmds)
|
98
|
+
# end
|
99
|
+
end
|
100
|
+
|
101
|
+
|
@@ -0,0 +1,272 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestStep < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_step_same_level
|
11
|
+
|
12
|
+
# See that we can step with parameter which is the same as 'step 1'
|
13
|
+
cmds = ['step', 'continue']
|
14
|
+
d = strarray_setup(cmds)
|
15
|
+
|
16
|
+
d.start
|
17
|
+
########### t1 ###############
|
18
|
+
x = 5
|
19
|
+
y = 6
|
20
|
+
##############################
|
21
|
+
d.stop
|
22
|
+
out = ['-- ', 'x = 5', '-- ', 'y = 6']
|
23
|
+
compare_output(out, d, cmds)
|
24
|
+
|
25
|
+
# See that we can step with a computed count value
|
26
|
+
cmds = ['step 5-3', 'continue']
|
27
|
+
d = strarray_setup(cmds)
|
28
|
+
d.start
|
29
|
+
########### t2 ###############
|
30
|
+
x = 5
|
31
|
+
y = 6
|
32
|
+
z = 7
|
33
|
+
##############################
|
34
|
+
d.stop # ({:remove => true})
|
35
|
+
out = ["-- ", "x = 5", "-- ", "z = 7"]
|
36
|
+
compare_output(out, d, cmds)
|
37
|
+
|
38
|
+
# # Test step>
|
39
|
+
# cmds = ['step>', 'continue']
|
40
|
+
# d = strarray_setup(cmds)
|
41
|
+
# d.start
|
42
|
+
# ########### t3 ###############
|
43
|
+
# x = 5
|
44
|
+
# def foo()
|
45
|
+
# end
|
46
|
+
# y = 6
|
47
|
+
# foo
|
48
|
+
# ##############################
|
49
|
+
# d.stop # {:remove => true})
|
50
|
+
# out = ['-- ', 'x = 5', 'METHOD TestStep#foo()', '-> ', 'def foo()']
|
51
|
+
# compare_output(out, d, cmds)
|
52
|
+
|
53
|
+
# # Test step!
|
54
|
+
# cmds = ['step!', 'continue']
|
55
|
+
# d = strarray_setup(cmds)
|
56
|
+
# d.start()
|
57
|
+
# ########### t4 ###############
|
58
|
+
# x = 5
|
59
|
+
# begin
|
60
|
+
# y = 2
|
61
|
+
# z = 1/0
|
62
|
+
# rescue
|
63
|
+
# end
|
64
|
+
# ##############################
|
65
|
+
# d.stop # ({:remove => true})
|
66
|
+
# out = ['-- ', 'x = 5',
|
67
|
+
# '#<ZeroDivisionError: divided by 0>',
|
68
|
+
# '!! ', 'z = 1/0']
|
69
|
+
# compare_output(out, d, cmds)
|
70
|
+
|
71
|
+
# # Test "step" with sets of events. Part 1
|
72
|
+
# cmds = ['set events call raise',
|
73
|
+
# 'step', 's!']
|
74
|
+
# d = strarray_setup(cmds)
|
75
|
+
# d.start()
|
76
|
+
# ########### t5 ###############
|
77
|
+
# x = 5
|
78
|
+
# def foo1
|
79
|
+
# y = 2
|
80
|
+
# raise Exception
|
81
|
+
# rescue Exception
|
82
|
+
# end
|
83
|
+
# foo1()
|
84
|
+
# z = 1
|
85
|
+
# ##############################
|
86
|
+
# d.stop # ({:remove => true})
|
87
|
+
# out = ['-- ',
|
88
|
+
# 'x = 5',
|
89
|
+
# 'Trace events we may stop on:',
|
90
|
+
# "\tbrkpt, call, raise",
|
91
|
+
# 'METHOD TestStep#foo1()',
|
92
|
+
# '-> ',
|
93
|
+
# 'def foo1',
|
94
|
+
# '#<Exception: Exception>',
|
95
|
+
# '!! ',
|
96
|
+
# 'raise Exception']
|
97
|
+
|
98
|
+
# got = filter_line_cmd(d.intf[-1].output.output)
|
99
|
+
# out.pop if got.size+1 == out.size
|
100
|
+
# compare_output(out, d, cmds)
|
101
|
+
|
102
|
+
# # Test "step" will sets of events. Part 2
|
103
|
+
# cmds = ['step> 1+0',
|
104
|
+
# 'step! 1', 'continue']
|
105
|
+
# d = strarray_setup(cmds)
|
106
|
+
# d.start()
|
107
|
+
# ########### t6 ###############
|
108
|
+
# x = 5
|
109
|
+
# begin
|
110
|
+
# def foo2()
|
111
|
+
# y = 2
|
112
|
+
# raise Exception
|
113
|
+
# end
|
114
|
+
# foo2()
|
115
|
+
# rescue Exception
|
116
|
+
# end
|
117
|
+
# z = 1
|
118
|
+
# ##############################
|
119
|
+
# d.stop({:remove => true})
|
120
|
+
# out = ['-- ',
|
121
|
+
# 'x = 5',
|
122
|
+
# 'METHOD TestStep#foo2()',
|
123
|
+
# '-> ',
|
124
|
+
# 'def foo2()',
|
125
|
+
# 'TestStep',
|
126
|
+
# '!! ',
|
127
|
+
# 'raise Exception']
|
128
|
+
|
129
|
+
end
|
130
|
+
|
131
|
+
def no_test_step_between_fn
|
132
|
+
|
133
|
+
# Step into and out of a function
|
134
|
+
def sqr(x)
|
135
|
+
y = x * x
|
136
|
+
end
|
137
|
+
cmds = %w(step) * 4 + %w(continue)
|
138
|
+
out = ['-- ',
|
139
|
+
'x = sqr(4)',
|
140
|
+
'METHOD TestStep#sqr(x)',
|
141
|
+
'-> ',
|
142
|
+
'def sqr(x)',
|
143
|
+
'-- ',
|
144
|
+
'y = x * x',
|
145
|
+
'<- ',
|
146
|
+
'R=> 16',
|
147
|
+
'end',
|
148
|
+
'-- ',
|
149
|
+
'y = 5']
|
150
|
+
d = strarray_setup(cmds)
|
151
|
+
d.start
|
152
|
+
########### t7 ###############
|
153
|
+
x = sqr(4)
|
154
|
+
y = 5
|
155
|
+
##############################
|
156
|
+
d.stop # ({:remove => true})
|
157
|
+
compare_output(out, d, cmds)
|
158
|
+
|
159
|
+
cmds = ['set events call return',
|
160
|
+
'step', 'step', 'continue']
|
161
|
+
out = ['-- ',
|
162
|
+
'x = sqr(4)',
|
163
|
+
'Trace events we may stop on:',
|
164
|
+
"\tbrkpt, call, return",
|
165
|
+
'METHOD TestStep#sqr(x)',
|
166
|
+
'-> ',
|
167
|
+
'def sqr(x)',
|
168
|
+
'<- ',
|
169
|
+
'R=> 16',
|
170
|
+
'end']
|
171
|
+
d = strarray_setup(cmds)
|
172
|
+
d.start
|
173
|
+
########### t8 ###############
|
174
|
+
x = sqr(4)
|
175
|
+
y = 5
|
176
|
+
##############################
|
177
|
+
d.stop # ({:remove => true})
|
178
|
+
compare_output(out, d, cmds)
|
179
|
+
end
|
180
|
+
|
181
|
+
def no_test_step_in_exception
|
182
|
+
def boom(x)
|
183
|
+
y = 0/x
|
184
|
+
end
|
185
|
+
def bad(x)
|
186
|
+
boom(x)
|
187
|
+
y = x * x
|
188
|
+
end
|
189
|
+
cmds = %w(step! continue)
|
190
|
+
d = strarray_setup(cmds)
|
191
|
+
begin
|
192
|
+
d.start()
|
193
|
+
x = bad(0)
|
194
|
+
assert_equal(false, true, 'should have raised an exception')
|
195
|
+
rescue ZeroDivisionError
|
196
|
+
assert true, 'Got the exception'
|
197
|
+
ensure
|
198
|
+
d.stop({:remove => true})
|
199
|
+
end
|
200
|
+
|
201
|
+
out = ['-- ',
|
202
|
+
'x = bad(0)', # line event
|
203
|
+
'#<ZeroDivisionError: divided by 0>',
|
204
|
+
'!! ', # exception event
|
205
|
+
'y = 0/x']
|
206
|
+
|
207
|
+
compare_output(out, d, cmds)
|
208
|
+
end
|
209
|
+
|
210
|
+
def no_test_step_event
|
211
|
+
|
212
|
+
def fact(x)
|
213
|
+
return 1 if x <= 1
|
214
|
+
x = x * fact(x-1)
|
215
|
+
return x
|
216
|
+
end
|
217
|
+
cmds = ['step<', '1 == x', 'continue']
|
218
|
+
d = strarray_setup(cmds)
|
219
|
+
d.start
|
220
|
+
########### t9 ###############
|
221
|
+
x = fact(4)
|
222
|
+
y = 5
|
223
|
+
##############################
|
224
|
+
d.stop # ({:remove => true})
|
225
|
+
out = ['-- ',
|
226
|
+
'x = fact(4)',
|
227
|
+
'<- ',
|
228
|
+
'R=> 1',
|
229
|
+
'return 1 if x <= 1',
|
230
|
+
'D=> true']
|
231
|
+
compare_output(out, d, cmds)
|
232
|
+
end
|
233
|
+
|
234
|
+
def no_test_step_into_fun
|
235
|
+
|
236
|
+
# Bug was that we were stopping at a VM instruction before the fn
|
237
|
+
# call proper ('bar' below), and not getting a line number for it.
|
238
|
+
# So a subsequent 'step' when 'set different' in effect was to stay
|
239
|
+
# at the same place at the function call.
|
240
|
+
cmds = ['set different', 'set events call, class, line, return',
|
241
|
+
'step', 'step', 'step', 'step', 'continue']
|
242
|
+
d = strarray_setup(cmds)
|
243
|
+
d.start
|
244
|
+
########### t10 ###############
|
245
|
+
def bar
|
246
|
+
return 1
|
247
|
+
end
|
248
|
+
|
249
|
+
def foo
|
250
|
+
bar
|
251
|
+
return 5
|
252
|
+
end
|
253
|
+
foo
|
254
|
+
##############################
|
255
|
+
d.stop # ({:remove => true})
|
256
|
+
out = ['-- ',
|
257
|
+
'def bar',
|
258
|
+
'different is on.',
|
259
|
+
'Trace events we may stop on:',
|
260
|
+
"\tbrkpt, call, class, line, return",
|
261
|
+
'-- ',
|
262
|
+
'def foo',
|
263
|
+
'-- ',
|
264
|
+
'foo',
|
265
|
+
'METHOD TestStep#foo()',
|
266
|
+
'-> ',
|
267
|
+
'def foo',
|
268
|
+
'-- ',
|
269
|
+
'bar']
|
270
|
+
compare_output(out, d, cmds)
|
271
|
+
end
|
272
|
+
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestStep2 < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_step_out_of_fn
|
11
|
+
|
12
|
+
# See that handle stepping out of a function properly.
|
13
|
+
cmds = ['step', 'step', 'continue']
|
14
|
+
d = strarray_setup(cmds)
|
15
|
+
|
16
|
+
def echo(x)
|
17
|
+
return x
|
18
|
+
end
|
19
|
+
|
20
|
+
d.start
|
21
|
+
########### t1 ###############
|
22
|
+
x = echo("hi")
|
23
|
+
y = 3
|
24
|
+
##############################
|
25
|
+
d.stop
|
26
|
+
out = ['-- ',
|
27
|
+
'x = echo("hi")',
|
28
|
+
'-> ',
|
29
|
+
'return x',
|
30
|
+
'-- ',
|
31
|
+
'x = echo("hi")']
|
32
|
+
compare_output(out, d, cmds)
|
33
|
+
end
|
34
|
+
|
35
|
+
end
|