trepanning 0.0.9 → 0.1.0
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 +237 -0
- data/NEWS +8 -0
- data/Rakefile +3 -2
- data/app/breakpoint.rb +8 -8
- data/app/brkptmgr.rb +86 -85
- data/app/client.rb +60 -0
- data/app/core.rb-consider +198 -0
- data/app/default.rb +17 -7
- data/app/disassemble.rb +12 -2
- data/app/options.rb +51 -20
- data/app/yarv.rb +183 -0
- data/bin/trepan +15 -9
- data/data/custom_require.rb +44 -0
- data/data/irbrc +41 -0
- data/data/prelude.rb +38 -0
- data/interface/base_intf.rb +10 -4
- data/interface/client.rb +79 -0
- data/interface/comcodes.rb +18 -0
- data/interface/server.rb +142 -0
- data/io/base_io.rb +57 -3
- data/io/tcpclient.rb +122 -0
- data/io/tcpfns.rb +31 -0
- data/io/tcpserver.rb +137 -0
- data/lib/trepanning.rb +57 -28
- data/processor/command/base/cmd.rb +10 -6
- data/processor/command/base/subcmd.rb +13 -1
- data/processor/command/directory.rb +15 -8
- data/processor/command/disassemble.rb +3 -2
- data/processor/command/help.rb +71 -19
- data/processor/command/info_subcmd/args.rb +2 -3
- data/processor/command/info_subcmd/breakpoints.rb +2 -3
- data/processor/command/info_subcmd/file.rb +2 -3
- data/processor/command/info_subcmd/frame.rb +2 -3
- data/processor/command/info_subcmd/iseq.rb +4 -5
- data/processor/command/info_subcmd/locals.rb +2 -3
- data/processor/command/info_subcmd/program.rb +2 -3
- data/processor/command/info_subcmd/registers.rb +2 -3
- data/processor/command/info_subcmd/return.rb +2 -3
- data/processor/command/info_subcmd/thread.rb +2 -3
- data/processor/command/list.rb +10 -6
- data/processor/command/reload.rb +1 -1
- data/processor/command/reload_subcmd/command.rb +29 -16
- data/processor/command/server.rb +70 -0
- data/processor/command/set_subcmd/auto.rb +2 -3
- data/processor/command/set_subcmd/basename.rb +2 -3
- data/processor/command/set_subcmd/debug.rb +2 -3
- data/processor/command/set_subcmd/different.rb +2 -3
- data/processor/command/set_subcmd/events.rb +2 -3
- data/processor/command/set_subcmd/hidelevel.rb +6 -7
- data/processor/command/set_subcmd/highlight.rb +32 -0
- data/processor/command/set_subcmd/max.rb +2 -3
- data/processor/command/set_subcmd/return.rb +2 -3
- data/processor/command/set_subcmd/sp.rb +2 -3
- data/processor/command/set_subcmd/substitute.rb +2 -3
- data/processor/command/set_subcmd/timer.rb +2 -3
- data/processor/command/set_subcmd/trace.rb +3 -4
- data/processor/command/show_subcmd/alias.rb +3 -3
- 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 -1
- data/processor/command/show_subcmd/events.rb +2 -2
- data/processor/command/show_subcmd/hidelevel.rb +2 -3
- data/processor/command/show_subcmd/highlight.rb +23 -0
- data/processor/command/show_subcmd/macro.rb +2 -1
- data/processor/command/show_subcmd/max.rb +2 -3
- data/processor/command/show_subcmd/trace.rb +2 -3
- data/processor/command/source.rb +78 -28
- data/processor/default.rb +3 -2
- data/processor/load_cmds.rb +39 -19
- data/processor/location.rb +11 -7
- data/processor/main.rb +31 -15
- data/processor/mock.rb +22 -7
- data/processor/msg.rb +24 -8
- data/test/data/fname-with-blank.right +3 -0
- data/test/data/quit.right +2 -0
- data/test/functional/test-break-long.rb +87 -0
- data/test/functional/tmp/b3.rb +5 -0
- data/test/functional/tmp/immediate-bug1.rb +9 -0
- data/test/integration/helper.rb +14 -11
- data/test/integration/test-fname-with-blank.rb +5 -1
- data/test/integration/test-quit.rb +6 -2
- data/test/unit/cmd-helper.rb +9 -4
- data/test/unit/mock-helper.rb +9 -0
- data/test/unit/test-app-brkpt.rb +4 -4
- data/test/unit/test-app-brkptmgr.rb +2 -2
- data/test/unit/test-app-file.rb +0 -1
- data/test/unit/test-app-options.rb +26 -5
- data/test/unit/test-base-subcmd.rb +0 -1
- data/test/unit/test-cmd-alias.rb +0 -1
- data/test/unit/test-cmd-break.rb +0 -4
- data/test/unit/test-cmd-endisable.rb +1 -3
- data/test/unit/test-cmd-help.rb +0 -1
- data/test/unit/test-cmd-kill.rb +4 -5
- data/test/unit/test-cmd-quit.rb +4 -7
- data/test/unit/test-cmd-source.rb +33 -0
- data/test/unit/test-cmd-step.rb +0 -2
- data/test/unit/test-io-tcp.rb +32 -0
- data/test/unit/test-io-tcpclient.rb +53 -0
- data/test/unit/test-io-tcpserver.rb +49 -0
- data/test/unit/test-proc-main.rb +2 -2
- metadata +195 -175
- data/processor/command/stepi.rb +0 -63
- data/test/functional/tmp/b1.rb +0 -5
- data/test/functional/tmp/s1.rb +0 -9
- data/test/functional/tmp/t2.rb +0 -6
- data/test/integration/try-test-enable.rb +0 -11
data/test/integration/helper.rb
CHANGED
@@ -32,25 +32,28 @@ def run_debugger(testname, ruby_file, opts={})
|
|
32
32
|
|
33
33
|
FileUtils.rm(outfile) if File.exist?(outfile)
|
34
34
|
|
35
|
-
cmd =
|
36
|
-
|
37
|
-
|
35
|
+
cmd =
|
36
|
+
if opts[:standalone]
|
37
|
+
"%s %s %s >%s 2>&1" %
|
38
|
+
[Trepanning::ruby_path, programfile, opts[:args], outfile]
|
39
|
+
else
|
40
|
+
"%s %s --nx --command %s %s '%s' %s >%s 2>&1" %
|
41
|
+
[Trepanning::ruby_path, dbgr_path, cmdfile, opts[:dbgr],
|
42
|
+
programfile, opts[:args], outfile]
|
43
|
+
end
|
38
44
|
|
39
45
|
system(cmd)
|
40
46
|
return false unless 0 == $?.exitstatus
|
41
47
|
if opts[:do_diff]
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
to_file = outfile
|
46
|
-
# todate = time.ctime(os.stat(tofile).st_mtime)
|
47
|
-
to_lines = File.open(to_file).readlines()
|
48
|
+
expected_lines = File.open(rightfile).readlines()
|
49
|
+
got_lines = File.open(outfile).readlines()
|
50
|
+
opts[:filter].call(got_lines, expected_lines) if opts[:filter]
|
48
51
|
|
49
52
|
# Seems to be a bug in LCS in that it will return a diff even if two
|
50
53
|
# files are the same.
|
51
|
-
return true if
|
54
|
+
return true if expected_lines == got_lines
|
52
55
|
|
53
|
-
sdiffs = Diff::LCS.sdiff(
|
56
|
+
sdiffs = Diff::LCS.sdiff(expected_lines, got_lines)
|
54
57
|
|
55
58
|
if sdiffs.empty?
|
56
59
|
FileUtils.rm(outfile)
|
@@ -6,6 +6,10 @@ class TestFnameWithBlank < Test::Unit::TestCase
|
|
6
6
|
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
7
7
|
|
8
8
|
def test_it
|
9
|
-
|
9
|
+
opts = {}
|
10
|
+
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
11
|
+
got_lines[0] = "-> (fname with blank.rb:1 @0)\n"
|
12
|
+
}
|
13
|
+
assert_equal(true, run_debugger(@@NAME, 'fname with blank.rb', opts))
|
10
14
|
end
|
11
15
|
end
|
@@ -5,7 +5,11 @@ require_relative 'helper'
|
|
5
5
|
class TestQuit < Test::Unit::TestCase
|
6
6
|
@@NAME = File.basename(__FILE__, '.rb')[5..-1]
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def test_trepan_call
|
9
|
+
opts = {}
|
10
|
+
opts[:filter] = Proc.new{|got_lines, correct_lines|
|
11
|
+
got_lines[0] = "-> (null.rb:1 @0)\n"
|
12
|
+
}
|
13
|
+
assert_equal(true, run_debugger(@@NAME, 'null.rb', opts))
|
10
14
|
end
|
11
15
|
end
|
data/test/unit/cmd-helper.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'test/unit'
|
2
|
+
require 'thread_frame'
|
1
3
|
require_relative '../../app/core'
|
2
4
|
require_relative '../../app/mock'
|
3
5
|
require_relative '../../processor/main' # Have to include before frame!
|
@@ -13,17 +15,20 @@ module UnitHelper
|
|
13
15
|
@cmdproc = @core.processor = Trepan::CmdProcessor.new(@core)
|
14
16
|
@cmds = @cmdproc.commands
|
15
17
|
|
16
|
-
def @cmdproc.msg(message)
|
18
|
+
def @cmdproc.msg(message, opts={})
|
17
19
|
@msgs << message
|
18
20
|
end
|
19
|
-
def @cmdproc.
|
21
|
+
def @cmdproc.msgs
|
22
|
+
@msgs
|
23
|
+
end
|
24
|
+
def @cmdproc.errmsg(message, opts={})
|
20
25
|
@errmsgs << message
|
21
26
|
end
|
22
27
|
def @cmdproc.errmsgs
|
23
28
|
@errmsgs
|
24
29
|
end
|
25
|
-
def @cmdproc.
|
26
|
-
@msgs
|
30
|
+
def @cmdproc.section(message, opts={})
|
31
|
+
@msgs << message
|
27
32
|
end
|
28
33
|
reset_cmdproc_vars
|
29
34
|
end
|
data/test/unit/test-app-brkpt.rb
CHANGED
@@ -8,7 +8,7 @@ class TestAppBrkpt < Test::Unit::TestCase
|
|
8
8
|
def test_basic
|
9
9
|
tf = RubyVM::ThreadFrame.current
|
10
10
|
iseq = tf.iseq
|
11
|
-
b1 =
|
11
|
+
b1 = Trepan::Breakpoint.new(iseq, 0)
|
12
12
|
assert_equal(false, b1.temp?)
|
13
13
|
assert_equal(0, b1.hits)
|
14
14
|
assert_equal('B', b1.icon_char)
|
@@ -18,13 +18,13 @@ class TestAppBrkpt < Test::Unit::TestCase
|
|
18
18
|
b1.enabled = false
|
19
19
|
assert_equal('b', b1.icon_char)
|
20
20
|
assert_raises TypeError do
|
21
|
-
|
21
|
+
Trepan::Breakpoint.new(iseq, iseq.iseq_size, :temp => true)
|
22
22
|
end
|
23
23
|
assert_raises TypeError do
|
24
|
-
|
24
|
+
Trepan::Breakpoint.new(0, 5)
|
25
25
|
end
|
26
26
|
require_relative '../../lib/trepanning.rb'
|
27
|
-
b2 =
|
27
|
+
b2 = Trepan::Breakpoint.new(iseq, 0, :temp => true)
|
28
28
|
assert_equal('t', b2.icon_char)
|
29
29
|
end
|
30
30
|
end
|
@@ -7,7 +7,7 @@ require 'thread_frame'
|
|
7
7
|
class TestLibAppBrkptMgr < Test::Unit::TestCase
|
8
8
|
|
9
9
|
def setup
|
10
|
-
@brkpts = BreakpointMgr.new
|
10
|
+
@brkpts = Trepan::BreakpointMgr.new
|
11
11
|
end
|
12
12
|
|
13
13
|
def test_basic
|
@@ -24,7 +24,7 @@ class TestLibAppBrkptMgr < Test::Unit::TestCase
|
|
24
24
|
assert_equal(0, @brkpts.size)
|
25
25
|
|
26
26
|
# Try adding via << rather than .add
|
27
|
-
b2 = @brkpts <<
|
27
|
+
b2 = @brkpts << Trepan::Breakpoint.new(iseq, offsets[1], :temp => true)
|
28
28
|
|
29
29
|
assert_equal(nil, @brkpts.find(iseq, offset, tf.binding))
|
30
30
|
@brkpts.reset
|
data/test/unit/test-app-file.rb
CHANGED
@@ -7,15 +7,14 @@ require_relative '../../app/options'
|
|
7
7
|
# To have something to work with.
|
8
8
|
load 'tmpdir.rb'
|
9
9
|
|
10
|
-
class
|
11
|
-
include Trepanning
|
10
|
+
class TestAppOptions < Test::Unit::TestCase
|
12
11
|
|
13
12
|
def setup
|
14
|
-
@options = DEFAULT_CMDLINE_SETTINGS.clone
|
13
|
+
@options = Trepan::DEFAULT_CMDLINE_SETTINGS.clone
|
15
14
|
@stderr = StringIO.new
|
16
15
|
@stdout = StringIO.new
|
17
|
-
@options = copy_default_options
|
18
|
-
@opts
|
16
|
+
@options = Trepan::copy_default_options
|
17
|
+
@opts = Trepan::setup_options(@options, @stdout, @stderr)
|
19
18
|
end
|
20
19
|
|
21
20
|
def test_cd
|
@@ -57,4 +56,26 @@ class TestAppStringIO < Test::Unit::TestCase
|
|
57
56
|
end
|
58
57
|
end
|
59
58
|
|
59
|
+
def test_both_client_server_opts
|
60
|
+
# Try each of --client and --server options separately
|
61
|
+
%w(client server).each do |name|
|
62
|
+
setup
|
63
|
+
o = ["--#{name}"]
|
64
|
+
rest = @opts.parse o
|
65
|
+
assert_equal('', @stdout.string)
|
66
|
+
assert_equal('', @stderr.string)
|
67
|
+
assert_equal(true, @options[name.to_sym])
|
68
|
+
end
|
69
|
+
|
70
|
+
# Try both --client and --server together. Should give a warning
|
71
|
+
setup
|
72
|
+
o = %w(--client --server)
|
73
|
+
rest = @opts.parse o
|
74
|
+
assert_not_equal('', @stderr.string)
|
75
|
+
assert_equal('', @stdout.string)
|
76
|
+
assert_equal(true, @options[:client])
|
77
|
+
assert_equal(false, @options[:server])
|
78
|
+
|
79
|
+
end
|
80
|
+
|
60
81
|
end
|
data/test/unit/test-cmd-alias.rb
CHANGED
data/test/unit/test-cmd-break.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'test/unit'
|
3
2
|
require_relative 'cmd-helper'
|
4
3
|
require_relative '../../app/breakpoint'
|
5
4
|
|
@@ -7,7 +6,7 @@ class TestCommandEnableDisable < Test::Unit::TestCase
|
|
7
6
|
|
8
7
|
include UnitHelper
|
9
8
|
def setup
|
10
|
-
|
9
|
+
Trepan::Breakpoint::reset
|
11
10
|
common_setup
|
12
11
|
@break_cmd = @cmds['break']
|
13
12
|
@disable_cmd = @cmds['disable']
|
@@ -35,7 +34,6 @@ class TestCommandEnableDisable < Test::Unit::TestCase
|
|
35
34
|
reset_cmdproc_vars
|
36
35
|
end
|
37
36
|
|
38
|
-
require 'thread_frame'
|
39
37
|
tf = RubyVM::ThreadFrame.current
|
40
38
|
@cmdproc.frame_setup(tf)
|
41
39
|
pc_offset = tf.pc_offset
|
data/test/unit/test-cmd-help.rb
CHANGED
data/test/unit/test-cmd-kill.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../../processor/mock'
|
2
|
+
require_relative './mock-helper'
|
4
3
|
require_relative '../../processor/command/kill'
|
5
4
|
|
6
5
|
class TestCommandKill < Test::Unit::TestCase
|
7
|
-
|
6
|
+
include MockUnitHelper
|
8
7
|
def setup
|
9
|
-
@name
|
10
|
-
|
8
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
9
|
+
common_setup(@name)
|
11
10
|
def @cmd.msg(message)
|
12
11
|
@msgs << message
|
13
12
|
end
|
data/test/unit/test-cmd-quit.rb
CHANGED
@@ -1,13 +1,12 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
|
3
|
-
require_relative '../../processor/mock'
|
2
|
+
require_relative './mock-helper'
|
4
3
|
require_relative '../../processor/command/quit'
|
5
4
|
|
6
5
|
class TestCommandQuit < Test::Unit::TestCase
|
7
|
-
|
6
|
+
include MockUnitHelper
|
8
7
|
def setup
|
9
|
-
@name
|
10
|
-
|
8
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
9
|
+
common_setup(@name)
|
11
10
|
end
|
12
11
|
|
13
12
|
def test_basic
|
@@ -21,6 +20,4 @@ class TestCommandQuit < Test::Unit::TestCase
|
|
21
20
|
# should test 'confirm' gets run; and should test that
|
22
21
|
# 'unconditional' is handled correctly.
|
23
22
|
end
|
24
|
-
|
25
|
-
|
26
23
|
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require_relative './mock-helper'
|
3
|
+
require_relative '../../processor/command/source'
|
4
|
+
|
5
|
+
# Test command source
|
6
|
+
class TestCommandSource < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include MockUnitHelper
|
9
|
+
def setup
|
10
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
11
|
+
common_setup(@name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_source_opts
|
15
|
+
|
16
|
+
[['--quiet', :verbose, false],
|
17
|
+
['-q', :quiet, true],
|
18
|
+
['--no-quiet', :quiet, false],
|
19
|
+
['--continue', :abort_on_error, false],
|
20
|
+
['--no-continue', :abort_on_error, true],
|
21
|
+
['-c', :abort_on_error, false],
|
22
|
+
['-v', :verbose, true],
|
23
|
+
['--verbose', :verbose, true],
|
24
|
+
['--no-verbose', :verbose, false]
|
25
|
+
].each do |opt, key, expect|
|
26
|
+
options =
|
27
|
+
@cmd.parse_options(Trepan::Command::SourceCommand::DEFAULT_OPTIONS.dup,
|
28
|
+
opt)
|
29
|
+
assert_equal(expect, options[key],
|
30
|
+
"Option #{opt} using key #{key} failure")
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
data/test/unit/test-cmd-step.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#!/usr/bin/env ruby
|
2
|
-
require 'test/unit'
|
3
2
|
require_relative 'cmd-helper'
|
4
3
|
require_relative '../../processor/command/step'
|
5
4
|
|
@@ -41,5 +40,4 @@ class TestCommandStep < Test::Unit::TestCase
|
|
41
40
|
@my_cmd.run([@name, '1+foo'])
|
42
41
|
assert_equal(false, @cmdproc.leave_cmd_loop)
|
43
42
|
end
|
44
|
-
|
45
43
|
end
|
@@ -0,0 +1,32 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
# Unit test for io/tcpclient.rb and io/tcpserver.rb together
|
5
|
+
require_relative '../../io/tcpfns'
|
6
|
+
require_relative '../../io/tcpclient'
|
7
|
+
require_relative '../../io/tcpserver'
|
8
|
+
|
9
|
+
# Tests TCPServer together with and TCPClient
|
10
|
+
class TestTCPClientServer < Test::Unit::TestCase
|
11
|
+
|
12
|
+
def test_client_server
|
13
|
+
server = Trepan::TCPDbgServer.new({ :open => true,
|
14
|
+
:port => 1028,
|
15
|
+
:host => 'localhost'
|
16
|
+
})
|
17
|
+
client = Trepan::TCPDbgClient.new({ :open => true,
|
18
|
+
:port => 1028,
|
19
|
+
:host => 'localhost'
|
20
|
+
})
|
21
|
+
%w(one, two, three).each do |line|
|
22
|
+
server.writeline(line)
|
23
|
+
assert_equal line, client.read_msg.chomp
|
24
|
+
end
|
25
|
+
%w(four, five, six).each do |line|
|
26
|
+
client.writeline(line)
|
27
|
+
assert_equal line, server.read_msg.chomp
|
28
|
+
end
|
29
|
+
client.close
|
30
|
+
server.close
|
31
|
+
end
|
32
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
|
4
|
+
# Unit test for io/tcpclient.rb
|
5
|
+
require_relative '../../io/tcpfns'
|
6
|
+
require_relative '../../io/tcpclient'
|
7
|
+
|
8
|
+
class TestTCPDbgClient < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include Trepanning::TCPPacking
|
11
|
+
|
12
|
+
def test_basic
|
13
|
+
client = Trepan::TCPDbgClient.new({ :open => false,
|
14
|
+
:port => 1027,
|
15
|
+
:host => 'localhost'
|
16
|
+
})
|
17
|
+
threads = []
|
18
|
+
Thread.new do
|
19
|
+
server = TCPServer.new('localhost', 1027)
|
20
|
+
session = server.accept
|
21
|
+
while 'quit' != (line = session.gets)
|
22
|
+
session.puts line
|
23
|
+
end
|
24
|
+
session.close
|
25
|
+
end
|
26
|
+
threads << Thread.new do
|
27
|
+
# require 'trepanning'; debugger
|
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
|