rbx-trepanning 0.2.0-universal-rubinius-2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog +2967 -0
- data/LICENSE +25 -0
- data/Makefile +13 -0
- data/NEWS +105 -0
- data/README.textile +34 -0
- data/Rakefile +244 -0
- data/THANKS +14 -0
- data/app/.gitignore +2 -0
- data/app/breakpoint.rb +242 -0
- data/app/brkptmgr.rb +153 -0
- data/app/client.rb +71 -0
- data/app/cmd_parse.kpeg +242 -0
- data/app/cmd_parse.rb +209 -0
- data/app/cmd_parser.rb +2083 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +22 -0
- data/app/default.rb +71 -0
- data/app/display.rb +186 -0
- data/app/eventbuffer.rb +147 -0
- data/app/file.rb +24 -0
- data/app/frame.rb +120 -0
- data/app/irb.rb +113 -0
- data/app/iseq.rb +188 -0
- data/app/method.rb +178 -0
- data/app/mock.rb +13 -0
- data/app/options.rb +154 -0
- data/app/rbx-llvm.rb +163 -0
- data/app/run.rb +92 -0
- data/app/util.rb +99 -0
- data/app/validate.rb +30 -0
- data/bin/.gitignore +2 -0
- data/bin/trepanx +69 -0
- data/data/.gitignore +2 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +2 -0
- data/interface/client.rb +84 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +112 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +158 -0
- data/interface.rb +109 -0
- data/io/.gitignore +3 -0
- data/io/input.rb +151 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +155 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/io.rb +148 -0
- data/lib/.gitignore +2 -0
- data/lib/trepanning.rb +467 -0
- data/processor/.gitignore +3 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +167 -0
- data/processor/command/.gitignore +2 -0
- data/processor/command/alias.rb +65 -0
- data/processor/command/backtrace.rb +68 -0
- data/processor/command/base/.gitignore +2 -0
- data/processor/command/base/subcmd.rb +226 -0
- data/processor/command/base/submgr.rb +185 -0
- data/processor/command/base/subsubcmd.rb +125 -0
- data/processor/command/base/subsubmgr.rb +196 -0
- data/processor/command/break.rb +78 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/delete.rb +44 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disable.rb +71 -0
- data/processor/command/disassemble.rb +180 -0
- data/processor/command/display.rb +84 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +74 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/eval.rb +93 -0
- data/processor/command/exit.rb +83 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +93 -0
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +58 -0
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/help.rb +228 -0
- data/processor/command/info.rb +30 -0
- data/processor/command/info_subcmd/.gitignore +3 -0
- data/processor/command/info_subcmd/breakpoints.rb +103 -0
- data/processor/command/info_subcmd/files.rb +219 -0
- data/processor/command/info_subcmd/frame.rb +68 -0
- data/processor/command/info_subcmd/line.rb +75 -0
- data/processor/command/info_subcmd/locals.rb +22 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +64 -0
- data/processor/command/info_subcmd/source.rb +75 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
- data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
- data/processor/command/kill.rb +79 -0
- data/processor/command/list.rb +234 -0
- data/processor/command/macro.rb +86 -0
- data/processor/command/next.rb +67 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/parsetree.rb +51 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +26 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -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 +61 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +39 -0
- data/processor/command/set_subcmd/kernelstep.rb +60 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -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 +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/reload.rb +42 -0
- data/processor/command/set_subcmd/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
- data/processor/command/shell.rb +131 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/aliases.rb +46 -0
- data/processor/command/show_subcmd/args.rb +25 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +24 -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 +20 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -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 +26 -0
- data/processor/command/show_subcmd/directories.rb +22 -0
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +25 -0
- data/processor/command/show_subcmd/kernelstep.rb +34 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -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/reload.rb +18 -0
- data/processor/command/show_subcmd/timer.rb +18 -0
- data/processor/command/show_subcmd/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +133 -0
- data/processor/command/step.rb +97 -0
- data/processor/command/tbreak.rb +20 -0
- data/processor/command/unalias.rb +49 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +89 -0
- data/processor/command.rb +173 -0
- data/processor/default.rb +64 -0
- data/processor/disassemble.rb +59 -0
- data/processor/display.rb +53 -0
- data/processor/eval.rb +97 -0
- data/processor/eventbuf.rb +101 -0
- data/processor/frame.rb +265 -0
- data/processor/help.rb +94 -0
- data/processor/hook.rb +134 -0
- data/processor/list.rb +123 -0
- data/processor/load_cmds.rb +253 -0
- data/processor/location.rb +228 -0
- data/processor/mock.rb +138 -0
- data/processor/msg.rb +74 -0
- data/processor/running.rb +244 -0
- data/processor/stepping.rb +135 -0
- data/processor/subcmd.rb +136 -0
- data/processor/validate.rb +379 -0
- data/processor/virtual.rb +33 -0
- data/processor.rb +404 -0
- data/rbx-trepanning.gemspec +39 -0
- data/sample/.gitignore +2 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +46 -0
- data/test/data/.gitignore +1 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +6 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +14 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +3 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/example/.gitignore +2 -0
- data/test/example/debugger-stop.rb +16 -0
- data/test/example/factorial.rb +10 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-server.rb +22 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/goto2goto.rb +11 -0
- data/test/example/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/.gitignore +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 +85 -0
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +56 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-recursive-bt.rb +94 -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/.gitignore +3 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +81 -0
- data/test/integration/test-fname-with-blank.rb +16 -0
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +47 -0
- data/test/unit/.gitignore +3 -0
- data/test/unit/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +31 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +23 -0
- data/test/unit/test-app-complete.rb +39 -0
- data/test/unit/test-app-condition.rb +18 -0
- data/test/unit/test-app-display.rb +22 -0
- data/test/unit/test-app-iseq.rb +64 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +94 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +45 -0
- data/test/unit/test-base-subcmd.rb +57 -0
- data/test/unit/test-base-submgr.rb +24 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-break.rb +66 -0
- data/test/unit/test-cmd-edit.rb +34 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +31 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +54 -0
- data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-command.rb +45 -0
- data/test/unit/test-completion.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-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +35 -0
- data/test/unit/test-proc-frame.rb +81 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-list.rb +55 -0
- data/test/unit/test-proc-load_cmds.rb +51 -0
- data/test/unit/test-proc-location.rb +67 -0
- data/test/unit/test-proc-main.rb +95 -0
- data/test/unit/test-proc-validate.rb +139 -0
- data/test/unit/test-subcmd-help.rb +43 -0
- metadata +545 -0
@@ -0,0 +1,81 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor'
|
5
|
+
require_relative '../../processor/frame'
|
6
|
+
require_relative '../../processor/mock'
|
7
|
+
|
8
|
+
$errors = []
|
9
|
+
$msgs = []
|
10
|
+
|
11
|
+
# Test Trepan::CmdProcessor Frame portion
|
12
|
+
class TestCmdProcessorFrame < Test::Unit::TestCase
|
13
|
+
|
14
|
+
def setup
|
15
|
+
$errors = []
|
16
|
+
$msgs = []
|
17
|
+
@dbgr = MockDebugger::MockDebugger.new
|
18
|
+
@proc = Trepan::CmdProcessor.new(@dbgr)
|
19
|
+
@proc.frame_index = 0
|
20
|
+
@proc.frame_initialize
|
21
|
+
class << @proc
|
22
|
+
def msg(msg)
|
23
|
+
$msgs << msg
|
24
|
+
end
|
25
|
+
def errmsg(msg)
|
26
|
+
$errors << msg
|
27
|
+
end
|
28
|
+
def print_location
|
29
|
+
# $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
|
30
|
+
$msgs << File.basename(@frame.file)
|
31
|
+
# puts $msgs
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
# See that we have can load up commands
|
37
|
+
def test_basic
|
38
|
+
@proc.frame_setup
|
39
|
+
|
40
|
+
# Test absolute positioning. Should all be okay
|
41
|
+
0.upto(@proc.stack_size-1) do |i|
|
42
|
+
@proc.adjust_frame(i, true)
|
43
|
+
assert_equal(0, $errors.size)
|
44
|
+
assert_equal(true, $msgs.size >= i+1)
|
45
|
+
end
|
46
|
+
|
47
|
+
# Test absolute before the beginning fo the stack
|
48
|
+
frame_index = @proc.frame_index
|
49
|
+
@proc.adjust_frame(-1, true)
|
50
|
+
assert_equal(0, $errors.size)
|
51
|
+
assert_equal(frame_index, @proc.frame_index)
|
52
|
+
@proc.adjust_frame(-@proc.stack_size-1, true)
|
53
|
+
assert_equal(1, $errors.size, $errors)
|
54
|
+
assert_equal(frame_index, @proc.frame_index)
|
55
|
+
|
56
|
+
## FIXME: look over and reinstate this code...
|
57
|
+
# setup
|
58
|
+
# @proc.top_frame = @proc.frame = @dbgr.vm_locations[0]
|
59
|
+
# @proc.adjust_frame(0, true)
|
60
|
+
|
61
|
+
# @dbgr.vm_locations.size-1.times do
|
62
|
+
# frame_index = @proc.frame_index
|
63
|
+
# @proc.adjust_frame(1, false)
|
64
|
+
# assert_equal(0, $errors.size)
|
65
|
+
# assert_not_equal(frame_index, @proc.frame_index,
|
66
|
+
# '@proc.frame_index should have moved')
|
67
|
+
# end
|
68
|
+
|
69
|
+
# FIXME: bug in threadframe top_frame.stack_size?
|
70
|
+
# # Adjust relative beyond the end
|
71
|
+
# @proc.adjust_frame(1, false)
|
72
|
+
# assert_equal(1, $errors.size)
|
73
|
+
|
74
|
+
# Should have stayed at the end
|
75
|
+
# proc.adjust_frame(proc.top_frame.stack_size-1, true)
|
76
|
+
# proc.top_frame.stack_size.times { proc.adjust_frame(-1, false) }
|
77
|
+
|
78
|
+
end
|
79
|
+
|
80
|
+
|
81
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/help'
|
5
|
+
|
6
|
+
# Test Trepan::CmdProcessor
|
7
|
+
class TestCmdProcessor < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Trepan::Help
|
10
|
+
# See that we have can load up commands
|
11
|
+
def test_abbrev_stringify
|
12
|
+
assert_equal('(test)ing',
|
13
|
+
abbrev_stringify('testing', 'test'.size))
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/hook'
|
5
|
+
|
6
|
+
# Test Debugger:CmdProcessor Hook portion
|
7
|
+
class TestProcHook < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def test_basic
|
10
|
+
@args = []
|
11
|
+
hook1 = Proc.new {|name, a| @args << [name, a]}
|
12
|
+
hooks = Trepan::CmdProcessor::Hook.new()
|
13
|
+
assert_equal(true, hooks.empty?)
|
14
|
+
hooks.insert(-1, 'hook1', hook1)
|
15
|
+
hooks.run
|
16
|
+
assert_equal([['hook1', nil]], @args)
|
17
|
+
hooks.insert_if_new(-1, 'hook1', hook1)
|
18
|
+
assert_equal([['hook1', nil]], @args)
|
19
|
+
|
20
|
+
@args = []
|
21
|
+
hooks.insert_if_new(-1, 'hook2', hook1)
|
22
|
+
hooks.run(10)
|
23
|
+
assert_equal([['hook1', 10], ['hook2', 10]], @args)
|
24
|
+
|
25
|
+
@args = []
|
26
|
+
hooks.delete_by_name('hook2')
|
27
|
+
hooks.run(30)
|
28
|
+
assert_equal([['hook1', 30]], @args)
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,55 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor'
|
5
|
+
require_relative '../../processor/frame'
|
6
|
+
require_relative '../../processor/list'
|
7
|
+
require_relative '../../processor/mock'
|
8
|
+
|
9
|
+
# Test Trepan::CmdProcessor List portion
|
10
|
+
class TestProcList < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def setup
|
13
|
+
$errors = []
|
14
|
+
$msgs = []
|
15
|
+
@dbgr = MockDebugger::MockDebugger.new
|
16
|
+
@proc = Trepan::CmdProcessor.new(@dbgr)
|
17
|
+
@proc.frame_index = 0
|
18
|
+
@proc.frame_initialize
|
19
|
+
class << @proc
|
20
|
+
def msg(msg)
|
21
|
+
$msgs << msg
|
22
|
+
end
|
23
|
+
def errmsg(msg)
|
24
|
+
$errors << msg
|
25
|
+
end
|
26
|
+
def print_location
|
27
|
+
# $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
|
28
|
+
$msgs << "#{@frame.source_container} "
|
29
|
+
# puts $msgs
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_basic
|
35
|
+
@proc.frame_setup
|
36
|
+
|
37
|
+
def foo; 5 end
|
38
|
+
def check(cmdp, arg, last=10)
|
39
|
+
r = cmdp.parse_list_cmd('.', last)
|
40
|
+
assert r[1]
|
41
|
+
assert r[2]
|
42
|
+
assert r[3]
|
43
|
+
end
|
44
|
+
check(@proc, '-')
|
45
|
+
check(@proc, 'foo')
|
46
|
+
check(@proc, '@0')
|
47
|
+
check(@proc, "#{__LINE__}")
|
48
|
+
check(@proc, "#{__FILE__} @0")
|
49
|
+
check(@proc, "#{__FILE__}:#{__LINE__}")
|
50
|
+
check(@proc, "#{__FILE__} #{__LINE__}")
|
51
|
+
check(@proc, "#{__FILE__} #{__LINE__}", -10)
|
52
|
+
check(@proc, "@proc.errmsg")
|
53
|
+
check(@proc, "@proc.errmsg:@0")
|
54
|
+
end
|
55
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor'
|
5
|
+
require_relative '../../app/mock'
|
6
|
+
|
7
|
+
class TestCmdProcessorLoadCmds < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
11
|
+
@proc.instance_variable_set('@settings', {})
|
12
|
+
end
|
13
|
+
|
14
|
+
# See that we have can load up commands
|
15
|
+
def test_basic
|
16
|
+
@proc.load_cmds_initialize
|
17
|
+
assert_equal(false, @proc.commands.empty?)
|
18
|
+
assert_equal(false, @proc.aliases.empty?)
|
19
|
+
end
|
20
|
+
|
21
|
+
def test_complete
|
22
|
+
assert_equal(%w(delete directory disable disassemble display down),
|
23
|
+
@proc.complete('d', 'd'),
|
24
|
+
"Failed completion of 'd' commands")
|
25
|
+
assert_equal(['debug', 'different', 'directories'],
|
26
|
+
@proc.complete('sho d', 'd'),
|
27
|
+
"Failed completion of 'sho d' subcommands")
|
28
|
+
$errors = []
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_run_cmd
|
32
|
+
$errors = []
|
33
|
+
|
34
|
+
def @proc.errmsg(mess)
|
35
|
+
$errors << mess
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_it(size, *args)
|
39
|
+
@proc.run_cmd(*args)
|
40
|
+
assert_equal(size, $errors.size, $errors)
|
41
|
+
end
|
42
|
+
test_it(1, 'foo')
|
43
|
+
test_it(2, [])
|
44
|
+
test_it(3, ['list', 5])
|
45
|
+
# See that we got different error messages
|
46
|
+
assert_not_equal($errors[0], $errors[1], $errors)
|
47
|
+
assert_not_equal($errors[1], $errors[2], $errors)
|
48
|
+
assert_not_equal($errors[2], $errors[0], $errors)
|
49
|
+
end
|
50
|
+
|
51
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'linecache'
|
5
|
+
require_relative '../../processor/location'
|
6
|
+
require_relative 'cmd-helper'
|
7
|
+
|
8
|
+
# Test Trepan::CmdProcessor location portion
|
9
|
+
class TestCmdProcessorLocation < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include UnitHelper
|
12
|
+
def setup
|
13
|
+
common_setup
|
14
|
+
@file ||= File.basename(__FILE__)
|
15
|
+
end
|
16
|
+
|
17
|
+
# Test resolve_file_with_dir() and line_at()
|
18
|
+
def test_line_at
|
19
|
+
@cmdproc.settings[:directory] = ''
|
20
|
+
assert_equal(nil, @cmdproc.resolve_file_with_dir(@file))
|
21
|
+
if File.expand_path(Dir.pwd) == File.expand_path(File.dirname(__FILE__))
|
22
|
+
line = @cmdproc.line_at(@file, __LINE__)
|
23
|
+
assert_match(/line = @cmdproc.line_at/, line)
|
24
|
+
else
|
25
|
+
assert_equal(nil, @cmdproc.line_at(@file, __LINE__))
|
26
|
+
end
|
27
|
+
dir = @cmdproc.settings[:directory] = File.dirname(__FILE__)
|
28
|
+
assert_equal(File.join(dir, @file),
|
29
|
+
@cmdproc.resolve_file_with_dir('test-proc-location.rb'))
|
30
|
+
test_line = 'test_line'
|
31
|
+
line = @cmdproc.line_at(@file, __LINE__-1)
|
32
|
+
assert_match(/#{line}/, line)
|
33
|
+
end
|
34
|
+
|
35
|
+
def test_loc_and_text
|
36
|
+
@cmdproc.frame_index = 0
|
37
|
+
@cmdproc.frame_initialize
|
38
|
+
@cmdproc.frame_setup
|
39
|
+
LineCache::clear_file_cache
|
40
|
+
dir = @cmdproc.settings[:directory] = File.dirname(__FILE__)
|
41
|
+
loc, line_no, text = @cmdproc.loc_and_text('hi')
|
42
|
+
assert loc and line_no.is_a?(Fixnum) and text
|
43
|
+
assert @cmdproc.current_source_text
|
44
|
+
# FIXME test that filename remapping works.
|
45
|
+
end
|
46
|
+
|
47
|
+
def test_canonic_file
|
48
|
+
@cmdproc.settings[:basename] = false
|
49
|
+
assert_equal __FILE__, @cmdproc.canonic_file(__FILE__)
|
50
|
+
assert @cmdproc.canonic_file('lib/compiler/ast.rb')
|
51
|
+
@cmdproc.settings[:basename] = true
|
52
|
+
assert_equal File.basename(__FILE__), @cmdproc.canonic_file(__FILE__)
|
53
|
+
assert_equal 'ast.rb', @cmdproc.canonic_file('lib/compiler/ast.rb')
|
54
|
+
end
|
55
|
+
|
56
|
+
|
57
|
+
def test_eval_current_source_text
|
58
|
+
eval <<-EOE
|
59
|
+
@cmdproc.frame_index = 0
|
60
|
+
@cmdproc.frame_initialize
|
61
|
+
@cmdproc.frame_setup
|
62
|
+
LineCache::clear_file_cache
|
63
|
+
assert @cmdproc.current_source_text
|
64
|
+
EOE
|
65
|
+
end
|
66
|
+
|
67
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
require_relative '../../processor'
|
5
|
+
## require_relative '../../app/core'
|
6
|
+
|
7
|
+
# Test Trepan:CmdProcessor
|
8
|
+
class TestCmdProcessor < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include UnitHelper
|
11
|
+
def setup
|
12
|
+
common_setup
|
13
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
14
|
+
end
|
15
|
+
|
16
|
+
# See that we have can load up commands
|
17
|
+
def test_command_load
|
18
|
+
assert @cmds.is_a?(Hash), 'Should have gotten a command hash'
|
19
|
+
assert @cmds.keys.size > 0, 'Should have found at least one command'
|
20
|
+
cmd_name, cmd_obj = @cmds.first
|
21
|
+
assert cmd_name.is_a?(String), 'Should have string name for a command'
|
22
|
+
assert(cmd_obj.kind_of?(Trepan::Command),
|
23
|
+
'Command should be a Trapan::Command')
|
24
|
+
assert cmd_obj.respond_to?(:run), 'Command should have a run method'
|
25
|
+
end
|
26
|
+
|
27
|
+
def no_test_compute_prompt
|
28
|
+
assert_equal('(rbdbgr): ', @cmdproc.compute_prompt)
|
29
|
+
Thread.new{ assert_equal('(rbdbgr@55): ', @cmdproc.compute_prompt.gsub(/@\d+/, '@55'))}.join
|
30
|
+
x = Thread.new{ Thread.pass; x = 1 }
|
31
|
+
assert_equal('(rbdbgr@main): ', @cmdproc.compute_prompt)
|
32
|
+
x.join
|
33
|
+
@cmdproc.debug_nest += 1
|
34
|
+
assert_equal('((rbdbgr)): ', @cmdproc.compute_prompt)
|
35
|
+
@cmdproc.debug_nest -= 1
|
36
|
+
end
|
37
|
+
|
38
|
+
# See that each command has required constants defined. Possibly in
|
39
|
+
# a strongly-typed language we wouldn't need to do much of this.
|
40
|
+
def test_command_class_vars
|
41
|
+
@cmds.each do |cmd_name, cmd|
|
42
|
+
%w(HELP CATEGORY NAME SHORT_HELP).each do
|
43
|
+
|const|
|
44
|
+
value = cmd.class.const_get(const)
|
45
|
+
assert(value.is_a?(String),
|
46
|
+
"#{const} in command #{cmd_name} should be a String; got #{value}.")
|
47
|
+
end
|
48
|
+
%w(MIN_ARGS MAX_ARGS).each do
|
49
|
+
|const|
|
50
|
+
value = cmd.class.const_get(const)
|
51
|
+
assert(value.is_a?(Fixnum) || value.nil?,
|
52
|
+
"#{const} in command #{cmd_name} should be a Fixnum or nil; got #{value}.")
|
53
|
+
end
|
54
|
+
%w(ALIASES).each do
|
55
|
+
|const|
|
56
|
+
next unless cmd.class.constants.member?(:ALIASES)
|
57
|
+
ary = cmd.class.const_get(const)
|
58
|
+
assert(ary.is_a?(Array),
|
59
|
+
"#{const} in command #{cmd_name} should be an Array")
|
60
|
+
|
61
|
+
ary.each do |v|
|
62
|
+
assert(v.is_a?(String),
|
63
|
+
"#{const} in command #{cmd_name} should be Array of Strings; got #{v}.")
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def no__test_run_command
|
70
|
+
def run_and_check(cmd, expect_msgs, expect_errmsgs, add_msg)
|
71
|
+
$errs = []; $msgs = []
|
72
|
+
@cmdproc.run_command(cmd)
|
73
|
+
assert_equal(expect_msgs, $msgs,
|
74
|
+
"#{add_msg}: mismatched messages from #{caller[0]}")
|
75
|
+
assert_equal(expect_errmsgs, $errs,
|
76
|
+
"Mismatched error messages from #{caller[0]}")
|
77
|
+
end
|
78
|
+
def @cmdproc.msg(mess, opts={})
|
79
|
+
$msgs << "#{mess}"
|
80
|
+
end
|
81
|
+
def @cmdproc.errmsg(mess, opts={})
|
82
|
+
$errs << "#{mess}"
|
83
|
+
end
|
84
|
+
run_and_check('!s=1', ['D=> 1'], [], "! evaluation")
|
85
|
+
run_and_check('print "foo"', ['foo'], [], "print command")
|
86
|
+
run_and_check('set autoeval off',
|
87
|
+
['Evaluation of unrecognized debugger commands is off.'], [],
|
88
|
+
"autoeval set")
|
89
|
+
run_and_check('asdf', [],
|
90
|
+
['Undefined command: "asdf". Try "help".'],
|
91
|
+
"invalid command")
|
92
|
+
|
93
|
+
end
|
94
|
+
|
95
|
+
end
|
@@ -0,0 +1,139 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor'
|
5
|
+
require_relative '../../processor/validate'
|
6
|
+
require_relative '../../app/mock'
|
7
|
+
require_relative 'cmd-helper'
|
8
|
+
|
9
|
+
$errors = []
|
10
|
+
$msgs = []
|
11
|
+
|
12
|
+
# Test Trepan::CmdProcessor Validation portion
|
13
|
+
class TestValidate < Test::Unit::TestCase
|
14
|
+
|
15
|
+
def setup
|
16
|
+
$errors = []
|
17
|
+
$msgs = []
|
18
|
+
@dbg ||= MockDebugger::MockDebugger.new(:nx => true)
|
19
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbg)
|
20
|
+
|
21
|
+
class << @cmdproc
|
22
|
+
def errmsg(msg)
|
23
|
+
$errors << msg
|
24
|
+
end
|
25
|
+
def print_location
|
26
|
+
# $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
|
27
|
+
$msgs << "#{@frame.source_container} "
|
28
|
+
# puts $msgs
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def test_get_int
|
34
|
+
[['1', 1], ['1E', nil], ['bad', nil], ['1+1', 2], ['-5', -5]].each do
|
35
|
+
|arg, expected|
|
36
|
+
assert_equal(expected, @cmdproc.get_int_noerr(arg))
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
def test_get_on_off
|
41
|
+
onoff =
|
42
|
+
[['1', true], ['on', true],
|
43
|
+
['0', false], ['off', false]].each do |arg, expected|
|
44
|
+
assert_equal(expected, @cmdproc.get_onoff(arg))
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
include UnitHelper
|
49
|
+
def outer_line
|
50
|
+
@line = __LINE__
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_parse_position
|
54
|
+
common_setup
|
55
|
+
outer_line
|
56
|
+
@dbg.instance_variable_set('@current_frame',
|
57
|
+
Trepan::Frame.new(self, 0,
|
58
|
+
Rubinius::VM.backtrace(0, true)[0]))
|
59
|
+
@cmdproc.frame_setup
|
60
|
+
file = File.basename(__FILE__)
|
61
|
+
[
|
62
|
+
[__FILE__, [true, file, nil, nil]],
|
63
|
+
['@8', [true, file, 8, :offset]],
|
64
|
+
[@line.to_s , [true, file, @line, :line]],
|
65
|
+
['2' , [true, file, 2, :line]],
|
66
|
+
["#{__FILE__}:#{__LINE__}" , [true, file, __LINE__, :line]],
|
67
|
+
["#{__FILE__} #{__LINE__}" , [true, file, __LINE__, :line]]
|
68
|
+
].each do |pos_str, expected|
|
69
|
+
result = @cmdproc.parse_position(pos_str)
|
70
|
+
result[1] = File.basename(result[1])
|
71
|
+
result[0] = !!result[0]
|
72
|
+
assert_equal(expected, result, "parsing position #{pos_str}")
|
73
|
+
end
|
74
|
+
end
|
75
|
+
|
76
|
+
def test_file_exists_proc
|
77
|
+
load 'tmpdir.rb'
|
78
|
+
# %W(#{__FILE__} tmpdir.rb mock.rb).each do |name|
|
79
|
+
%W(#{__FILE__}).each do |name|
|
80
|
+
assert_equal true, @cmdproc.file_exists_proc.call(name), "Should find #{name}"
|
81
|
+
end
|
82
|
+
%W(#{File.dirname(__FILE__)} tmpdir).each do |name|
|
83
|
+
assert_equal false, !!@cmdproc.file_exists_proc.call(name), "Should not find #{name}"
|
84
|
+
end
|
85
|
+
end
|
86
|
+
|
87
|
+
def test_breakpoint_position
|
88
|
+
start_line = __LINE__
|
89
|
+
common_setup
|
90
|
+
outer_line
|
91
|
+
@dbg.instance_variable_set('@current_frame',
|
92
|
+
Trepan::Frame.new(self, 0,
|
93
|
+
Rubinius::VM.backtrace(0, true)[0]))
|
94
|
+
@cmdproc.frame_setup
|
95
|
+
|
96
|
+
def munge(args)
|
97
|
+
args[0] = args[0].class
|
98
|
+
args
|
99
|
+
end
|
100
|
+
|
101
|
+
assert_equal([Rubinius::CompiledMethod, start_line, 0, 'true', false],
|
102
|
+
munge(@cmdproc.breakpoint_position('@0', false)))
|
103
|
+
result = @cmdproc.breakpoint_position("outer_line:#{@line}", true)
|
104
|
+
result[0] = result[0].name
|
105
|
+
assert_equal([:outer_line, @line, 0, 'true', false], result)
|
106
|
+
result = @cmdproc.breakpoint_position("#{@line} unless 1 == 2", true)
|
107
|
+
result[0] = result[0].name
|
108
|
+
assert_equal([:outer_line, @line, 0, '1 == 2', true], result)
|
109
|
+
end
|
110
|
+
|
111
|
+
def test_int_list
|
112
|
+
assert_equal([1,2,3], @cmdproc.get_int_list(%w(1+0 3-1 3)))
|
113
|
+
assert_equal(0, $errors.size)
|
114
|
+
assert_equal([2,3], @cmdproc.get_int_list(%w(a 2 3)))
|
115
|
+
assert_equal(1, $errors.size)
|
116
|
+
end
|
117
|
+
|
118
|
+
def test_method?
|
119
|
+
def foo; 5 end
|
120
|
+
|
121
|
+
# require_relative '../../lib/rbdbgr'
|
122
|
+
# dbgr = Trepan.new(:set_restart => true)
|
123
|
+
# FIXME: 'foo',
|
124
|
+
['Array.map', 'Trepan::CmdProcessor.new',
|
125
|
+
'errmsg'
|
126
|
+
].each do |str|
|
127
|
+
# dbgr.debugger if 'foo' == str
|
128
|
+
assert @cmdproc.method?(str), "#{str} should be known as a method"
|
129
|
+
end
|
130
|
+
['food', '.errmsg'
|
131
|
+
].each do |str|
|
132
|
+
# dbgr.debugger if 'foo' == str
|
133
|
+
assert_equal(false, !!@cmdproc.method?(str),
|
134
|
+
"#{str} should not be known as a method")
|
135
|
+
end
|
136
|
+
|
137
|
+
end
|
138
|
+
|
139
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor'
|
5
|
+
|
6
|
+
# Test Trepan::CmdProcessor
|
7
|
+
class TestSubCmdHelp < Test::Unit::TestCase
|
8
|
+
|
9
|
+
def setup
|
10
|
+
@dbg = Trepan.new
|
11
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbg)
|
12
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
13
|
+
end
|
14
|
+
|
15
|
+
# See that subcommand class constants exist.
|
16
|
+
def test_required_class_constants
|
17
|
+
@cmds.each do |cmd_name, cmd|
|
18
|
+
if cmd.is_a?(Trepan::SubcommandMgr)
|
19
|
+
cmd.subcmds.subcmds.each do |subcmd_name, subcmd|
|
20
|
+
where = "of subcommand #{subcmd_name} in command #{cmd_name}"
|
21
|
+
%w(HELP NAME SHORT_HELP).each do
|
22
|
+
|const|
|
23
|
+
value = subcmd.my_const(const)
|
24
|
+
assert_equal(true, value.is_a?(String),
|
25
|
+
"#{const} #{where} should be a String; got #{value}.")
|
26
|
+
end
|
27
|
+
value = subcmd.my_const('MIN_ABBREV')
|
28
|
+
assert(value.is_a?(Fixnum),
|
29
|
+
"MIN_ABBREV #{where} should be a Fixnum; got #{value}.")
|
30
|
+
|
31
|
+
if 'show' == cmd_name
|
32
|
+
short_help = subcmd.my_const('SHORT_HELP')
|
33
|
+
needed_start = 'Show '
|
34
|
+
assert_equal(needed_start, short_help[0..needed_start.size-1],
|
35
|
+
"Short help #{where} should start: \"#{needed_start}\"; got #{short_help}")
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
end
|