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,47 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/mock'
|
|
4
|
+
require_relative '../../processor/command/kill'
|
|
5
|
+
|
|
6
|
+
class TestCommandKill < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
|
10
|
+
@dbg, @cmd = MockDebugger::setup(@name, false)
|
|
11
|
+
def @cmd.msg(message)
|
|
12
|
+
@msgs << message
|
|
13
|
+
end
|
|
14
|
+
def @cmd.errmsg(message)
|
|
15
|
+
@errmsgs << message
|
|
16
|
+
end
|
|
17
|
+
reset_cmdproc_vars
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def reset_cmdproc_vars
|
|
21
|
+
@cmd.instance_variable_set('@msgs', [])
|
|
22
|
+
@cmd.instance_variable_set('@errmsgs', [])
|
|
23
|
+
@cmd.proc.leave_cmd_loop = false
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
def test_kill_command
|
|
27
|
+
@cmd.run([@name, 'foo'])
|
|
28
|
+
assert_equal(false, @cmd.proc.leave_cmd_loop)
|
|
29
|
+
assert_equal(1, @cmd.instance_variable_get('@errmsgs').size)
|
|
30
|
+
|
|
31
|
+
if false
|
|
32
|
+
save_trap = Signal.trap(10) {
|
|
33
|
+
@success = true
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
@success = false
|
|
37
|
+
@cmd.run([@name, '10'])
|
|
38
|
+
# assert_equal(true, @success,
|
|
39
|
+
# 'Should have run the handler')
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
ensure
|
|
43
|
+
# restore old trap if any
|
|
44
|
+
trap(10, save_trap)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/mock'
|
|
4
|
+
require_relative '../../processor/command/quit'
|
|
5
|
+
|
|
6
|
+
class TestCommandQuit < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
|
10
|
+
@dbg, @cmd = MockDebugger::setup(@name, false)
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
def test_basic
|
|
14
|
+
pid = fork { @cmd.run([@name, '10']) }
|
|
15
|
+
Process.wait
|
|
16
|
+
assert_equal(10, $?.exitstatus)
|
|
17
|
+
pid = fork { @cmd.run([@name]) }
|
|
18
|
+
Process.wait
|
|
19
|
+
assert_equal(0, $?.exitstatus)
|
|
20
|
+
# FIXME: should test that finalization routines get run;
|
|
21
|
+
# should test 'confirm' gets run; and should test that
|
|
22
|
+
# 'unconditional' is handled correctly.
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative 'cmd-helper'
|
|
4
|
+
require_relative '../../processor/command/step'
|
|
5
|
+
|
|
6
|
+
class TestCommandStep < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include UnitHelper
|
|
9
|
+
def setup
|
|
10
|
+
common_setup
|
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
|
12
|
+
@my_cmd = @cmds[@name]
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
def reset_cmdproc_vars
|
|
16
|
+
@cmdproc.instance_variable_set('@msgs', [])
|
|
17
|
+
@cmdproc.instance_variable_set('@errmsgs', [])
|
|
18
|
+
@cmdproc.leave_cmd_loop = false
|
|
19
|
+
end
|
|
20
|
+
|
|
21
|
+
def test_step_command
|
|
22
|
+
@my_cmd.run([@name, 'foo'])
|
|
23
|
+
assert_equal(false, @cmdproc.leave_cmd_loop)
|
|
24
|
+
|
|
25
|
+
reset_cmdproc_vars
|
|
26
|
+
@my_cmd.run([@name, '5'])
|
|
27
|
+
assert_equal(true, @cmdproc.leave_cmd_loop)
|
|
28
|
+
assert_equal(4, @core.step_count)
|
|
29
|
+
|
|
30
|
+
reset_cmdproc_vars
|
|
31
|
+
@my_cmd.run([@name])
|
|
32
|
+
assert_equal(true, @cmdproc.leave_cmd_loop)
|
|
33
|
+
assert_equal(0, @core.step_count)
|
|
34
|
+
|
|
35
|
+
reset_cmdproc_vars
|
|
36
|
+
@my_cmd.run([@name, '1+(2*3)'])
|
|
37
|
+
assert_equal(true, @cmdproc.leave_cmd_loop)
|
|
38
|
+
assert_equal(6, @core.step_count)
|
|
39
|
+
|
|
40
|
+
reset_cmdproc_vars
|
|
41
|
+
@my_cmd.run([@name, '1+foo'])
|
|
42
|
+
assert_equal(false, @cmdproc.leave_cmd_loop)
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
end
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
# Unit test for trepan.interface.user
|
|
3
|
+
|
|
4
|
+
require 'test/unit'
|
|
5
|
+
require_relative '../../interface/user'
|
|
6
|
+
|
|
7
|
+
# Tests Trepan::UserInterface
|
|
8
|
+
class TestInterfaceUser < Test::Unit::TestCase
|
|
9
|
+
|
|
10
|
+
# Test UserInterface.confirm()
|
|
11
|
+
def test_confirm
|
|
12
|
+
|
|
13
|
+
user_intf = Trepan::UserInterface.new
|
|
14
|
+
def user_intf.readline(prompt)
|
|
15
|
+
$response_answer
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
['y', 'Y', 'Yes', ' YES '].each do |s|
|
|
19
|
+
$response_answer = s
|
|
20
|
+
ans = user_intf.confirm('Testing', true)
|
|
21
|
+
assert_equal(true, ans)
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
['n', 'N', 'No', ' NO '].each do |s|
|
|
25
|
+
$response_answer = s
|
|
26
|
+
ans = user_intf.confirm('Testing', true)
|
|
27
|
+
assert_equal(false, ans)
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
def user_intf.readline(prompt)
|
|
31
|
+
raise EOFError
|
|
32
|
+
end
|
|
33
|
+
|
|
34
|
+
[true, false].each do |tf|
|
|
35
|
+
assert_equal(tf, user_intf.confirm('default testing', tf))
|
|
36
|
+
end
|
|
37
|
+
|
|
38
|
+
# Ok, we'll throw in one test of EOFError
|
|
39
|
+
assert_raises EOFError do
|
|
40
|
+
user_intf.readline('')
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
end
|
|
44
|
+
# FIXME: more thorough testing of other routines in user.
|
|
45
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../io/input'
|
|
4
|
+
|
|
5
|
+
# Test Trepan::UserInput
|
|
6
|
+
class TestIOInput < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def test_UserInput
|
|
9
|
+
inp = Trepan::UserInput.open(__FILE__)
|
|
10
|
+
assert inp, 'Should have gotten a Trepan::UserInput object back'
|
|
11
|
+
line = inp.readline.chomp
|
|
12
|
+
assert_equal '#!/usr/bin/env ruby', line
|
|
13
|
+
assert_equal false, inp.eof?
|
|
14
|
+
inp.close
|
|
15
|
+
assert_equal true, inp.closed?
|
|
16
|
+
inp = Trepan::UserInput.open(__FILE__)
|
|
17
|
+
while not inp.eof?
|
|
18
|
+
begin
|
|
19
|
+
inp.readline
|
|
20
|
+
rescue EOFError
|
|
21
|
+
assert_equal(true, inp.eof?,
|
|
22
|
+
'EOF should be true after EOFError')
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/main' # Have to include before frame!
|
|
4
|
+
# FIXME
|
|
5
|
+
require_relative '../../processor/eval'
|
|
6
|
+
require_relative '../../app/mock'
|
|
7
|
+
|
|
8
|
+
# Test Trepan::CmdProcessor Eval portion
|
|
9
|
+
class TestProcEval < Test::Unit::TestCase
|
|
10
|
+
|
|
11
|
+
def test_basic
|
|
12
|
+
cmdp = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
|
13
|
+
assert_equal('(eval "x = 1; y = 2")',
|
|
14
|
+
cmdp.fake_eval_filename('x = 1; y = 2'))
|
|
15
|
+
assert_equal('(eval "x = 1;"...)',
|
|
16
|
+
cmdp.fake_eval_filename('x = 1; y = 2', 7))
|
|
17
|
+
x = 1
|
|
18
|
+
require 'thread_frame'
|
|
19
|
+
cmdp.instance_variable_set('@frame', RubyVM::ThreadFrame.current)
|
|
20
|
+
cmdp.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
|
21
|
+
assert_equal('1', cmdp.debug_eval('x = "#{x}"'))
|
|
22
|
+
x = 2
|
|
23
|
+
assert_equal('2', cmdp.debug_eval_no_errmsg('x = "#{x}"'))
|
|
24
|
+
assert_equal(nil, cmdp.debug_eval_no_errmsg('x+'))
|
|
25
|
+
end
|
|
26
|
+
end
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require 'thread_frame'
|
|
4
|
+
require_relative '../../processor/main' # Have to include before frame!
|
|
5
|
+
# FIXME
|
|
6
|
+
require_relative '../../processor/frame'
|
|
7
|
+
require_relative '../../app/mock'
|
|
8
|
+
|
|
9
|
+
$errors = []
|
|
10
|
+
$msgs = []
|
|
11
|
+
|
|
12
|
+
# Test Trepan::CmdProcessor Frame portion
|
|
13
|
+
class TestCmdProcessorFrame < Test::Unit::TestCase
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
$errors = []
|
|
17
|
+
$msgs = []
|
|
18
|
+
@proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
|
19
|
+
@proc.frame_index = 0
|
|
20
|
+
class << @proc
|
|
21
|
+
def errmsg(msg)
|
|
22
|
+
$errors << msg
|
|
23
|
+
end
|
|
24
|
+
def print_location
|
|
25
|
+
# $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
|
|
26
|
+
$msgs << "#{@frame.source_container} "
|
|
27
|
+
# puts $msgs
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
|
|
32
|
+
# See that we have can load up commands
|
|
33
|
+
def test_basic
|
|
34
|
+
@proc.frame_setup(RubyVM::ThreadFrame.current)
|
|
35
|
+
@proc.hidelevels = {}
|
|
36
|
+
|
|
37
|
+
# Test absolute positioning. Should all be okay
|
|
38
|
+
0.upto(@proc.top_frame.stack_size-1) do |i|
|
|
39
|
+
@proc.adjust_frame(i, true)
|
|
40
|
+
assert_equal(0, $errors.size)
|
|
41
|
+
assert_equal(i+1, $msgs.size)
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
# Test absolute before the beginning fo the stack
|
|
45
|
+
frame_index = @proc.frame_index
|
|
46
|
+
@proc.adjust_frame(-1, true)
|
|
47
|
+
assert_equal(0, $errors.size)
|
|
48
|
+
assert_equal(frame_index, @proc.frame_index)
|
|
49
|
+
@proc.adjust_frame(-@proc.top_frame.stack_size-1, true)
|
|
50
|
+
assert_equal(1, $errors.size, $errors)
|
|
51
|
+
assert_equal(frame_index, @proc.frame_index)
|
|
52
|
+
|
|
53
|
+
setup
|
|
54
|
+
@proc.top_frame = @proc.frame = RubyVM::ThreadFrame.current
|
|
55
|
+
@proc.hidelevels = {}
|
|
56
|
+
@proc.adjust_frame(0, true)
|
|
57
|
+
|
|
58
|
+
@proc.top_frame.stack_size-1.times do
|
|
59
|
+
frame_index = @proc.frame_index
|
|
60
|
+
@proc.adjust_frame(1, false)
|
|
61
|
+
assert_equal(0, $errors.size)
|
|
62
|
+
assert_not_equal(frame_index, @proc.frame_index,
|
|
63
|
+
'@proc.frame_index should have moved')
|
|
64
|
+
end
|
|
65
|
+
# FIXME: bug in threadframe top_frame.stack_size?
|
|
66
|
+
# # Adjust relative beyond the end
|
|
67
|
+
# @proc.adjust_frame(1, false)
|
|
68
|
+
# assert_equal(1, $errors.size)
|
|
69
|
+
|
|
70
|
+
# Should have stayed at the end
|
|
71
|
+
# proc.adjust_frame(proc.top_frame.stack_size-1, true)
|
|
72
|
+
# proc.top_frame.stack_size.times { proc.adjust_frame(-1, false) }
|
|
73
|
+
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
end
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/help'
|
|
4
|
+
|
|
5
|
+
# Test Trepan::CmdProcessor
|
|
6
|
+
class TestCmdProcessor < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
include Trepan::Help
|
|
9
|
+
# See that we have can load up commands
|
|
10
|
+
def test_abbrev_stringify
|
|
11
|
+
assert_equal('(test)ing',
|
|
12
|
+
abbrev_stringify('testing', 'test'.size))
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
end
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/hook'
|
|
4
|
+
|
|
5
|
+
# Test Debugger:CmdProcessor Hook portion
|
|
6
|
+
class TestProcHook < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def test_basic
|
|
9
|
+
@args = []
|
|
10
|
+
hook1 = Proc.new {|name, a| @args << [name, a]}
|
|
11
|
+
hooks = Trepan::CmdProcessor::Hook.new()
|
|
12
|
+
assert_equal(true, hooks.empty?)
|
|
13
|
+
hooks.insert(-1, 'hook1', hook1)
|
|
14
|
+
hooks.run
|
|
15
|
+
assert_equal([['hook1', nil]], @args)
|
|
16
|
+
hooks.insert_if_new(-1, 'hook1', hook1)
|
|
17
|
+
assert_equal([['hook1', nil]], @args)
|
|
18
|
+
|
|
19
|
+
@args = []
|
|
20
|
+
hooks.insert_if_new(-1, 'hook2', hook1)
|
|
21
|
+
hooks.run(10)
|
|
22
|
+
assert_equal([['hook1', 10], ['hook2', 10]], @args)
|
|
23
|
+
|
|
24
|
+
@args = []
|
|
25
|
+
hooks.delete_by_name('hook2')
|
|
26
|
+
hooks.run(30)
|
|
27
|
+
assert_equal([['hook1', 30]], @args)
|
|
28
|
+
end
|
|
29
|
+
end
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/load_cmds'
|
|
4
|
+
require_relative '../../app/mock'
|
|
5
|
+
|
|
6
|
+
class TestCmdProcessorLoadCmds < Test::Unit::TestCase
|
|
7
|
+
|
|
8
|
+
def setup
|
|
9
|
+
@proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
|
10
|
+
@proc.instance_variable_set('@settings', {})
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
# See that we have can load up commands
|
|
14
|
+
def test_basic
|
|
15
|
+
@proc.load_cmds_initialize
|
|
16
|
+
assert_equal(false, @proc.commands.empty?)
|
|
17
|
+
assert_equal(false, @proc.aliases.empty?)
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
def test_run_cmd
|
|
21
|
+
$errors = []
|
|
22
|
+
|
|
23
|
+
def @proc.errmsg(mess)
|
|
24
|
+
$errors << mess
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_it(size, *args)
|
|
28
|
+
@proc.run_cmd(*args)
|
|
29
|
+
assert_equal(size, $errors.size, $errors)
|
|
30
|
+
end
|
|
31
|
+
test_it(1, 'foo')
|
|
32
|
+
test_it(2, [])
|
|
33
|
+
test_it(3, ['list', 5])
|
|
34
|
+
# See that we got different error messages
|
|
35
|
+
assert_not_equal($errors[0], $errors[1], $errors)
|
|
36
|
+
assert_not_equal($errors[1], $errors[2], $errors)
|
|
37
|
+
assert_not_equal($errors[2], $errors[0], $errors)
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
end
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/main'
|
|
4
|
+
require_relative '../../app/core'
|
|
5
|
+
|
|
6
|
+
# Mock debugger stub. FIXME: put in comment helper routine.
|
|
7
|
+
class Trepan
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Test Trepan:CmdProcessor
|
|
11
|
+
class TestCmdProcessor < Test::Unit::TestCase
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
@dbg = Trepan.new
|
|
15
|
+
@core = Trepan::Core.new(@dbg)
|
|
16
|
+
@cmdproc = @core.processor = Trepan::CmdProcessor.new(@core)
|
|
17
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# See that we have can load up commands
|
|
21
|
+
def test_command_load
|
|
22
|
+
assert @cmds.is_a?(Hash), 'Should have gotten a command hash'
|
|
23
|
+
assert @cmds.keys.size > 0, 'Should have found at least one command'
|
|
24
|
+
cmd_name, cmd_obj = @cmds.first
|
|
25
|
+
assert cmd_name.is_a?(String), 'Should have string name for a command'
|
|
26
|
+
assert(cmd_obj.kind_of?(Trepan::Command),
|
|
27
|
+
'Command should be a Trapan::Command')
|
|
28
|
+
assert cmd_obj.respond_to?(:run), 'Command should have a run method'
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def test_compute_prompt
|
|
32
|
+
assert_equal('(trepan): ', @cmdproc.compute_prompt)
|
|
33
|
+
Thread.new{ assert_equal('(trepan@55): ', @cmdproc.compute_prompt.gsub(/@\d+/, '@55'))}.join
|
|
34
|
+
x = Thread.new{ Thread.pass; x = 1 }
|
|
35
|
+
assert_equal('(trepan@main): ', @cmdproc.compute_prompt)
|
|
36
|
+
x.join
|
|
37
|
+
@cmdproc.debug_nest += 1
|
|
38
|
+
assert_equal('((trepan)): ', @cmdproc.compute_prompt)
|
|
39
|
+
@cmdproc.debug_nest -= 1
|
|
40
|
+
end
|
|
41
|
+
|
|
42
|
+
# See that each command has required constants defined. Possibly in
|
|
43
|
+
# a strongly-typed language we wouldn't need to do much of this.
|
|
44
|
+
def test_command_class_vars
|
|
45
|
+
@cmds.each do |cmd_name, cmd|
|
|
46
|
+
%w(HELP CATEGORY NAME SHORT_HELP).each do
|
|
47
|
+
|const|
|
|
48
|
+
value = cmd.class.const_get(const)
|
|
49
|
+
assert(value.is_a?(String),
|
|
50
|
+
"#{const} in command #{cmd_name} should be a String; got #{value}.")
|
|
51
|
+
end
|
|
52
|
+
%w(MIN_ARGS MAX_ARGS).each do
|
|
53
|
+
|const|
|
|
54
|
+
value = cmd.class.const_get(const)
|
|
55
|
+
assert(value.is_a?(Fixnum) || value.nil?,
|
|
56
|
+
"#{const} in command #{cmd_name} should be a Fixnum or nil; got #{value}.")
|
|
57
|
+
end
|
|
58
|
+
%w(ALIASES).each do
|
|
59
|
+
|const|
|
|
60
|
+
next unless cmd.class.constants.member?(:ALIASES)
|
|
61
|
+
ary = cmd.class.const_get(const)
|
|
62
|
+
assert(ary.is_a?(Array),
|
|
63
|
+
"#{const} in command #{cmd_name} should be an Array")
|
|
64
|
+
|
|
65
|
+
ary.each do |v|
|
|
66
|
+
assert(v.is_a?(String),
|
|
67
|
+
"#{const} in command #{cmd_name} should be Array of Strings; got #{v}.")
|
|
68
|
+
end
|
|
69
|
+
end
|
|
70
|
+
end
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
def test_run_command
|
|
74
|
+
def run_and_check(cmd, expect_msgs, expect_errmsgs, add_msg)
|
|
75
|
+
$errs = []; $msgs = []
|
|
76
|
+
@cmdproc.run_command(cmd)
|
|
77
|
+
assert_equal(expect_msgs, $msgs,
|
|
78
|
+
"#{add_msg}: mismatched messages from #{caller[0]}")
|
|
79
|
+
assert_equal(expect_errmsgs, $errs,
|
|
80
|
+
"Mismatched error messages from #{caller[0]}")
|
|
81
|
+
end
|
|
82
|
+
def @cmdproc.msg(mess)
|
|
83
|
+
$msgs << "#{mess}"
|
|
84
|
+
end
|
|
85
|
+
def @cmdproc.errmsg(mess)
|
|
86
|
+
$errs << "#{mess}"
|
|
87
|
+
end
|
|
88
|
+
run_and_check('!s=1', ['D=> 1'], [], "! evaluation")
|
|
89
|
+
run_and_check('print "foo"', ['foo'], [], "print command")
|
|
90
|
+
run_and_check('set autoeval off',
|
|
91
|
+
['Evaluation of unrecognized debugger commands is off.'], [],
|
|
92
|
+
"autoeval set")
|
|
93
|
+
run_and_check('asdf', [],
|
|
94
|
+
['Undefined command: "asdf". Try "help".'],
|
|
95
|
+
"invalid command")
|
|
96
|
+
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
end
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/main' # Have to include before validate!
|
|
4
|
+
# FIXME
|
|
5
|
+
require_relative '../../processor/validate'
|
|
6
|
+
require_relative '../../app/mock'
|
|
7
|
+
|
|
8
|
+
$errors = []
|
|
9
|
+
$msgs = []
|
|
10
|
+
|
|
11
|
+
# Test Trepan::CmdProcessor Validation portion
|
|
12
|
+
class TestValidate < Test::Unit::TestCase
|
|
13
|
+
|
|
14
|
+
def setup
|
|
15
|
+
$errors = []
|
|
16
|
+
$msgs = []
|
|
17
|
+
@proc = Trepan::CmdProcessor.new(Trepan::MockCore.new())
|
|
18
|
+
|
|
19
|
+
class << @proc
|
|
20
|
+
def errmsg(msg)
|
|
21
|
+
$errors << msg
|
|
22
|
+
end
|
|
23
|
+
def print_location
|
|
24
|
+
# $msgs << "#{@frame.source_container} #{@frame.source_location[0]}"
|
|
25
|
+
$msgs << "#{@frame.source_container} "
|
|
26
|
+
# puts $msgs
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# See that we have can load up commands
|
|
32
|
+
def test_basic
|
|
33
|
+
onoff =
|
|
34
|
+
[['1', true], ['on', true],
|
|
35
|
+
['0', false], ['off', false]].each do |arg, expected|
|
|
36
|
+
assert_equal(expected, @proc.get_onoff(arg))
|
|
37
|
+
end
|
|
38
|
+
[['1', 1], ['1E', nil], ['bad', nil], ['1+1', 2], ['-5', -5]].each do
|
|
39
|
+
|arg, expected|
|
|
40
|
+
assert_equal(expected, @proc.get_int_noerr(arg))
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
|
|
44
|
+
def test_breakpoint_position
|
|
45
|
+
require 'thread_frame'
|
|
46
|
+
tf = RubyVM::ThreadFrame.current
|
|
47
|
+
@proc.frame_setup(tf)
|
|
48
|
+
|
|
49
|
+
def munge(args)
|
|
50
|
+
args[1] = 'bogus'
|
|
51
|
+
args
|
|
52
|
+
end
|
|
53
|
+
|
|
54
|
+
assert_equal([0, 'bogus', true, 'true', nil],
|
|
55
|
+
munge(@proc.breakpoint_position(%w(O0))))
|
|
56
|
+
assert_equal([1, 'bogus', false, 'true', nil],
|
|
57
|
+
munge(@proc.breakpoint_position(%w(1))))
|
|
58
|
+
assert_equal([2, 'bogus', false, 'a > b', nil],
|
|
59
|
+
munge(@proc.breakpoint_position(%w(2 if a > b))))
|
|
60
|
+
end
|
|
61
|
+
|
|
62
|
+
def test_int_list
|
|
63
|
+
assert_equal([1,2,3], @proc.get_int_list(%w(1+0 3-1 3)))
|
|
64
|
+
assert_equal(0, $errors.size)
|
|
65
|
+
assert_equal([2,3], @proc.get_int_list(%w(a 2 3)))
|
|
66
|
+
assert_equal(1, $errors.size)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
def test_method?
|
|
70
|
+
def foo; 5 end
|
|
71
|
+
|
|
72
|
+
# require_relative '../../lib/trepan'
|
|
73
|
+
# dbgr = Trepan.new(:set_restart => true)
|
|
74
|
+
# FIXME: 'foo', 'errmsg'
|
|
75
|
+
['Array#map', 'Trepan::CmdProcessor.new'
|
|
76
|
+
].each do |str|
|
|
77
|
+
# dbgr.debugger if 'foo' == str
|
|
78
|
+
assert_equal(true, @proc.method?(str),
|
|
79
|
+
"#{str} should be known as a method")
|
|
80
|
+
end
|
|
81
|
+
['food', '.errmsg'
|
|
82
|
+
].each do |str|
|
|
83
|
+
# dbgr.debugger if 'foo' == str
|
|
84
|
+
assert_equal(false, @proc.method?(str),
|
|
85
|
+
"#{str} should be known as a method")
|
|
86
|
+
end
|
|
87
|
+
|
|
88
|
+
end
|
|
89
|
+
|
|
90
|
+
end
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
#!/usr/bin/env ruby
|
|
2
|
+
require 'test/unit'
|
|
3
|
+
require_relative '../../processor/main'
|
|
4
|
+
require_relative '../../app/core'
|
|
5
|
+
|
|
6
|
+
# Mock debugger stub. FIXME: put in comment helper routine.
|
|
7
|
+
class Trepan
|
|
8
|
+
end
|
|
9
|
+
|
|
10
|
+
# Test Trepan::CmdProcessor
|
|
11
|
+
class TestSubCmdHelp < Test::Unit::TestCase
|
|
12
|
+
|
|
13
|
+
def setup
|
|
14
|
+
@dbg = Trepan.new
|
|
15
|
+
@core = Trepan::Core.new(@dbg)
|
|
16
|
+
@cmdproc = @core.processor = Trepan::CmdProcessor.new(@core)
|
|
17
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
# See that subcommand class constants exist.
|
|
21
|
+
def test_required_class_constants
|
|
22
|
+
@cmds.each do |cmd_name, cmd|
|
|
23
|
+
if cmd.is_a?(Trepan::SubcommandMgr)
|
|
24
|
+
cmd.subcmds.subcmds.each do |subcmd_name, subcmd|
|
|
25
|
+
where = "of subcommand #{subcmd_name} in command #{cmd_name}"
|
|
26
|
+
%w(HELP NAME SHORT_HELP).each do
|
|
27
|
+
|const|
|
|
28
|
+
value = subcmd.my_const(const)
|
|
29
|
+
assert_equal(true, value.is_a?(String),
|
|
30
|
+
"#{const} #{where} should be a String; got #{value}.")
|
|
31
|
+
end
|
|
32
|
+
value = subcmd.my_const('MIN_ABBREV')
|
|
33
|
+
assert(value.is_a?(Fixnum),
|
|
34
|
+
"MIN_ABBREV #{where} should be a Fixnum; got #{value}.")
|
|
35
|
+
|
|
36
|
+
if 'show' == cmd_name
|
|
37
|
+
short_help = subcmd.my_const('SHORT_HELP')
|
|
38
|
+
needed_start = 'Show '
|
|
39
|
+
assert_equal(needed_start, short_help[0..needed_start.size-1],
|
|
40
|
+
"Short help #{where} should start: \"#{needed_start}\"; got #{short_help}")
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
end
|