rb8-trepanning 0.1.3 → 0.1.4
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGES +10 -0
- data/ChangeLog +276 -0
- data/Makefile +13 -0
- data/Rakefile +1 -2
- data/app/display.rb +41 -1
- data/app/irb.rb +55 -49
- data/app/options.rb +3 -2
- data/app/run.rb +25 -7
- data/app/util.rb +19 -1
- data/bin/trepan8 +0 -2
- data/data/perldb.bindings +17 -0
- data/interface/script.rb +1 -1
- data/interface/server.rb +1 -1
- data/interface/user.rb +3 -1
- data/{interface/base_intf.rb → interface.rb} +1 -1
- data/io/input.rb +1 -1
- data/io/null_output.rb +1 -1
- data/io/string_array.rb +2 -2
- data/io/tcpclient.rb +1 -1
- data/io/tcpserver.rb +1 -1
- data/{io/base_io.rb → io.rb} +0 -0
- data/lib/debugger.rb +0 -1
- data/lib/trepanning.rb +3 -1
- data/processor/command/alias.rb +13 -2
- data/processor/command/backtrace.rb +2 -1
- data/processor/command/base/subcmd.rb +1 -5
- data/processor/command/base/submgr.rb +1 -1
- data/processor/command/base/subsubcmd.rb +1 -1
- data/processor/command/base/subsubmgr.rb +4 -4
- data/processor/command/break.rb +19 -11
- data/processor/command/catch.rb +1 -1
- data/processor/command/complete.rb +1 -1
- data/processor/command/continue.rb +7 -1
- data/processor/command/directory.rb +2 -2
- data/processor/command/disable.rb +13 -14
- data/processor/command/display.rb +3 -1
- data/processor/command/down.rb +8 -8
- data/processor/command/edit.rb +1 -1
- data/processor/command/enable.rb +21 -22
- data/processor/command/eval.rb +1 -2
- data/processor/command/exit.rb +25 -8
- data/processor/command/finish.rb +7 -2
- data/processor/command/frame.rb +1 -1
- data/processor/command/help.rb +3 -4
- data/processor/command/info.rb +2 -0
- data/processor/command/info_subcmd/files.rb +2 -2
- data/processor/command/info_subcmd/locals.rb +6 -53
- data/processor/command/info_subcmd/source.rb +10 -4
- data/processor/command/info_subcmd/variables.rb +35 -0
- data/processor/command/info_subcmd/variables_subcmd/.gitignore +1 -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/{globals.rb → variables_subcmd/globals.rb} +22 -17
- 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 +8 -7
- data/processor/command/list.rb +2 -2
- data/processor/command/macro.rb +27 -9
- data/processor/command/next.rb +1 -1
- data/processor/command/parsetree.rb +1 -1
- data/processor/command/pp.rb +1 -1
- data/processor/command/pr.rb +1 -1
- data/processor/command/ps.rb +1 -1
- data/processor/command/restart.rb +1 -1
- data/processor/command/save.rb +1 -1
- data/processor/command/set_subcmd/auto.rb +7 -1
- data/processor/command/set_subcmd/different.rb +1 -1
- data/processor/command/set_subcmd/trace.rb +5 -4
- data/processor/command/set_subcmd/trace_subcmd/print.rb +4 -3
- data/processor/command/shell.rb +5 -4
- data/processor/command/show_subcmd/{alias.rb → aliases.rb} +2 -2
- data/processor/command/source.rb +1 -1
- data/processor/command/step.rb +2 -5
- data/processor/command/tbreak.rb +1 -1
- data/processor/command/unalias.rb +13 -8
- data/processor/command/undisplay.rb +13 -9
- data/processor/command/up.rb +12 -14
- data/processor/command.rb +138 -230
- data/processor/display.rb +46 -10
- data/processor/help.rb +5 -3
- data/processor/hook.rb +2 -2
- data/processor/location.rb +25 -0
- data/processor/mock.rb +3 -2
- data/processor/msg.rb +55 -42
- data/processor/old-command.rb +270 -0
- data/processor/{processor.rb → old-processor.rb} +7 -8
- data/processor/running.rb +7 -12
- data/processor/subcmd.rb +15 -41
- data/processor/validate.rb +240 -238
- data/{processor/main.rb → processor.rb} +20 -42
- data/test/data/trace.cmd +6 -0
- data/test/data/trace.right +46 -0
- data/test/integration/helper.rb +2 -0
- data/test/integration/test-trace.rb +29 -0
- data/test/unit/cmd-helper.rb +2 -3
- data/test/unit/test-app-options.rb +13 -11
- data/test/unit/test-app-run.rb +7 -1
- data/test/unit/test-base-cmd.rb +1 -1
- data/test/unit/test-cmd-kill.rb +11 -4
- data/test/unit/test-io-tcpserver.rb +9 -4
- data/test/unit/test-proc-eval.rb +1 -2
- data/test/unit/test-proc-location.rb +26 -32
- data/test/unit/test-subcmd-help.rb +1 -1
- data/trepan8.gemspec +9 -1
- metadata +60 -17
- data/processor/command/base/cmd.rb +0 -177
@@ -1,177 +0,0 @@
|
|
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
|
-
## require 'rubygems'; require 'ruby-debug'; Debugger.start
|
10
|
-
|
11
|
-
module Trepan
|
12
|
-
class Command
|
13
|
-
attr_accessor :core, :proc
|
14
|
-
|
15
|
-
unless defined?(MIN_ARGS)
|
16
|
-
MIN_ARGS = 0 # run()'s args array must be at least this many
|
17
|
-
MAX_ARGS = nil # run()'s args array must be at least this many
|
18
|
-
NEED_STACK = false # We'll say that commands which need a stack
|
19
|
-
# to run have to declare that and those that
|
20
|
-
# don't don't have to mention it.
|
21
|
-
end
|
22
|
-
|
23
|
-
def initialize(proc)
|
24
|
-
@name = my_const(:NAME)
|
25
|
-
@proc = proc
|
26
|
-
end
|
27
|
-
|
28
|
-
def category
|
29
|
-
my_const(:CATEGORY)
|
30
|
-
end
|
31
|
-
|
32
|
-
# List commands arranged in an aligned columns
|
33
|
-
def columnize_commands(commands)
|
34
|
-
width = settings[:maxwidth]
|
35
|
-
Columnize::columnize(commands, width, ' ' * 4,
|
36
|
-
true, true, ' ' * 2).chomp
|
37
|
-
end
|
38
|
-
|
39
|
-
def columnize_numbers(commands)
|
40
|
-
width = settings[:maxwidth]
|
41
|
-
Columnize::columnize(commands, width, ', ',
|
42
|
-
false, false, ' ' * 2).chomp
|
43
|
-
end
|
44
|
-
|
45
|
-
# FIXME: probably there is a way to do the delegation to proc methods
|
46
|
-
# without having type it all out.
|
47
|
-
|
48
|
-
def confirm(message, default)
|
49
|
-
@proc.confirm(message, default)
|
50
|
-
end
|
51
|
-
|
52
|
-
def errmsg(message, opts={})
|
53
|
-
@proc.errmsg(message, opts)
|
54
|
-
end
|
55
|
-
|
56
|
-
def obj_const(obj, name)
|
57
|
-
obj.class.const_get(name)
|
58
|
-
end
|
59
|
-
|
60
|
-
def msg(message, opts={})
|
61
|
-
@proc.msg(message, opts)
|
62
|
-
end
|
63
|
-
|
64
|
-
# Convenience short-hand for @dbgr.intf[-1].msg_nocr
|
65
|
-
def msg_nocr(msg, opts={})
|
66
|
-
@proc.msg_nocr(msg, opts)
|
67
|
-
end
|
68
|
-
|
69
|
-
def my_const(name)
|
70
|
-
# Set class constant SHORT_HELP to be the first line of HELP
|
71
|
-
# unless it has been defined in the class already.
|
72
|
-
# The below was the simplest way I could find to do this since
|
73
|
-
# we are the super class but want to set the subclass's constant.
|
74
|
-
# defined? didn't seem to work here.
|
75
|
-
c = self.class.constants
|
76
|
-
if (c.member?('HELP') || c.member?(:HELP)) and
|
77
|
-
!(c.member?('SHORT_HELP') || c.member?(:SHORT_HELP))
|
78
|
-
help = self.class.const_get(:HELP) || self.class.const_get('HELP')
|
79
|
-
short_help = help.split("\n")[0].chomp('.')
|
80
|
-
self.class.const_set(:SHORT_HELP, short_help)
|
81
|
-
end
|
82
|
-
self.class.const_get(name)
|
83
|
-
end
|
84
|
-
|
85
|
-
def name
|
86
|
-
self.class.const_get(:NAME)
|
87
|
-
end
|
88
|
-
|
89
|
-
# The method that implements the debugger command.
|
90
|
-
def run(*args)
|
91
|
-
raise RuntimeError, 'You need to define this method elsewhere'
|
92
|
-
end
|
93
|
-
|
94
|
-
def section(message, opts={})
|
95
|
-
## debugger
|
96
|
-
@proc.section(message, opts)
|
97
|
-
end
|
98
|
-
|
99
|
-
def settings
|
100
|
-
@proc.settings
|
101
|
-
end
|
102
|
-
|
103
|
-
def short_help
|
104
|
-
help_constant_sym = if self.class.constants.member?('SHORT_HELP')
|
105
|
-
:SHORT_HELP
|
106
|
-
else :HELP
|
107
|
-
end
|
108
|
-
my_const(help_constant_sym)
|
109
|
-
end
|
110
|
-
|
111
|
-
# Define a method called 'complete' on the singleton class.
|
112
|
-
def self.completion(ary)
|
113
|
-
self.send(:define_method,
|
114
|
-
:complete,
|
115
|
-
Proc.new {|prefix|
|
116
|
-
Trepan::Complete.complete_token(ary, prefix) })
|
117
|
-
end
|
118
|
-
|
119
|
-
# From reference debugger
|
120
|
-
def run_code(str)
|
121
|
-
@proc.dbgr.current_frame.run(str)
|
122
|
-
end
|
123
|
-
|
124
|
-
def current_method
|
125
|
-
@proc.frame.method
|
126
|
-
end
|
127
|
-
|
128
|
-
def current_frame
|
129
|
-
@proc.frame
|
130
|
-
end
|
131
|
-
|
132
|
-
def variables
|
133
|
-
@proc.variables
|
134
|
-
end
|
135
|
-
|
136
|
-
def listen(step=false)
|
137
|
-
@proc.listen(step)
|
138
|
-
end
|
139
|
-
|
140
|
-
end
|
141
|
-
end
|
142
|
-
if __FILE__ == $0
|
143
|
-
module Trepan
|
144
|
-
class CmdProcessor
|
145
|
-
def initialize(dbgr)
|
146
|
-
end
|
147
|
-
def confirm(message, default)
|
148
|
-
p ['confirm: ', message, default]
|
149
|
-
end
|
150
|
-
def errmsg(message, opts)
|
151
|
-
p ['err:', message, opts]
|
152
|
-
end
|
153
|
-
def msg(message, opts)
|
154
|
-
p [message, opts]
|
155
|
-
end
|
156
|
-
def msg_nocr(message, opts)
|
157
|
-
p ['nocr: ', message, opts]
|
158
|
-
end
|
159
|
-
def section(message, opts)
|
160
|
-
p ['section: ', message, opts]
|
161
|
-
end
|
162
|
-
end
|
163
|
-
class Command::Test < Trepan::Command
|
164
|
-
NAME = 'test'
|
165
|
-
CATEGORY = 'testcategory'
|
166
|
-
completion %w(a aa ab ba aac)
|
167
|
-
end
|
168
|
-
end
|
169
|
-
proc = Trepan::CmdProcessor.new(nil)
|
170
|
-
cmd = Trepan::Command::Test.new(proc)
|
171
|
-
%w(confirm errmsg msg msg_nocr section).each do |meth|
|
172
|
-
cmd.send(meth, 'test', nil)
|
173
|
-
end
|
174
|
-
p cmd.complete('aa')
|
175
|
-
cmd.instance_variable_set('@completions', %w(aardvark apple))
|
176
|
-
p cmd.complete('aa')
|
177
|
-
end
|