rbx-trepanning 0.0.5-universal-rubinius-1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2002 -0
- data/LICENSE +25 -0
- data/NEWS +31 -0
- data/README.textile +34 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +219 -0
- data/app/breakpoint.rbc +3551 -0
- data/app/brkptmgr.rb +140 -0
- data/app/brkptmgr.rbc +2903 -0
- data/app/client.rb +61 -0
- data/app/client.rbc +1225 -0
- data/app/complete.rb +52 -0
- data/app/complete.rbc +1288 -0
- data/app/default.rb +71 -0
- data/app/default.rbc +1132 -0
- data/app/display.rb +148 -0
- data/app/display.rbc +2578 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +111 -0
- data/app/irb.rbc +2094 -0
- data/app/iseq.rb +117 -0
- data/app/iseq.rbc +2192 -0
- data/app/llvm.rbc +2478 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/method_name.rbc +2467 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +137 -0
- data/app/options.rbc +2898 -0
- data/app/rbx-llvm.rb +165 -0
- data/app/rbx-llvm.rbc +2478 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1146 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +69 -0
- data/bin/trepanx.compiled.rbc +1049 -0
- data/data/irbrc +41 -0
- data/data/irbrc.compiled.rbc +640 -0
- data/interface/base_intf.rb +105 -0
- data/interface/base_intf.rbc +1899 -0
- data/interface/client.rb +80 -0
- data/interface/client.rbc +1072 -0
- data/interface/comcodes.rb +20 -0
- data/interface/comcodes.rbc +385 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/server.rb +143 -0
- data/interface/server.rbc +2213 -0
- data/interface/user.rb +150 -0
- data/interface/user.rbc +2867 -0
- data/io/base_io.rb +148 -0
- data/io/base_io.rbc +2111 -0
- data/io/input.rb +135 -0
- data/io/input.rbc +2528 -0
- data/io/null_output.rb +42 -0
- data/io/null_output.rbc +730 -0
- data/io/string_array.rb +156 -0
- data/io/string_array.rbc +2466 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpclient.rbc +2419 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpfns.rbc +694 -0
- data/io/tcpserver.rb +141 -0
- data/io/tcpserver.rbc +2638 -0
- data/lib/trepanning.rb +474 -0
- data/lib/trepanning.rbc +7705 -0
- data/lib/trepanning2.rb +441 -0
- data/processor/breakpoint.rb +164 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +76 -0
- data/processor/command/base/cmd.rb +173 -0
- data/processor/command/base/subcmd.rb +229 -0
- data/processor/command/base/submgr.rb +182 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +195 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/complete.rb +37 -0
- data/processor/command/continue.rb +91 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disassemble.rb +145 -0
- data/processor/command/display.rb +82 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +51 -0
- data/processor/command/exit.rb +62 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +251 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +73 -0
- data/processor/command/info_subcmd/files.rb +209 -0
- data/processor/command/info_subcmd/line.rb +86 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +49 -0
- data/processor/command/info_subcmd/ruby.rb +62 -0
- data/processor/command/info_subcmd/variables.rb +48 -0
- data/processor/command/irb.rb +128 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +300 -0
- data/processor/command/macro.rb +76 -0
- data/processor/command/next.rb +66 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/pr.rb +38 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -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/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 +59 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +33 -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/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/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +36 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +38 -0
- data/processor/command/show_subcmd/alias.rb +42 -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/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -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/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/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +24 -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/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/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +126 -0
- data/processor/command/step.rb +84 -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 +86 -0
- data/processor/default.rb +58 -0
- data/processor/disassemble.rb +46 -0
- data/processor/display.rb +18 -0
- data/processor/eval.rb +96 -0
- data/processor/frame.rb +211 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +133 -0
- data/processor/load_cmds.rb +185 -0
- data/processor/location.rb +137 -0
- data/processor/main.rb +412 -0
- data/processor/mock.rb +144 -0
- data/processor/msg.rb +43 -0
- data/processor/running.rb +234 -0
- data/processor/stepping.rb +114 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/list-terminal-colors.rbc +2318 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +47 -0
- data/sample/rocky-trepanx-colors.rbc +530 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +4 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +13 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +2 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/step-bug.cmd +11 -0
- data/test/data/step-bug.right +3 -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/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/step-bug.rb +14 -0
- data/test/example/thread1.rb +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 +51 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +55 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -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/file-diff.rb +89 -0
- data/test/integration/helper.rb +78 -0
- data/test/integration/skip-test-step-bug.rb +17 -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/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +29 -0
- data/test/unit/test-app-brkptmgr.rb +51 -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 +82 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +27 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +47 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-base-submgr.rb +24 -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 +22 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +47 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-completion.rb +38 -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-frame.rb +79 -0
- data/test/unit/test-proc-help.rb +16 -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 +53 -0
- data/test/unit/test-proc-main.rb +99 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +47 -0
- metadata +398 -0
@@ -0,0 +1,76 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
require_relative '../eval'
|
6
|
+
class Trepan::Command::MacroCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{NAME} MACRO-NAME PROC-OBJECT
|
12
|
+
|
13
|
+
Define MACRO-NAME as a debugger macro. Debugger macros get a list of
|
14
|
+
arguments and should return either a String or an Array of Strings to
|
15
|
+
use in its place. If the return is a String, that gets tokenized by a
|
16
|
+
simple String#split . Note that macro processing is done right after
|
17
|
+
splitting on ;; so if the macro returns a string containing ;; those
|
18
|
+
won't be handled on the first string returned.
|
19
|
+
|
20
|
+
If instead, Array of Strings is returned, then the first string is
|
21
|
+
unshifted from the array and executed. The remaning strings are pushed
|
22
|
+
onto the command queue. In contrast to the first string, subsequent
|
23
|
+
strings which contain other macros or ;; splitting will be acted upon.
|
24
|
+
|
25
|
+
Here is an example. The below creates a macro called finish+ which
|
26
|
+
issues two commands 'finish' followed by 'step':
|
27
|
+
|
28
|
+
macro fin+ Proc.new{|*args| %w(finish step)}
|
29
|
+
|
30
|
+
Here is another example using arguments. I use the following to debug
|
31
|
+
a debugger command:
|
32
|
+
|
33
|
+
macro dbgcmd Proc.new{|*args| ["set debug dbgr", "debug $trepan_cmdproc.commands['\#{args[0]}'].run(\#{args.inspect})"]}
|
34
|
+
|
35
|
+
With the above, 'dbgcmd list 5' will ultimately expand to:
|
36
|
+
set debug dbgr
|
37
|
+
debug $trepan_cmdproc.commands['list'].run(['5'])
|
38
|
+
|
39
|
+
and will debug the debugger's 'list' command on the command 'list 5'.
|
40
|
+
|
41
|
+
See also 'show macro'.
|
42
|
+
HELP
|
43
|
+
|
44
|
+
CATEGORY = 'support'
|
45
|
+
MIN_ARGS = 2 # Need at least this many
|
46
|
+
SHORT_HELP = 'Define a macro'
|
47
|
+
end
|
48
|
+
|
49
|
+
def run(args)
|
50
|
+
macro_name = args[1]
|
51
|
+
proc_argstr = @proc.cmd_argstr[macro_name.size..-1].lstrip
|
52
|
+
proc_obj = @proc.debug_eval(proc_argstr, @proc.settings[:maxstring])
|
53
|
+
if proc_obj
|
54
|
+
if proc_obj.is_a?(Proc)
|
55
|
+
@proc.macros[macro_name] = proc_obj
|
56
|
+
msg "Macro \"#{macro_name}\" defined."
|
57
|
+
else
|
58
|
+
errmsg "Expecting a Proc object; got: #{proc_argstr}"
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
if __FILE__ == $0
|
65
|
+
require_relative '../mock'
|
66
|
+
dbgr, cmd = MockDebugger::setup
|
67
|
+
cmdproc = cmd.proc
|
68
|
+
["#{cmd.name} foo Proc.new{|x, y| 'x+y'}",
|
69
|
+
"#{cmd.name} bad2 1+2"].each do |cmdline|
|
70
|
+
args = cmdline.split
|
71
|
+
cmd_argstr = cmdline[args[0].size..-1].lstrip
|
72
|
+
cmdproc.instance_variable_set('@cmd_argstr', cmd_argstr)
|
73
|
+
cmd.run(args)
|
74
|
+
end
|
75
|
+
p cmdproc.macros
|
76
|
+
end
|
@@ -0,0 +1,66 @@
|
|
1
|
+
require 'rubygems'; require 'require_relative'
|
2
|
+
require_relative 'base/cmd'
|
3
|
+
require_relative '../stepping'
|
4
|
+
require_relative '../../app/breakpoint'
|
5
|
+
|
6
|
+
class Trepan::Command::NextCommand < Trepan::Command
|
7
|
+
|
8
|
+
ALIASES = %w(n)
|
9
|
+
CATEGORY = 'running'
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP= <<-HELP
|
12
|
+
#{NAME} [NUM]
|
13
|
+
|
14
|
+
Attempt to continue execution and stop at the next line. If there is
|
15
|
+
a conditional branch between the current position and the next line,
|
16
|
+
execution is stopped within the conditional branch instead.
|
17
|
+
|
18
|
+
The optional argument is a number which specifies how many lines to
|
19
|
+
attempt to skip past before stopping execution.
|
20
|
+
|
21
|
+
If the current line is the last in a method, execution is stopped
|
22
|
+
at the current position of the caller.
|
23
|
+
|
24
|
+
See also 'step' and 'nexti'.
|
25
|
+
HELP
|
26
|
+
NEED_RUNNING = true
|
27
|
+
SHORT_HELP = 'Move to the next line or conditional branch'
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
if args.size == 1
|
31
|
+
step_count = 1
|
32
|
+
else
|
33
|
+
step_str = args[1]
|
34
|
+
opts = {
|
35
|
+
:msg_on_error =>
|
36
|
+
"The #{NAME} command argument must eval to an integer. Got: %s" %
|
37
|
+
step_str,
|
38
|
+
:min_value => 1
|
39
|
+
}
|
40
|
+
step_count = @proc.get_an_int(step_str, opts)
|
41
|
+
return unless step_count
|
42
|
+
end
|
43
|
+
|
44
|
+
@proc.step('next', step_count)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
if __FILE__ == $0
|
50
|
+
require_relative '../mock'
|
51
|
+
dbgr, cmd = MockDebugger::setup
|
52
|
+
# [%w(n 5), %w(next 1+2), %w(n foo)].each do |c|
|
53
|
+
# dbgr.core.step_count = 0
|
54
|
+
# cmd.proc.leave_cmd_loop = false
|
55
|
+
# result = cmd.run(c)
|
56
|
+
# puts 'Run result: %s' % result
|
57
|
+
# puts 'step_count %d, leave_cmd_loop: %s' % [dbgr.core.step_count,
|
58
|
+
# cmd.proc.leave_cmd_loop]
|
59
|
+
# end
|
60
|
+
# [%w(n), %w(next+), %w(n-)].each do |c|
|
61
|
+
# dbgr.core.step_count = 0
|
62
|
+
# cmd.proc.leave_cmd_loop = false
|
63
|
+
# result = cmd.run(c)
|
64
|
+
# puts cmd.proc.different_pos
|
65
|
+
# end
|
66
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
require 'rubygems'; require 'require_relative'
|
2
|
+
require_relative 'base/cmd'
|
3
|
+
require_relative '../stepping'
|
4
|
+
require_relative '../../app/breakpoint'
|
5
|
+
require_relative '../../app/iseq'
|
6
|
+
|
7
|
+
class Trepan::Command::NextInstructionCommand < Trepan::Command
|
8
|
+
ALIASES = %w(ni)
|
9
|
+
CATEGORY = 'running'
|
10
|
+
HELP = <<-HELP
|
11
|
+
Continue but stop execution at the next bytecode instruction.
|
12
|
+
|
13
|
+
Does not step into send instructions.
|
14
|
+
|
15
|
+
See also 'continue', 'step', and 'next' commands.
|
16
|
+
HELP
|
17
|
+
NAME = File.basename(__FILE__, '.rb')
|
18
|
+
NEED_STACK = true
|
19
|
+
SHORT_HELP = 'Move to the next bytecode instruction'
|
20
|
+
|
21
|
+
def run(args)
|
22
|
+
if args.size == 1
|
23
|
+
step = 1
|
24
|
+
else
|
25
|
+
step_str = args[1]
|
26
|
+
opts = {
|
27
|
+
:msg_on_error =>
|
28
|
+
"The 'next' command argument must eval to an integer. Got: %s" %
|
29
|
+
step_str,
|
30
|
+
:min_value => 1
|
31
|
+
}
|
32
|
+
step = @proc.get_an_int(step_str, opts)
|
33
|
+
return unless step
|
34
|
+
end
|
35
|
+
|
36
|
+
exec = current_method
|
37
|
+
insn = Rubinius::InstructionSet[exec.iseq[@proc.frame.next_ip]]
|
38
|
+
|
39
|
+
next_ip = @proc.frame.next_ip + insn.width
|
40
|
+
|
41
|
+
if next_ip >= exec.iseq.size
|
42
|
+
@proc.step_to_parent
|
43
|
+
elsif ISeq.goto_op?(exec, @proc.frame.next_ip)
|
44
|
+
@proc.set_breakpoints_between(exec, @proc.frame.next_ip, next_ip)
|
45
|
+
else
|
46
|
+
line = exec.line_from_ip(next_ip)
|
47
|
+
|
48
|
+
bp = Breakpoint.for_ip(exec, next_ip, :event => 'vm-insn')
|
49
|
+
bp.scoped!(@proc.frame.scope)
|
50
|
+
bp.activate
|
51
|
+
end
|
52
|
+
@proc.continue('nexti')
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
if __FILE__ == $0
|
57
|
+
require_relative '../mock'
|
58
|
+
dbgr, cmd = MockDebugger::setup
|
59
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
require_relative '../eval'
|
6
|
+
class Trepan::Command::PrCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP =
|
11
|
+
"#{NAME} EXPRESSION
|
12
|
+
|
13
|
+
Print the value of the EXPRESSION. Variables accessible are those of the
|
14
|
+
environment of the selected stack frame, plus globals.
|
15
|
+
|
16
|
+
If the length output string large, the first part of the value is
|
17
|
+
shown and ... indicates it has been truncated.
|
18
|
+
|
19
|
+
See 'set max string' to change the string truncation limit.
|
20
|
+
"
|
21
|
+
|
22
|
+
# ALIASES = %w(p)
|
23
|
+
CATEGORY = 'data'
|
24
|
+
SHORT_HELP = 'print expression truncating long output'
|
25
|
+
end
|
26
|
+
|
27
|
+
def run(args)
|
28
|
+
msg @proc.debug_eval(@proc.cmd_argstr, settings[:maxstring])
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
if __FILE__ == $0
|
33
|
+
require_relative '../mock'
|
34
|
+
dbgr, cmd = MockDebugger::setup
|
35
|
+
arg_str = '1 + 2'
|
36
|
+
cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
|
37
|
+
cmd.run([cmd.name, arg_str])
|
38
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
require_relative '../eval'
|
6
|
+
class Trepan::Command::PsCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
HELP =
|
10
|
+
"ps ARRAY
|
11
|
+
|
12
|
+
Print the value of the ARRAY in columns and sorted."
|
13
|
+
|
14
|
+
CATEGORY = 'data'
|
15
|
+
MIN_ARGS = 1 # Need least this many
|
16
|
+
NAME = File.basename(__FILE__, '.rb')
|
17
|
+
SHORT_HELP = 'Print array sorted and in columns'
|
18
|
+
end
|
19
|
+
|
20
|
+
def run(args)
|
21
|
+
array = @proc.debug_eval(@proc.cmd_argstr, settings[:maxstring])
|
22
|
+
# FIXME: should test for enumerable
|
23
|
+
if array.is_a?(Array)
|
24
|
+
msg columnize_commands(array.sort)
|
25
|
+
else
|
26
|
+
errmsg "ps: #{@proc.cmd_argstr} should evaluate an Array not #{array.class}"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
if __FILE__ == $0
|
32
|
+
require_relative '../mock'
|
33
|
+
dbgr, cmd = MockDebugger::setup
|
34
|
+
arg_str = '(1..30).to_a'
|
35
|
+
cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
|
36
|
+
cmd.run([cmd.name, arg_str])
|
37
|
+
arg_str = '1'
|
38
|
+
cmd.proc.instance_variable_set('@cmd_argstr', arg_str)
|
39
|
+
cmd.run([cmd.name, arg_str])
|
40
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/cmd'
|
5
|
+
require_relative '../../app/run'
|
6
|
+
class Trepan::Command::RestartCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
ALIASES = %w(R run)
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME}
|
13
|
+
|
14
|
+
Restart debugger and program via an exec call. All state is lost, and
|
15
|
+
new copy of the debugger is used.
|
16
|
+
HELP
|
17
|
+
|
18
|
+
CATEGORY = 'running'
|
19
|
+
MAX_ARGS = 0 # Need at most this many
|
20
|
+
SHORT_HELP = '(Hard) restart of program via exec()'
|
21
|
+
end
|
22
|
+
|
23
|
+
# This method runs the command
|
24
|
+
def run(args)
|
25
|
+
|
26
|
+
dbgr = @proc.dbgr
|
27
|
+
argv = dbgr.restart_argv
|
28
|
+
if argv and argv.size > 0
|
29
|
+
# unless File.executable?(argv[0])
|
30
|
+
# msg(["File #{argv[0]} not executable.",
|
31
|
+
# "Adding Ruby interpreter."])
|
32
|
+
# argv.unshift Trepanning::ruby_path
|
33
|
+
# end
|
34
|
+
@proc.run_cmd(%w(show args))
|
35
|
+
if not confirm('Restart (exec)?', false)
|
36
|
+
msg "Restart not confirmed"
|
37
|
+
else
|
38
|
+
msg 'Restarting...'
|
39
|
+
@proc.run_cmd(%w(save))
|
40
|
+
# FIXME: Run atexit finalize routines?
|
41
|
+
Dir.chdir(Rubinius::OS_STARTUP_DIR)
|
42
|
+
exec(*argv)
|
43
|
+
end
|
44
|
+
else
|
45
|
+
errmsg("No executable file and command options recorded.")
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
if __FILE__ == $0
|
51
|
+
exit if ARGV[-1] == 'exit'
|
52
|
+
require_relative '../mock'
|
53
|
+
dbgr, cmd = MockDebugger::setup
|
54
|
+
dbgr.restart_argv = []
|
55
|
+
cmd.run([cmd.name])
|
56
|
+
dbgr.restart_argv = Rubinius::OS_ARGV + ['exit']
|
57
|
+
# require_relative '../../debugger'
|
58
|
+
# Trepan.start
|
59
|
+
cmd.run([cmd.name])
|
60
|
+
end
|
@@ -0,0 +1,72 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'optparse'
|
4
|
+
require 'rubygems'; require 'require_relative'
|
5
|
+
require_relative 'base/cmd'
|
6
|
+
require_relative '../../app/default'
|
7
|
+
require_relative '../../interface/server' # server interface (remote debugging)
|
8
|
+
class Trepan::Command::ServerCommand < Trepan::Command
|
9
|
+
include Trepanning
|
10
|
+
|
11
|
+
unless defined?(HELP)
|
12
|
+
CATEGORY = 'support'
|
13
|
+
DEFAULT_OPTIONS = {
|
14
|
+
:host => Trepan::DEFAULT_SETTINGS[:host],
|
15
|
+
:port => Trepan::DEFAULT_SETTINGS[:port]
|
16
|
+
}
|
17
|
+
MAX_ARGS = 4 # Need at most this many
|
18
|
+
NAME = File.basename(__FILE__, '.rb')
|
19
|
+
HELP = <<-HELP
|
20
|
+
#{NAME} [{--port|-p} NUM] [{--host|-h} HOST-OR-IP]
|
21
|
+
|
22
|
+
Put session into server mode which allows an out-of-process or remote
|
23
|
+
connection to the debugged program. --port and --host can be supplied
|
24
|
+
to specify the port number to use and the host name for TCP
|
25
|
+
connections. If neither is given, the default host (#{Trepan::DEFAULT_SETTINGS[:host]})
|
26
|
+
and the default port (#{Trepan::DEFAULT_SETTINGS[:port]}) are used.
|
27
|
+
|
28
|
+
Examples:
|
29
|
+
#{NAME} # Accept remote connections using defaults
|
30
|
+
#{NAME} --port 123 # Accept remote connections on port 123
|
31
|
+
#{NAME} --host my.host.net --port 2048
|
32
|
+
#{NAME} -h my.host.net -p 2048 # same as above
|
33
|
+
HELP
|
34
|
+
|
35
|
+
SHORT_HELP = 'Go into out-of-process debugging (server) mode'
|
36
|
+
|
37
|
+
end
|
38
|
+
|
39
|
+
def parse_options(options, args) # nodoc
|
40
|
+
parser = OptionParser.new do |opts|
|
41
|
+
opts.on("-h", "--host NAME", String,
|
42
|
+
"Host or IP used in TCP connections for --server or --client. " +
|
43
|
+
"Default is #{DEFAULT_SETTINGS[:host].inspect}.") do
|
44
|
+
|name_or_ip|
|
45
|
+
options[:host] = name_or_ip
|
46
|
+
end
|
47
|
+
opts.on("-p", "--port NUMBER", Integer,
|
48
|
+
"Port number used in TCP connections for --server or --client. " +
|
49
|
+
"Default is #{DEFAULT_SETTINGS[:port]}.") do
|
50
|
+
|num|
|
51
|
+
options[:port] = num
|
52
|
+
end
|
53
|
+
end
|
54
|
+
parser.parse(args)
|
55
|
+
return options
|
56
|
+
end
|
57
|
+
|
58
|
+
# This method runs the command
|
59
|
+
def run(args) # :nodoc
|
60
|
+
options = parse_options(DEFAULT_OPTIONS.dup, args[1..-1])
|
61
|
+
msg("starting debugger in out-of-process mode on host #{options[:host].inspect}, " +
|
62
|
+
"port: #{options[:port]}")
|
63
|
+
@proc.dbgr.intf << Trepan::ServerInterface.new(nil, nil, options)
|
64
|
+
end
|
65
|
+
end
|
66
|
+
|
67
|
+
if __FILE__ == $0
|
68
|
+
require_relative '../mock'
|
69
|
+
dbgr, cmd = MockDebugger::setup
|
70
|
+
# cmd.run([cmd.name])
|
71
|
+
# cmd.run([cmd.name, '--server'])
|
72
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'base/submgr'
|
5
|
+
|
6
|
+
class Trepan::Command::SetCommand < Trepan::SubcommandMgr
|
7
|
+
unless defined?(HELP)
|
8
|
+
HELP =
|
9
|
+
'Modifies parts of the debugger environment.
|
10
|
+
|
11
|
+
You can give unique prefix of the name of a subcommand to get
|
12
|
+
information about just that subcommand.
|
13
|
+
|
14
|
+
Type "set" for a list of "set" subcommands and what they do.
|
15
|
+
Type "help set *" for just the list of "set" subcommands.
|
16
|
+
|
17
|
+
For compatability with older ruby-debug "set auto..." is the
|
18
|
+
same as "set auto ...". For example "set autolist" is the same
|
19
|
+
as "set auto list".
|
20
|
+
'
|
21
|
+
|
22
|
+
CATEGORY = 'support'
|
23
|
+
NAME = File.basename(__FILE__, '.rb')
|
24
|
+
NEED_STACK = false
|
25
|
+
SHORT_HELP = 'Modify parts of the debugger environment'
|
26
|
+
end
|
27
|
+
|
28
|
+
def run(args)
|
29
|
+
if args.size > 1
|
30
|
+
first = args[1].downcase
|
31
|
+
alen = 'auto'.size
|
32
|
+
args[1..1] = ['auto', first[alen..-1]] if
|
33
|
+
first.start_with?('auto') && first.size > alen
|
34
|
+
end
|
35
|
+
super
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
39
|
+
|
40
|
+
if __FILE__ == $0
|
41
|
+
require_relative '../mock'
|
42
|
+
dbgr, cmd = MockDebugger::setup
|
43
|
+
cmd.run([cmd.name])
|
44
|
+
cmd.run([cmd.name, 'autolist'])
|
45
|
+
cmd.run([cmd.name, 'autoeval', 'off'])
|
46
|
+
cmd.run([cmd.name, 'basename'])
|
47
|
+
end
|