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,49 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
require_relative '../../app/complete'
|
5
|
+
|
6
|
+
class Trepan::Command::UnaliasCommand < Trepan::Command
|
7
|
+
|
8
|
+
unless defined?(HELP)
|
9
|
+
HELP = <<-HELP
|
10
|
+
unalias ALIAS
|
11
|
+
|
12
|
+
Remove alias ALIAS
|
13
|
+
|
14
|
+
See also 'alias'.
|
15
|
+
HELP
|
16
|
+
|
17
|
+
CATEGORY = 'support'
|
18
|
+
MIN_ARGS = 1
|
19
|
+
# MAX_ARGS = 1 # Need at most this many
|
20
|
+
NAME = File.basename(__FILE__, '.rb')
|
21
|
+
NEED_STACK = true
|
22
|
+
SHORT_HELP = 'Remove an alias'
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete(prefix)
|
26
|
+
Trepan::Complete.complete_token(@proc.aliases.keys, prefix)
|
27
|
+
end
|
28
|
+
|
29
|
+
# Run command.
|
30
|
+
def run(args)
|
31
|
+
args[1..-1].each do |arg|
|
32
|
+
if @proc.aliases.member?(arg)
|
33
|
+
@proc.aliases.delete(arg)
|
34
|
+
msg "Alias for #{arg} removed."
|
35
|
+
else
|
36
|
+
msg "No alias found for #{arg}."
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
if __FILE__ == $0
|
43
|
+
# Demo it.
|
44
|
+
require_relative '../mock'
|
45
|
+
dbgr, cmd = MockDebugger::setup
|
46
|
+
cmd.run %w(cmd.name n)
|
47
|
+
cmd.run %w(cmd.name n)
|
48
|
+
cmd.run %w(cmd.name foo bar c)
|
49
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../command'
|
5
|
+
|
6
|
+
# undisplay display-number...
|
7
|
+
class Trepan::Command::UndisplayCommand < Trepan::Command
|
8
|
+
|
9
|
+
unless defined?(HELP)
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP = <<EOH
|
12
|
+
#{NAME} DISPLAY_NUMBER ...
|
13
|
+
Cancel some expressions to be displayed when program stops.
|
14
|
+
Arguments are the code numbers of the expressions to stop displaying.
|
15
|
+
No argument means cancel all automatic-display expressions.
|
16
|
+
"delete display" has the same effect as this command.
|
17
|
+
Use "info display" to see current list of display numbers.
|
18
|
+
EOH
|
19
|
+
|
20
|
+
CATEGORY = 'data'
|
21
|
+
NEED_STACK = false
|
22
|
+
SHORT_HELP = 'Cancel some expressions to be displayed when program stops'
|
23
|
+
end
|
24
|
+
|
25
|
+
def complete(prefix)
|
26
|
+
@proc.displays.nums.map{|disp| disp.to_s}
|
27
|
+
end
|
28
|
+
|
29
|
+
def run(args)
|
30
|
+
|
31
|
+
if args.size == 1
|
32
|
+
if confirm('Delete all displays?', false)
|
33
|
+
@proc.displays.clear
|
34
|
+
return
|
35
|
+
end
|
36
|
+
end
|
37
|
+
opts = {}
|
38
|
+
args[1..-1].each do |arg|
|
39
|
+
opts = {:msg_on_error => '%s must be a display number' % arg}
|
40
|
+
i = @proc.get_an_int(arg, opts)
|
41
|
+
if i
|
42
|
+
unless @proc.displays.delete_index(i)
|
43
|
+
errmsg("No display number %d." % i)
|
44
|
+
return
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
if __FILE__ == $0
|
52
|
+
# demo it.
|
53
|
+
require_relative '../mock'
|
54
|
+
dbgr, cmd = MockDebugger::setup
|
55
|
+
|
56
|
+
def run_cmd(cmd, args)
|
57
|
+
cmd.run(args)
|
58
|
+
puts '==' * 10
|
59
|
+
end
|
60
|
+
|
61
|
+
run_cmd(cmd, %W(#{cmd.name} z))
|
62
|
+
run_cmd(cmd, %W(#{cmd.name} 1 10))
|
63
|
+
end
|
@@ -0,0 +1,89 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
require_relative '../../app/util'
|
5
|
+
|
6
|
+
# up command. Like 'down' but the direction (set by DIRECTION) is different.
|
7
|
+
#
|
8
|
+
# NOTE: The down command subclasses this, so beware when changing!
|
9
|
+
class Trepan::Command::UpCommand < Trepan::Command
|
10
|
+
|
11
|
+
Trepan::Util.suppress_warnings {
|
12
|
+
NAME = File.basename(__FILE__, '.rb')
|
13
|
+
HELP = <<-HELP
|
14
|
+
#{NAME} [count]
|
15
|
+
|
16
|
+
Move the current frame up in the stack trace (to an older frame). 0 is
|
17
|
+
the most recent frame. If no count is given, move up 1.
|
18
|
+
|
19
|
+
See also 'down' and 'frame'.
|
20
|
+
HELP
|
21
|
+
|
22
|
+
ALIASES = %w(u)
|
23
|
+
CATEGORY = 'stack'
|
24
|
+
MAX_ARGS = 1 # Need at most this many
|
25
|
+
NEED_STACK = true
|
26
|
+
SHORT_HELP = 'Move frame in the direction of the caller of the last-selected frame'
|
27
|
+
}
|
28
|
+
|
29
|
+
def complete(prefix)
|
30
|
+
@proc.frame_complete(prefix, @direction)
|
31
|
+
end
|
32
|
+
|
33
|
+
def initialize(proc)
|
34
|
+
super
|
35
|
+
@direction = +1 # -1 for down.
|
36
|
+
end
|
37
|
+
|
38
|
+
# Run 'up' command.
|
39
|
+
def run(args)
|
40
|
+
|
41
|
+
# FIXME: move into @proc and test based on NEED_STACK.
|
42
|
+
if @proc.stack_size == 0
|
43
|
+
errmsg('No frames recorded.')
|
44
|
+
return false
|
45
|
+
end
|
46
|
+
|
47
|
+
if args.size == 1
|
48
|
+
# Form is: "up" which means "up 1"
|
49
|
+
count = 1
|
50
|
+
else
|
51
|
+
count_str = args[1]
|
52
|
+
name_or_id = args[1]
|
53
|
+
low, high = @proc.frame_low_high(@direction)
|
54
|
+
opts = {
|
55
|
+
:msg_on_error =>
|
56
|
+
"The '#{NAME}' command argument must eval to an integer. Got: %s" % count_str,
|
57
|
+
:min_value => low, :max_value => high
|
58
|
+
}
|
59
|
+
count = @proc.get_an_int(count_str, opts)
|
60
|
+
return false unless count
|
61
|
+
end
|
62
|
+
@proc.adjust_frame(@direction * count, false)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
if __FILE__ == $0
|
67
|
+
# Demo it.
|
68
|
+
require_relative '../mock'
|
69
|
+
dbgr, cmd = MockDebugger::setup
|
70
|
+
|
71
|
+
# def sep ; puts '=' * 40 end
|
72
|
+
# cmd.run [cmd.name]
|
73
|
+
# %w(-1 0 1 -2).each do |count|
|
74
|
+
# puts "#{cmd.name} #{count}"
|
75
|
+
# cmd.run([cmd.name, count])
|
76
|
+
# sep
|
77
|
+
# end
|
78
|
+
# def foo(cmd, cmd.name)
|
79
|
+
# puts "#{cmd.name}"
|
80
|
+
# cmd.run([cmd.name])
|
81
|
+
# sep
|
82
|
+
# %w(-2 -1).each do |count|
|
83
|
+
# puts "#{cmd.name} #{count}"
|
84
|
+
# cmd.run([cmd.name, count])
|
85
|
+
# sep
|
86
|
+
# end
|
87
|
+
# end
|
88
|
+
# foo(cmd, cmd.name)
|
89
|
+
end
|
@@ -0,0 +1,173 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
# Base class of all commands. Code common to all commands is here.
|
4
|
+
# Note: don't end classname with Command (capital C) since main
|
5
|
+
# will think this a command name like QuitCommand
|
6
|
+
require 'rubygems'; require 'require_relative'
|
7
|
+
require 'columnize'
|
8
|
+
require_relative '../app/complete'
|
9
|
+
|
10
|
+
class Trepan
|
11
|
+
class Command
|
12
|
+
attr_accessor :core, :proc
|
13
|
+
|
14
|
+
unless defined?(MIN_ARGS)
|
15
|
+
MIN_ARGS = 0 # run()'s args array must be at least this many
|
16
|
+
MAX_ARGS = nil # run()'s args array must be at least this many
|
17
|
+
NEED_STACK = false # We'll say that commands which need a stack
|
18
|
+
# to run have to declare that and those that
|
19
|
+
# don't don't have to mention it.
|
20
|
+
end
|
21
|
+
|
22
|
+
def initialize(proc)
|
23
|
+
@name = my_const(:NAME)
|
24
|
+
@proc = proc
|
25
|
+
end
|
26
|
+
|
27
|
+
def category
|
28
|
+
my_const(:CATEGORY)
|
29
|
+
end
|
30
|
+
|
31
|
+
# List commands arranged in an aligned columns
|
32
|
+
def columnize_commands(commands)
|
33
|
+
width = settings[:maxwidth]
|
34
|
+
Columnize::columnize(commands, width, ' ' * 4,
|
35
|
+
true, true, ' ' * 2).chomp
|
36
|
+
end
|
37
|
+
|
38
|
+
def columnize_numbers(commands)
|
39
|
+
width = settings[:maxwidth]
|
40
|
+
Columnize::columnize(commands, width, ', ',
|
41
|
+
false, false, ' ' * 2).chomp
|
42
|
+
end
|
43
|
+
|
44
|
+
# FIXME: probably there is a way to do the delegation to proc methods
|
45
|
+
# without having type it all out.
|
46
|
+
|
47
|
+
def confirm(message, default)
|
48
|
+
@proc.confirm(message, default)
|
49
|
+
end
|
50
|
+
|
51
|
+
def errmsg(message, opts={})
|
52
|
+
@proc.errmsg(message, opts)
|
53
|
+
end
|
54
|
+
|
55
|
+
def obj_const(obj, name)
|
56
|
+
obj.class.const_get(name)
|
57
|
+
end
|
58
|
+
|
59
|
+
def msg(message, opts={})
|
60
|
+
@proc.msg(message, opts)
|
61
|
+
end
|
62
|
+
|
63
|
+
# Convenience short-hand for @dbgr.intf[-1].msg_nocr
|
64
|
+
def msg_nocr(msg, opts={})
|
65
|
+
@proc.msg_nocr(msg, opts)
|
66
|
+
end
|
67
|
+
|
68
|
+
def my_const(name)
|
69
|
+
# Set class constant SHORT_HELP to be the first line of HELP
|
70
|
+
# unless it has been defined in the class already.
|
71
|
+
# The below was the simplest way I could find to do this since
|
72
|
+
# we are the super class but want to set the subclass's constant.
|
73
|
+
# defined? didn't seem to work here.
|
74
|
+
c = self.class.constants
|
75
|
+
if c.member?('HELP') and !c.member?('SHORT_HELP')
|
76
|
+
short_help = self.class.const_get(:HELP).split("\n")[0].chomp('.')
|
77
|
+
self.class.const_set(:SHORT_HELP, short_help)
|
78
|
+
end
|
79
|
+
self.class.const_get(name)
|
80
|
+
end
|
81
|
+
|
82
|
+
def name
|
83
|
+
self.class.const_get(:NAME)
|
84
|
+
end
|
85
|
+
|
86
|
+
# The method that implements the debugger command.
|
87
|
+
def run(*args)
|
88
|
+
raise RuntimeError, 'You need to define this method elsewhere'
|
89
|
+
end
|
90
|
+
|
91
|
+
def section(message, opts={})
|
92
|
+
@proc.section(message, opts)
|
93
|
+
end
|
94
|
+
|
95
|
+
def settings
|
96
|
+
@proc.settings
|
97
|
+
end
|
98
|
+
|
99
|
+
def short_help
|
100
|
+
help_constant_sym = if self.class.constants.member?('SHORT_HELP')
|
101
|
+
:SHORT_HELP
|
102
|
+
else :HELP
|
103
|
+
end
|
104
|
+
my_const(help_constant_sym)
|
105
|
+
end
|
106
|
+
|
107
|
+
# Define a method called 'complete' on the singleton class.
|
108
|
+
def self.completion(ary)
|
109
|
+
self.send(:define_method,
|
110
|
+
:complete,
|
111
|
+
Proc.new {|prefix|
|
112
|
+
Trepan::Complete.complete_token(ary, prefix) })
|
113
|
+
end
|
114
|
+
|
115
|
+
# From reference debugger
|
116
|
+
def run_code(str)
|
117
|
+
@proc.dbgr.current_frame.run(str)
|
118
|
+
end
|
119
|
+
|
120
|
+
def current_method
|
121
|
+
@proc.frame.method
|
122
|
+
end
|
123
|
+
|
124
|
+
def current_frame
|
125
|
+
@proc.frame
|
126
|
+
end
|
127
|
+
|
128
|
+
def variables
|
129
|
+
@proc.variables
|
130
|
+
end
|
131
|
+
|
132
|
+
def listen(step=false)
|
133
|
+
@proc.listen(step)
|
134
|
+
end
|
135
|
+
|
136
|
+
end
|
137
|
+
end
|
138
|
+
if __FILE__ == $0
|
139
|
+
class Trepan
|
140
|
+
class CmdProcessor
|
141
|
+
def initialize(dbgr)
|
142
|
+
end
|
143
|
+
def confirm(message, default)
|
144
|
+
p ['confirm: ', message, default]
|
145
|
+
end
|
146
|
+
def errmsg(message, opts)
|
147
|
+
p ['err:', message, opts]
|
148
|
+
end
|
149
|
+
def msg(message, opts)
|
150
|
+
p [message, opts]
|
151
|
+
end
|
152
|
+
def msg_nocr(message, opts)
|
153
|
+
p ['nocr: ', message, opts]
|
154
|
+
end
|
155
|
+
def section(message, opts)
|
156
|
+
p ['section: ', message, opts]
|
157
|
+
end
|
158
|
+
end
|
159
|
+
class Command::Test < Trepan::Command
|
160
|
+
NAME = 'test'
|
161
|
+
CATEGORY = 'testcategory'
|
162
|
+
completion %w(a aa ab ba aac)
|
163
|
+
end
|
164
|
+
end
|
165
|
+
proc = Trepan::CmdProcessor.new(nil)
|
166
|
+
cmd = Trepan::Command::Test.new(proc)
|
167
|
+
%w(confirm errmsg msg msg_nocr section).each do |meth|
|
168
|
+
cmd.send(meth, 'test', nil)
|
169
|
+
end
|
170
|
+
p cmd.complete('aa')
|
171
|
+
cmd.instance_variable_set('@completions', %w(aardvark apple))
|
172
|
+
p cmd.complete('aa')
|
173
|
+
end
|
@@ -0,0 +1,64 @@
|
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../app/default'
|
4
|
+
require_relative 'virtual'
|
5
|
+
class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
6
|
+
|
7
|
+
computed_displaywidth = (ENV['COLUMNS'] || '80').to_i
|
8
|
+
computed_displaywidth = 80 unless computed_displaywidth >= 10
|
9
|
+
|
10
|
+
DEFAULT_SETTINGS = {
|
11
|
+
:abbrev => true, # Allow abbreviations of debugger commands?
|
12
|
+
:autoeval => true, # Ruby eval non-debugger commands
|
13
|
+
:autoirb => false, # Go into IRB in debugger command loop
|
14
|
+
:autolist => false, # Run 'list'
|
15
|
+
|
16
|
+
:basename => false, # Show basename of filenames only
|
17
|
+
:confirm => true, # Confirm potentially dangerous operations?
|
18
|
+
:different => 'nostack', # stop *only* when different position?
|
19
|
+
|
20
|
+
:debugdbgr => false, # Debugging the debugger
|
21
|
+
:debugexcept => true, # Internal debugging of command exceptions
|
22
|
+
:debugmacro => false, # debugging macros
|
23
|
+
:debugskip => false, # Internal debugging of step/next skipping
|
24
|
+
:directory => # last-resort path-search for files
|
25
|
+
'$rbx:$cdir:$cwd', # that are not fully qualified.
|
26
|
+
|
27
|
+
:hidestack => nil, # Fixnum. How many hidden outer
|
28
|
+
# debugger stack frames to hide?
|
29
|
+
# nil or -1 means compute value. 0
|
30
|
+
# means hide none. Less than 0 means show
|
31
|
+
# all stack entries.
|
32
|
+
:hightlight => false, # Use terminal highlight?
|
33
|
+
|
34
|
+
:maxlist => 10, # Number of source lines to list
|
35
|
+
:maxstack => 10, # backtrace limit
|
36
|
+
:maxstring => 150, # Strings which are larger than this
|
37
|
+
# will be truncated to this length when
|
38
|
+
# printed
|
39
|
+
:maxwidth => computed_displaywidth,
|
40
|
+
:prompt => 'trepanx', # core part of prompt. Additional info like
|
41
|
+
# debug nesting and thread name is fixed
|
42
|
+
# and added on.
|
43
|
+
:reload => false, # Reread source file if we determine
|
44
|
+
# it has changed?
|
45
|
+
:save_cmdfile => nil, # If set, debugger command file to be
|
46
|
+
# used on restart
|
47
|
+
:timer => false, # show elapsed time between events
|
48
|
+
:traceprint => false, # event tracing printing
|
49
|
+
:tracebuffer => false, # save events to a trace buffer.
|
50
|
+
:user_cmd_dir => File.join(%W(#{Trepan::HOME_DIR} trepanx command)),
|
51
|
+
# User command directory
|
52
|
+
|
53
|
+
# Rubinius-specific user variables
|
54
|
+
:show_ip => false,
|
55
|
+
:show_bytecode => false,
|
56
|
+
|
57
|
+
} unless defined?(CmdProcessor::DEFAULT_SETTINGS)
|
58
|
+
end
|
59
|
+
|
60
|
+
if __FILE__ == $0
|
61
|
+
# Show it:
|
62
|
+
require 'pp'
|
63
|
+
PP.pp(Trepan::CmdProcessor::DEFAULT_SETTINGS)
|
64
|
+
end
|
@@ -0,0 +1,59 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../app/iseq'
|
4
|
+
require_relative 'virtual'
|
5
|
+
|
6
|
+
class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
7
|
+
|
8
|
+
def show_bytecode(line=@frame.vm_location.line, ip=@frame.next_ip)
|
9
|
+
meth = @frame.method
|
10
|
+
if 0 == line
|
11
|
+
start, fin = Trepan::ISeq::ip_ranges_for_ip(@frame.method.lines, ip)[0]
|
12
|
+
else
|
13
|
+
start = meth.first_ip_on_line(line)
|
14
|
+
unless start
|
15
|
+
errmsg "Can't find bytecode for line #{line}"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
fin = meth.first_ip_on_line(line+1)
|
19
|
+
end
|
20
|
+
|
21
|
+
if !fin || fin == -1
|
22
|
+
fin = meth.iseq.size
|
23
|
+
end
|
24
|
+
|
25
|
+
start += 1 if start == -1
|
26
|
+
suffix =
|
27
|
+
if 0 == line
|
28
|
+
"tail code before line #{Trepan::ISeq::tail_code_line(meth, ip)}"
|
29
|
+
else
|
30
|
+
"line #{line}"
|
31
|
+
end
|
32
|
+
section "Bytecode between #{start} and #{fin-1} for line #{suffix}"
|
33
|
+
|
34
|
+
iseq_decoder = Rubinius::InstructionDecoder.new(meth.iseq)
|
35
|
+
partial = iseq_decoder.decode_between(start, fin)
|
36
|
+
|
37
|
+
ip = start
|
38
|
+
|
39
|
+
prefixes = []
|
40
|
+
disasm = partial.inject('') do |result, ins|
|
41
|
+
inst = Rubinius::CompiledMethod::Instruction.new(ins, meth, ip)
|
42
|
+
prefixes << Trepan::ISeq::disasm_prefix(ip, frame.next_ip, meth)
|
43
|
+
ip += ins.size
|
44
|
+
result += "#{inst}\n"
|
45
|
+
end
|
46
|
+
|
47
|
+
# FIXME DRY with command/disassemble.rb
|
48
|
+
if @settings[:highlight]
|
49
|
+
require_relative '../app/rbx-llvm'
|
50
|
+
@llvm_highlighter = CodeRay::Duo[:llvm, :term]
|
51
|
+
# llvm_scanner = CodeRay.scanner :llvm
|
52
|
+
# p llvm_scanner.tokenize(disasm)
|
53
|
+
disasm = @llvm_highlighter.encode(disasm)
|
54
|
+
end
|
55
|
+
disasm.split("\n").each_with_index do |inst, i|
|
56
|
+
msg "#{prefixes[i]} #{inst}", :unlimited => true
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../app/display'
|
4
|
+
require_relative 'virtual'
|
5
|
+
class Trepan
|
6
|
+
class CmdProcessor < VirtualCmdProcessor
|
7
|
+
attr_reader :displays
|
8
|
+
|
9
|
+
def display_initialize
|
10
|
+
@displays = DisplayMgr.new
|
11
|
+
end
|
12
|
+
|
13
|
+
def display_find(num, show_errmsg = true)
|
14
|
+
if 0 == @displays.size
|
15
|
+
errmsg('No display expressions set.') if show_errmsg
|
16
|
+
return nil
|
17
|
+
elsif num > @displays.max || num < 1
|
18
|
+
errmsg('Display number %d is out of range 1..%d' %
|
19
|
+
[num, @displays.max]) if show_errmsg
|
20
|
+
return nil
|
21
|
+
end
|
22
|
+
disp = @displays[num]
|
23
|
+
if disp
|
24
|
+
return disp
|
25
|
+
else
|
26
|
+
errmsg('Display number %d previously deleted.' %
|
27
|
+
num) if show_errmsg
|
28
|
+
return nil
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
# Enable or disable a breakpoint given its breakpoint number.
|
33
|
+
def en_disable_display_by_number(num, do_enable=true)
|
34
|
+
disp = display_find(num)
|
35
|
+
return false unless disp
|
36
|
+
|
37
|
+
enable_disable = do_enable ? 'en' : 'dis'
|
38
|
+
if disp.enabled? == do_enable
|
39
|
+
errmsg('Display %d previously %sabled.' %
|
40
|
+
[num, enable_disable])
|
41
|
+
return false
|
42
|
+
end
|
43
|
+
disp.enabled = do_enable
|
44
|
+
return true
|
45
|
+
end
|
46
|
+
|
47
|
+
def run_eval_display(args={})
|
48
|
+
for line in @displays.display(@frame) do
|
49
|
+
msg(line)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
data/processor/eval.rb
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'
|
3
|
+
require 'require_relative'
|
4
|
+
require_relative 'virtual'
|
5
|
+
class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
6
|
+
|
7
|
+
def debug_eval(str, max_fake_filename=15)
|
8
|
+
begin
|
9
|
+
debug_eval_with_exception(str, max_fake_filename)
|
10
|
+
rescue SyntaxError, StandardError, ScriptError => e
|
11
|
+
exception_dump(e, @settings[:stack_trace_on_error], $!.backtrace)
|
12
|
+
nil
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def debug_eval_with_exception(str, max_fake_filename=15)
|
17
|
+
@frame.run(str, fake_eval_filename(str, max_fake_filename))
|
18
|
+
end
|
19
|
+
|
20
|
+
def debug_eval_no_errmsg(str, max_fake_filename=15)
|
21
|
+
begin
|
22
|
+
debug_eval_with_exception(str, max_fake_filename)
|
23
|
+
rescue SyntaxError, StandardError, ScriptError => e
|
24
|
+
nil
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def eval_code(str, max_fake_filename)
|
29
|
+
obj = debug_eval(str, max_fake_filename)
|
30
|
+
|
31
|
+
idx = @user_variables
|
32
|
+
@user_variables += 1
|
33
|
+
|
34
|
+
str = "$d#{idx}"
|
35
|
+
Rubinius::Globals[str.to_sym] = obj
|
36
|
+
msg "#{str} = #{obj.inspect}"
|
37
|
+
obj
|
38
|
+
end
|
39
|
+
|
40
|
+
def exception_dump(e, stack_trace, backtrace)
|
41
|
+
str = "#{e.class} Exception:\n\t#{e.message}"
|
42
|
+
if stack_trace
|
43
|
+
str += "\n" + backtrace.map{|l| "\t#{l}"}.join("\n") rescue nil
|
44
|
+
end
|
45
|
+
msg str
|
46
|
+
# throw :debug_error
|
47
|
+
end
|
48
|
+
|
49
|
+
def fake_eval_filename(str, maxlen = 15)
|
50
|
+
fake_filename =
|
51
|
+
if maxlen < str.size
|
52
|
+
# FIXME: Guard against \" in positions 13..15?
|
53
|
+
str.inspect[0..maxlen-1] + '"...'
|
54
|
+
else
|
55
|
+
str.inspect
|
56
|
+
end
|
57
|
+
"(eval #{fake_filename})"
|
58
|
+
end
|
59
|
+
|
60
|
+
end
|
61
|
+
|
62
|
+
if __FILE__ == $0
|
63
|
+
# Demo it.
|
64
|
+
cmdp = Trepan::CmdProcessor.new([])
|
65
|
+
puts cmdp.fake_eval_filename('x = 1; y = 2')
|
66
|
+
puts cmdp.fake_eval_filename('x = 1; y = 2', 7)
|
67
|
+
def cmdp.errmsg(msg)
|
68
|
+
puts "** #{msg}"
|
69
|
+
end
|
70
|
+
def cmdp.msg(msg)
|
71
|
+
puts "#{msg}"
|
72
|
+
end
|
73
|
+
begin
|
74
|
+
1/0
|
75
|
+
rescue Exception => exc
|
76
|
+
cmdp.exception_dump(exc, true, $!.backtrace)
|
77
|
+
puts '=' * 40
|
78
|
+
end
|
79
|
+
|
80
|
+
x = 10
|
81
|
+
|
82
|
+
require 'rubygems'; require 'require_relative'
|
83
|
+
require_relative '../app/frame'
|
84
|
+
frame = Trepan::Frame.new(self, 1, Rubinius::VM.backtrace(0)[0])
|
85
|
+
cmdp.instance_variable_set('@frame', frame)
|
86
|
+
cmdp.instance_variable_set('@settings', {:stack_trace_on_error => true})
|
87
|
+
def cmdp.errmsg(mess) ; puts mess end
|
88
|
+
# require_relative '../lib/trepanning'
|
89
|
+
# Trepan.start
|
90
|
+
puts cmdp.debug_eval('x = "#{x}"')
|
91
|
+
puts '=' * 40
|
92
|
+
puts cmdp.debug_eval('x+')
|
93
|
+
puts cmdp.debug_eval_no_errmsg('y+')
|
94
|
+
puts '=' * 40
|
95
|
+
puts cmdp.debug_eval('x+')
|
96
|
+
puts cmdp.debug_eval('y = 1; x+', 4)
|
97
|
+
end
|