rbx-trepanning 0.0.2-universal-rubinius-1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +376 -0
- data/LICENSE +25 -0
- data/NEWS +2 -0
- data/README.textile +35 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +218 -0
- data/app/breakpoint.rbc +3564 -0
- data/app/brkptmgr.rb +138 -0
- data/app/brkptmgr.rbc +2827 -0
- data/app/default.rb +61 -0
- data/app/default.rbc +1011 -0
- data/app/display.rb +35 -0
- data/app/display.rbc +968 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +112 -0
- data/app/irb.rbc +2111 -0
- data/app/iseq.rb +95 -0
- data/app/iseq.rbc +1801 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +123 -0
- data/app/options.rbc +2183 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1144 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +63 -0
- data/bin/trepanx.compiled.rbc +985 -0
- data/interface/base_intf.rb +95 -0
- data/interface/base_intf.rbc +1742 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/user.rb +91 -0
- data/interface/user.rbc +1418 -0
- data/io/base_io.rb +94 -0
- data/io/base_io.rbc +1404 -0
- data/io/input.rb +112 -0
- data/io/input.rbc +1979 -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/lib/trepanning.rb +398 -0
- data/lib/trepanning.rbc +6661 -0
- data/processor/breakpoint.rb +161 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +46 -0
- data/processor/command/base/cmd.rb +124 -0
- data/processor/command/base/subcmd.rb +213 -0
- data/processor/command/base/submgr.rb +179 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +184 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/continue.rb +82 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +43 -0
- data/processor/command/disassemble.rb +103 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +31 -0
- data/processor/command/exit.rb +58 -0
- data/processor/command/finish.rb +78 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +146 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +75 -0
- data/processor/command/info_subcmd/file.rb +153 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +59 -0
- data/processor/command/info_subcmd/variables.rb +40 -0
- data/processor/command/irb.rb +96 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +296 -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/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +28 -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 +26 -0
- data/processor/command/set_subcmd/debug.rb +27 -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 +60 -0
- data/processor/command/set_subcmd/hidelevel.rb +63 -0
- data/processor/command/set_subcmd/kernelstep.rb +61 -0
- data/processor/command/set_subcmd/max.rb +29 -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 +54 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/substitute.rb +25 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +37 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +27 -0
- data/processor/command/show_subcmd/alias.rb +43 -0
- data/processor/command/show_subcmd/args.rb +26 -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 +22 -0
- data/processor/command/show_subcmd/debug.rb +27 -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 +27 -0
- data/processor/command/show_subcmd/hidelevel.rb +42 -0
- data/processor/command/show_subcmd/kernelstep.rb +37 -0
- data/processor/command/show_subcmd/max.rb +30 -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 +29 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/source.rb +83 -0
- data/processor/command/step.rb +49 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/up.rb +87 -0
- data/processor/default.rb +56 -0
- data/processor/disassemble.rb +32 -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 +101 -0
- data/processor/location.rb +128 -0
- data/processor/main.rb +394 -0
- data/processor/mock.rb +137 -0
- data/processor/msg.rb +28 -0
- data/processor/running.rb +230 -0
- data/processor/stepping.rb +115 -0
- data/processor/subcmd.rb +160 -0
- data/processor/validate.rb +355 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +1 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +0 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-xx.rb +18 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/gcd1.rb +24 -0
- data/test/example/null.rb +1 -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/test-fname-with-blank.rb +12 -0
- data/test/integration/test-quit.rb +25 -0
- data/test/unit/cmd-helper.rb +46 -0
- data/test/unit/test-app-brkpt.rb +30 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-iseq.rb +49 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +61 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +28 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +49 -0
- data/test/unit/test-cmd-break.rb +23 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-help.rb +101 -0
- data/test/unit/test-cmd-kill.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-proc-eval.rb +37 -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 +41 -0
- data/test/unit/test-proc-location.rb +48 -0
- data/test/unit/test-proc-main.rb +96 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +51 -0
- metadata +337 -0
@@ -0,0 +1,296 @@
|
|
1
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
2
|
+
# -*- coding: utf-8 -*-
|
3
|
+
require 'rubygems'
|
4
|
+
require 'require_relative'
|
5
|
+
require 'linecache'
|
6
|
+
require_relative 'base/cmd'
|
7
|
+
|
8
|
+
class Trepan::Command::ListCommand < Trepan::Command
|
9
|
+
unless defined?(HELP)
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
HELP = <<-HELP
|
12
|
+
#{NAME}[>] [FIRST [NUM]]
|
13
|
+
#{NAME}[>] LOCATION [NUM]
|
14
|
+
|
15
|
+
#{NAME} source code.
|
16
|
+
|
17
|
+
Without arguments, prints lines centered around the current
|
18
|
+
line. If this is the first #{NAME} command issued since the debugger
|
19
|
+
command loop was entered, then the current line is the current
|
20
|
+
frame. If a subsequent #{NAME} command was issued with no intervening
|
21
|
+
frame changing, then that is start the line after we last one
|
22
|
+
previously shown.
|
23
|
+
|
24
|
+
If the command has a '>' suffix, then line centering is disabled and
|
25
|
+
listing begins at the specificed location.
|
26
|
+
|
27
|
+
The number of line to show is controled by the debugger listsize
|
28
|
+
setting. Use 'set listsize' or 'show listsize' to see or set the
|
29
|
+
value.
|
30
|
+
|
31
|
+
\"#{NAME} -\" shows lines before a previous listing.
|
32
|
+
|
33
|
+
A LOCATION is a either
|
34
|
+
- number, e.g. 5,
|
35
|
+
- a function, e.g. join or os.path.join
|
36
|
+
- a module, e.g. os or os.path
|
37
|
+
- a filename, colon, and a number, e.g. foo.rb:5,
|
38
|
+
- or a module name and a number, e.g,. os.path:5.
|
39
|
+
- a '.' for the current line number
|
40
|
+
- a '-' for the lines before the current line number
|
41
|
+
|
42
|
+
If the location form is used with a subsequent parameter, the
|
43
|
+
parameter is the starting line number. When there two numbers are
|
44
|
+
given, the last number value is treated as a stopping line unless it
|
45
|
+
is less than the start line, in which case it is taken to mean the
|
46
|
+
number of lines to list instead.
|
47
|
+
|
48
|
+
Wherever a number is expected, it does not need to be a constant --
|
49
|
+
just something that evaluates to a positive integer.
|
50
|
+
|
51
|
+
Some examples:
|
52
|
+
|
53
|
+
#{NAME} 5 # List centered around line 5
|
54
|
+
#{NAME} 4+1 # Same as above.
|
55
|
+
#{NAME} 5> # List starting at line 5
|
56
|
+
#{NAME} foo.rb:5 # List centered around line 5 of foo.rb
|
57
|
+
#{NAME} foo.rb 5 # Same as above.
|
58
|
+
#{NAME} foo.rb:5> # List starting around line 5 of foo.rb
|
59
|
+
#{NAME} foo.rb 5 6 # list lines 5 and 6 of foo.rb
|
60
|
+
#{NAME} foo.rb 5 2 # Same as above, since 2 < 5.
|
61
|
+
#{NAME} foo.rb:5 2 # Same as above
|
62
|
+
#{NAME} FileUtils.cp # List lines around the FileUtils.cp function.
|
63
|
+
#{NAME} . # List lines centered from where we currently are stopped
|
64
|
+
#{NAME} . 3 # List 3 lines starting from where we currently are stopped
|
65
|
+
# if . > 3. Otherwise we list from . to 3.
|
66
|
+
#{NAME} - # List lines previous to those just shown
|
67
|
+
|
68
|
+
HELP
|
69
|
+
|
70
|
+
ALIASES = %W(l #{NAME}> l>)
|
71
|
+
CATEGORY = 'files'
|
72
|
+
MAX_ARGS = 3
|
73
|
+
SHORT_HELP = 'List source code'
|
74
|
+
end
|
75
|
+
|
76
|
+
# If last is less than first, assume last is a count rather than an
|
77
|
+
# end line number.
|
78
|
+
def adjust_last(first, last)
|
79
|
+
last < first ? first + last - 1 : last
|
80
|
+
end
|
81
|
+
|
82
|
+
# What a f*cking mess. Necessitated I suppose because we want to
|
83
|
+
# allow somewhat flexible parsing with either module names, files or none
|
84
|
+
# and optional line counts or end-line numbers.
|
85
|
+
|
86
|
+
# Parses arguments for the "list" command and returns the tuple:
|
87
|
+
# filename, start, last
|
88
|
+
# or sets these to nil if there was some problem.
|
89
|
+
def parse_list_cmd(args, listsize, center_correction)
|
90
|
+
|
91
|
+
last = nil
|
92
|
+
|
93
|
+
if args.size > 0
|
94
|
+
if args[0] == '-'
|
95
|
+
return no_frame_msg unless @proc.line_no
|
96
|
+
first = [1, @proc.line_no - 2*listsize - 1].max
|
97
|
+
file = @proc.frame.file
|
98
|
+
elsif args[0] == '.'
|
99
|
+
return no_frame_msg unless @proc.line_no
|
100
|
+
if args.size == 2
|
101
|
+
opts = {
|
102
|
+
:msg_on_error =>
|
103
|
+
"#{NAME} command last or count parameter expected, " +
|
104
|
+
'got: %s.' % args[2]
|
105
|
+
}
|
106
|
+
second = @proc.get_an_int(args[1], opts)
|
107
|
+
return nil, nil, nil unless second
|
108
|
+
first = @proc.frame.line
|
109
|
+
last = adjust_last(first, second)
|
110
|
+
else
|
111
|
+
first = [1, @proc.frame.line - center_correction].max
|
112
|
+
end
|
113
|
+
|
114
|
+
file = @proc.frame.file
|
115
|
+
else
|
116
|
+
modfunc, file, first = @proc.parse_position(args[0])
|
117
|
+
if first == nil and modfunc == nil
|
118
|
+
# error should have been shown previously
|
119
|
+
return nil, nil, nil
|
120
|
+
end
|
121
|
+
if args.size == 1
|
122
|
+
first = 1 if !first and modfunc
|
123
|
+
first = [1, first - center_correction].max
|
124
|
+
elsif args.size == 2 or (args.size == 3 and modfunc)
|
125
|
+
opts = {
|
126
|
+
:msg_on_error =>
|
127
|
+
"#{NAME} command starting line expected, got %s." % args[-1]
|
128
|
+
}
|
129
|
+
last = @proc.get_an_int(args[1], opts)
|
130
|
+
return nil, nil, nil unless last
|
131
|
+
if modfunc
|
132
|
+
if first
|
133
|
+
first = last
|
134
|
+
if args.size == 3 and modfunc
|
135
|
+
opts[:msg_on_error] =
|
136
|
+
("#{NAME} command last or count parameter expected, " +
|
137
|
+
'got: %s.' % args[2])
|
138
|
+
last = @proc.get_an_int(args[2], opts)
|
139
|
+
return nil, nil, nil unless last
|
140
|
+
end
|
141
|
+
end
|
142
|
+
end
|
143
|
+
last = adjust_last(first, last)
|
144
|
+
elsif not modfunc
|
145
|
+
errmsg('At most 2 parameters allowed when no module' +
|
146
|
+
' name is found/given. Saw: %d parameters' % args.size)
|
147
|
+
return nil, nil, nil
|
148
|
+
else
|
149
|
+
errmsg(('At most 3 parameters allowed when a module' +
|
150
|
+
' name is given. Saw: %d parameters') % args.size)
|
151
|
+
return nil, nil, nil
|
152
|
+
end
|
153
|
+
end
|
154
|
+
elsif !@proc.line_no and @proc.frame
|
155
|
+
first = [1, @proc.frame.line - center_correction].max
|
156
|
+
file = @proc.frame.file
|
157
|
+
else
|
158
|
+
first = [1, @proc.line_no - center_correction].max
|
159
|
+
file = @proc.frame.file
|
160
|
+
end
|
161
|
+
last = first + listsize - 1 unless last
|
162
|
+
|
163
|
+
if @proc.frame.eval?
|
164
|
+
script = @proc.frame.vm_location.static_scope.script
|
165
|
+
LineCache::cache(script)
|
166
|
+
else
|
167
|
+
LineCache::cache(file)
|
168
|
+
script = nil
|
169
|
+
end
|
170
|
+
return file, script, first, last
|
171
|
+
end
|
172
|
+
|
173
|
+
def no_frame_msg
|
174
|
+
errmsg("No Ruby program loaded.")
|
175
|
+
return nil, nil, nil
|
176
|
+
end
|
177
|
+
|
178
|
+
def run(args)
|
179
|
+
listsize = settings[:maxlist]
|
180
|
+
center_correction =
|
181
|
+
if args[0][-1..-1] == '>'
|
182
|
+
0
|
183
|
+
else
|
184
|
+
(listsize-1) / 2
|
185
|
+
end
|
186
|
+
|
187
|
+
file, script, first, last =
|
188
|
+
parse_list_cmd(args[1..-1], listsize, center_correction)
|
189
|
+
frame = @proc.frame
|
190
|
+
return unless file
|
191
|
+
|
192
|
+
cached_item = script || file
|
193
|
+
|
194
|
+
# We now have range information. Do the listing.
|
195
|
+
max_line = LineCache::size(cached_item)
|
196
|
+
|
197
|
+
# FIXME: join with line_at of location.rb
|
198
|
+
unless max_line && file
|
199
|
+
# Try using search directories (set with command "directory")
|
200
|
+
if file[0..0] != File::SEPARATOR
|
201
|
+
try_filename = @proc.resolve_file_with_dir(file)
|
202
|
+
if try_filename &&
|
203
|
+
max_line = LineCache::size(try_filename)
|
204
|
+
LineCache::remap_file(file, try_filename)
|
205
|
+
end
|
206
|
+
end
|
207
|
+
end
|
208
|
+
|
209
|
+
unless max_line
|
210
|
+
errmsg('File "%s" not found.' % file)
|
211
|
+
return
|
212
|
+
end
|
213
|
+
|
214
|
+
if first > max_line
|
215
|
+
errmsg('Bad line range [%d...%d]; file "%s" has only %d lines' %
|
216
|
+
[first, last, file, max_line])
|
217
|
+
return
|
218
|
+
end
|
219
|
+
|
220
|
+
if last > max_line
|
221
|
+
# msg('End position changed to last line %d ' % max_line)
|
222
|
+
last = max_line
|
223
|
+
end
|
224
|
+
|
225
|
+
begin
|
226
|
+
first.upto(last).each do |lineno|
|
227
|
+
line = LineCache::getline(cached_item, lineno,
|
228
|
+
@proc.reload_on_change)
|
229
|
+
unless line
|
230
|
+
msg('[EOF]')
|
231
|
+
break
|
232
|
+
end
|
233
|
+
line.chomp!
|
234
|
+
s = '%3d' % lineno
|
235
|
+
s = s + ' ' if s.size < 4
|
236
|
+
s += (@proc.frame && lineno == @proc.frame.vm_location.line) ? '->' : ' '
|
237
|
+
# && container == frame.source_container)
|
238
|
+
msg(s + "\t" + line)
|
239
|
+
@proc.line_no = lineno
|
240
|
+
end
|
241
|
+
rescue => e
|
242
|
+
errmsg e.to_s if settings[:debugexcept]
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
if __FILE__ == $0
|
248
|
+
require_relative '../location'
|
249
|
+
require_relative '../mock'
|
250
|
+
require_relative '../frame'
|
251
|
+
dbgr, cmd = MockDebugger::setup
|
252
|
+
cmd.proc.send('frame_initialize')
|
253
|
+
LineCache::cache(__FILE__)
|
254
|
+
cmd.run([cmd.name])
|
255
|
+
cmd.run([cmd.name, __FILE__ + ':10'])
|
256
|
+
|
257
|
+
def run_cmd(cmd, args)
|
258
|
+
seps = '--' * 10
|
259
|
+
puts "%s %s %s" % [seps, args.join(' '), seps]
|
260
|
+
cmd.run(args)
|
261
|
+
end
|
262
|
+
|
263
|
+
|
264
|
+
load 'tmpdir.rb'
|
265
|
+
run_cmd(cmd, %W(#{cmd.name} tmpdir.rb 10))
|
266
|
+
run_cmd(cmd, %W(#{cmd.name} tmpdir.rb))
|
267
|
+
|
268
|
+
run_cmd(cmd, %W(cmd.name .))
|
269
|
+
run_cmd(cmd, %W(cmd.name 30))
|
270
|
+
|
271
|
+
# cmd.run(['list', '9+1'])
|
272
|
+
|
273
|
+
run_cmd(cmd, %W(cmd.name> 10))
|
274
|
+
run_cmd(cmd, %W(cmd.name 3000))
|
275
|
+
run_cmd(cmd, %W(cmd.name run_cmd))
|
276
|
+
|
277
|
+
p = Proc.new do
|
278
|
+
|x,y| x + y
|
279
|
+
end
|
280
|
+
run_cmd(cmd, %W(#{cmd.name} p))
|
281
|
+
|
282
|
+
# Function from a file found via an instruction sequence
|
283
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize))
|
284
|
+
|
285
|
+
# Use Class/method name. 15 isn't in the function - should this be okay?
|
286
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize 15))
|
287
|
+
|
288
|
+
# Start line and count, since 3 < 30
|
289
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize 30 3))
|
290
|
+
|
291
|
+
# Start line finish line
|
292
|
+
run_cmd(cmd, %W(#{cmd.name} Columnize.columnize 40 50))
|
293
|
+
|
294
|
+
# Method name
|
295
|
+
run_cmd(cmd, %W(#{cmd.name} cmd.run))
|
296
|
+
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 Trepanning::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 = Trepanning::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 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, @proc.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 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, @proc.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,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
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../base/subsubcmd'
|
5
|
+
require_relative '../base/subsubmgr'
|
6
|
+
|
7
|
+
class Trepan::SubSubcommand::SetAuto < Trepan::SubSubcommandMgr
|
8
|
+
unless defined?(HELP)
|
9
|
+
HELP = 'Set controls for things with some sort of "automatic" default behavior'
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
PREFIX = %W(set #{NAME})
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
if __FILE__ == $0
|
16
|
+
require_relative '../../mock'
|
17
|
+
dbgr, cmd = MockDebugger::setup('set')
|
18
|
+
# cmds = dbgr.core.processor.commands
|
19
|
+
# set_cmd = cmds['set']
|
20
|
+
# command = Trepan::SubSubcommand::SetAuto.new(dbgr.core.processor,
|
21
|
+
# set_cmd)
|
22
|
+
# name = File.basename(__FILE__, '.rb')
|
23
|
+
# cmd_args = ['set', name]
|
24
|
+
# set_cmd.instance_variable_set('@last_args', cmd_args)
|
25
|
+
# # require_relative '../../../lib/trepanning'
|
26
|
+
# # Trepan.debug(:set_restart => true)
|
27
|
+
# command.run(cmd_args)
|
28
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../base/subsubcmd'
|
5
|
+
|
6
|
+
class Trepan::Subcommand::SetAutoDis < Trepan::SetBoolSubSubcommand
|
7
|
+
unless defined?(HELP)
|
8
|
+
HELP = "Set to run a 'disassemble' command each time we enter the debugger"
|
9
|
+
MIN_ABBREV = 'd'.size
|
10
|
+
NAME = File.basename(__FILE__, '.rb')
|
11
|
+
PREFIX = %W(set auto #{NAME})
|
12
|
+
SHORT_HELP = "Set running a 'disassemble' command each time we enter the debugger"
|
13
|
+
end
|
14
|
+
|
15
|
+
def run(args)
|
16
|
+
super
|
17
|
+
if @proc.settings[:autodis]
|
18
|
+
@proc.cmdloop_prehooks.insert_if_new(10, *@proc.autodis_hook)
|
19
|
+
else
|
20
|
+
@proc.cmdloop_prehooks.delete_by_name('autodis')
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
if __FILE__ == $0
|
27
|
+
# Demo it.
|
28
|
+
require_relative '../../../mock'
|
29
|
+
require_relative '../auto'
|
30
|
+
cmd = MockDebugger::subsub_setup(Trepan::SubSubcommand::SetAuto,
|
31
|
+
Trepan::SubSubcommand::SetAutoDis)
|
32
|
+
cmd.run([cmd.name, 'off'])
|
33
|
+
end
|