rbx-trepanning 0.2.0-universal-rubinius-2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +7 -0
- data/ChangeLog +2967 -0
- data/LICENSE +25 -0
- data/Makefile +13 -0
- data/NEWS +105 -0
- data/README.textile +34 -0
- data/Rakefile +244 -0
- data/THANKS +14 -0
- data/app/.gitignore +2 -0
- data/app/breakpoint.rb +242 -0
- data/app/brkptmgr.rb +153 -0
- data/app/client.rb +71 -0
- data/app/cmd_parse.kpeg +242 -0
- data/app/cmd_parse.rb +209 -0
- data/app/cmd_parser.rb +2083 -0
- data/app/complete.rb +79 -0
- data/app/condition.rb +22 -0
- data/app/default.rb +71 -0
- data/app/display.rb +186 -0
- data/app/eventbuffer.rb +147 -0
- data/app/file.rb +24 -0
- data/app/frame.rb +120 -0
- data/app/irb.rb +113 -0
- data/app/iseq.rb +188 -0
- data/app/method.rb +178 -0
- data/app/mock.rb +13 -0
- data/app/options.rb +154 -0
- data/app/rbx-llvm.rb +163 -0
- data/app/run.rb +92 -0
- data/app/util.rb +99 -0
- data/app/validate.rb +30 -0
- data/bin/.gitignore +2 -0
- data/bin/trepanx +69 -0
- data/data/.gitignore +2 -0
- data/data/irbrc +41 -0
- data/interface/.gitignore +2 -0
- data/interface/client.rb +84 -0
- data/interface/comcodes.rb +20 -0
- data/interface/script.rb +112 -0
- data/interface/server.rb +147 -0
- data/interface/user.rb +158 -0
- data/interface.rb +109 -0
- data/io/.gitignore +3 -0
- data/io/input.rb +151 -0
- data/io/null_output.rb +46 -0
- data/io/string_array.rb +155 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpserver.rb +141 -0
- data/io.rb +148 -0
- data/lib/.gitignore +2 -0
- data/lib/trepanning.rb +467 -0
- data/processor/.gitignore +3 -0
- data/processor/Makefile +7 -0
- data/processor/breakpoint.rb +167 -0
- data/processor/command/.gitignore +2 -0
- data/processor/command/alias.rb +65 -0
- data/processor/command/backtrace.rb +68 -0
- data/processor/command/base/.gitignore +2 -0
- data/processor/command/base/subcmd.rb +226 -0
- data/processor/command/base/submgr.rb +185 -0
- data/processor/command/base/subsubcmd.rb +125 -0
- data/processor/command/base/subsubmgr.rb +196 -0
- data/processor/command/break.rb +78 -0
- data/processor/command/complete.rb +39 -0
- data/processor/command/condition.rb +64 -0
- data/processor/command/continue.rb +61 -0
- data/processor/command/delete.rb +44 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disable.rb +71 -0
- data/processor/command/disassemble.rb +180 -0
- data/processor/command/display.rb +84 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/edit.rb +74 -0
- data/processor/command/enable.rb +43 -0
- data/processor/command/eval.rb +93 -0
- data/processor/command/exit.rb +83 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +93 -0
- data/processor/command/help/.gitignore +1 -0
- data/processor/command/help/README +10 -0
- data/processor/command/help/command.txt +58 -0
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/help.rb +228 -0
- data/processor/command/info.rb +30 -0
- data/processor/command/info_subcmd/.gitignore +3 -0
- data/processor/command/info_subcmd/breakpoints.rb +103 -0
- data/processor/command/info_subcmd/files.rb +219 -0
- data/processor/command/info_subcmd/frame.rb +68 -0
- data/processor/command/info_subcmd/line.rb +75 -0
- data/processor/command/info_subcmd/locals.rb +22 -0
- data/processor/command/info_subcmd/macro.rb +62 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +51 -0
- data/processor/command/info_subcmd/ruby.rb +64 -0
- data/processor/command/info_subcmd/source.rb +75 -0
- data/processor/command/info_subcmd/stack.rb +25 -0
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +2 -0
- data/processor/command/info_subcmd/variables_subcmd/class.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/constant.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/globals.rb +69 -0
- data/processor/command/info_subcmd/variables_subcmd/instance.rb +42 -0
- data/processor/command/info_subcmd/variables_subcmd/locals.rb +80 -0
- data/processor/command/kill.rb +79 -0
- data/processor/command/list.rb +234 -0
- data/processor/command/macro.rb +86 -0
- data/processor/command/next.rb +67 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/parsetree.rb +51 -0
- data/processor/command/pr.rb +37 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/save.rb +58 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/abbrev.rb +25 -0
- data/processor/command/set_subcmd/auto.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +53 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +33 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +26 -0
- data/processor/command/set_subcmd/debug_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +61 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +39 -0
- data/processor/command/set_subcmd/kernelstep.rb +60 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/reload.rb +42 -0
- data/processor/command/set_subcmd/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/.gitignore +3 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/timer.rb +58 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +42 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +41 -0
- data/processor/command/shell.rb +131 -0
- data/processor/command/show.rb +39 -0
- data/processor/command/show_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/abbrev.rb +20 -0
- data/processor/command/show_subcmd/aliases.rb +46 -0
- data/processor/command/show_subcmd/args.rb +25 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +24 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +20 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/.gitignore +3 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +26 -0
- data/processor/command/show_subcmd/directories.rb +22 -0
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +25 -0
- data/processor/command/show_subcmd/kernelstep.rb +34 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/reload.rb +18 -0
- data/processor/command/show_subcmd/timer.rb +18 -0
- data/processor/command/show_subcmd/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/.gitignore +2 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +64 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +23 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +133 -0
- data/processor/command/step.rb +97 -0
- data/processor/command/tbreak.rb +20 -0
- data/processor/command/unalias.rb +49 -0
- data/processor/command/undisplay.rb +63 -0
- data/processor/command/up.rb +89 -0
- data/processor/command.rb +173 -0
- data/processor/default.rb +64 -0
- data/processor/disassemble.rb +59 -0
- data/processor/display.rb +53 -0
- data/processor/eval.rb +97 -0
- data/processor/eventbuf.rb +101 -0
- data/processor/frame.rb +265 -0
- data/processor/help.rb +94 -0
- data/processor/hook.rb +134 -0
- data/processor/list.rb +123 -0
- data/processor/load_cmds.rb +253 -0
- data/processor/location.rb +228 -0
- data/processor/mock.rb +138 -0
- data/processor/msg.rb +74 -0
- data/processor/running.rb +244 -0
- data/processor/stepping.rb +135 -0
- data/processor/subcmd.rb +136 -0
- data/processor/validate.rb +379 -0
- data/processor/virtual.rb +33 -0
- data/processor.rb +404 -0
- data/rbx-trepanning.gemspec +39 -0
- data/sample/.gitignore +2 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +46 -0
- data/test/data/.gitignore +1 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +6 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +14 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +3 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/example/.gitignore +2 -0
- data/test/example/debugger-stop.rb +16 -0
- data/test/example/factorial.rb +10 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-server.rb +22 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/goto2goto.rb +11 -0
- data/test/example/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/.gitignore +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +85 -0
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +56 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-recursive-bt.rb +94 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/.gitignore +3 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +81 -0
- data/test/integration/test-fname-with-blank.rb +16 -0
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +47 -0
- data/test/unit/.gitignore +3 -0
- data/test/unit/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +31 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +23 -0
- data/test/unit/test-app-complete.rb +39 -0
- data/test/unit/test-app-condition.rb +18 -0
- data/test/unit/test-app-display.rb +22 -0
- data/test/unit/test-app-iseq.rb +64 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +94 -0
- data/test/unit/test-app-run.rb +14 -0
- data/test/unit/test-app-util.rb +44 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +45 -0
- data/test/unit/test-base-subcmd.rb +57 -0
- data/test/unit/test-base-submgr.rb +24 -0
- data/test/unit/test-base-subsubcmd.rb +17 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-break.rb +66 -0
- data/test/unit/test-cmd-edit.rb +34 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +31 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +54 -0
- data/test/unit/test-cmd-parse_list_cmd.rb +36 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-command.rb +45 -0
- data/test/unit/test-completion.rb +48 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +35 -0
- data/test/unit/test-proc-frame.rb +81 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-list.rb +55 -0
- data/test/unit/test-proc-load_cmds.rb +51 -0
- data/test/unit/test-proc-location.rb +67 -0
- data/test/unit/test-proc-main.rb +95 -0
- data/test/unit/test-proc-validate.rb +139 -0
- data/test/unit/test-subcmd-help.rb +43 -0
- metadata +545 -0
@@ -0,0 +1,14 @@
|
|
1
|
+
-- (inline-call.rb:11 @12)
|
2
|
+
if a > b
|
3
|
+
basename is off.
|
4
|
+
3 require_relative '../../lib/trepanning.rb'
|
5
|
+
4 DATA_DIR = File.join(File.dirname(RequireRelative::abs_file), %w(.. data))
|
6
|
+
5 cmdfile = File.join(DATA_DIR, 'inline-call.cmd')
|
7
|
+
6 $dbgr = Trepan.new(:nx => true, :cmdfiles => [cmdfile])
|
8
|
+
7 # GCD. We assume positive numbers
|
9
|
+
8 def gcd(a, b)
|
10
|
+
9 $dbgr.debugger
|
11
|
+
10 # Make: a <= b
|
12
|
+
11 -> if a > b
|
13
|
+
12 a, b = [b, a]
|
14
|
+
trepanx: That's all, folks...
|
data/test/data/quit.cmd
ADDED
data/test/data/quit2.cmd
ADDED
@@ -0,0 +1,16 @@
|
|
1
|
+
# !/usr/bin/env ruby
|
2
|
+
# Bug in debugger in 1.9.2 only in that where
|
3
|
+
# stopping where we were inside debugger was stopping
|
4
|
+
# inside itself because multiple debugger names in the presence of modules
|
5
|
+
#
|
6
|
+
require 'rubygems'; require 'require_relative'
|
7
|
+
require_relative '../../lib/trepanning'
|
8
|
+
module Foo
|
9
|
+
module_function
|
10
|
+
def five
|
11
|
+
debugger # Resolves to Module#debugger not Kernel#debugger
|
12
|
+
5
|
13
|
+
end
|
14
|
+
end
|
15
|
+
debugger(:immediate=>true)
|
16
|
+
Foo::five
|
@@ -0,0 +1 @@
|
|
1
|
+
puts "Ha!"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# GCD. We assume positive numbers
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../lib/trepanning.rb'
|
5
|
+
$dbgr = Trepan.new(:server => true)
|
6
|
+
def gcd(a, b)
|
7
|
+
$dbgr.debugger
|
8
|
+
# Make: a <= b
|
9
|
+
if a > b
|
10
|
+
a, b = [b, a]
|
11
|
+
end
|
12
|
+
|
13
|
+
return nil if a <= 0
|
14
|
+
|
15
|
+
if a == 1 or b-a == 0
|
16
|
+
return a
|
17
|
+
end
|
18
|
+
return gcd(b-a, a)
|
19
|
+
end
|
20
|
+
|
21
|
+
a, b = ARGV[0..1].map {|arg| arg.to_i}
|
22
|
+
puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
|
data/test/example/gcd.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# GCD. We assume positive numbers
|
4
|
+
def gcd(a, b)
|
5
|
+
# Make: a <= b
|
6
|
+
if a > b
|
7
|
+
a, b = [b, a]
|
8
|
+
end
|
9
|
+
|
10
|
+
return nil if a <= 0
|
11
|
+
|
12
|
+
if a == 1 or b-a == 0
|
13
|
+
return a
|
14
|
+
end
|
15
|
+
return gcd(b-a, a)
|
16
|
+
end
|
17
|
+
|
18
|
+
a, b = ARGV[0..1].map {|arg| arg.to_i}
|
19
|
+
puts "The GCD of %d and %d is %d" % [a, b, gcd(a, b)]
|
@@ -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)]
|
@@ -0,0 +1 @@
|
|
1
|
+
# Nothing here. Move along.
|
@@ -0,0 +1,112 @@
|
|
1
|
+
## require 'thread_frame'
|
2
|
+
## require 'trace'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../lib/trepanning'
|
5
|
+
require_relative '../../io/string_array'
|
6
|
+
|
7
|
+
module FnTestHelper
|
8
|
+
## include Trace
|
9
|
+
|
10
|
+
## # Synchronous events without C frames or instructions
|
11
|
+
# Common setup to create a debugger with String Array I/O attached
|
12
|
+
def strarray_setup(debugger_cmds, insn_stepping=false)
|
13
|
+
stringin = Trepan::StringArrayInput.open(debugger_cmds)
|
14
|
+
stringout = Trepan::StringArrayOutput.open
|
15
|
+
d_opts = {:input => stringin, :output => stringout,
|
16
|
+
:nx => true}
|
17
|
+
d = Trepan.new(d_opts)
|
18
|
+
|
19
|
+
d.settings[:basename] = d.processor.settings[:basename] = true
|
20
|
+
d.settings[:different] = false
|
21
|
+
d.settings[:autoeval] = false
|
22
|
+
return d
|
23
|
+
end
|
24
|
+
|
25
|
+
unless defined?(TREPAN_PROMPT)
|
26
|
+
TREPAN_PROMPT = /^\(trepanx\): /
|
27
|
+
TREPAN_LOC = /.. \(.+:\d+( @\d+)?\)/
|
28
|
+
end
|
29
|
+
|
30
|
+
# Return the caller's line number
|
31
|
+
def get_lineno
|
32
|
+
Rubinius::VM.backtrace(0)[1].line
|
33
|
+
end
|
34
|
+
|
35
|
+
def compare_output(right, d, debugger_cmds)
|
36
|
+
# require_relative '../../lib/trepanning'
|
37
|
+
# Trepan.debug(:set_restart => true)
|
38
|
+
got = filter_line_cmd(d.intf[-1].output.output)
|
39
|
+
if got != right
|
40
|
+
got.each_with_index do |got_line, i|
|
41
|
+
if i < right.size and got_line != right[i]
|
42
|
+
# dbgr.debugger
|
43
|
+
puts "! #{got_line}"
|
44
|
+
else
|
45
|
+
puts " #{got_line}"
|
46
|
+
end
|
47
|
+
end
|
48
|
+
puts '-' * 10
|
49
|
+
right.each_with_index do |right_line, i|
|
50
|
+
if i < got.size and got[i] != right_line
|
51
|
+
# dbgr.debugger
|
52
|
+
puts "! #{right_line}"
|
53
|
+
else
|
54
|
+
puts " #{right_line}"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
assert_equal(right, got, caller[0])
|
59
|
+
end
|
60
|
+
|
61
|
+
# Return output with source lines prompt and command removed
|
62
|
+
def filter_line_cmd(a, show_prompt=false)
|
63
|
+
# Remove debugger prompt
|
64
|
+
a = a.map do |s|
|
65
|
+
s =~ TREPAN_PROMPT ? nil : s
|
66
|
+
end.compact unless show_prompt
|
67
|
+
|
68
|
+
# Remove debugger location lines.
|
69
|
+
# For example:
|
70
|
+
# -- (/src/external-vcs/trepan/tmp/gcd.rb:4 @21)
|
71
|
+
# becomes:
|
72
|
+
# --
|
73
|
+
a2 = a.map do |s|
|
74
|
+
s =~ TREPAN_LOC ? s.gsub(/\(.+:\d+( @\d+)?\)\n/, '').chomp : s.chomp
|
75
|
+
end
|
76
|
+
|
77
|
+
# Canonicalize breakpoint messages.
|
78
|
+
# For example:
|
79
|
+
# Set breakpoint 1: test/functional/test-tbreak.rb:10 (@0)
|
80
|
+
# becomes :
|
81
|
+
# Set breakpoint 1: foo.rb:55 (@3)
|
82
|
+
a3 = a2.map do |s|
|
83
|
+
s.gsub(/^Set (temporary )?breakpoint (\d+): .+:(\d+) \(@\d+\)/,
|
84
|
+
'Set \1breakpoint \2: foo.rb:55 (@3)')
|
85
|
+
end
|
86
|
+
return a3
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
# Demo it
|
92
|
+
if __FILE__ == $0
|
93
|
+
include FnTestHelper
|
94
|
+
strarray_setup(%w(eh bee see))
|
95
|
+
puts get_lineno()
|
96
|
+
p '-- (/src/external-vcs/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC
|
97
|
+
p '(trepan): exit' =~ TREPAN_PROMPT
|
98
|
+
output='
|
99
|
+
-- (/src/external-vcs/trepan/tmp/gcd.rb:4)
|
100
|
+
(trepan): s
|
101
|
+
-- (/src/external-vcs/trepan/tmp/gcd.rb:18)
|
102
|
+
(trepan): s
|
103
|
+
-- (/src/external-vcs/trepan/tmp/gcd.rb:19)
|
104
|
+
(trepan): s
|
105
|
+
.. (/src/external-vcs/trepan/tmp/gcd.rb:0)
|
106
|
+
(trepan): s
|
107
|
+
-> (/src/external-vcs/trepan/tmp/gcd.rb:4)
|
108
|
+
'.split(/\n/)
|
109
|
+
puts filter_line_cmd(output)
|
110
|
+
puts '-' * 10
|
111
|
+
puts filter_line_cmd(output, true)
|
112
|
+
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
def five
|
7
|
+
5
|
8
|
+
end
|
9
|
+
|
10
|
+
class TestNameBreak < Test::Unit::TestCase
|
11
|
+
|
12
|
+
include FnTestHelper
|
13
|
+
|
14
|
+
def self.six=(val)
|
15
|
+
@six = val
|
16
|
+
end
|
17
|
+
|
18
|
+
def five?(num) 5 == num; end
|
19
|
+
|
20
|
+
def test_basic
|
21
|
+
# Check that we can set breakpoints in parent, sibling and children
|
22
|
+
# of sibling returns. We have one more 'continue' than we need
|
23
|
+
# just in case something goes wrong.
|
24
|
+
cmds = ['break Object.five', 'break TestNameBreak.five?',
|
25
|
+
'break TestNameBreak.six=',
|
26
|
+
'continue', 'continue', 'continue', 'continue']
|
27
|
+
|
28
|
+
d = strarray_setup(cmds)
|
29
|
+
##############################
|
30
|
+
d.start
|
31
|
+
five
|
32
|
+
five?(5)
|
33
|
+
TestNameBreak::six=6
|
34
|
+
##############################
|
35
|
+
d.stop # ({:remove => true})
|
36
|
+
out = ["-- ",
|
37
|
+
"five ",
|
38
|
+
"Set breakpoint 1: foo.rb:55 (@3)",
|
39
|
+
"Set breakpoint 2: foo.rb:55 (@3)",
|
40
|
+
"Set breakpoint 3: foo.rb:55 (@3)",
|
41
|
+
"xx ",
|
42
|
+
"5",
|
43
|
+
"xx ",
|
44
|
+
"def five?(num) 5 == num; end",
|
45
|
+
"xx ",
|
46
|
+
"@six = val"]
|
47
|
+
compare_output(out, d, cmds)
|
48
|
+
end
|
49
|
+
|
50
|
+
end
|
51
|
+
|
52
|
+
|
@@ -0,0 +1,85 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestBreak < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
# Looks like we can no longer get lines inside of foo or inner blocks
|
11
|
+
def FIXME_test_line_only_break
|
12
|
+
# Check that we can set breakpoints in parent, sibling and children
|
13
|
+
# of sibling returns. We have one more 'continue' than we need
|
14
|
+
# just in case something goes wrong.
|
15
|
+
cmds_pat = ((['break %d'] * 4) + (%w(continue) * 4)).join("\n")
|
16
|
+
line = __LINE__
|
17
|
+
cmds = (cmds_pat % [line, line+6, line+11, line+14]).split(/\n/)
|
18
|
+
d = strarray_setup(cmds)
|
19
|
+
##############################
|
20
|
+
def foo # line + 4
|
21
|
+
a = 5 # line + 5
|
22
|
+
b = 6 # line + 6
|
23
|
+
end # line + 7
|
24
|
+
1.times do # line + 8
|
25
|
+
d.start # line + 9
|
26
|
+
1.times do # line + 10
|
27
|
+
x = 11 # line + 11
|
28
|
+
foo # line + 12
|
29
|
+
end # line + 13
|
30
|
+
c = 14 # line + 14
|
31
|
+
end
|
32
|
+
##############################
|
33
|
+
d.stop # ({:remove => true})
|
34
|
+
puts d.intf[-1].output.output
|
35
|
+
assert(true)
|
36
|
+
return
|
37
|
+
out = ["-- ",
|
38
|
+
'1.times do # line + 10',
|
39
|
+
'Set breakpoint 1: foo.rb:55 (@3)',
|
40
|
+
'Set breakpoint 2: foo.rb:55 (@3)',
|
41
|
+
'Set breakpoint 3: foo.rb:55 (@3)',
|
42
|
+
'Set breakpoint 4: foo.rb:55 (@3)',
|
43
|
+
'xx ',
|
44
|
+
'x = 11 # line + 11',
|
45
|
+
'xx ',
|
46
|
+
'b = 6 # line + 6',
|
47
|
+
'xx ',
|
48
|
+
'c = 14 # line + 14'
|
49
|
+
]
|
50
|
+
compare_output(out, d, cmds)
|
51
|
+
end
|
52
|
+
|
53
|
+
def test_line_only_break_reduced
|
54
|
+
# Check that we can set breakpoints in parent, sibling and children
|
55
|
+
# of sibling returns. We have one more 'continue' than we need
|
56
|
+
# just in case something goes wrong.
|
57
|
+
cmds_pat = ((['break %d'] * 1) + (%w(continue) * 3)).join("\n")
|
58
|
+
line = __LINE__
|
59
|
+
cmds = (cmds_pat % [line+14]).split(/\n/)
|
60
|
+
d = strarray_setup(cmds)
|
61
|
+
##############################
|
62
|
+
def foo # line + 4
|
63
|
+
a = 5 # line + 5
|
64
|
+
b = 6 # line + 6
|
65
|
+
end # line + 7
|
66
|
+
1.times do # line + 8
|
67
|
+
d.start # line + 9
|
68
|
+
1.times do # line + 10
|
69
|
+
x = 11 # line + 11
|
70
|
+
foo # line + 12
|
71
|
+
end # line + 13
|
72
|
+
c = 14 # line + 14
|
73
|
+
end
|
74
|
+
##############################
|
75
|
+
d.stop # ({:remove => true})
|
76
|
+
out = ["-- ",
|
77
|
+
'1.times do # line + 10',
|
78
|
+
'Set breakpoint 1: foo.rb:55 (@3)',
|
79
|
+
'xx ',
|
80
|
+
'c = 14 # line + 14'
|
81
|
+
]
|
82
|
+
compare_output(out, d, cmds)
|
83
|
+
end
|
84
|
+
|
85
|
+
end
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestEval < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_eval_questionmark
|
11
|
+
|
12
|
+
# See that eval? strips 'if'
|
13
|
+
cmds = %w(eval? continue)
|
14
|
+
d = strarray_setup(cmds)
|
15
|
+
d.start
|
16
|
+
if 3 > 5
|
17
|
+
assert false
|
18
|
+
end
|
19
|
+
d.stop
|
20
|
+
out = ['-- ', 'if 3 > 5', 'eval: 3 > 5', '$d0 = false']
|
21
|
+
compare_output(out, d, cmds)
|
22
|
+
|
23
|
+
# See that eval? strips 'if' and 'then'
|
24
|
+
cmds = %w(eval? continue)
|
25
|
+
d = strarray_setup(cmds)
|
26
|
+
d.start
|
27
|
+
if 3 > 5 then
|
28
|
+
assert false
|
29
|
+
end
|
30
|
+
d.stop
|
31
|
+
out = ['-- ', 'if 3 > 5 then', 'eval: 3 > 5', '$d0 = false']
|
32
|
+
compare_output(out, d, cmds)
|
33
|
+
|
34
|
+
# See that eval? strips 'unless'
|
35
|
+
cmds = %w(eval? continue)
|
36
|
+
d = strarray_setup(cmds)
|
37
|
+
d.start
|
38
|
+
unless 3 < 5
|
39
|
+
assert false
|
40
|
+
end
|
41
|
+
d.stop
|
42
|
+
out = ['-- ', 'unless 3 < 5', 'eval: 3 < 5', '$d0 = true']
|
43
|
+
compare_output(out, d, cmds)
|
44
|
+
|
45
|
+
# See that eval? strips 'unless' and 'then
|
46
|
+
cmds = %w(eval? continue)
|
47
|
+
d = strarray_setup(cmds)
|
48
|
+
d.start
|
49
|
+
unless 3 < 5 then
|
50
|
+
assert false
|
51
|
+
end
|
52
|
+
d.stop
|
53
|
+
out = ['-- ', 'unless 3 < 5 then', 'eval: 3 < 5', '$d0 = true']
|
54
|
+
compare_output(out, d, cmds)
|
55
|
+
|
56
|
+
# See that eval? strips 'while'
|
57
|
+
cmds = %w(eval? continue)
|
58
|
+
d = strarray_setup(cmds)
|
59
|
+
d.start
|
60
|
+
while nil
|
61
|
+
assert false
|
62
|
+
end
|
63
|
+
d.stop
|
64
|
+
out = ['-- ', 'while nil', 'eval: nil', '$d0 = nil']
|
65
|
+
compare_output(out, d, cmds)
|
66
|
+
|
67
|
+
# See that eval? strips 'while' and 'do'
|
68
|
+
cmds = %w(eval? continue)
|
69
|
+
d = strarray_setup(cmds)
|
70
|
+
d.start
|
71
|
+
while nil do
|
72
|
+
assert false
|
73
|
+
end
|
74
|
+
d.stop
|
75
|
+
out = ['-- ', 'while nil do', 'eval: nil', '$d0 = nil']
|
76
|
+
compare_output(out, d, cmds)
|
77
|
+
|
78
|
+
# See that eval? strips 'until' and 'do'
|
79
|
+
cmds = %w(eval? continue)
|
80
|
+
d = strarray_setup(cmds)
|
81
|
+
d.start
|
82
|
+
until true do
|
83
|
+
assert false
|
84
|
+
end
|
85
|
+
d.stop
|
86
|
+
out = ['-- ', 'until true do', 'eval: true', '$d0 = true']
|
87
|
+
compare_output(out, d, cmds)
|
88
|
+
|
89
|
+
# See that eval? strips 'until'
|
90
|
+
cmds = %w(eval? continue)
|
91
|
+
d = strarray_setup(cmds)
|
92
|
+
d.start
|
93
|
+
until true
|
94
|
+
assert false
|
95
|
+
end
|
96
|
+
d.stop
|
97
|
+
out = ['-- ', 'until true', 'eval: true', '$d0 = true']
|
98
|
+
compare_output(out, d, cmds)
|
99
|
+
|
100
|
+
# See that eval? strips 'return'
|
101
|
+
def five
|
102
|
+
return 5
|
103
|
+
end
|
104
|
+
cmds = %w(step eval? continue)
|
105
|
+
d = strarray_setup(cmds)
|
106
|
+
d.start
|
107
|
+
five
|
108
|
+
d.stop
|
109
|
+
out = ['-- ', 'five', '-> ', 'return 5', 'eval: 5', '$d0 = 5']
|
110
|
+
compare_output(out, d, cmds)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
@@ -0,0 +1,70 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestFinish < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_finish_between_fn
|
11
|
+
# "Finish" over a recursive function. We use a recursive function
|
12
|
+
# so that we check that the temporary breakpoint created in the
|
13
|
+
# implementation is specific to the frame. See Rubinius issue
|
14
|
+
# #558.
|
15
|
+
def fact(x)
|
16
|
+
return 1 if x <= 1
|
17
|
+
x = x * fact(x-1)
|
18
|
+
return x
|
19
|
+
end
|
20
|
+
# An extra 'continue' added in case something goes wrong.
|
21
|
+
cmds = %w(step finish) + ['pr x', 'continue', 'continue']
|
22
|
+
d = strarray_setup(cmds)
|
23
|
+
d.start
|
24
|
+
##############################
|
25
|
+
x = fact(4)
|
26
|
+
y = 5
|
27
|
+
##############################
|
28
|
+
d.stop # ({:remove => true})
|
29
|
+
out = ['-- ',
|
30
|
+
'x = fact(4)',
|
31
|
+
'-> ',
|
32
|
+
'return 1 if x <= 1',
|
33
|
+
'<- ',
|
34
|
+
'return x',
|
35
|
+
'24']
|
36
|
+
compare_output(out, d, cmds)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_finish_between_fn_simple
|
40
|
+
|
41
|
+
# Finish over functions
|
42
|
+
def five; 5 end
|
43
|
+
def something(x)
|
44
|
+
return 1 if x <= 1
|
45
|
+
x =
|
46
|
+
if five > 5
|
47
|
+
24
|
48
|
+
else
|
49
|
+
22
|
50
|
+
end
|
51
|
+
end
|
52
|
+
cmds = %w(step finish) + ['pr x', 'continue']
|
53
|
+
d = strarray_setup(cmds)
|
54
|
+
d.start
|
55
|
+
##############################
|
56
|
+
x = something(4)
|
57
|
+
y = 5
|
58
|
+
##############################
|
59
|
+
d.stop # ({:remove => true})
|
60
|
+
out = [
|
61
|
+
'-- ',
|
62
|
+
'x = something(4)',
|
63
|
+
'-> ',
|
64
|
+
'return 1 if x <= 1',
|
65
|
+
'<- ',
|
66
|
+
'x =', '22']
|
67
|
+
compare_output(out, d, cmds)
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestFnTestHelper < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_basic
|
11
|
+
assert_equal(__LINE__, get_lineno, 'get_lineno()')
|
12
|
+
assert_equal(0,
|
13
|
+
'-- (/tmp/trepan/tmp/gcd.rb:4)' =~ TREPAN_LOC)
|
14
|
+
assert_equal(0, '(trepanx): exit' =~ TREPAN_PROMPT)
|
15
|
+
|
16
|
+
output='
|
17
|
+
-- (/tmp/trepan/tmp/gcd.rb:4)
|
18
|
+
(trepanx): s
|
19
|
+
-- (/tmp/trepan/tmp/gcd.rb:18)
|
20
|
+
(trepanx): s
|
21
|
+
-- (/tmp/trepan/tmp/gcd.rb:19)
|
22
|
+
(trepanx): s
|
23
|
+
.. (/tmp/trepan/tmp/gcd.rb:0)
|
24
|
+
(trepanx): s
|
25
|
+
-> (/tmp/trepan/tmp/gcd.rb:4)
|
26
|
+
'.split(/\n/)
|
27
|
+
expect='
|
28
|
+
-- (/tmp/trepan/tmp/gcd.rb:4)
|
29
|
+
-- (/tmp/trepan/tmp/gcd.rb:18)
|
30
|
+
-- (/tmp/trepan/tmp/gcd.rb:19)
|
31
|
+
.. (/tmp/trepan/tmp/gcd.rb:0)
|
32
|
+
-> (/tmp/trepan/tmp/gcd.rb:4)
|
33
|
+
'.split(/\n/)
|
34
|
+
assert_equal(expect, filter_line_cmd(output))
|
35
|
+
end
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
|
40
|
+
|
41
|
+
|
42
|
+
|
43
|
+
|