rb8-trepanning 0.1.3-universal-ruby-1.8.7
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +3 -0
- data/CHANGES +34 -0
- data/ChangeLog +875 -0
- data/README.textile +59 -0
- data/Rakefile +215 -0
- data/app/.gitignore +1 -0
- data/app/cmd_parse.kpeg +241 -0
- data/app/cmd_parse.rb +212 -0
- data/app/cmd_parser.rb +1948 -0
- data/app/complete.rb +79 -0
- data/app/default.rb +90 -0
- data/app/display.rb +148 -0
- data/app/eventbuffer.rb +147 -0
- data/app/frame.rb +166 -0
- data/app/irb.rb +114 -0
- data/app/options.rb +200 -0
- data/app/run.rb +74 -0
- data/app/util.rb +65 -0
- data/bin/.gitignore +1 -0
- data/bin/trepan8 +115 -0
- data/data/.gitignore +1 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +1 -0
- data/interface/base_intf.rb +109 -0
- data/interface/client.rb +82 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +110 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +165 -0
- data/io/base_io.rb +148 -0
- data/io/input.rb +158 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +156 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/lib/debugger.rb +8 -0
- data/lib/trepanning.rb +283 -0
- data/processor/.gitignore +1 -0
- data/processor/command/.gitignore +1 -0
- data/processor/command/alias.rb +54 -0
- data/processor/command/backtrace.rb +123 -0
- data/processor/command/base/cmd.rb +177 -0
- data/processor/command/base/subcmd.rb +230 -0
- data/processor/command/base/submgr.rb +188 -0
- data/processor/command/base/subsubcmd.rb +128 -0
- data/processor/command/base/subsubmgr.rb +199 -0
- data/processor/command/break.rb +114 -0
- data/processor/command/catch.rb +71 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/continue.rb +57 -0
- data/processor/command/directory.rb +50 -0
- data/processor/command/disable.rb +85 -0
- data/processor/command/display.rb +78 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +79 -0
- data/processor/command/enable.rb +48 -0
- data/processor/command/eval.rb +90 -0
- data/processor/command/exit.rb +66 -0
- data/processor/command/finish.rb +59 -0
- data/processor/command/frame.rb +97 -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 +230 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/.gitignore +1 -0
- data/processor/command/info_subcmd/args.rb +39 -0
- data/processor/command/info_subcmd/breakpoints.rb +80 -0
- data/processor/command/info_subcmd/catch.rb +36 -0
- data/processor/command/info_subcmd/files.rb +39 -0
- data/processor/command/info_subcmd/globals.rb +64 -0
- data/processor/command/info_subcmd/line.rb +30 -0
- data/processor/command/info_subcmd/locals.rb +69 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +57 -0
- data/processor/command/info_subcmd/source.rb +74 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/threads.rb +75 -0
- data/processor/command/kill.rb +78 -0
- data/processor/command/list.rb +117 -0
- data/processor/command/macro.rb +68 -0
- data/processor/command/next.rb +79 -0
- data/processor/command/parsetree.rb +56 -0
- data/processor/command/pp.rb +40 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +86 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +1 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +1 -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/callstyle.rb +46 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +47 -0
- data/processor/command/set_subcmd/different.rb +61 -0
- data/processor/command/set_subcmd/highlight.rb +43 -0
- data/processor/command/set_subcmd/max.rb +26 -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/timer.rb +58 -0
- data/processor/command/shell.rb +139 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +1 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/alias.rb +46 -0
- data/processor/command/show_subcmd/args.rb +34 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +27 -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/callstyle.rb +22 -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/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/highlight.rb +24 -0
- data/processor/command/show_subcmd/max.rb +27 -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/version.rb +23 -0
- data/processor/command/source.rb +134 -0
- data/processor/command/step.rb +81 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +59 -0
- data/processor/command/up.rb +72 -0
- data/processor/command-ruby-debug/breakpoints.rb +155 -0
- data/processor/command-ruby-debug/catchpoint.rb +55 -0
- data/processor/command-ruby-debug/condition.rb +49 -0
- data/processor/command-ruby-debug/control.rb +31 -0
- data/processor/command-ruby-debug/display.rb +120 -0
- data/processor/command-ruby-debug/enable.rb +202 -0
- data/processor/command-ruby-debug/frame.rb +199 -0
- data/processor/command-ruby-debug/help.rb +63 -0
- data/processor/command-ruby-debug/info.rb +359 -0
- data/processor/command-ruby-debug/method.rb +84 -0
- data/processor/command-ruby-debug/reload.rb +40 -0
- data/processor/command-ruby-debug/save.rb +90 -0
- data/processor/command-ruby-debug/set.rb +237 -0
- data/processor/command-ruby-debug/show.rb +251 -0
- data/processor/command-ruby-debug/source.rb +36 -0
- data/processor/command-ruby-debug/threads.rb +189 -0
- data/processor/command-ruby-debug/trace.rb +57 -0
- data/processor/command-ruby-debug/variables.rb +199 -0
- data/processor/command.rb +270 -0
- data/processor/default.rb +56 -0
- data/processor/display.rb +17 -0
- data/processor/eval.rb +113 -0
- data/processor/eventbuf.rb +105 -0
- data/processor/frame.rb +172 -0
- data/processor/help.rb +92 -0
- data/processor/helper.rb +76 -0
- data/processor/hook.rb +134 -0
- data/processor/load_cmds.rb +258 -0
- data/processor/location.rb +174 -0
- data/processor/main.rb +455 -0
- data/processor/mock.rb +136 -0
- data/processor/msg.rb +61 -0
- data/processor/processor.rb +674 -0
- data/processor/running.rb +168 -0
- data/processor/stepping.rb +18 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/processor/virtual.rb +34 -0
- data/test/data/.gitignore +1 -0
- data/test/data/break_bad.cmd +19 -0
- data/test/data/break_bad.right +29 -0
- data/test/data/break_loop_bug.cmd +5 -0
- data/test/data/break_loop_bug.right +15 -0
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +14 -0
- data/test/data/edit.right +24 -0
- data/test/data/file-with-space.cmd +6 -0
- data/test/data/file-with-space.right +4 -0
- data/test/data/printvar.cmd +17 -0
- data/test/data/printvar.right +31 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +19 -0
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +18 -0
- data/test/data/stepping-1.9.right +50 -0
- data/test/data/stepping.cmd +21 -0
- data/test/data/stepping.right +48 -0
- data/test/data/trepan8-save.1 +6 -0
- data/test/example/bp_loop_issue.rb +3 -0
- data/test/example/break-bug.rb +7 -0
- data/test/example/brkpt-class-bug.rb +8 -0
- data/test/example/classes.rb +11 -0
- data/test/example/dollar-0.rb +5 -0
- data/test/example/except-bug1.rb +4 -0
- data/test/example/except-bug2.rb +7 -0
- data/test/example/file with space.rb +1 -0
- data/test/example/gcd.rb +18 -0
- data/test/example/info-var-bug.rb +47 -0
- data/test/example/info-var-bug2.rb +2 -0
- data/test/example/null.rb +1 -0
- data/test/example/pm-bug.rb +3 -0
- data/test/example/pm.rb +11 -0
- data/test/example/raise.rb +3 -0
- data/test/integration/.gitignore +4 -0
- data/test/integration/config.yaml +8 -0
- data/test/integration/helper.rb +154 -0
- data/test/integration/test-break_bad.rb +26 -0
- data/test/integration/test-dollar-0.rb +31 -0
- data/test/integration/test-edit.rb +17 -0
- data/test/integration/test-file-with-space.rb +26 -0
- data/test/integration/test-printvar.rb +17 -0
- data/test/integration/test-raise.rb +21 -0
- data/test/integration/test-source.rb +16 -0
- data/test/integration/test-stepping.rb +24 -0
- data/test/unit/.gitignore +1 -0
- data/test/unit/cmd-helper.rb +52 -0
- data/test/unit/mock-helper.rb +12 -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-frame.rb +32 -0
- data/test/unit/test-app-options.rb +92 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -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 +23 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +46 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-completion.rb +42 -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 +36 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +50 -0
- data/test/unit/test-proc-location.rb +79 -0
- data/test/unit/test-subcmd-help.rb +44 -0
- data/trepan8.gemspec +58 -0
- metadata +385 -0
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
|
5
|
+
# Unit test for io/tcpclient.rb and io/tcpserver.rb together
|
6
|
+
require_relative '../../io/tcpfns'
|
7
|
+
require_relative '../../io/tcpclient'
|
8
|
+
require_relative '../../io/tcpserver'
|
9
|
+
|
10
|
+
# Tests TCPServer together with and TCPClient
|
11
|
+
class TestTCPClientServer < Test::Unit::TestCase
|
12
|
+
|
13
|
+
def test_client_server
|
14
|
+
server = Trepan::TCPDbgServer.new({ :open => true,
|
15
|
+
:port => 1028,
|
16
|
+
:host => 'localhost'
|
17
|
+
})
|
18
|
+
client = Trepan::TCPDbgClient.new({ :open => true,
|
19
|
+
:port => 1028,
|
20
|
+
:host => 'localhost'
|
21
|
+
})
|
22
|
+
%w(one, two, three).each do |line|
|
23
|
+
server.writeline(line)
|
24
|
+
assert_equal line, client.read_msg.chomp
|
25
|
+
end
|
26
|
+
%w(four, five, six).each do |line|
|
27
|
+
client.writeline(line)
|
28
|
+
assert_equal line, server.read_msg.chomp
|
29
|
+
end
|
30
|
+
client.close
|
31
|
+
server.close
|
32
|
+
end
|
33
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
|
5
|
+
# Unit test for io/tcpclient.rb
|
6
|
+
require_relative '../../io/tcpfns'
|
7
|
+
require_relative '../../io/tcpclient'
|
8
|
+
|
9
|
+
class TestTCPDbgClient < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Trepanning::TCPPacking
|
12
|
+
|
13
|
+
def test_basic
|
14
|
+
client = Trepan::TCPDbgClient.new({ :open => false,
|
15
|
+
:port => 1027,
|
16
|
+
:host => 'localhost'
|
17
|
+
})
|
18
|
+
threads = []
|
19
|
+
Thread.new do
|
20
|
+
server = TCPServer.new('localhost', 1027)
|
21
|
+
session = server.accept
|
22
|
+
while 'quit' != (line = session.gets)
|
23
|
+
session.puts line
|
24
|
+
end
|
25
|
+
session.close
|
26
|
+
end
|
27
|
+
threads << Thread.new do
|
28
|
+
3.times do
|
29
|
+
begin
|
30
|
+
client.open
|
31
|
+
rescue IOError
|
32
|
+
end
|
33
|
+
break
|
34
|
+
end
|
35
|
+
assert client
|
36
|
+
msgs = %w(four five six)
|
37
|
+
msgs.each do |mess|
|
38
|
+
begin
|
39
|
+
break if client.disconnected?
|
40
|
+
client.writeline(mess)
|
41
|
+
assert_equal mess, client.read_msg.chomp
|
42
|
+
rescue EOFError
|
43
|
+
puts "In client: got EOF"
|
44
|
+
break
|
45
|
+
rescue Exception => e
|
46
|
+
puts "In client: got #{e}"
|
47
|
+
break
|
48
|
+
end
|
49
|
+
end
|
50
|
+
client.close
|
51
|
+
end
|
52
|
+
threads.each {|t| t.join }
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
|
5
|
+
# Unit test for io/tcpfns.rb
|
6
|
+
|
7
|
+
require_relative '../../io/tcpfns'
|
8
|
+
|
9
|
+
class TestTCPPacking < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Trepanning::TCPPacking
|
12
|
+
|
13
|
+
def test_pack_unpack
|
14
|
+
msg = "Hi there!"
|
15
|
+
assert_equal unpack_msg(pack_msg(msg))[1], msg
|
16
|
+
end
|
17
|
+
end
|
@@ -0,0 +1,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
|
5
|
+
# Unit test for io/tcpserver.rb
|
6
|
+
require_relative '../../io/tcpfns'
|
7
|
+
require_relative '../../io/tcpserver'
|
8
|
+
|
9
|
+
class TestTCPDbgServer < Test::Unit::TestCase
|
10
|
+
|
11
|
+
include Trepanning::TCPPacking
|
12
|
+
|
13
|
+
def test_basic
|
14
|
+
server = Trepan::TCPDbgServer.new
|
15
|
+
server.open({ :open => false,
|
16
|
+
:port => 1027,
|
17
|
+
:host => '127.0.0.1'
|
18
|
+
})
|
19
|
+
threads = []
|
20
|
+
msgs = %w(one two three)
|
21
|
+
Thread.new do
|
22
|
+
msgs.each do |msg|
|
23
|
+
begin
|
24
|
+
line = server.read_msg.chomp
|
25
|
+
assert_equal(msg, line)
|
26
|
+
rescue EOFError
|
27
|
+
puts 'Got EOF'
|
28
|
+
break
|
29
|
+
end
|
30
|
+
end
|
31
|
+
end
|
32
|
+
threads << Thread.new do
|
33
|
+
t = TCPSocket.new('127.0.0.1', 1027)
|
34
|
+
msgs.each do |msg|
|
35
|
+
begin
|
36
|
+
t.puts(pack_msg(msg))
|
37
|
+
rescue EOFError
|
38
|
+
puts "Got EOF"
|
39
|
+
break
|
40
|
+
rescue Exception => e
|
41
|
+
puts "Got #{e}"
|
42
|
+
break
|
43
|
+
end
|
44
|
+
end
|
45
|
+
t.close
|
46
|
+
end
|
47
|
+
threads.each {|t| t.join }
|
48
|
+
server.close
|
49
|
+
end
|
50
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
require_relative '../../processor/main' # Have to include before frame!
|
5
|
+
# FIXME
|
6
|
+
require_relative '../../app/frame'
|
7
|
+
require_relative '../../processor/eval'
|
8
|
+
require_relative '../../processor/mock'
|
9
|
+
|
10
|
+
# Test Trepan::CmdProcessor Eval portion
|
11
|
+
class TestProcEval < Test::Unit::TestCase
|
12
|
+
|
13
|
+
include UnitHelper
|
14
|
+
def test_basic
|
15
|
+
common_setup
|
16
|
+
@dbgr = MockDebugger::MockDebugger.new
|
17
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbgr.intf)
|
18
|
+
assert_equal('(eval "x = 1; y = 2")',
|
19
|
+
|
20
|
+
@cmdproc.fake_eval_filename('x = 1; y = 2'))
|
21
|
+
assert_equal('(eval "x = 1;"...)',
|
22
|
+
@cmdproc.fake_eval_filename('x = 1; y = 2', 7))
|
23
|
+
|
24
|
+
@cmdproc.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
25
|
+
# x = 1
|
26
|
+
# vm_locations = Rubinius::VM.backtrace(0, true)
|
27
|
+
# @dbgr.instance_variable_set('@vm_locations', vm_locations)
|
28
|
+
# @cmdproc.instance_variable_set('@current_frame',
|
29
|
+
# Trepan::Frame.new(self, 0, vm_locations[0]))
|
30
|
+
# @cmdproc.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
31
|
+
# assert_equal('1', @cmdproc.debug_eval('x = "#{x}"'))
|
32
|
+
# x = 2
|
33
|
+
# assert_equal('2', @cmdproc.debug_eval_no_errmsg('x = "#{x}"'))
|
34
|
+
# assert_equal(nil, @cmdproc.debug_eval_no_errmsg('x+'))
|
35
|
+
end
|
36
|
+
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,50 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'cmd-helper'
|
5
|
+
|
6
|
+
class TestCmdProcessorLoadCmds < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include UnitHelper
|
9
|
+
def setup
|
10
|
+
common_setup
|
11
|
+
end
|
12
|
+
|
13
|
+
# See that we have can load up commands
|
14
|
+
def test_basic
|
15
|
+
@cmdproc.load_cmds_initialize
|
16
|
+
assert_equal(false, @cmdproc.commands.empty?)
|
17
|
+
assert_equal(false, @cmdproc.aliases.empty?)
|
18
|
+
end
|
19
|
+
|
20
|
+
def test_complete
|
21
|
+
assert_equal(%w(directory disable display down),
|
22
|
+
@cmdproc.complete('d', 'd'),
|
23
|
+
"Failed completion of 'd' commands")
|
24
|
+
assert_equal(['debug', 'different', 'directories'],
|
25
|
+
@cmdproc.complete('sho d', 'd'),
|
26
|
+
"Failed completion of 'sho d' subcommands")
|
27
|
+
$errors = []
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_run_cmd
|
31
|
+
$errors = []
|
32
|
+
|
33
|
+
def @cmdproc.errmsg(mess)
|
34
|
+
$errors << mess
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_it(size, *args)
|
38
|
+
@cmdproc.run_cmd(*args)
|
39
|
+
assert_equal(size, $errors.size, $errors)
|
40
|
+
end
|
41
|
+
test_it(1, 'foo')
|
42
|
+
test_it(2, [])
|
43
|
+
test_it(3, ['list', 5])
|
44
|
+
# See that we got different error messages
|
45
|
+
assert_not_equal($errors[0], $errors[1], $errors)
|
46
|
+
assert_not_equal($errors[1], $errors[2], $errors)
|
47
|
+
assert_not_equal($errors[2], $errors[0], $errors)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
@@ -0,0 +1,79 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require 'ruby-debug';
|
5
|
+
begin
|
6
|
+
require 'linecache'
|
7
|
+
rescue LoadError
|
8
|
+
require 'linecache19'
|
9
|
+
end
|
10
|
+
require_relative '../../processor/location'
|
11
|
+
require_relative '../../processor/mock'
|
12
|
+
|
13
|
+
$errors = []
|
14
|
+
$msgs = []
|
15
|
+
|
16
|
+
# Test Trepan::CmdProcessor location portion
|
17
|
+
class TestCmdProcessorLocation < Test::Unit::TestCase
|
18
|
+
|
19
|
+
def setup
|
20
|
+
$errors = []
|
21
|
+
$msgs = []
|
22
|
+
@dbgr = MockDebugger::MockDebugger.new
|
23
|
+
@proc = Trepan::CmdProcessor.new(@dbgr.intf)
|
24
|
+
@file = File.basename(__FILE__)
|
25
|
+
end
|
26
|
+
|
27
|
+
# Test resolve_file_with_dir() and line_at()
|
28
|
+
def test_line_at
|
29
|
+
@proc.settings[:directory] = ''
|
30
|
+
assert_equal(nil, @proc.resolve_file_with_dir(@file))
|
31
|
+
if File.expand_path(Dir.pwd) == File.expand_path(File.dirname(__FILE__))
|
32
|
+
line = @proc.line_at(@file, __LINE__)
|
33
|
+
assert_match(/line = @proc.line_at/, line)
|
34
|
+
else
|
35
|
+
assert_equal(nil, @proc.line_at(@file, __LINE__))
|
36
|
+
end
|
37
|
+
dir = @proc.settings[:directory] = File.dirname(__FILE__)
|
38
|
+
assert_equal(File.join(dir, @file),
|
39
|
+
@proc.resolve_file_with_dir('test-proc-location.rb'))
|
40
|
+
test_line = 'test_line'
|
41
|
+
line = @proc.line_at(@file, __LINE__-1)
|
42
|
+
assert_match(/#{line}/, line)
|
43
|
+
end
|
44
|
+
|
45
|
+
def test_loc_and_text
|
46
|
+
@proc.frame_index = 0
|
47
|
+
@proc.frame_initialize
|
48
|
+
Debugger.start
|
49
|
+
@proc.frame_setup(Debugger.current_context, nil)
|
50
|
+
LineCache::clear_file_cache
|
51
|
+
dir = @proc.settings[:directory] = File.dirname(__FILE__)
|
52
|
+
loc, line_no, text = @proc.loc_and_text('hi')
|
53
|
+
assert loc and line_no.is_a?(Fixnum) and text
|
54
|
+
assert @proc.current_source_text
|
55
|
+
# FIXME test that filename remapping works.
|
56
|
+
Debugger.stop
|
57
|
+
end
|
58
|
+
|
59
|
+
def test_canonic_file
|
60
|
+
@proc.settings[:basename] = false
|
61
|
+
assert_equal File.expand_path(__FILE__), @proc.canonic_file(__FILE__)
|
62
|
+
@proc.settings[:basename] = true
|
63
|
+
assert_equal File.basename(__FILE__), @proc.canonic_file(__FILE__)
|
64
|
+
end
|
65
|
+
|
66
|
+
|
67
|
+
def test_eval_current_source_text
|
68
|
+
Debugger.start
|
69
|
+
eval <<-EOE
|
70
|
+
@proc.frame_index = 0
|
71
|
+
@proc.frame_initialize
|
72
|
+
@proc.frame_setup(Debugger.current_context, nil)
|
73
|
+
LineCache::clear_file_cache
|
74
|
+
assert @proc.current_source_text
|
75
|
+
EOE
|
76
|
+
Debugger.stop
|
77
|
+
end
|
78
|
+
|
79
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../processor/main'
|
5
|
+
require_relative '../../processor/mock'
|
6
|
+
|
7
|
+
# Test Trepan::CmdProcessor
|
8
|
+
class TestSubCmdHelp < Test::Unit::TestCase
|
9
|
+
|
10
|
+
def setup
|
11
|
+
@dbgr = MockDebugger::MockDebugger.new
|
12
|
+
@cmdproc = Trepan::CmdProcessor.new(@dbgr.intf)
|
13
|
+
@cmds = @cmdproc.instance_variable_get('@commands')
|
14
|
+
end
|
15
|
+
|
16
|
+
# See that subcommand class constants exist.
|
17
|
+
def test_required_class_constants
|
18
|
+
@cmds.each do |cmd_name, cmd|
|
19
|
+
if cmd.is_a?(Trepan::SubcommandMgr)
|
20
|
+
cmd.subcmds.subcmds.each do |subcmd_name, subcmd|
|
21
|
+
where = "of subcommand #{subcmd_name} in command #{cmd_name}"
|
22
|
+
%w(HELP NAME SHORT_HELP).each do
|
23
|
+
|const|
|
24
|
+
value = subcmd.my_const(const)
|
25
|
+
assert_equal(true, value.is_a?(String),
|
26
|
+
"#{const} #{where} should be a String; got #{value}.")
|
27
|
+
end
|
28
|
+
value = subcmd.my_const('MIN_ABBREV')
|
29
|
+
assert(value.is_a?(Fixnum),
|
30
|
+
"MIN_ABBREV #{where} should be a Fixnum; got #{value}.")
|
31
|
+
|
32
|
+
if 'show' == cmd_name
|
33
|
+
short_help = subcmd.my_const('SHORT_HELP')
|
34
|
+
needed_start = 'Show '
|
35
|
+
assert_equal(needed_start, short_help[0..needed_start.size-1],
|
36
|
+
"Short help #{where} should start: \"#{needed_start}\"; got #{short_help}")
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
|
44
|
+
end
|
data/trepan8.gemspec
ADDED
@@ -0,0 +1,58 @@
|
|
1
|
+
# -*- Ruby -*-
|
2
|
+
# -*- encoding: utf-8 -*-
|
3
|
+
require 'rake'
|
4
|
+
unless Object.const_defined?(:'Trepan')
|
5
|
+
if RUBY_VERSION =~ /^1.9.2/
|
6
|
+
require File.expand_path(File.dirname(__FILE__) + '/app/options')
|
7
|
+
else
|
8
|
+
require 'rubygems'; require 'require_relative'
|
9
|
+
require_relative './app/options'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
Gem::Specification.new do |spec|
|
14
|
+
spec.authors = ['R. Bernstein']
|
15
|
+
spec.date = Time.now
|
16
|
+
spec.description = <<-EOF
|
17
|
+
A modular, testable, Ruby debugger using some of the best ideas from ruby-debug, other debuggers, and Ruby Rails.
|
18
|
+
|
19
|
+
Some of the core debugger concepts have been rethought. As a result, some of this may be experimental.
|
20
|
+
|
21
|
+
This version works only with a MRI 1.8 and 1.9.2'
|
22
|
+
|
23
|
+
See also rb-trepanning and rbx-trepanning versions that works with Rubinius.
|
24
|
+
and a patched YARV 1.9.2.
|
25
|
+
EOF
|
26
|
+
# spec.add_dependency('rb-trace', '>= 0.5')
|
27
|
+
|
28
|
+
if RUBY_VERSION.start_with?('1.8')
|
29
|
+
spec.add_dependency('linecache', '>= 0.43')
|
30
|
+
elsif RUBY_VERSION.start_with?('1.9')
|
31
|
+
spec.add_dependency('linecache19', '>= 0.5.12')
|
32
|
+
end
|
33
|
+
|
34
|
+
spec.add_dependency('rbx-require-relative', '> 0.0.4')
|
35
|
+
spec.add_dependency('columnize')
|
36
|
+
spec.author = 'R. Bernstein'
|
37
|
+
spec.bindir = 'bin'
|
38
|
+
spec.email = 'rockyb@rubyforge.net'
|
39
|
+
spec.executables = ['trepan8']
|
40
|
+
spec.files = `git ls-files`.split("\n")
|
41
|
+
spec.has_rdoc = true
|
42
|
+
spec.homepage = 'http://wiki.github.com/rocky/rb8-trepanning'
|
43
|
+
spec.name = 'rb8-trepanning'
|
44
|
+
spec.license = 'MIT'
|
45
|
+
if RUBY_VERSION =~ /^1.8.7/
|
46
|
+
spec.platform = Gem::Platform::new ['universal', 'ruby', '1.8.7']
|
47
|
+
elsif RUBY_VERSION =~ /^1.9.2/
|
48
|
+
spec.platform = Gem::Platform::new ['universal', 'ruby', '1.9.2']
|
49
|
+
else
|
50
|
+
STDERR.puts "Have only tested on MRI 1.8.7 and 1.9.2"
|
51
|
+
end
|
52
|
+
spec.require_path = 'lib'
|
53
|
+
spec.summary = 'Ruby MRI 1.8.7 and 1.9.2 Trepanning Debugger'
|
54
|
+
spec.version = Trepan::VERSION
|
55
|
+
|
56
|
+
spec.rdoc_options += ['--title', "Trepan #{Trepan::VERSION} Documentation"]
|
57
|
+
|
58
|
+
end
|