rbx-trepanning 0.0.3-universal-rubinius-1.2 → 0.0.4-universal-rubinius-1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +152 -55
- data/NEWS +7 -0
- data/Rakefile +1 -1
- data/app/breakpoint.rb +3 -2
- data/app/breakpoint.rbc +207 -220
- data/app/brkptmgr.rb +84 -82
- data/app/brkptmgr.rbc +263 -193
- data/app/client.rb +61 -0
- data/app/client.rbc +1225 -0
- data/app/default.rb +17 -7
- data/app/default.rbc +302 -181
- data/app/display.rb +134 -21
- data/app/display.rbc +2176 -566
- data/app/iseq.rb +33 -11
- data/app/iseq.rbc +634 -243
- data/app/llvm.rbc +2576 -0
- data/app/options.rb +51 -20
- data/app/options.rb.orig +154 -0
- data/app/options.rbc +1148 -561
- data/app/rbx-llvm.rb +165 -0
- data/app/util.rb +1 -1
- data/app/util.rbc +38 -32
- data/bin/trepan.orig +0 -0
- data/bin/trepan.rej +11 -0
- data/bin/trepanx +13 -8
- data/bin/trepanx.compiled.rbc +373 -319
- data/interface/base_intf.rb +11 -5
- data/interface/base_intf.rbc +173 -70
- data/interface/client.rb +80 -0
- data/interface/client.rbc +1072 -0
- data/interface/comcodes.rb +18 -0
- data/interface/comcodes.rbc +343 -0
- data/interface/server.rb +143 -0
- data/interface/server.rbc +2213 -0
- data/interface/user.rb +1 -8
- data/interface/user.rbc +68 -165
- data/io/base_io.rb +56 -2
- data/io/base_io.rbc +727 -20
- data/io/tcpclient.rb +123 -0
- data/io/tcpclient.rbc +2327 -0
- data/io/tcpfns.rb +31 -0
- data/io/tcpfns.rbc +652 -0
- data/io/tcpserver.rb +138 -0
- data/io/tcpserver.rbc +2585 -0
- data/lib/trepanning.rb +91 -56
- data/lib/trepanning.rb.orig +433 -0
- data/lib/trepanning.rb.rej +11 -0
- data/lib/trepanning.rbc +1954 -1340
- data/processor/command/backtrace.rb +45 -15
- data/processor/command/base/cmd.rb +10 -6
- data/processor/command/base/subcmd.rb +16 -1
- data/processor/command/complete.rb +47 -0
- data/processor/command/continue.rb +4 -3
- data/processor/command/directory.rb +9 -1
- data/processor/command/disassemble.rb +22 -7
- data/processor/command/display.rb +82 -0
- data/processor/command/eval.rb +3 -1
- data/processor/command/exit.rb +4 -0
- data/processor/command/help.rb +69 -18
- data/processor/command/info_subcmd/breakpoints.rb +6 -8
- data/processor/command/info_subcmd/file.rb +5 -7
- data/processor/command/info_subcmd/method.rb +9 -9
- data/processor/command/info_subcmd/program.rb +3 -4
- data/processor/command/info_subcmd/variables.rb +4 -3
- data/processor/command/list.rb +8 -4
- data/processor/command/nexti.rb +2 -2
- data/processor/command/pr.rb +2 -2
- data/processor/command/ps.rb +2 -2
- data/processor/command/server.rb +72 -0
- data/processor/command/set_subcmd/auto.rb +2 -3
- data/processor/command/set_subcmd/basename.rb +3 -4
- data/processor/command/set_subcmd/debug.rb +2 -3
- data/processor/command/set_subcmd/different.rb +3 -4
- data/processor/command/set_subcmd/hidelevel.rb +6 -7
- data/processor/command/set_subcmd/highlight.rb +33 -0
- data/processor/command/set_subcmd/kernelstep.rb +3 -4
- data/processor/command/set_subcmd/max.rb +2 -4
- data/processor/command/set_subcmd/max_subcmd/string.rb +44 -22
- data/processor/command/set_subcmd/substitute.rb +2 -3
- data/processor/command/set_subcmd/trace.rb +3 -4
- data/processor/command/show_subcmd/alias.rb +3 -4
- data/processor/command/show_subcmd/args.rb +2 -3
- data/processor/command/show_subcmd/auto.rb +1 -2
- data/processor/command/show_subcmd/basename.rb +2 -3
- data/processor/command/show_subcmd/debug.rb +1 -2
- data/processor/command/show_subcmd/different.rb +2 -3
- data/processor/command/show_subcmd/hidelevel.rb +1 -2
- data/processor/command/show_subcmd/highlight.rb +24 -0
- data/processor/command/show_subcmd/kernelstep.rb +3 -6
- data/processor/command/show_subcmd/max.rb +4 -5
- data/processor/command/show_subcmd/trace.rb +9 -11
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +75 -31
- data/processor/command/undisplay.rb +59 -0
- data/processor/default.rb +4 -4
- data/processor/disassemble.rb +18 -5
- data/processor/display.rb +18 -0
- data/processor/location.rb +15 -5
- data/processor/main.rb +27 -13
- data/processor/mock.rb +12 -9
- data/processor/msg.rb +24 -9
- data/processor/stepping.rb +10 -12
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/list-terminal-colors.rbc +2164 -0
- data/sample/rocky-dot-trepanrc.orig +0 -0
- data/sample/rocky-dot-trepanrc.rej +11 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +39 -0
- data/test/data/fname-with-blank.right +3 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +13 -0
- data/test/data/quit.right +2 -0
- data/test/example/{gcd1.rb → gcd-server.rb} +4 -6
- data/test/example/gcd.rb +0 -0
- data/test/example/inline-call.rb +23 -0
- data/test/integration/helper.rb +8 -8
- data/test/integration/test-fname-with-blank.rb +5 -1
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +5 -1
- data/test/unit/cmd-helper.rb +7 -4
- data/test/unit/mock-helper.rb +1 -0
- data/test/unit/test-app-brkpt.rb +4 -5
- data/test/unit/test-app-brkptmgr.rb +2 -2
- data/test/unit/test-app-iseq.rb +29 -14
- data/test/unit/test-app-options.rb +26 -5
- data/test/unit/test-base-subcmd.rb +1 -1
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +53 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-main.rb +6 -2
- metadata +53 -10
- data/test/example/gcd-xx.rb +0 -18
File without changes
|
@@ -0,0 +1,11 @@
|
|
1
|
+
--- sample/rocky-dot-trepanrc
|
2
|
+
+++ sample/rocky-dot-trepanrc
|
3
|
+
@@ -4,7 +4,7 @@
|
4
|
+
dir /home/rocky-rvm/.rvm/src/rbx-head/
|
5
|
+
|
6
|
+
set autoeval on # Is default, but just in case
|
7
|
+
-# set terminal on # turn on syntax highlight by default
|
8
|
+
+# set highlight on # turn on syntax highlight by default
|
9
|
+
|
10
|
+
# My customization to the default syntax coloring
|
11
|
+
load "#{ENV['HOME']}/.trepanx-colors.rb"
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# Rocky's trepanx profile for Rubinius.
|
2
|
+
|
3
|
+
# Place where I have Rubinius source (in rvm)
|
4
|
+
dir /home/rocky-rvm/.rvm/src/rbx-head/
|
5
|
+
|
6
|
+
set autoeval on # Is default, but just in case
|
7
|
+
# set terminal on # turn on syntax highlight by default
|
8
|
+
|
9
|
+
# My customization to the default syntax coloring
|
10
|
+
load "#{ENV['HOME']}/.trepanx-colors.rb"
|
11
|
+
|
12
|
+
# let me know that this ran...
|
13
|
+
puts "Rocky's .trepanxrc loaded"
|
14
|
+
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Terminal color settings I use. I doubt terminal colors are
|
2
|
+
# standardized let alone what colors you want for the various
|
3
|
+
# syntax elements. So you should adjust as desired.
|
4
|
+
|
5
|
+
# Values are either a number string, e.g. '36' or a pair of number
|
6
|
+
# semicolon and number, e.g. '3;36'.
|
7
|
+
#
|
8
|
+
# The first number before a semicolon is a font modifier from the
|
9
|
+
# following table:
|
10
|
+
#
|
11
|
+
# 1 - bold
|
12
|
+
# 3 - italic
|
13
|
+
# 4 - underline
|
14
|
+
|
15
|
+
require 'rubygems'
|
16
|
+
require 'coderay'
|
17
|
+
require 'coderay/encoders/term'
|
18
|
+
TERM_TOKEN_COLORS = {
|
19
|
+
:comment => '3;36', # italic yellow brownish
|
20
|
+
:constant => '1;34', # bold blue
|
21
|
+
:global_variable => '36', # yellow brownish
|
22
|
+
:integer => '34', # blue
|
23
|
+
:label => '4', # black underline
|
24
|
+
:regexp => {
|
25
|
+
:content => '33', # light turquoise (from red)
|
26
|
+
:delimiter => '1;29',
|
27
|
+
:modifier => '35',
|
28
|
+
:function => '1;29'
|
29
|
+
},
|
30
|
+
:reserved => '1;32', # bold green (from red)
|
31
|
+
:symbol => '35', # purple
|
32
|
+
}
|
33
|
+
module CodeRay::Encoders
|
34
|
+
class Term < Encoder
|
35
|
+
TERM_TOKEN_COLORS.each_pair do |key, value|
|
36
|
+
TOKEN_COLORS[key] = value
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
-- (inline-call.rb:11 @12)
|
2
|
+
if a > b
|
3
|
+
basename is off.
|
4
|
+
6 $dbgr = Trepan.new(:nx => true, :cmdfiles => [cmdfile])
|
5
|
+
7 # GCD. We assume positive numbers
|
6
|
+
8 def gcd(a, b)
|
7
|
+
9 $dbgr.debugger
|
8
|
+
10 # Make: a <= b
|
9
|
+
11 -> if a > b
|
10
|
+
12 a, b = [b, a]
|
11
|
+
13 end
|
12
|
+
14
|
13
|
+
15 return nil if a <= 0
|
data/test/data/quit.right
CHANGED
@@ -1,12 +1,10 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'thread_frame'
|
3
|
-
tf = RubyVM::ThreadFrame.current
|
4
|
-
iseq = tf.iseq
|
5
|
-
p iseq.child_iseqs
|
6
|
-
puts iseq.disassemble
|
7
|
-
|
8
2
|
# GCD. We assume positive numbers
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../lib/trepanning.rb'
|
5
|
+
$dbgr = Trepan.new(:server => true)
|
9
6
|
def gcd(a, b)
|
7
|
+
$dbgr.debugger
|
10
8
|
# Make: a <= b
|
11
9
|
if a > b
|
12
10
|
a, b = [b, a]
|
data/test/example/gcd.rb
CHANGED
File without changes
|
@@ -0,0 +1,23 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../../lib/trepanning.rb'
|
4
|
+
DATA_DIR = File.join(File.dirname(RequireRelative::abs_file), %w(.. data))
|
5
|
+
cmdfile = File.join(DATA_DIR, 'inline-call.cmd')
|
6
|
+
$dbgr = Trepan.new(:nx => true, :cmdfiles => [cmdfile])
|
7
|
+
# GCD. We assume positive numbers
|
8
|
+
def gcd(a, b)
|
9
|
+
$dbgr.debugger
|
10
|
+
# Make: a <= b
|
11
|
+
if a > b
|
12
|
+
a, b = [b, a]
|
13
|
+
end
|
14
|
+
|
15
|
+
return nil if a <= 0
|
16
|
+
|
17
|
+
if a == 1 or b-a == 0
|
18
|
+
return a
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
a, b = ARGV[0..1].map {|arg| arg.to_i}
|
23
|
+
puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
|
data/test/integration/helper.rb
CHANGED
@@ -37,6 +37,9 @@ def run_debugger(testname, ruby_file, opts={})
|
|
37
37
|
if opts[:xdebug]
|
38
38
|
"%s -Xdebug '%s' %s >%s 2>&1 <%s" %
|
39
39
|
[Trepanning::ruby_path, programfile, opts[:args], outfile, cmdfile]
|
40
|
+
elsif opts[:standalone]
|
41
|
+
"%s %s %s >%s 2>&1" %
|
42
|
+
[Trepanning::ruby_path, programfile, opts[:args], outfile]
|
40
43
|
else
|
41
44
|
"%s %s --nx --command %s %s '%s' %s >%s 2>&1" %
|
42
45
|
[Trepanning::ruby_path, dbgr_path, cmdfile, opts[:dbgr],
|
@@ -46,18 +49,15 @@ def run_debugger(testname, ruby_file, opts={})
|
|
46
49
|
system(cmd)
|
47
50
|
return false unless 0 == $?.exitstatus
|
48
51
|
if opts[:do_diff]
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
to_file = outfile
|
53
|
-
# todate = time.ctime(os.stat(tofile).st_mtime)
|
54
|
-
to_lines = File.open(to_file).readlines()
|
52
|
+
expected_lines = File.open(rightfile).readlines()
|
53
|
+
got_lines = File.open(outfile).readlines()
|
54
|
+
opts[:filter].call(got_lines, expected_lines) if opts[:filter]
|
55
55
|
|
56
56
|
# Seems to be a bug in LCS in that it will return a diff even if two
|
57
57
|
# files are the same.
|
58
|
-
return true if
|
58
|
+
return true if expected_lines == got_lines
|
59
59
|
|
60
|
-
sdiffs = Diff::LCS.sdiff(
|
60
|
+
sdiffs = Diff::LCS.sdiff(expected_lines, got_lines)
|
61
61
|
|
62
62
|
if sdiffs.empty?
|
63
63
|
FileUtils.rm(outfile)
|
@@ -7,6 +7,10 @@ class TestFnameWithBlank < Test::Unit::TestCase
|
|
7
7
|
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
8
8
|
|
9
9
|
def test_it
|
10
|
-
|
10
|
+
opts = {}
|
11
|
+
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
12
|
+
got_lines[0] = "-> (fname with blank.rb:1 @0)\n"
|
13
|
+
}
|
14
|
+
assert_equal(true, run_debugger(@@NAME, 'fname with blank.rb', opts))
|
11
15
|
end
|
12
16
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'helper'
|
5
|
+
|
6
|
+
class TestInlineCall < Test::Unit::TestCase
|
7
|
+
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
8
|
+
def test_inline_call
|
9
|
+
opts = {
|
10
|
+
:short_cmd => @@NAME, :do_diff => true,
|
11
|
+
:standalone => true
|
12
|
+
}
|
13
|
+
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
14
|
+
got_lines[0] = "-- (inline-call.rb:11 @12)\n"
|
15
|
+
}
|
16
|
+
|
17
|
+
no_error = run_debugger(@@NAME, @@NAME + '.rb', opts)
|
18
|
+
assert_equal(true, no_error)
|
19
|
+
end
|
20
|
+
end
|
@@ -7,7 +7,11 @@ class TestQuit < Test::Unit::TestCase
|
|
7
7
|
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
8
8
|
|
9
9
|
def test_trepanx_call
|
10
|
-
|
10
|
+
opts = {}
|
11
|
+
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
12
|
+
got_lines[0] = "-> (null.rb:1 @0)\n"
|
13
|
+
}
|
14
|
+
assert_equal(true, run_debugger(@@NAME, 'null.rb', opts))
|
11
15
|
end
|
12
16
|
|
13
17
|
def test_xcode_call
|
data/test/unit/cmd-helper.rb
CHANGED
@@ -16,18 +16,21 @@ module UnitHelper
|
|
16
16
|
@cmdproc.dbgr = @dbg
|
17
17
|
@cmds = @cmdproc.commands
|
18
18
|
|
19
|
-
def @cmdproc.
|
20
|
-
@msgs << message
|
21
|
-
end
|
22
|
-
def @cmdproc.errmsg(message)
|
19
|
+
def @cmdproc.errmsg(message, opts={})
|
23
20
|
@errmsgs << message
|
24
21
|
end
|
25
22
|
def @cmdproc.errmsgs
|
26
23
|
@errmsgs
|
27
24
|
end
|
25
|
+
def @cmdproc.msg(message, opts={})
|
26
|
+
@msgs << message
|
27
|
+
end
|
28
28
|
def @cmdproc.msgs
|
29
29
|
@msgs
|
30
30
|
end
|
31
|
+
def @cmdproc.section(message, opts={})
|
32
|
+
@msgs << message
|
33
|
+
end
|
31
34
|
reset_cmdproc_vars
|
32
35
|
end
|
33
36
|
module_function :common_setup
|
data/test/unit/mock-helper.rb
CHANGED
data/test/unit/test-app-brkpt.rb
CHANGED
@@ -7,7 +7,7 @@ class TestAppBrkpt < Test::Unit::TestCase
|
|
7
7
|
|
8
8
|
def test_basic
|
9
9
|
method = Rubinius::CompiledMethod.of_sender
|
10
|
-
b1 =
|
10
|
+
b1 = Trepan::Breakpoint.new('<start>', method, 1, 2, 0)
|
11
11
|
assert_equal(false, b1.temp?)
|
12
12
|
assert_equal(0, b1.hits)
|
13
13
|
assert_equal('B', b1.icon_char)
|
@@ -17,14 +17,13 @@ class TestAppBrkpt < Test::Unit::TestCase
|
|
17
17
|
b1.enabled = false
|
18
18
|
assert_equal('b', b1.icon_char)
|
19
19
|
# assert_raises TypeError do
|
20
|
-
#
|
20
|
+
# Trepan::Breakpoint.new(iseq, iseq.iseq_size, :temp => true)
|
21
21
|
# end
|
22
22
|
# assert_raises TypeError do
|
23
|
-
#
|
23
|
+
# Trepan::Breakpoint.new(0, 5)
|
24
24
|
# end
|
25
25
|
# require_relative '../../lib/trepanning.rb'
|
26
|
-
b2 =
|
27
|
-
:temp => true)
|
26
|
+
b2 = Trepan::Breakpoint.new('temp brkpt', method, 2, 3, 0, :temp => true)
|
28
27
|
assert_equal('t', b2.icon_char)
|
29
28
|
end
|
30
29
|
end
|
@@ -8,7 +8,7 @@ class TestLibAppBrkptMgr < Test::Unit::TestCase
|
|
8
8
|
|
9
9
|
def setup
|
10
10
|
@meth = Rubinius::CompiledMethod.of_sender
|
11
|
-
@brkpts = BreakpointMgr.new
|
11
|
+
@brkpts = Trepan::BreakpointMgr.new
|
12
12
|
@offset = 0
|
13
13
|
end
|
14
14
|
|
@@ -23,7 +23,7 @@ class TestLibAppBrkptMgr < Test::Unit::TestCase
|
|
23
23
|
assert_equal(0, @brkpts.size)
|
24
24
|
|
25
25
|
# Try adding via << rather than .add
|
26
|
-
b2 = @brkpts <<
|
26
|
+
b2 = @brkpts << Trepan::Breakpoint.new(@meth, 5, nil, :temp => true)
|
27
27
|
|
28
28
|
assert_equal(nil, @brkpts.find(@meth, 6))
|
29
29
|
@brkpts.reset
|
data/test/unit/test-app-iseq.rb
CHANGED
@@ -4,40 +4,55 @@ require 'rubygems'; require 'require_relative'
|
|
4
4
|
require_relative '../../app/iseq'
|
5
5
|
|
6
6
|
class TestAppISeq < Test::Unit::TestCase
|
7
|
-
include Trepanning::ISeq
|
8
7
|
|
9
8
|
def test_disasm_prefix
|
10
9
|
meth = Rubinius::VM.backtrace(0, true)[0].method
|
11
|
-
assert_equal(' -->', disasm_prefix(0, 0, meth))
|
12
|
-
assert_equal(' ', disasm_prefix(0, 1, meth))
|
10
|
+
assert_equal(' -->', Trepan::ISeq.disasm_prefix(0, 0, meth))
|
11
|
+
assert_equal(' ', Trepan::ISeq.disasm_prefix(0, 1, meth))
|
13
12
|
meth.set_breakpoint(0, nil)
|
14
|
-
assert_equal('B-->', disasm_prefix(0, 0, meth))
|
15
|
-
assert_equal('B ', disasm_prefix(0, 1, meth))
|
13
|
+
assert_equal('B-->', Trepan::ISeq.disasm_prefix(0, 0, meth))
|
14
|
+
assert_equal('B ', Trepan::ISeq.disasm_prefix(0, 1, meth))
|
16
15
|
end
|
17
16
|
|
18
17
|
def test_basic
|
19
18
|
|
20
19
|
def single_return
|
21
|
-
|
22
|
-
|
23
|
-
|
20
|
+
cm = Rubinius::VM.backtrace(0, true)[0].method
|
21
|
+
last = cm.lines.last
|
22
|
+
first = 0
|
23
|
+
0.upto((cm.lines.last+1)/2) do |i|
|
24
|
+
first = cm.lines[i*2]
|
25
|
+
break if -1 != first
|
26
|
+
end
|
27
|
+
[last, Trepan::ISeq.yield_or_return_between(cm, first, last)]
|
24
28
|
end
|
25
29
|
|
26
30
|
def branching(bool)
|
27
|
-
|
28
|
-
|
31
|
+
cm = Rubinius::VM.backtrace(0, true)[0].method
|
32
|
+
last = cm.lines.last
|
33
|
+
first = nil
|
34
|
+
0.upto((cm.lines.last+1)/2) do |i|
|
35
|
+
first = cm.lines[i*2]
|
36
|
+
break if -1 != first
|
37
|
+
end
|
38
|
+
|
29
39
|
if bool
|
30
40
|
x = 5
|
31
41
|
else
|
32
42
|
x = 6
|
33
43
|
end
|
34
|
-
goto_between(
|
44
|
+
Trepan::ISeq.goto_between(cm, first, last)
|
35
45
|
end
|
36
46
|
|
37
47
|
def no_branching
|
38
|
-
|
39
|
-
|
40
|
-
|
48
|
+
cm = Rubinius::VM.backtrace(0, true)[0].method
|
49
|
+
last = cm.lines.last
|
50
|
+
first = 0
|
51
|
+
0.upto((cm.lines.last+1)/2) do |i|
|
52
|
+
first = cm.lines[i*2]
|
53
|
+
break if -1 != first
|
54
|
+
end
|
55
|
+
Trepan::ISeq.goto_between(cm, first, last)
|
41
56
|
end
|
42
57
|
|
43
58
|
last, return_ips = single_return
|
@@ -8,15 +8,14 @@ require_relative '../../app/options'
|
|
8
8
|
# To have something to work with.
|
9
9
|
load 'tmpdir.rb'
|
10
10
|
|
11
|
-
class
|
12
|
-
include Trepanning
|
11
|
+
class TestAppOptions < Test::Unit::TestCase
|
13
12
|
|
14
13
|
def setup
|
15
|
-
@options = DEFAULT_CMDLINE_SETTINGS.clone
|
14
|
+
@options = Trepan::DEFAULT_CMDLINE_SETTINGS.clone
|
16
15
|
@stderr = StringIO.new
|
17
16
|
@stdout = StringIO.new
|
18
|
-
@options = copy_default_options
|
19
|
-
@opts
|
17
|
+
@options = Trepan::copy_default_options
|
18
|
+
@opts = Trepan::setup_options(@options, @stdout, @stderr)
|
20
19
|
end
|
21
20
|
|
22
21
|
def test_cd
|
@@ -58,4 +57,26 @@ class TestAppStringIO < Test::Unit::TestCase
|
|
58
57
|
end
|
59
58
|
end
|
60
59
|
|
60
|
+
def test_both_client_server_opts
|
61
|
+
# Try each of --client and --server options separately
|
62
|
+
%w(client server).each do |name|
|
63
|
+
setup
|
64
|
+
o = ["--#{name}"]
|
65
|
+
rest = @opts.parse o
|
66
|
+
assert_equal('', @stdout.string)
|
67
|
+
assert_equal('', @stderr.string)
|
68
|
+
assert_equal(true, @options[name.to_sym])
|
69
|
+
end
|
70
|
+
|
71
|
+
# Try both --client and --server together. Should give a warning
|
72
|
+
setup
|
73
|
+
o = %w(--client --server)
|
74
|
+
rest = @opts.parse o
|
75
|
+
assert_not_equal('', @stderr.string)
|
76
|
+
assert_equal('', @stdout.string)
|
77
|
+
assert_equal(true, @options[:client])
|
78
|
+
assert_equal(false, @options[:server])
|
79
|
+
|
80
|
+
end
|
81
|
+
|
61
82
|
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative './mock-helper'
|
4
|
+
require_relative '../../processor/command/source'
|
5
|
+
|
6
|
+
# Test command source
|
7
|
+
class TestCommandSource < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include MockUnitHelper
|
10
|
+
def setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
common_setup(@name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_source_opts
|
16
|
+
|
17
|
+
[['--quiet', :verbose, false],
|
18
|
+
['-q', :quiet, true],
|
19
|
+
['--no-quiet', :quiet, false],
|
20
|
+
['--continue', :abort_on_error, false],
|
21
|
+
['--no-continue', :abort_on_error, true],
|
22
|
+
['-c', :abort_on_error, false],
|
23
|
+
['-v', :verbose, true],
|
24
|
+
['--verbose', :verbose, true],
|
25
|
+
['--no-verbose', :verbose, false]
|
26
|
+
].each do |opt, key, expect|
|
27
|
+
options =
|
28
|
+
@cmd.parse_options(Trepan::Command::SourceCommand::DEFAULT_OPTIONS.dup,
|
29
|
+
opt)
|
30
|
+
assert_equal(expect, options[key],
|
31
|
+
"Option #{opt} using key #{key} failure")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -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,53 @@
|
|
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
|
+
client.writeline(mess)
|
40
|
+
assert_equal mess, client.read_msg.chomp
|
41
|
+
rescue EOFError
|
42
|
+
puts "Got EOF"
|
43
|
+
break
|
44
|
+
rescue Exception => e
|
45
|
+
puts "Got #{e}"
|
46
|
+
break
|
47
|
+
end
|
48
|
+
end
|
49
|
+
client.close
|
50
|
+
end
|
51
|
+
threads.each {|t| t.join }
|
52
|
+
end
|
53
|
+
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
|
data/test/unit/test-proc-main.rb
CHANGED
@@ -4,6 +4,10 @@ require_relative 'cmd-helper'
|
|
4
4
|
require_relative '../../processor/main'
|
5
5
|
## require_relative '../../app/core'
|
6
6
|
|
7
|
+
# Mock debugger stub. FIXME: put in comment helper routine.
|
8
|
+
class Trepan
|
9
|
+
end
|
10
|
+
|
7
11
|
# Test Trepan:CmdProcessor
|
8
12
|
class TestCmdProcessor < Test::Unit::TestCase
|
9
13
|
|
@@ -75,10 +79,10 @@ class TestCmdProcessor < Test::Unit::TestCase
|
|
75
79
|
assert_equal(expect_errmsgs, $errs,
|
76
80
|
"Mismatched error messages from #{caller[0]}")
|
77
81
|
end
|
78
|
-
def @cmdproc.msg(mess)
|
82
|
+
def @cmdproc.msg(mess, opts={})
|
79
83
|
$msgs << "#{mess}"
|
80
84
|
end
|
81
|
-
def @cmdproc.errmsg(mess)
|
85
|
+
def @cmdproc.errmsg(mess, opts={})
|
82
86
|
$errs << "#{mess}"
|
83
87
|
end
|
84
88
|
run_and_check('!s=1', ['D=> 1'], [], "! evaluation")
|