trepanning 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +4422 -0
- data/LICENSE +23 -0
- data/NEWS +12 -0
- data/README.textile +56 -0
- data/Rakefile +171 -0
- data/app/Makefile +7 -0
- data/app/breakpoint.rb +157 -0
- data/app/brkptmgr.rb +149 -0
- data/app/condition.rb +22 -0
- data/app/core.rb +203 -0
- data/app/default.rb +54 -0
- data/app/disassemble.rb +61 -0
- data/app/display.rb +148 -0
- data/app/file.rb +135 -0
- data/app/frame.rb +275 -0
- data/app/irb.rb +112 -0
- data/app/mock.rb +22 -0
- data/app/options.rb +122 -0
- data/app/run.rb +95 -0
- data/app/thread.rb +24 -0
- data/app/util.rb +32 -0
- data/bin/trepan +63 -0
- data/data/custom_require.rb +44 -0
- data/data/irbrc +55 -0
- data/data/prelude.rb +38 -0
- data/interface/base_intf.rb +95 -0
- data/interface/script.rb +103 -0
- data/interface/user.rb +90 -0
- data/io/base_io.rb +92 -0
- data/io/input.rb +111 -0
- data/io/string_array.rb +155 -0
- data/lib/Makefile +7 -0
- data/lib/trepanning.rb +277 -0
- data/processor/breakpoint.rb +108 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +95 -0
- data/processor/command/base/cmd.rb +97 -0
- data/processor/command/base/subcmd.rb +207 -0
- data/processor/command/base/submgr.rb +178 -0
- data/processor/command/base/subsubcmd.rb +102 -0
- data/processor/command/base/subsubmgr.rb +182 -0
- data/processor/command/break.rb +85 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/debug.rb +85 -0
- data/processor/command/delete.rb +54 -0
- data/processor/command/directory.rb +43 -0
- data/processor/command/disable.rb +65 -0
- data/processor/command/disassemble.rb +103 -0
- data/processor/command/display.rb +81 -0
- data/processor/command/down.rb +56 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/exit.rb +54 -0
- data/processor/command/finish.rb +81 -0
- data/processor/command/frame.rb +117 -0
- data/processor/command/help.rb +146 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/args.rb +56 -0
- data/processor/command/info_subcmd/breakpoints.rb +162 -0
- data/processor/command/info_subcmd/file.rb +162 -0
- data/processor/command/info_subcmd/frame.rb +39 -0
- data/processor/command/info_subcmd/iseq.rb +83 -0
- data/processor/command/info_subcmd/locals.rb +88 -0
- data/processor/command/info_subcmd/program.rb +54 -0
- data/processor/command/info_subcmd/registers.rb +72 -0
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +38 -0
- data/processor/command/info_subcmd/registers_subcmd/helper.rb +40 -0
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +54 -0
- data/processor/command/info_subcmd/registers_subcmd/pc.rb +44 -0
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +75 -0
- data/processor/command/info_subcmd/return.rb +40 -0
- data/processor/command/info_subcmd/thread.rb +106 -0
- data/processor/command/irb.rb +106 -0
- data/processor/command/kill.rb +58 -0
- data/processor/command/list.rb +327 -0
- data/processor/command/macro.rb +65 -0
- data/processor/command/next.rb +89 -0
- data/processor/command/nocache.rb +33 -0
- data/processor/command/print.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/quit.rb +62 -0
- data/processor/command/raise.rb +47 -0
- data/processor/command/reload.rb +28 -0
- data/processor/command/reload_subcmd/command.rb +34 -0
- data/processor/command/restart.rb +57 -0
- data/processor/command/save.rb +60 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +67 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +49 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +51 -0
- data/processor/command/set_subcmd/basename.rb +39 -0
- data/processor/command/set_subcmd/debug.rb +27 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +49 -0
- data/processor/command/set_subcmd/debug_subcmd/except.rb +35 -0
- data/processor/command/set_subcmd/debug_subcmd/macro.rb +35 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +35 -0
- data/processor/command/set_subcmd/debug_subcmd/stack.rb +45 -0
- data/processor/command/set_subcmd/different.rb +67 -0
- data/processor/command/set_subcmd/events.rb +71 -0
- data/processor/command/set_subcmd/max.rb +35 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +60 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +53 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +50 -0
- data/processor/command/set_subcmd/return.rb +66 -0
- data/processor/command/set_subcmd/sp.rb +62 -0
- data/processor/command/set_subcmd/substitute.rb +25 -0
- data/processor/command/set_subcmd/substitute_subcmd/eval.rb +98 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +55 -0
- data/processor/command/set_subcmd/substitute_subcmd/string.rb +72 -0
- data/processor/command/set_subcmd/timer.rb +68 -0
- data/processor/command/set_subcmd/trace.rb +43 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +56 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +54 -0
- data/processor/command/set_subcmd/trace_subcmd/var.rb +61 -0
- data/processor/command/show.rb +27 -0
- data/processor/command/show_subcmd/alias.rb +50 -0
- data/processor/command/show_subcmd/args.rb +50 -0
- data/processor/command/show_subcmd/auto.rb +27 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +38 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +36 -0
- data/processor/command/show_subcmd/basename.rb +28 -0
- data/processor/command/show_subcmd/debug.rb +27 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +31 -0
- data/processor/command/show_subcmd/debug_subcmd/except.rb +33 -0
- data/processor/command/show_subcmd/debug_subcmd/macro.rb +32 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +33 -0
- data/processor/command/show_subcmd/debug_subcmd/stack.rb +32 -0
- data/processor/command/show_subcmd/different.rb +37 -0
- data/processor/command/show_subcmd/events.rb +40 -0
- data/processor/command/show_subcmd/macro.rb +45 -0
- data/processor/command/show_subcmd/max.rb +31 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +39 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +35 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +41 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +36 -0
- data/processor/command/show_subcmd/trace.rb +29 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +84 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/source.rb +74 -0
- data/processor/command/step.rb +139 -0
- data/processor/command/stepi.rb +63 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +92 -0
- data/processor/default.rb +45 -0
- data/processor/display.rb +17 -0
- data/processor/eval.rb +88 -0
- data/processor/eventbuf.rb +131 -0
- data/processor/frame.rb +230 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +128 -0
- data/processor/load_cmds.rb +102 -0
- data/processor/location.rb +126 -0
- data/processor/main.rb +364 -0
- data/processor/mock.rb +100 -0
- data/processor/msg.rb +26 -0
- data/processor/running.rb +170 -0
- data/processor/subcmd.rb +159 -0
- data/processor/validate.rb +395 -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 +119 -0
- data/test/functional/test-break.rb +87 -0
- data/test/functional/test-condition.rb +59 -0
- data/test/functional/test-debugger-call-bug.rb +31 -0
- data/test/functional/test-delete.rb +71 -0
- data/test/functional/test-finish.rb +44 -0
- data/test/functional/test-immediate-step-bug.rb +35 -0
- data/test/functional/test-next.rb +77 -0
- data/test/functional/test-raise.rb +73 -0
- data/test/functional/test-return.rb +100 -0
- data/test/functional/test-step.rb +274 -0
- data/test/functional/test-stepbug.rb +40 -0
- data/test/functional/test-trace-var.rb +40 -0
- data/test/functional/tmp/b1.rb +5 -0
- data/test/functional/tmp/s1.rb +9 -0
- data/test/functional/tmp/t2.rb +6 -0
- data/test/integration/file-diff.rb +88 -0
- data/test/integration/helper.rb +52 -0
- data/test/integration/test-fname-with-blank.rb +11 -0
- data/test/integration/test-quit.rb +11 -0
- data/test/integration/try-test-enable.rb +11 -0
- data/test/unit/cmd-helper.rb +44 -0
- data/test/unit/test-app-brkpt.rb +30 -0
- data/test/unit/test-app-brkptmgr.rb +56 -0
- data/test/unit/test-app-disassemble.rb +60 -0
- data/test/unit/test-app-file.rb +46 -0
- data/test/unit/test-app-frame.rb +49 -0
- data/test/unit/test-app-options.rb +60 -0
- data/test/unit/test-app-run.rb +19 -0
- data/test/unit/test-app-thread.rb +25 -0
- data/test/unit/test-app-util.rb +17 -0
- data/test/unit/test-base-subcmd.rb +59 -0
- data/test/unit/test-bin-trepan.rb +48 -0
- data/test/unit/test-cmd-alias.rb +50 -0
- data/test/unit/test-cmd-break.rb +80 -0
- data/test/unit/test-cmd-endisable.rb +59 -0
- data/test/unit/test-cmd-help.rb +100 -0
- data/test/unit/test-cmd-kill.rb +47 -0
- data/test/unit/test-cmd-quit.rb +26 -0
- data/test/unit/test-cmd-step.rb +45 -0
- data/test/unit/test-intf-user.rb +45 -0
- data/test/unit/test-io-input.rb +26 -0
- data/test/unit/test-proc-eval.rb +26 -0
- data/test/unit/test-proc-frame.rb +77 -0
- data/test/unit/test-proc-help.rb +15 -0
- data/test/unit/test-proc-hook.rb +29 -0
- data/test/unit/test-proc-load_cmds.rb +40 -0
- data/test/unit/test-proc-main.rb +99 -0
- data/test/unit/test-proc-validate.rb +90 -0
- data/test/unit/test-subcmd-help.rb +48 -0
- metadata +358 -0
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
4
|
+
require_relative 'fn_helper'
|
|
5
|
+
require_relative '../../app/breakpoint'
|
|
6
|
+
|
|
7
|
+
class TestBreak < Test::Unit::TestCase
|
|
8
|
+
|
|
9
|
+
include FnTestHelper
|
|
10
|
+
|
|
11
|
+
def test_condition
|
|
12
|
+
file = File.basename(__FILE__)
|
|
13
|
+
|
|
14
|
+
# See that we can next with parameter which is the same as 'next 1'
|
|
15
|
+
cmds = ['set basename on',
|
|
16
|
+
'break ' + (__LINE__ + 7).to_s,
|
|
17
|
+
'condition 1 x < 5',
|
|
18
|
+
'continue']
|
|
19
|
+
d = strarray_setup(cmds)
|
|
20
|
+
d.start
|
|
21
|
+
########### b1 ###############
|
|
22
|
+
x = 6
|
|
23
|
+
y = 7
|
|
24
|
+
z = 8
|
|
25
|
+
##############################
|
|
26
|
+
d.stop
|
|
27
|
+
out = ['-- ',
|
|
28
|
+
'x = 6',
|
|
29
|
+
'basename is on.',
|
|
30
|
+
"Breakpoint 1 set at line #{__LINE__-7} in file #{file},\n" +
|
|
31
|
+
"\tVM offset 55 of instruction sequence \"test_condition\"."
|
|
32
|
+
]
|
|
33
|
+
compare_output(out, d, cmds)
|
|
34
|
+
|
|
35
|
+
# Try a condition that fails
|
|
36
|
+
cmds = ['set basename on',
|
|
37
|
+
'break ' + (__LINE__ + 7).to_s,
|
|
38
|
+
'condition 1 x > 5',
|
|
39
|
+
'continue']
|
|
40
|
+
d = strarray_setup(cmds)
|
|
41
|
+
d.start
|
|
42
|
+
########### b2 ###############
|
|
43
|
+
x = 6
|
|
44
|
+
y = 7
|
|
45
|
+
z = 8
|
|
46
|
+
##############################
|
|
47
|
+
d.stop
|
|
48
|
+
out = ['-- ',
|
|
49
|
+
'x = 6',
|
|
50
|
+
'basename is on.',
|
|
51
|
+
"Breakpoint 1 set at line #{__LINE__-7} in file #{file},\n" +
|
|
52
|
+
"\tVM offset 55 of instruction sequence \"test_condition\".",
|
|
53
|
+
'xx ',
|
|
54
|
+
'y = 7']
|
|
55
|
+
compare_output(out, d, cmds)
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
end
|
|
59
|
+
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../lib/trepanning'
|
|
4
|
+
|
|
5
|
+
class TestTrepanCallBug < Test::Unit::TestCase
|
|
6
|
+
|
|
7
|
+
def test_debugger_call_bug
|
|
8
|
+
$calls = []
|
|
9
|
+
mydbgr = nil
|
|
10
|
+
2.times do
|
|
11
|
+
x = 1
|
|
12
|
+
mydbgr = Trepan.new()
|
|
13
|
+
mydbgr.core.processor.define_singleton_method(:process_commands) do
|
|
14
|
+
|frame|
|
|
15
|
+
# p [frame.source_container, frame.source_location, @core.event].flatten
|
|
16
|
+
$calls << [frame.source_container, frame.source_location].flatten
|
|
17
|
+
end
|
|
18
|
+
mydbgr.debugger
|
|
19
|
+
y = 2
|
|
20
|
+
end
|
|
21
|
+
mydbgr.stop
|
|
22
|
+
assert_equal true, $calls.size > 0, $calls
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
4
|
+
require_relative 'fn_helper'
|
|
5
|
+
require_relative '../../app/breakpoint'
|
|
6
|
+
|
|
7
|
+
class TestDelete < Test::Unit::TestCase
|
|
8
|
+
|
|
9
|
+
include FnTestHelper
|
|
10
|
+
|
|
11
|
+
def test_delete
|
|
12
|
+
|
|
13
|
+
# See that when we can delete a breakpoint.
|
|
14
|
+
cmds = ['set basename on',
|
|
15
|
+
'break ' + (__LINE__ + 9).to_s,
|
|
16
|
+
'delete 1',
|
|
17
|
+
'continue',
|
|
18
|
+
]
|
|
19
|
+
d = strarray_setup(cmds)
|
|
20
|
+
d.start
|
|
21
|
+
########### b1 ###############
|
|
22
|
+
va = 1
|
|
23
|
+
vb = 2
|
|
24
|
+
vc = 3
|
|
25
|
+
vd = 4
|
|
26
|
+
ve = 5
|
|
27
|
+
##############################
|
|
28
|
+
d.stop
|
|
29
|
+
out = ['-- ',
|
|
30
|
+
'va = 1',
|
|
31
|
+
'basename is on.',
|
|
32
|
+
"Breakpoint 1 set at line #{__LINE__-8} in file test-delete.rb,\n\tVM offset 55 of instruction sequence \"test_delete\".",
|
|
33
|
+
"Deleted breakpoint 1."]
|
|
34
|
+
compare_output(out, d, cmds)
|
|
35
|
+
|
|
36
|
+
# See that when we can delete a breakpoint but get to the next one.
|
|
37
|
+
cmds = ['set basename on',
|
|
38
|
+
'set autoeval on',
|
|
39
|
+
'break ' + (__LINE__ + 11).to_s,
|
|
40
|
+
'break ' + (__LINE__ + 12).to_s,
|
|
41
|
+
'delete 1',
|
|
42
|
+
'continue',
|
|
43
|
+
'va',
|
|
44
|
+
'continue',
|
|
45
|
+
]
|
|
46
|
+
d = strarray_setup(cmds)
|
|
47
|
+
d.start
|
|
48
|
+
########### b1 ###############
|
|
49
|
+
va = 1
|
|
50
|
+
vb = 2
|
|
51
|
+
va = 3
|
|
52
|
+
vd = 4
|
|
53
|
+
ve = 5
|
|
54
|
+
##############################
|
|
55
|
+
d.stop
|
|
56
|
+
out = ["-- ",
|
|
57
|
+
"va = 1",
|
|
58
|
+
"basename is on.",
|
|
59
|
+
"Evaluation of unrecognized debugger commands is on.",
|
|
60
|
+
"Breakpoint 1 set at line #{__LINE__-10} in file test-delete.rb,\n\tVM offset 55 of instruction sequence \"test_delete\".",
|
|
61
|
+
"Breakpoint 2 set at line #{__LINE__-9} in file test-delete.rb,\n\tVM offset 55 of instruction sequence \"test_delete\".",
|
|
62
|
+
"Deleted breakpoint 1.",
|
|
63
|
+
"xx ",
|
|
64
|
+
"vd = 4",
|
|
65
|
+
"D=> 3"]
|
|
66
|
+
compare_output(out, d, cmds)
|
|
67
|
+
|
|
68
|
+
end
|
|
69
|
+
|
|
70
|
+
end
|
|
71
|
+
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
4
|
+
require_relative 'fn_helper'
|
|
5
|
+
|
|
6
|
+
class TestFinish < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include FnTestHelper
|
|
9
|
+
|
|
10
|
+
def test_finish_between_fn
|
|
11
|
+
|
|
12
|
+
# Finish over functions
|
|
13
|
+
def fact(x)
|
|
14
|
+
return 1 if x <= 1
|
|
15
|
+
x = x * fact(x-1)
|
|
16
|
+
return x
|
|
17
|
+
end
|
|
18
|
+
cmds = %w(step finish) + ['24 == x', 'continue']
|
|
19
|
+
d = strarray_setup(cmds)
|
|
20
|
+
d.start
|
|
21
|
+
##############################
|
|
22
|
+
x = fact(4)
|
|
23
|
+
y = 5
|
|
24
|
+
##############################
|
|
25
|
+
d.stop # ({:remove => true})
|
|
26
|
+
out = ['-- ',
|
|
27
|
+
'x = fact(4)',
|
|
28
|
+
'METHOD TestFinish#fact(x)',
|
|
29
|
+
'-> ',
|
|
30
|
+
'def fact(x)',
|
|
31
|
+
'<- ',
|
|
32
|
+
'R=> 24',
|
|
33
|
+
'end',
|
|
34
|
+
'D=> true']
|
|
35
|
+
compare_output(out, d, cmds)
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
4
|
+
require_relative 'fn_helper'
|
|
5
|
+
|
|
6
|
+
class TestStep < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include FnTestHelper
|
|
9
|
+
include Trace
|
|
10
|
+
|
|
11
|
+
def test_step_same_level
|
|
12
|
+
|
|
13
|
+
puts "FIXME test_step_same_level"
|
|
14
|
+
assert true
|
|
15
|
+
return
|
|
16
|
+
# See that we can step with parameter which is the same as 'step 1'
|
|
17
|
+
cmds = ['next', 'next', 'continue', 'continue']
|
|
18
|
+
d = strarray_setup(cmds)
|
|
19
|
+
d.core.step_events = TEST_STEP_EVENT_MASK
|
|
20
|
+
|
|
21
|
+
########### immediate bug1 ###############
|
|
22
|
+
2.times do
|
|
23
|
+
x = 1
|
|
24
|
+
d.debugger(:immediate => true)
|
|
25
|
+
y = 2
|
|
26
|
+
end
|
|
27
|
+
##############################
|
|
28
|
+
d.stop
|
|
29
|
+
out = [':o ', 'd.debugger(:immediate => true)',
|
|
30
|
+
'-- ', 'y = 2',
|
|
31
|
+
'-- ', 'x = 1',
|
|
32
|
+
':o ', 'd.debugger(:immediate => true)']
|
|
33
|
+
compare_output(out, d, cmds)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
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 continue)
|
|
14
|
+
d = strarray_setup(cmds)
|
|
15
|
+
d.start
|
|
16
|
+
x = 5
|
|
17
|
+
y = 6
|
|
18
|
+
d.stop
|
|
19
|
+
out = ['-- ', 'x = 5', '-- ', 'y = 6']
|
|
20
|
+
compare_output(out, d, cmds)
|
|
21
|
+
|
|
22
|
+
# See that we can next with a computed count value
|
|
23
|
+
cmds = ['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 # ({'remove': true})
|
|
32
|
+
out = ['-- ', 'x = 5', '-- ', 'z = 7']
|
|
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_next_in_exception
|
|
56
|
+
cmds = %w(next! continue)
|
|
57
|
+
d = strarray_setup(cmds)
|
|
58
|
+
d.start
|
|
59
|
+
########### t2 ###############
|
|
60
|
+
begin
|
|
61
|
+
got_boom = false
|
|
62
|
+
x = 4/0
|
|
63
|
+
rescue
|
|
64
|
+
got_boom = true
|
|
65
|
+
end
|
|
66
|
+
##############################
|
|
67
|
+
d.stop # ({:remove => true})
|
|
68
|
+
out = ['-- ', 'begin']
|
|
69
|
+
compare_output(out, d, cmds)
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
4
|
+
require_relative 'fn_helper'
|
|
5
|
+
|
|
6
|
+
class TestRaise < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include FnTestHelper
|
|
9
|
+
|
|
10
|
+
def test_raise
|
|
11
|
+
|
|
12
|
+
cmds = [
|
|
13
|
+
'step',
|
|
14
|
+
'step',
|
|
15
|
+
'raise',
|
|
16
|
+
'print "hi"',
|
|
17
|
+
]
|
|
18
|
+
d = strarray_setup(cmds)
|
|
19
|
+
d.start
|
|
20
|
+
##############################
|
|
21
|
+
begin
|
|
22
|
+
x = 1
|
|
23
|
+
y = 2
|
|
24
|
+
z = 3
|
|
25
|
+
rescue RuntimeError
|
|
26
|
+
d.stop
|
|
27
|
+
assert 'We are cool with RuntimeError'
|
|
28
|
+
else
|
|
29
|
+
d.stop
|
|
30
|
+
assert false, 'Should have got RuntimeError'
|
|
31
|
+
end
|
|
32
|
+
##############################
|
|
33
|
+
out = ['-- ', 'begin',
|
|
34
|
+
'-- ', 'x = 1',
|
|
35
|
+
'-- ', 'y = 2',
|
|
36
|
+
'-- ', 'd.stop',
|
|
37
|
+
'hi']
|
|
38
|
+
compare_output(out, d, cmds)
|
|
39
|
+
|
|
40
|
+
# Try with explicit Exception name
|
|
41
|
+
cmds = [
|
|
42
|
+
'next',
|
|
43
|
+
'raise [5]',
|
|
44
|
+
'raise NotanError',
|
|
45
|
+
'step',
|
|
46
|
+
'raise TypeError',
|
|
47
|
+
]
|
|
48
|
+
d = strarray_setup(cmds)
|
|
49
|
+
d.start
|
|
50
|
+
##############################
|
|
51
|
+
begin
|
|
52
|
+
x = 1
|
|
53
|
+
y = 2
|
|
54
|
+
z = 3
|
|
55
|
+
rescue TypeError
|
|
56
|
+
d.stop
|
|
57
|
+
assert 'We are cool with TypeError'
|
|
58
|
+
else
|
|
59
|
+
d.stop
|
|
60
|
+
assert false, 'Should have got TypeError'
|
|
61
|
+
end
|
|
62
|
+
##############################
|
|
63
|
+
d.stop # ({:remove => true})
|
|
64
|
+
out = ['-- ', 'begin',
|
|
65
|
+
'-- ', 'x = 1',
|
|
66
|
+
'** "[5]" does not inherit Exception.',
|
|
67
|
+
'** "NotanError" does not inherit Exception.',
|
|
68
|
+
'-- ', 'y = 2',
|
|
69
|
+
'-- ', 'd.stop']
|
|
70
|
+
compare_output(out, d, cmds)
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'trace'
|
|
4
|
+
require_relative 'fn_helper'
|
|
5
|
+
|
|
6
|
+
class TestRaise < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include FnTestHelper
|
|
9
|
+
|
|
10
|
+
def test_return
|
|
11
|
+
|
|
12
|
+
cmds = [
|
|
13
|
+
'set events call, return',
|
|
14
|
+
'step',
|
|
15
|
+
'info args',
|
|
16
|
+
'step',
|
|
17
|
+
'info return',
|
|
18
|
+
'set return 10',
|
|
19
|
+
'set events line',
|
|
20
|
+
'step',
|
|
21
|
+
'print foo_retval',
|
|
22
|
+
]
|
|
23
|
+
d = strarray_setup(cmds)
|
|
24
|
+
d.start
|
|
25
|
+
##############################
|
|
26
|
+
x = 1
|
|
27
|
+
def foo(arg)
|
|
28
|
+
5
|
|
29
|
+
end
|
|
30
|
+
foo_retval = foo('ho')
|
|
31
|
+
z = 3
|
|
32
|
+
##############################
|
|
33
|
+
d.stop
|
|
34
|
+
out = ['-- ',
|
|
35
|
+
'x = 1',
|
|
36
|
+
'Trace events we may stop on:',
|
|
37
|
+
"\tbrkpt, call, return",
|
|
38
|
+
'METHOD TestRaise#foo(arg)',
|
|
39
|
+
'-> ',
|
|
40
|
+
'def foo(arg)',
|
|
41
|
+
"arg = \"ho\"",
|
|
42
|
+
'<- ',
|
|
43
|
+
'R=> 5',
|
|
44
|
+
'end',
|
|
45
|
+
'Return value: 5',
|
|
46
|
+
'Return value was: 5',
|
|
47
|
+
'New value is: 10',
|
|
48
|
+
'Trace events we may stop on:',
|
|
49
|
+
"\tbrkpt, line",
|
|
50
|
+
'-- ',
|
|
51
|
+
'z = 3',
|
|
52
|
+
'10',
|
|
53
|
+
'-- ',
|
|
54
|
+
'd.stop']
|
|
55
|
+
compare_output(out, d, cmds)
|
|
56
|
+
|
|
57
|
+
# Try C function
|
|
58
|
+
cmds = [
|
|
59
|
+
'set different off',
|
|
60
|
+
'set events c_call, c_return',
|
|
61
|
+
'step',
|
|
62
|
+
'info args',
|
|
63
|
+
'step',
|
|
64
|
+
'info return',
|
|
65
|
+
'set return "abc"',
|
|
66
|
+
'set events line',
|
|
67
|
+
'step',
|
|
68
|
+
'print result',
|
|
69
|
+
]
|
|
70
|
+
d = strarray_setup(cmds)
|
|
71
|
+
d.start
|
|
72
|
+
##############################
|
|
73
|
+
a = 1
|
|
74
|
+
result = File.basename('/a/b.c')
|
|
75
|
+
##############################
|
|
76
|
+
d.stop # ({:remove => true})
|
|
77
|
+
out = ["-- ",
|
|
78
|
+
"a = 1",
|
|
79
|
+
'different is off.',
|
|
80
|
+
"Trace events we may stop on:",
|
|
81
|
+
"\tbrkpt, c_call, c_return",
|
|
82
|
+
"CFUNC File#basename(\"/a/b.c\")",
|
|
83
|
+
"C> ",
|
|
84
|
+
"result = File.basename('/a/b.c')",
|
|
85
|
+
"1: \"/a/b.c\"",
|
|
86
|
+
"<C ",
|
|
87
|
+
"R=> \"b.c\"",
|
|
88
|
+
"result = File.basename('/a/b.c')",
|
|
89
|
+
"Return value: \"b.c\"",
|
|
90
|
+
"Return value was: \"b.c\"",
|
|
91
|
+
"New value is: \"abc\"",
|
|
92
|
+
"Trace events we may stop on:",
|
|
93
|
+
"\tbrkpt, line",
|
|
94
|
+
"-- ",
|
|
95
|
+
"d.stop # ({:remove => true})",
|
|
96
|
+
"abc"]
|
|
97
|
+
compare_output(out, d, cmds)
|
|
98
|
+
end
|
|
99
|
+
|
|
100
|
+
end
|