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,196 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'subcmd'
|
5
|
+
require_relative '../../subcmd'
|
6
|
+
require_relative '../../help'
|
7
|
+
|
8
|
+
class Trepan::SubSubcommandMgr < Trepan::Subcommand
|
9
|
+
|
10
|
+
include Trepan::Help
|
11
|
+
|
12
|
+
unless defined?(CATEGORY)
|
13
|
+
CATEGORY = 'status'
|
14
|
+
MIN_ARGS = 0
|
15
|
+
MAX_ARGS = nil
|
16
|
+
NAME = '?' # FIXME: Need to define this, but should
|
17
|
+
# pick this up from class/file name.
|
18
|
+
NEED_STACK = false
|
19
|
+
end
|
20
|
+
|
21
|
+
attr_accessor :pname
|
22
|
+
attr_accessor :subcmds # Array of instantiated Trepan::Subcommand objects
|
23
|
+
|
24
|
+
# Initialize show subcommands. Note: instance variable name
|
25
|
+
# has to be setcmds ('set' + 'cmds') for subcommand completion
|
26
|
+
# to work.
|
27
|
+
# FIXME: do we need proc still?
|
28
|
+
def initialize(proc, parent)
|
29
|
+
name = obj_const(self, :NAME)
|
30
|
+
@name = name.to_sym
|
31
|
+
@subcmds = Trepan::Subcmd.new(self)
|
32
|
+
@parent = parent
|
33
|
+
@pname = parent.name
|
34
|
+
@proc = parent.proc
|
35
|
+
|
36
|
+
# Set class constant SHORT_HELP to be the first line of HELP
|
37
|
+
# unless it has been defined in the class already.
|
38
|
+
# The below was the simplest way I could find to do this since
|
39
|
+
# we are the super class but want to set the subclass's constant.
|
40
|
+
# defined? didn't seem to work here.
|
41
|
+
c = self.class.constants
|
42
|
+
self.class.const_set('SHORT_HELP',
|
43
|
+
self.class.const_get('HELP')) if
|
44
|
+
c.member?('HELP') and !c.member?('SHORT_HELP')
|
45
|
+
|
46
|
+
load_debugger_subsubcommands(name, self)
|
47
|
+
end
|
48
|
+
|
49
|
+
# Create an instance of each of the debugger subcommands. Commands
|
50
|
+
# are found by importing files in the directory 'name' + 'sub'. Some
|
51
|
+
# files are excluded via an array set in initialize. For each of
|
52
|
+
# the remaining files, we import them and scan for class names
|
53
|
+
# inside those files and for each class name, we will create an
|
54
|
+
# instance of that class. The set of TrepanCommand class instances
|
55
|
+
# form set of possible debugger commands.
|
56
|
+
def load_debugger_subsubcommands(name, obj)
|
57
|
+
|
58
|
+
# Initialization
|
59
|
+
cmd_names = []
|
60
|
+
cmd_dir = File.dirname(__FILE__)
|
61
|
+
subcmd_dir = File.join(cmd_dir, '..', @pname + '_subcmd', name + '_subcmd')
|
62
|
+
files = Dir.glob(File.join(subcmd_dir, '*.rb'))
|
63
|
+
files.each do |rb|
|
64
|
+
cmd_names << name.capitalize + File.basename(rb, '.rb').capitalize
|
65
|
+
require rb
|
66
|
+
end if File.directory?(subcmd_dir)
|
67
|
+
|
68
|
+
subcommands = {}
|
69
|
+
cmd_names.each do |subname|
|
70
|
+
cmd_name = "#{pname}#{subname.downcase}"
|
71
|
+
subclass_name = "#{@pname.capitalize}#{subname}"
|
72
|
+
next unless
|
73
|
+
Trepan::SubSubcommand.constants.member?(subclass_name)
|
74
|
+
cmd = self.instance_eval("Trepan::SubSubcommand::" + subclass_name +
|
75
|
+
".new(self, @parent, '#{cmd_name}')")
|
76
|
+
@subcmds.add(cmd, cmd_name)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
|
80
|
+
# Give help for a command which has subcommands. This can be
|
81
|
+
# called in several ways:
|
82
|
+
# help cmd
|
83
|
+
# help cmd subcmd
|
84
|
+
# help cmd commands
|
85
|
+
#
|
86
|
+
# Our shtick is to give help for the overall command only if
|
87
|
+
# subcommand or 'commands' is not given. If a subcommand is given and
|
88
|
+
# found, then specific help for that is given. If 'commands' is given
|
89
|
+
# we will list the all the subcommands.
|
90
|
+
def help(args)
|
91
|
+
if args.size <= 3
|
92
|
+
# "help cmd". Give the general help for the command part.
|
93
|
+
doc = self.class.const_get(:HELP)
|
94
|
+
if doc
|
95
|
+
return doc
|
96
|
+
else
|
97
|
+
errmsg('Sorry - author mess up. ' +
|
98
|
+
'No help registered for command' +
|
99
|
+
@name)
|
100
|
+
return nil
|
101
|
+
end
|
102
|
+
end
|
103
|
+
|
104
|
+
prefix = my_const(:PREFIX)
|
105
|
+
subcmd_name = args[prefix.size+1]
|
106
|
+
prefix_str = prefix.join(' ')
|
107
|
+
|
108
|
+
if '*' == subcmd_name
|
109
|
+
help_text = ["List of subcommands for '%s':" % prefix_str]
|
110
|
+
cmd_names = @subcmds.list.map{|c| c[prefix_str.size-1..-1]}
|
111
|
+
help_text << columnize_commands(cmd_names)
|
112
|
+
return help_text
|
113
|
+
end
|
114
|
+
|
115
|
+
# "help cmd subcmd". Give help specific for that subcommand if
|
116
|
+
# the command matches uniquely, or show a list of matching
|
117
|
+
# subcommands
|
118
|
+
keyprefix_str = prefix.join('')
|
119
|
+
key_str = keyprefix_str + subcmd_name
|
120
|
+
cmd = @subcmds.lookup(key_str, false)
|
121
|
+
if cmd
|
122
|
+
doc = obj_const(cmd, :HELP)
|
123
|
+
if doc
|
124
|
+
return doc
|
125
|
+
else
|
126
|
+
errmsg('Sorry - author mess up. ' +
|
127
|
+
'No help registered for subcommand: ' +
|
128
|
+
subcmd_name + ', of command: ' +
|
129
|
+
@name)
|
130
|
+
return nil
|
131
|
+
end
|
132
|
+
else
|
133
|
+
matches = @subcmds.list.grep(/^#{key_str}/).sort
|
134
|
+
if matches.empty?
|
135
|
+
errmsg("No #{name} subcommands found matching /^#{subcmd_name}/. Try \"help #{@name}\".")
|
136
|
+
return nil
|
137
|
+
elsif 1 == matches.size
|
138
|
+
args[-1] = matches[0].to_s[keyprefix_str.size..-1]
|
139
|
+
help(args)
|
140
|
+
else
|
141
|
+
help_text = ["Subcommands of \"#{@name}\" matching /^#{subcmd_name}/:"]
|
142
|
+
help_text << columnize_commands(matches.sort)
|
143
|
+
return help_text
|
144
|
+
end
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
148
|
+
# Return an Array of subcommands that can start with +arg+. If none
|
149
|
+
# found we just return +arg+.
|
150
|
+
def complete(prefix)
|
151
|
+
prior = self.prefix.join('').size
|
152
|
+
last_args = @subcmds.list.map{|str| str[prior..-1]}
|
153
|
+
Trepan::Complete.complete_token(last_args, prefix)
|
154
|
+
end
|
155
|
+
|
156
|
+
def complete_token_with_next(prefix)
|
157
|
+
Trepan::Complete.complete_token_with_next(@subcmds.subcmds, prefix,
|
158
|
+
self.prefix.join(''))
|
159
|
+
end
|
160
|
+
|
161
|
+
def run(args)
|
162
|
+
args = @parent.last_args if args.size == 0
|
163
|
+
if args.size < 3 || args.size == 3 && args[2] == '*'
|
164
|
+
summary_list(obj_const(self, :NAME), @subcmds)
|
165
|
+
return false
|
166
|
+
end
|
167
|
+
|
168
|
+
subcmd_prefix = obj_const(self, :PREFIX).join('')
|
169
|
+
# We were given: cmd subcmd ...
|
170
|
+
# Run that.
|
171
|
+
subcmd = @subcmds.lookup(subcmd_prefix + args[2])
|
172
|
+
if subcmd
|
173
|
+
subcmd.run(args[2..-1])
|
174
|
+
else
|
175
|
+
undefined_subcmd(obj_const(self, :PREFIX).join(' '), args[2])
|
176
|
+
end
|
177
|
+
end
|
178
|
+
|
179
|
+
end
|
180
|
+
|
181
|
+
if __FILE__ == $0
|
182
|
+
# Demo it.
|
183
|
+
require_relative '../../mock'
|
184
|
+
dbgr = MockDebugger::MockDebugger.new
|
185
|
+
# cmds = dbgr.core.processor.commands
|
186
|
+
# cmd = cmds['info']
|
187
|
+
# Trepan::SubSubcommandMgr.new(dbgr.core.processor, cmd)
|
188
|
+
# puts cmd.help(%w(help info registers))
|
189
|
+
# puts '=' * 40
|
190
|
+
# puts cmd.help(%w(help info registers *))
|
191
|
+
# puts '=' * 40
|
192
|
+
# FIXME
|
193
|
+
# require_relative '../../lib/trepanning'
|
194
|
+
# Trepan.debugger
|
195
|
+
# puts cmd.help(%w(help info registers p.*))
|
196
|
+
end
|
@@ -0,0 +1,78 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
|
5
|
+
class Trepan::Command::BreakCommand < Trepan::Command
|
6
|
+
|
7
|
+
ALIASES = %w(b brk)
|
8
|
+
CATEGORY = 'breakpoints'
|
9
|
+
NAME = File.basename(__FILE__, '.rb')
|
10
|
+
HELP = <<-HELP
|
11
|
+
#{NAME} LOCATION [ {if|unless} CONDITION ]
|
12
|
+
|
13
|
+
Set a breakpoint. In the second form where CONDITIOn is given, the
|
14
|
+
condition is evaluated in the context of the position. We stop only If
|
15
|
+
CONDITION evalutes to non-false/nil and the "if" form used, or it is
|
16
|
+
false and the "unless" form used.\
|
17
|
+
|
18
|
+
Examples:
|
19
|
+
#{NAME}
|
20
|
+
#{NAME} 10 # set breakpoint on line 10
|
21
|
+
#{NAME} 10 if 1 == a # like above but only if a is equal to 1
|
22
|
+
#{NAME} 10 unless 1 == a # like above but only if a is equal to 1
|
23
|
+
#{NAME} me.rb:10
|
24
|
+
#{NAME} @20 # set breakpoint VM Instruction Sequence offset 20
|
25
|
+
#{NAME} Kernel.pp # Set a breakpoint at the beginning of Kernel.pp
|
26
|
+
|
27
|
+
See also condition, continue and "help location".
|
28
|
+
HELP
|
29
|
+
SHORT_HELP = 'Set a breakpoint at a point in a method'
|
30
|
+
|
31
|
+
# This method runs the command
|
32
|
+
def run(args, temp=false)
|
33
|
+
|
34
|
+
arg_str = args.size == 1 ? @proc.frame.line.to_s : @proc.cmd_argstr
|
35
|
+
cm, line, ip, condition, negate =
|
36
|
+
@proc.breakpoint_position(arg_str, true)
|
37
|
+
if cm
|
38
|
+
event = temp ? 'tbrkpt' : 'brkpt'
|
39
|
+
opts={:event => event, :temp => temp, :condition => condition,
|
40
|
+
:negate => negate}
|
41
|
+
bp = @proc.set_breakpoint_method(cm, line, ip, opts)
|
42
|
+
bp.set_temp! if temp
|
43
|
+
return bp
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
def ask_deferred(klass_name, which, name, line)
|
48
|
+
if confirm('Would you like to defer this breakpoint to later?', false)
|
49
|
+
@proc.dbgr.add_deferred_breakpoint(klass_name, which, name, line)
|
50
|
+
msg 'Deferred breakpoint created.'
|
51
|
+
else
|
52
|
+
msg 'Not confirmed.'
|
53
|
+
end
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if __FILE__ == $0
|
58
|
+
require_relative '../mock'
|
59
|
+
dbgr, cmd = MockDebugger::setup
|
60
|
+
# require_relative '../../lib/trepanning'
|
61
|
+
def run_cmd(cmd, args)
|
62
|
+
cmd.proc.instance_variable_set('@cmd_argstr', args[1..-1].join(' '))
|
63
|
+
cmd.run(args)
|
64
|
+
end
|
65
|
+
|
66
|
+
run_cmd(cmd, [cmd.name])
|
67
|
+
run_cmd(cmd, [cmd.name, __LINE__.to_s])
|
68
|
+
|
69
|
+
def foo
|
70
|
+
5
|
71
|
+
end
|
72
|
+
run_cmd(cmd, [cmd.name, 'foo', (__LINE__-2).to_s])
|
73
|
+
run_cmd(cmd, [cmd.name, 'foo'])
|
74
|
+
run_cmd(cmd, [cmd.name, "MockDebugger::setup"])
|
75
|
+
require 'irb'
|
76
|
+
run_cmd(cmd, [cmd.name, "IRB.start"])
|
77
|
+
run_cmd(cmd, [cmd.name, 'foo93'])
|
78
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
require_relative '../load_cmds'
|
5
|
+
class Trepan::Command::CompleteCommand < Trepan::Command
|
6
|
+
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} COMMAND-PREFIX
|
11
|
+
|
12
|
+
List the completions for the rest of the line as a command.
|
13
|
+
HELP
|
14
|
+
CATEGORY = 'support'
|
15
|
+
NEED_STACK = false
|
16
|
+
SHORT_HELP = 'List the completions for the rest of the line as a command'
|
17
|
+
end
|
18
|
+
|
19
|
+
# This method runs the command
|
20
|
+
def run(args) # :nodoc
|
21
|
+
last_arg = @proc.cmd_argstr.end_with?(' ') ? '' : args[-1]
|
22
|
+
@proc.complete(@proc.cmd_argstr, last_arg).each do |match|
|
23
|
+
msg match
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
if __FILE__ == $0
|
29
|
+
# Demo it.
|
30
|
+
require_relative '../mock'
|
31
|
+
dbgr, cmd = MockDebugger::setup
|
32
|
+
%w(d b bt).each do |prefix|
|
33
|
+
cmd.proc.instance_variable_set('@cmd_argstr', prefix)
|
34
|
+
cmd.run [cmd.name, prefix]
|
35
|
+
puts '=' * 40
|
36
|
+
end
|
37
|
+
cmd.run %w(#{cmd.name} fdafsasfda)
|
38
|
+
puts '=' * 40
|
39
|
+
end
|
@@ -0,0 +1,64 @@
|
|
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
|
+
require_relative '../breakpoint'
|
6
|
+
require_relative '../../app/breakpoint'
|
7
|
+
require_relative '../../app/condition'
|
8
|
+
|
9
|
+
class Trepan::Command::ConditionCommand < Trepan::Command
|
10
|
+
|
11
|
+
unless defined?(HELP)
|
12
|
+
NAME = File.basename(__FILE__, '.rb')
|
13
|
+
HELP = <<-HELP
|
14
|
+
#{NAME} BP_NUMBER CONDITION
|
15
|
+
|
16
|
+
BP_NUMBER is a breakpoint number. CONDITION is an expression which
|
17
|
+
must evaluate to True before the breakpoint is honored. If CONDITION
|
18
|
+
is absent, any existing condition is removed; i.e., the breakpoint is
|
19
|
+
made unconditional.
|
20
|
+
|
21
|
+
Examples:
|
22
|
+
#{NAME} 5 x > 10 # Breakpoint 5 now has condition x > 10
|
23
|
+
#{NAME} 5 # Remove above condition
|
24
|
+
|
25
|
+
See also "break", "enable" and "disable".
|
26
|
+
HELP
|
27
|
+
|
28
|
+
ALIASES = %w(cond)
|
29
|
+
CATEGORY = 'breakpoints'
|
30
|
+
MIN_ARGS = 1
|
31
|
+
NEED_STACK = false
|
32
|
+
SHORT_HELP = 'Specify breakpoint number N to break only if COND is true'
|
33
|
+
end
|
34
|
+
|
35
|
+
include Trepan::Condition
|
36
|
+
|
37
|
+
def run(args)
|
38
|
+
bpnum = @proc.get_an_int(args[1])
|
39
|
+
bp = @proc.breakpoint_find(bpnum)
|
40
|
+
return unless bp
|
41
|
+
|
42
|
+
if args.size > 2
|
43
|
+
condition = args[2..-1].join(' ')
|
44
|
+
return unless valid_condition?(condition)
|
45
|
+
else
|
46
|
+
condition = 'true'
|
47
|
+
msg('Breakpoint %d is now unconditional.' % bp.id)
|
48
|
+
end
|
49
|
+
bp.condition = condition
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
if __FILE__ == $0
|
54
|
+
require_relative '../mock'
|
55
|
+
dbgr, cmd = MockDebugger::setup
|
56
|
+
|
57
|
+
cmd.run([cmd.name, '1'])
|
58
|
+
cmdproc = dbgr.processor
|
59
|
+
cmds = cmdproc.commands
|
60
|
+
break_cmd = cmds['break']
|
61
|
+
break_cmd.run([break_cmd.name, __LINE__.to_s])
|
62
|
+
cmd.run([cmd.name, '1', 'x' '>' '10'])
|
63
|
+
cmd.run([cmd.name, '1'])
|
64
|
+
end
|
@@ -0,0 +1,61 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
require_relative '../stepping'
|
5
|
+
|
6
|
+
class Trepan::Command::ContinueCommand < Trepan::Command
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} [LOCATION]
|
11
|
+
|
12
|
+
Leave the debugger loop and continue execution. Subsequent entry to
|
13
|
+
the debugger however may occur via breakpoints or explicit calls, or
|
14
|
+
exceptions.
|
15
|
+
|
16
|
+
If a parameter is given, a temporary breakpoint is set at that position
|
17
|
+
before continuing. Offset are numbers prefixed with an "@" otherwise
|
18
|
+
the parameter is taken as a line number.
|
19
|
+
|
20
|
+
Examples:
|
21
|
+
#{NAME}
|
22
|
+
#{NAME} 10 # continue to line 10
|
23
|
+
#{NAME} @20 # continue to VM Instruction Sequence offset 20
|
24
|
+
#{NAME} gcd # continue to first instruction of method gcd
|
25
|
+
#{NAME} IRB.start @7 # continue to IRB.start offset 7
|
26
|
+
|
27
|
+
See also 'step', 'next', 'finish', 'nexti' commands and "help location".
|
28
|
+
HELP
|
29
|
+
|
30
|
+
ALIASES = %w(c cont)
|
31
|
+
CATEGORY = 'running'
|
32
|
+
MAX_ARGS = 2 # Need at most this many
|
33
|
+
NEED_RUNNING = true
|
34
|
+
SHORT_HELP = 'Continue execution of the debugged program'
|
35
|
+
end
|
36
|
+
|
37
|
+
# This is the method that runs the command
|
38
|
+
def run(args)
|
39
|
+
|
40
|
+
## FIXME: DRY this code, tbreak and break.
|
41
|
+
unless args.size == 1
|
42
|
+
cm, line, ip, condition, negate =
|
43
|
+
@proc.breakpoint_position(@proc.cmd_argstr, false)
|
44
|
+
if cm
|
45
|
+
opts={:event => 'tbrkpt', :temp => true}
|
46
|
+
bp = @proc.set_breakpoint_method(cm, line, ip, opts)
|
47
|
+
bp.set_temp!
|
48
|
+
else
|
49
|
+
errmsg "Trouble setting temporary breakpoint"
|
50
|
+
return
|
51
|
+
end
|
52
|
+
end
|
53
|
+
@proc.continue('continue')
|
54
|
+
end
|
55
|
+
end
|
56
|
+
|
57
|
+
if __FILE__ == $0
|
58
|
+
require_relative '../mock'
|
59
|
+
dbgr, cmd = MockDebugger::setup
|
60
|
+
p cmd.run([cmd.name])
|
61
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
# Copyright (C) 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
|
5
|
+
class Trepan::Command::DeleteBreakpontCommand < Trepan::Command
|
6
|
+
|
7
|
+
unless defined?(HELP)
|
8
|
+
NAME = File.basename(__FILE__, '.rb')
|
9
|
+
HELP = <<-HELP
|
10
|
+
#{NAME} [bpnumber [bpnumber...]]
|
11
|
+
|
12
|
+
Delete some breakpoints.
|
13
|
+
|
14
|
+
Arguments are breakpoint numbers with spaces in between. To delete
|
15
|
+
all breakpoints, give no argument. those breakpoints. Without
|
16
|
+
argument, clear all breaks (but first ask confirmation).
|
17
|
+
|
18
|
+
See also the "clear" command which clears breakpoints by line/file
|
19
|
+
number.
|
20
|
+
HELP
|
21
|
+
|
22
|
+
CATEGORY = 'breakpoints'
|
23
|
+
SHORT_HELP = 'Delete some breakpoints'
|
24
|
+
end
|
25
|
+
|
26
|
+
def run(args)
|
27
|
+
if args.size == 1
|
28
|
+
if confirm('Delete all breakpoints?', false)
|
29
|
+
@proc.brkpts.reset
|
30
|
+
return
|
31
|
+
end
|
32
|
+
end
|
33
|
+
first = args.shift
|
34
|
+
args.each do |num_str|
|
35
|
+
opts = {:msg_on_error => '%s must be a number' % num_str}
|
36
|
+
i = @proc.get_an_int(num_str, opts)
|
37
|
+
if i
|
38
|
+
success = @proc.delete_breakpoint_by_number(num_str.to_i, false) if i
|
39
|
+
msg('Deleted breakpoint %d.' % i) if success
|
40
|
+
end
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
@@ -0,0 +1,51 @@
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative '../command'
|
4
|
+
class Trepan::Command::DirectoryCommand < Trepan::Command
|
5
|
+
|
6
|
+
unless defined?(HELP)
|
7
|
+
ALIASES = %w(dir)
|
8
|
+
CATEGORY = 'files'
|
9
|
+
MAX_ARGS = 1 # Need at most this many
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME} [DIR]
|
13
|
+
|
14
|
+
Add directory DIR to beginning of search path for source files.
|
15
|
+
DIR can also be $cwd for the current working directory, or $cdir for the
|
16
|
+
directory in which the debugged file start.
|
17
|
+
With no argument, reset the search path to $cdir:$cwd, the default.
|
18
|
+
|
19
|
+
This command may be useful for debugging into Rubinius methods such as
|
20
|
+
kernel/common/module.rb if have the source code somewhere.
|
21
|
+
|
22
|
+
Examples:
|
23
|
+
#{NAME} ~/.rvm/src/rbx-head # Adds an rvm-like directory to path
|
24
|
+
#{NAME} # reset to $cdir:$cwd
|
25
|
+
HELP
|
26
|
+
|
27
|
+
SHORT_HELP =
|
28
|
+
'Add directory DIR to beginning of search path for source files'
|
29
|
+
end
|
30
|
+
|
31
|
+
# This method runs the command
|
32
|
+
def run(args) # :nodoc
|
33
|
+
if args.size > 1
|
34
|
+
path = File.expand_path(args[1])
|
35
|
+
settings[:directory] = "#{path}:#{settings[:directory]}"
|
36
|
+
msg "Source directories searched: #{settings[:directory]}"
|
37
|
+
else
|
38
|
+
if confirm('Reintialize source path to empty?', false)
|
39
|
+
settings[:directory] = '$rbx:$cdir:$cwd'
|
40
|
+
msg "Source directories searched: #{settings[:directory]}"
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
if __FILE__ == $0
|
47
|
+
require_relative '../mock'
|
48
|
+
dbgr, cmd = MockDebugger::setup
|
49
|
+
cmd.run([cmd.name])
|
50
|
+
cmd.run([cmd.name, '/tmp'])
|
51
|
+
end
|
@@ -0,0 +1,71 @@
|
|
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
|
+
require_relative '../../app/util'
|
6
|
+
require_relative '../breakpoint'
|
7
|
+
require_relative '../../app/breakpoint'
|
8
|
+
|
9
|
+
# disable breakpoint command. The difference however is that the
|
10
|
+
# parameter to @proc.en_disable_breakpoint_by_number is different (set
|
11
|
+
# as ENABLE_PARM below).
|
12
|
+
#
|
13
|
+
# NOTE: The enable command subclasses this, so beware when changing!
|
14
|
+
class Trepan::Command::DisableCommand < Trepan::Command
|
15
|
+
|
16
|
+
Trepan::Util.suppress_warnings {
|
17
|
+
NAME = File.basename(__FILE__, '.rb')
|
18
|
+
HELP = <<-HELP
|
19
|
+
#{NAME} [display] NUM1 [NUM2 ...]
|
20
|
+
|
21
|
+
Disables the breakpoints or display given as a space separated list of
|
22
|
+
numbers.
|
23
|
+
|
24
|
+
See also "enable" and "info break".
|
25
|
+
HELP
|
26
|
+
|
27
|
+
CATEGORY = 'breakpoints'
|
28
|
+
SHORT_HELP = 'Disable some breakpoints or displays'
|
29
|
+
}
|
30
|
+
|
31
|
+
def initialize(proc)
|
32
|
+
super
|
33
|
+
@enable_parm = false # true if enable
|
34
|
+
end
|
35
|
+
|
36
|
+
def run(args)
|
37
|
+
if args.size == 1
|
38
|
+
errmsg('No breakpoint or display number given.')
|
39
|
+
return
|
40
|
+
end
|
41
|
+
if args[1] == 'display'
|
42
|
+
args.shift
|
43
|
+
first = args.shift
|
44
|
+
args.each do |num_str|
|
45
|
+
i = @proc.get_an_int(num_str)
|
46
|
+
success = @proc.en_disable_display_by_number(i, @enable_parm) if i
|
47
|
+
msg("Display %s #{@name}d." % i) if success
|
48
|
+
end
|
49
|
+
end
|
50
|
+
first = args.shift
|
51
|
+
args.each do |num_str|
|
52
|
+
i = @proc.get_an_int(num_str)
|
53
|
+
success = @proc.en_disable_breakpoint_by_number(i, @enable_parm) if i
|
54
|
+
msg("Breakpoint %s #{@name}d." % i) if success
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
if __FILE__ == $0
|
60
|
+
require_relative '../mock'
|
61
|
+
dbgr, cmd = MockDebugger::setup
|
62
|
+
cmd.run([cmd.name])
|
63
|
+
cmd.run([cmd.name, '1'])
|
64
|
+
cmdproc = dbgr.core.processor
|
65
|
+
cmds = cmdproc.commands
|
66
|
+
break_cmd = cmds['break']
|
67
|
+
break_cmd.run(['break', cmdproc.frame.source_location[0].to_s])
|
68
|
+
# require_relative '../../lib/trepanning'
|
69
|
+
# Trepan.debug
|
70
|
+
cmd.run([cmd.name, '1'])
|
71
|
+
end
|