Class: Debugger::Command
- Inherits:
-
Object
show all
- Extended by:
- Forwardable
- Includes:
- Columnize
- Defined in:
- lib/ruby-debug/command.rb
Overview
Direct Known Subclasses
AddBreakpoint, AddDisplayCommand, CatchCommand, ConditionCommand, ContinueCommand, DeleteBreakpointCommand, DeleteDisplayCommand, DisableCommand, DisplayCommand, DownCommand, Edit, EnableCommand, EvalCommand, FinishCommand, FrameCommand, HelpCommand, IRBCommand, InfoCommand, InterruptCommand, JumpCommand, KillCommand, ListCommand, MethodCommand, MethodSigCommand, NextCommand, PPCommand, PSCommand, PutLCommand, QuitCommand, ReloadCommand, RestartCommand, SaveCommand, SetCommand, ShowCommand, SkipCommand, SourceCommand, StartCommand, StepCommand, TextMateCommand, ThreadCurrentCommand, ThreadListCommand, ThreadResumeCommand, ThreadStopCommand, ThreadSwitchCommand, TraceCommand, UpCommand, VarClassVarCommand, VarConstantCommand, VarGlobalCommand, VarInheritCommand, VarInstanceCommand, VarLocalCommand, WhereCommand
Defined Under Namespace
Classes: SubcmdStruct
Constant Summary
collapse
- DEF_OPTIONS =
{
:allow_in_control => false,
:allow_in_post_mortem => true,
:event => true,
:always_run => 0,
:unknown => false,
:need_context => false,
}
Class Method Summary
collapse
Instance Method Summary
collapse
Constructor Details
#initialize(state) ⇒ Command
Returns a new instance of Command.
154
155
156
|
# File 'lib/ruby-debug/command.rb', line 154
def initialize(state)
@state = state
end
|
Class Method Details
.commands ⇒ Object
34
35
36
|
# File 'lib/ruby-debug/command.rb', line 34
def commands
@commands ||= []
end
|
.inherited(klass) ⇒ Object
47
48
49
50
51
52
|
# File 'lib/ruby-debug/command.rb', line 47
def inherited(klass)
DEF_OPTIONS.each do |o, v|
klass.options[o] = v if klass.options[o].nil?
end
commands << klass
end
|
.load_commands ⇒ Object
54
55
56
57
58
59
60
61
|
# File 'lib/ruby-debug/command.rb', line 54
def load_commands
Dir[File.join(Debugger.const_get(:RUBY_DEBUG_DIR), 'commands', '*')].each do |file|
require file if file =~ /\.rb$/
end
Debugger.constants.grep(/Functions$/).map { |name| Debugger.const_get(name) }.each do |mod|
include mod
end
end
|
.method_missing(meth, *args, &block) ⇒ Object
63
64
65
66
67
68
69
70
71
72
73
|
# File 'lib/ruby-debug/command.rb', line 63
def method_missing(meth, *args, &block)
if meth.to_s =~ /^(.+?)=$/
@options[$1.intern] = args.first
else
if @options.has_key?(meth)
@options[meth]
else
super
end
end
end
|
.options ⇒ Object
75
76
77
|
# File 'lib/ruby-debug/command.rb', line 75
def options
@options ||= {}
end
|
.register_setting_get(name, &block) ⇒ Object
123
124
125
126
|
# File 'lib/ruby-debug/command.rb', line 123
def register_setting_get(name, &block)
settings_map[name] ||= {}
settings_map[name][:getter] = block
end
|
.register_setting_set(name, &block) ⇒ Object
128
129
130
131
|
# File 'lib/ruby-debug/command.rb', line 128
def register_setting_set(name, &block)
settings_map[name] ||= {}
settings_map[name][:setter] = block
end
|
.register_setting_var(name, default) ⇒ Object
116
117
118
119
120
121
|
# File 'lib/ruby-debug/command.rb', line 116
def register_setting_var(name, default)
var_name = "@@#{name}"
class_variable_set(var_name, default)
register_setting_get(name) { class_variable_get(var_name) }
register_setting_set(name) { |value| class_variable_set(var_name, value) }
end
|
.settings ⇒ Object
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
# File 'lib/ruby-debug/command.rb', line 84
def settings
unless true and defined? @settings and @settings
@settings = Object.new
map = settings_map
c = class << @settings; self end
if c.respond_to?(:funcall)
c.funcall(:define_method, :[]) do |name|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:getter].call
end
else
c.send(:define_method, :[]) do |name|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:getter].call
end
end
c = class << @settings; self end
if c.respond_to?(:funcall)
c.funcall(:define_method, :[]=) do |name, value|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:setter].call(value)
end
else
c.send(:define_method, :[]=) do |name, value|
raise "No such setting #{name}" unless map.has_key?(name)
map[name][:setter].call(value)
end
end
end
@settings
end
|
.settings_map ⇒ Object
79
80
81
|
# File 'lib/ruby-debug/command.rb', line 79
def settings_map
@@settings_map ||= {}
end
|
Instance Method Details
#find(subcmds, param) ⇒ Object
Find param in subcmds. param id downcased and can be abbreviated to the minimum length listed in the subcommands
22
23
24
25
26
27
28
29
30
31
|
# File 'lib/ruby-debug/command.rb', line 22
def find(subcmds, param)
param.downcase!
for try_subcmd in subcmds do
if (param.size >= try_subcmd.min) and
(try_subcmd.name[0..param.size-1] == param)
return try_subcmd
end
end
return nil
end
|
#match(input) ⇒ Object
158
159
160
|
# File 'lib/ruby-debug/command.rb', line 158
def match(input)
@match = regexp.match(input)
end
|