rbx-trepanning 0.0.7-universal-rubinius-1.2 → 0.0.8-universal-rubinius-1.2
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +236 -0
- data/NEWS +16 -0
- data/Rakefile +60 -11
- data/app/breakpoint.rb +5 -1
- data/app/brkptmgr.rb +5 -0
- data/app/cmd_parse.kpeg +225 -0
- data/app/cmd_parse.rb +209 -0
- data/app/cmd_parser.rb +1894 -0
- data/app/default.rb +0 -1
- data/app/method.rb +12 -8
- data/app/options.rb +2 -9
- data/app/validate.rb +2 -2
- data/bin/trepanx +3 -3
- data/lib/trepanning.rb +9 -6
- data/processor/breakpoint.rb +5 -19
- data/processor/command/alias.rb +4 -5
- data/processor/command/base/submgr.rb +2 -2
- data/processor/command/break.rb +44 -66
- data/processor/command/condition.rb +2 -0
- data/processor/command/continue.rb +11 -41
- data/processor/command/disassemble.rb +2 -0
- data/processor/command/eval.rb +20 -8
- data/processor/command/exit.rb +3 -2
- data/{doc → processor/command/help}/.gitignore +0 -0
- data/processor/command/help/command.txt +48 -0
- data/processor/command/help/filename.txt +40 -0
- data/processor/command/help/location.txt +37 -0
- data/processor/command/help.rb +52 -73
- data/processor/command/info_subcmd/breakpoints.rb +35 -13
- data/processor/command/info_subcmd/files.rb +34 -25
- data/processor/command/info_subcmd/frame.rb +67 -0
- data/processor/command/kill.rb +0 -1
- data/processor/command/restart.rb +8 -8
- data/processor/command/save.rb +58 -0
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +1 -1
- data/processor/command/set_subcmd/trace_subcmd/print.rb +1 -1
- data/processor/command/show.rb +7 -6
- data/processor/command/step.rb +16 -3
- data/processor/command/tbreak.rb +1 -1
- data/processor/disassemble.rb +1 -1
- data/processor/help.rb +20 -0
- data/processor/load_cmds.rb +53 -4
- data/processor/location.rb +47 -1
- data/processor/main.rb +4 -9
- data/processor/mock.rb +3 -3
- data/processor/running.rb +16 -17
- data/processor/validate.rb +171 -159
- data/rbx-trepanning.gemspec +1 -1
- data/test/example/debugger-stop.rb +16 -0
- data/test/functional/test-break-name.rb +1 -1
- data/test/functional/test-eval.rb +115 -0
- data/test/functional/test-tbreak.rb +1 -1
- data/test/integration/helper.rb +5 -2
- data/test/unit/cmd-helper.rb +1 -1
- data/test/unit/test-app-cmd_parse.rb +97 -0
- data/test/unit/test-app-cmd_parser.rb +22 -0
- data/test/unit/test-app-options.rb +1 -0
- data/test/unit/test-app-validate.rb +2 -2
- data/test/unit/test-cmd-break.rb +47 -5
- data/test/unit/test-completion.rb +2 -1
- data/test/unit/test-proc-location.rb +11 -0
- data/test/unit/test-proc-validate.rb +68 -30
- metadata +26 -11
- data/doc/debugger.html +0 -108
data/processor/validate.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
|
3
3
|
# Trepan command input validation routines. A String type is
|
4
4
|
# usually passed in as the argument to validation routines.
|
@@ -6,10 +6,15 @@
|
|
6
6
|
require 'rubygems'
|
7
7
|
require 'require_relative'
|
8
8
|
require 'linecache'
|
9
|
+
|
10
|
+
require_relative '../app/cmd_parse'
|
11
|
+
require_relative '../app/condition'
|
9
12
|
require_relative '../app/method'
|
10
13
|
require_relative '../app/validate'
|
11
|
-
|
12
|
-
|
14
|
+
|
15
|
+
require_relative 'location' # for resolve_file_with_dir
|
16
|
+
require_relative 'msg' # for errmsg, msg
|
17
|
+
|
13
18
|
class Trepan
|
14
19
|
class CmdProcessor
|
15
20
|
|
@@ -19,7 +24,7 @@ class Trepan
|
|
19
24
|
include Trepanning::Method
|
20
25
|
include Trepan::Validate
|
21
26
|
## include Trepan::ThreadHelper
|
22
|
-
|
27
|
+
include Trepan::Condition
|
23
28
|
|
24
29
|
def confirm(msg, default)
|
25
30
|
@settings[:confirm] ? @dbgr.intf[-1].confirm(msg, default) : true
|
@@ -129,70 +134,56 @@ class Trepan
|
|
129
134
|
end
|
130
135
|
end
|
131
136
|
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
return nil
|
147
|
-
elsif args.size == 2
|
148
|
-
ip, line = line_or_ip(args[1])
|
149
|
-
unless line || ip
|
150
|
-
errmsg ("Expecting a line or an IP offset number")
|
151
|
-
return nil
|
137
|
+
def position_to_line_and_offset(cm, filename, position, offset_type)
|
138
|
+
case offset_type
|
139
|
+
when :line
|
140
|
+
vm_offset = cm.first_ip_on_line(position, -2)
|
141
|
+
line_no = position
|
142
|
+
when :offset
|
143
|
+
line_no = cm.line_from_ip(position)
|
144
|
+
vm_offset = position
|
145
|
+
when nil
|
146
|
+
vm_offset, line_no =
|
147
|
+
if cm.lines[0] == -1
|
148
|
+
[cm.lines[2], cm.lines.size > 3 ? cm.lines[3] : cm.lines[1]]
|
149
|
+
else
|
150
|
+
[cm.lines[0], cm.lines[1]]
|
152
151
|
end
|
152
|
+
else
|
153
|
+
errmsg "Bad parse offset_type: #{offset_type.inspect}"
|
154
|
+
return [nil, nil]
|
155
|
+
end
|
156
|
+
return [line_no, vm_offset]
|
157
|
+
end
|
158
|
+
|
159
|
+
# Parse a breakpoint position. On success return:
|
160
|
+
# - the CompileMethod the position is in
|
161
|
+
# - the line number - a Fixnum
|
162
|
+
# - vm_offset - a Fixnum
|
163
|
+
# - the condition (by default 'true') to use for this breakpoint
|
164
|
+
# - true condition should be negated. Used in *condition* if/unless
|
165
|
+
def breakpoint_position(position_str, allow_condition)
|
166
|
+
break_cmd_parse = if allow_condition
|
167
|
+
parse_breakpoint(position_str)
|
168
|
+
else
|
169
|
+
parse_breakpoint_no_condition(position_str)
|
170
|
+
end
|
171
|
+
return [nil] * 5 unless break_cmd_parse
|
172
|
+
tail = [break_cmd_parse.condition, break_cmd_parse.negate]
|
173
|
+
cm, file, position, offset_type =
|
174
|
+
parse_position(break_cmd_parse.position)
|
175
|
+
if cm
|
176
|
+
line_no, vm_offset =
|
177
|
+
position_to_line_and_offset(cm, file, position, offset_type)
|
178
|
+
if vm_offset && line_no
|
179
|
+
return [cm, line_no, vm_offset] + tail
|
153
180
|
else
|
154
|
-
|
155
|
-
|
156
|
-
return [args.join(' '), '.', '__script__', line, ip]
|
157
|
-
elsif args.size == 1
|
158
|
-
meth = parse_method(args[0])
|
159
|
-
if meth
|
160
|
-
cm = meth.executable
|
161
|
-
return [args[0], nil, true, cm, cm.lines[1], cm.lines[0]]
|
162
|
-
else
|
163
|
-
m = /([A-Z]\w*(?:::[A-Z]\w*)*)([.#])(\w+[!?=]?)(?:[:]([oO])?(\d+))?/.match(args[0])
|
164
|
-
if m
|
165
|
-
if m[4]
|
166
|
-
return [m[0], m[1], m[2], m[3], nil, m[5] ? m[5].to_i : nil]
|
167
|
-
else
|
168
|
-
return [m[0], m[1], m[2], m[3], (m[4] ? m[4].to_i : nil), nil]
|
169
|
-
end
|
170
|
-
else
|
171
|
-
ip, line = line_or_ip(args[0])
|
172
|
-
unless line || ip
|
173
|
-
errmsg ("Expecting a line or an IP offset number")
|
174
|
-
return nil
|
175
|
-
end
|
176
|
-
if line
|
177
|
-
meth = find_method_with_line(frame.method, line)
|
178
|
-
unless meth
|
179
|
-
errmsg "Cannot find method location for line #{line}"
|
180
|
-
return nil
|
181
|
-
end
|
182
|
-
return [meth.name.to_s, nil, '#', meth, line, nil]
|
183
|
-
elsif valid_ip?(frame.method, ip)
|
184
|
-
return [args.join(' '), meth.class, '#', frame.method, nil, ip]
|
185
|
-
else
|
186
|
-
errmsg 'Cannot parse breakpoint location'
|
187
|
-
return nil
|
188
|
-
end
|
189
|
-
|
190
|
-
return ["#{meth.describe}", nil, '#', meth, line, nil]
|
191
|
-
end
|
181
|
+
errmsg("Unable to set breakpoint in #{cm}")
|
182
|
+
return
|
192
183
|
end
|
193
184
|
end
|
194
|
-
errmsg
|
195
|
-
return nil
|
185
|
+
errmsg("Unable to get breakpoint position for #{position_str}")
|
186
|
+
return [nil] * 5
|
196
187
|
end
|
197
188
|
|
198
189
|
# Return true if arg is 'on' or 1 and false arg is 'off' or 0.
|
@@ -216,95 +207,94 @@ class Trepan
|
|
216
207
|
raise TypeError
|
217
208
|
end
|
218
209
|
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
|
210
|
+
include CmdParser
|
211
|
+
|
212
|
+
def get_method(meth)
|
213
|
+
start_binding =
|
214
|
+
begin
|
215
|
+
@frame.binding
|
216
|
+
rescue
|
217
|
+
binding
|
225
218
|
end
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
219
|
+
if meth.kind_of?(String)
|
220
|
+
meth_for_string(meth, start_binding)
|
221
|
+
else
|
222
|
+
begin
|
223
|
+
meth_for_parse_struct(meth, start_binding)
|
224
|
+
rescue NameError
|
225
|
+
errmsg("Can't evaluate #{meth.name} to get a method")
|
226
|
+
return nil
|
227
|
+
end
|
228
|
+
end
|
229
|
+
end
|
230
|
+
|
231
|
+
# FIXME: this is a ? method but we return
|
232
|
+
# the method value.
|
233
|
+
def method?(meth)
|
234
|
+
get_method(meth)
|
230
235
|
end
|
231
236
|
|
232
|
-
# parse_position(self, arg)->(
|
233
|
-
#
|
237
|
+
# parse_position(self, arg)->(meth, filename, offset, offset_type)
|
238
|
+
# See app/cmd_parser.kpeg for the syntax of a position which
|
239
|
+
# should include things like:
|
234
240
|
# Parse arg as [filename:]lineno | function | module
|
235
241
|
# Make sure it works for C:\foo\bar.py:12
|
236
|
-
def parse_position(
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
242
|
+
def parse_position(info)
|
243
|
+
info = parse_location(info) if info.kind_of?(String)
|
244
|
+
case info.container_type
|
245
|
+
when :fn
|
246
|
+
unless info.container
|
247
|
+
errmsg "Bad function parse #{info.container.inspect}"
|
248
|
+
return
|
249
|
+
end
|
250
|
+
if meth = method?(info.container)
|
251
|
+
cm = meth.executable
|
252
|
+
return [cm, canonic_file(cm.active_path), info.position,
|
253
|
+
info.position_type]
|
248
254
|
else
|
249
|
-
|
255
|
+
return [nil] * 4
|
250
256
|
end
|
251
|
-
|
252
|
-
|
253
|
-
|
254
|
-
|
255
|
-
|
256
|
-
|
257
|
-
|
258
|
-
|
259
|
-
|
260
|
-
|
261
|
-
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
266
|
-
|
267
|
-
|
268
|
-
|
269
|
-
|
270
|
-
|
271
|
-
|
272
|
-
|
273
|
-
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
# How about a method name with an instruction sequence?
|
279
|
-
meth = parse_method(arg)
|
280
|
-
if meth
|
281
|
-
cm = meth.executable
|
282
|
-
return arg, canonic_file(cm.active_path), cm.lines[1]
|
283
|
-
end
|
284
|
-
|
285
|
-
if show_errmsg
|
286
|
-
unless (allow_offset && arg.size > 0 && arg[0].downcase == 'o')
|
287
|
-
errmsg("#{arg} is not a line number, filename or method " +
|
288
|
-
"we can get location information about")
|
257
|
+
when :file
|
258
|
+
filename = canonic_file(info.container)
|
259
|
+
cm =
|
260
|
+
if canonic_file(@frame.file) == filename
|
261
|
+
cm = @frame.method
|
262
|
+
if :line == info.position_type
|
263
|
+
find_method_with_line(cm, info.position)
|
264
|
+
end
|
265
|
+
else
|
266
|
+
LineCache.compiled_method(filename)
|
267
|
+
end
|
268
|
+
return cm, filename, info.position, info.position_type
|
269
|
+
when nil
|
270
|
+
if [:line, :offset].member?(info.position_type)
|
271
|
+
filename = @frame.file
|
272
|
+
cm = @frame.method
|
273
|
+
if :line == info.position_type
|
274
|
+
cm = find_method_with_line(cm, info.position)
|
275
|
+
end
|
276
|
+
return [cm, canonic_file(filename), info.position, info.position_type]
|
277
|
+
elsif !info.position_type
|
278
|
+
errmsg "Can't parse #{arg} as a position"
|
279
|
+
return [nil] * 4
|
280
|
+
else
|
281
|
+
errmsg "Unknown position type #{info.position_type} for location #{arg}"
|
282
|
+
return [nil] * 4
|
289
283
|
end
|
284
|
+
else
|
285
|
+
errmsg "Unknown container type #{info.container_type} for location #{arg}"
|
286
|
+
return [nil] * 4
|
290
287
|
end
|
291
|
-
return nil, nil, nil
|
292
288
|
end
|
293
|
-
|
289
|
+
|
294
290
|
def parse_method(meth_str)
|
295
|
-
|
296
|
-
|
297
|
-
|
298
|
-
|
299
|
-
|
300
|
-
|
301
|
-
# For meth_str = "a.b.foo",
|
302
|
-
# try via a.b.method("foo".to_sym)
|
303
|
-
try_eval = "#{meth_str[0..last_dot]}method" +
|
304
|
-
"(#{meth_str[last_dot+1..-1].inspect}.to_sym)"
|
305
|
-
meth = debug_eval_no_errmsg(try_eval)
|
291
|
+
begin
|
292
|
+
meth_for_string(meth_str, @frame.binding)
|
293
|
+
rescue NameError
|
294
|
+
nil
|
295
|
+
rescue
|
296
|
+
nil
|
306
297
|
end
|
307
|
-
return meth
|
308
298
|
end
|
309
299
|
|
310
300
|
def validate_initialize
|
@@ -316,24 +306,36 @@ end
|
|
316
306
|
|
317
307
|
if __FILE__ == $0
|
318
308
|
# Demo it.
|
319
|
-
|
309
|
+
# FIXME have to pull in main for its initalize routine
|
310
|
+
DIRNAME = File.dirname(__FILE__)
|
311
|
+
load File.join(DIRNAME, 'main.rb')
|
312
|
+
|
313
|
+
require_relative 'mock'
|
320
314
|
dbgr, cmd = MockDebugger::setup('exit', false)
|
321
|
-
|
315
|
+
cmdproc = cmd.proc
|
322
316
|
onoff = %w(1 0 on off)
|
323
|
-
onoff.each { |val| puts "onoff(#{val}) = #{
|
317
|
+
onoff.each { |val| puts "onoff(#{val}) = #{cmdproc.get_onoff(val)}" }
|
324
318
|
%w(1 1E bad 1+1 -5).each do |val|
|
325
|
-
puts "get_int_noerr(#{val}) = #{
|
319
|
+
puts "get_int_noerr(#{val}) = #{cmdproc.get_int_noerr(val).inspect}"
|
326
320
|
end
|
327
321
|
def foo; 5 end
|
328
|
-
def
|
322
|
+
def cmdproc.errmsg(msg)
|
329
323
|
puts msg
|
330
324
|
end
|
331
|
-
|
325
|
+
|
326
|
+
pos = cmdproc.parse_position('../../rubies/rbx-head/bin/irb')
|
327
|
+
puts pos.inspect
|
328
|
+
|
329
|
+
puts cmdproc.parse_position(__FILE__).inspect
|
330
|
+
puts cmdproc.parse_position('@8').inspect
|
331
|
+
puts cmdproc.parse_position('8').inspect
|
332
|
+
puts cmdproc.parse_position("#{__FILE__} #{__LINE__}").inspect
|
332
333
|
|
334
|
+
cmdproc.method?('cmdproc.errmsg')
|
333
335
|
puts '=' * 40
|
334
|
-
['Array
|
335
|
-
'foo', '
|
336
|
-
puts "#{str} should be true: #{
|
336
|
+
['Array.map', 'Trepan::CmdProcessor.new',
|
337
|
+
'foo', 'cmdproc.errmsg'].each do |str|
|
338
|
+
puts "#{str} should be true: #{cmdproc.method?(str).inspect}"
|
337
339
|
end
|
338
340
|
puts '=' * 40
|
339
341
|
|
@@ -342,15 +344,25 @@ if __FILE__ == $0
|
|
342
344
|
# Trepan::CmdProcessor.allocate should be false: true
|
343
345
|
|
344
346
|
['food', '.errmsg'].each do |str|
|
345
|
-
puts "#{str} should be false: #{
|
347
|
+
puts "#{str} should be false: #{cmdproc.method?(str).inspect}"
|
346
348
|
end
|
347
349
|
puts '-' * 20
|
348
|
-
|
349
|
-
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
# p
|
354
|
-
|
355
|
-
p
|
350
|
+
|
351
|
+
puts "Trepan::CmdProcessor.allocate is: #{cmdproc.get_method('Trepan::CmdProcessor.allocate')}"
|
352
|
+
|
353
|
+
# require_relative '../lib/trepanning'; debugger
|
354
|
+
# pos = cmdproc.breakpoint_position('../processor/validate.rb', true)
|
355
|
+
# p ['breakpoint validate', pos]
|
356
|
+
|
357
|
+
p cmdproc.breakpoint_position('foo', true)
|
358
|
+
p cmdproc.breakpoint_position('@0', true)
|
359
|
+
p cmdproc.breakpoint_position("#{__LINE__}", true)
|
360
|
+
p cmdproc.breakpoint_position("#{__FILE__} @0", false)
|
361
|
+
p cmdproc.breakpoint_position("#{__FILE__}:#{__LINE__}", true)
|
362
|
+
p cmdproc.breakpoint_position("#{__FILE__} #{__LINE__} if 1 == a", true)
|
363
|
+
p cmdproc.breakpoint_position("cmdproc.errmsg", false)
|
364
|
+
p cmdproc.breakpoint_position("cmdproc.errmsg:@0", false)
|
365
|
+
### p cmdproc.breakpoint_position(%w(2 if a > b))
|
366
|
+
p cmdproc.get_int_list(%w(1+0 3-1 3))
|
367
|
+
p cmdproc.get_int_list(%w(a 2 3))
|
356
368
|
end
|
data/rbx-trepanning.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.add_dependency('columnize')
|
11
11
|
s.add_dependency('diff-lcs') # For testing only
|
12
12
|
s.add_dependency('rbx-require-relative')
|
13
|
-
s.add_dependency('rbx-linecache', '~>1.
|
13
|
+
s.add_dependency('rbx-linecache', '~>1.2')
|
14
14
|
s.authors = ['R. Bernstein']
|
15
15
|
s.date = Time.now
|
16
16
|
s.description = <<-EOF
|
@@ -0,0 +1,16 @@
|
|
1
|
+
# !/usr/bin/env ruby
|
2
|
+
# Bug in debugger in 1.9.2 only in that where
|
3
|
+
# stopping where we were inside debugger was stopping
|
4
|
+
# inside itself because multiple debugger names in the presence of modules
|
5
|
+
#
|
6
|
+
require 'rubygems'; require 'require_relative'
|
7
|
+
require_relative '../../lib/trepanning'
|
8
|
+
module Foo
|
9
|
+
module_function
|
10
|
+
def five
|
11
|
+
debugger # Resolves to Module#debugger not Kernel#debugger
|
12
|
+
5
|
13
|
+
end
|
14
|
+
end
|
15
|
+
debugger
|
16
|
+
Foo::five
|
@@ -21,7 +21,7 @@ class TestNameBreak < Test::Unit::TestCase
|
|
21
21
|
# Check that we can set breakpoints in parent, sibling and children
|
22
22
|
# of sibling returns. We have one more 'continue' than we need
|
23
23
|
# just in case something goes wrong.
|
24
|
-
cmds = ['break Object
|
24
|
+
cmds = ['break Object.five', 'break TestNameBreak.five?',
|
25
25
|
'break TestNameBreak.six=',
|
26
26
|
'continue', 'continue', 'continue', 'continue']
|
27
27
|
|
@@ -0,0 +1,115 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative 'fn_helper'
|
5
|
+
|
6
|
+
class TestEval < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include FnTestHelper
|
9
|
+
|
10
|
+
def test_eval_questionmark
|
11
|
+
|
12
|
+
# See that eval? strips 'if'
|
13
|
+
cmds = %w(eval? continue)
|
14
|
+
d = strarray_setup(cmds)
|
15
|
+
d.start
|
16
|
+
if 3 > 5
|
17
|
+
assert false
|
18
|
+
end
|
19
|
+
d.stop
|
20
|
+
out = ['-- ', 'if 3 > 5', 'eval: 3 > 5', '$d0 = false']
|
21
|
+
compare_output(out, d, cmds)
|
22
|
+
|
23
|
+
# See that eval? strips 'if' and 'then'
|
24
|
+
cmds = %w(eval? continue)
|
25
|
+
d = strarray_setup(cmds)
|
26
|
+
d.start
|
27
|
+
if 3 > 5 then
|
28
|
+
assert false
|
29
|
+
end
|
30
|
+
d.stop
|
31
|
+
out = ['-- ', 'if 3 > 5 then', 'eval: 3 > 5', '$d0 = false']
|
32
|
+
compare_output(out, d, cmds)
|
33
|
+
|
34
|
+
# See that eval? strips 'unless'
|
35
|
+
cmds = %w(eval? continue)
|
36
|
+
d = strarray_setup(cmds)
|
37
|
+
d.start
|
38
|
+
unless 3 < 5
|
39
|
+
assert false
|
40
|
+
end
|
41
|
+
d.stop
|
42
|
+
out = ['-- ', 'unless 3 < 5', 'eval: 3 < 5', '$d0 = true']
|
43
|
+
compare_output(out, d, cmds)
|
44
|
+
|
45
|
+
# See that eval? strips 'unless' and 'then
|
46
|
+
cmds = %w(eval? continue)
|
47
|
+
d = strarray_setup(cmds)
|
48
|
+
d.start
|
49
|
+
unless 3 < 5 then
|
50
|
+
assert false
|
51
|
+
end
|
52
|
+
d.stop
|
53
|
+
out = ['-- ', 'unless 3 < 5 then', 'eval: 3 < 5', '$d0 = true']
|
54
|
+
compare_output(out, d, cmds)
|
55
|
+
|
56
|
+
# See that eval? strips 'while'
|
57
|
+
cmds = %w(eval? continue)
|
58
|
+
d = strarray_setup(cmds)
|
59
|
+
d.start
|
60
|
+
while nil
|
61
|
+
assert false
|
62
|
+
end
|
63
|
+
d.stop
|
64
|
+
out = ['-- ', 'while nil', 'eval: nil', '$d0 = nil']
|
65
|
+
compare_output(out, d, cmds)
|
66
|
+
|
67
|
+
# See that eval? strips 'while' and 'do'
|
68
|
+
cmds = %w(eval? continue)
|
69
|
+
d = strarray_setup(cmds)
|
70
|
+
d.start
|
71
|
+
while nil do
|
72
|
+
assert false
|
73
|
+
end
|
74
|
+
d.stop
|
75
|
+
out = ['-- ', 'while nil do', 'eval: nil', '$d0 = nil']
|
76
|
+
compare_output(out, d, cmds)
|
77
|
+
|
78
|
+
# See that eval? strips 'until' and 'do'
|
79
|
+
cmds = %w(eval? continue)
|
80
|
+
d = strarray_setup(cmds)
|
81
|
+
d.start
|
82
|
+
until true do
|
83
|
+
assert false
|
84
|
+
end
|
85
|
+
d.stop
|
86
|
+
out = ['-- ', 'until true do', 'eval: true', '$d0 = true']
|
87
|
+
compare_output(out, d, cmds)
|
88
|
+
|
89
|
+
# See that eval? strips 'until'
|
90
|
+
cmds = %w(eval? continue)
|
91
|
+
d = strarray_setup(cmds)
|
92
|
+
d.start
|
93
|
+
until true
|
94
|
+
assert false
|
95
|
+
end
|
96
|
+
d.stop
|
97
|
+
out = ['-- ', 'until true', 'eval: true', '$d0 = true']
|
98
|
+
compare_output(out, d, cmds)
|
99
|
+
|
100
|
+
# See that eval? strips 'return'
|
101
|
+
def five
|
102
|
+
return 5
|
103
|
+
end
|
104
|
+
cmds = %w(step eval? continue)
|
105
|
+
d = strarray_setup(cmds)
|
106
|
+
d.start
|
107
|
+
five
|
108
|
+
d.stop
|
109
|
+
out = ['-- ', 'five', '-> ', 'return 5', 'eval: 5', '$d0 = 5']
|
110
|
+
compare_output(out, d, cmds)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
114
|
+
|
115
|
+
|
@@ -18,7 +18,7 @@ class TestTBreak < Test::Unit::TestCase
|
|
18
18
|
# Check that temporary breaks are, well, temporary.
|
19
19
|
# The last "continue" below isn't used. It to make sure we finish
|
20
20
|
# the test even when the breakpoint isn't temporary.
|
21
|
-
cmds = ['tbreak TestTBreak
|
21
|
+
cmds = ['tbreak TestTBreak.foo', 'continue', 'continue', 'continue']
|
22
22
|
d = strarray_setup(cmds)
|
23
23
|
d.start
|
24
24
|
##############################
|
data/test/integration/helper.rb
CHANGED
@@ -33,7 +33,8 @@ def run_debugger(testname, ruby_file, opts={})
|
|
33
33
|
|
34
34
|
FileUtils.rm(outfile) if File.exist?(outfile)
|
35
35
|
|
36
|
-
cmd =
|
36
|
+
cmd = opts[:feed_input] ? "#{opts[:feed_input]} |" : ''
|
37
|
+
cmd +=
|
37
38
|
if opts[:xdebug]
|
38
39
|
"%s -Xdebug '%s' %s >%s 2>&1 <%s" %
|
39
40
|
[Trepanning::ruby_path, programfile, opts[:args], outfile, cmdfile]
|
@@ -45,13 +46,15 @@ def run_debugger(testname, ruby_file, opts={})
|
|
45
46
|
[Trepanning::ruby_path, dbgr_path, cmdfile, opts[:dbgr],
|
46
47
|
programfile, opts[:args], outfile]
|
47
48
|
end
|
48
|
-
|
49
|
+
puts cmd if opts[:verbose]
|
49
50
|
system(cmd)
|
50
51
|
return false unless 0 == $?.exitstatus
|
51
52
|
if opts[:do_diff]
|
52
53
|
expected_lines = File.open(rightfile).readlines()
|
53
54
|
got_lines = File.open(outfile).readlines()
|
54
55
|
opts[:filter].call(got_lines, expected_lines) if opts[:filter]
|
56
|
+
# puts "=" * 80
|
57
|
+
# got_lines.map{|line| puts line}
|
55
58
|
|
56
59
|
# Seems to be a bug in LCS in that it will return a diff even if two
|
57
60
|
# files are the same.
|
data/test/unit/cmd-helper.rb
CHANGED
@@ -11,7 +11,7 @@ module UnitHelper
|
|
11
11
|
|
12
12
|
module_function
|
13
13
|
def common_setup
|
14
|
-
@dbg
|
14
|
+
@dbg ||= MockDebugger::MockDebugger.new(:nx => true)
|
15
15
|
@cmdproc = Trepan::CmdProcessor.new(@dbg)
|
16
16
|
@cmdproc.frame_initialize
|
17
17
|
@cmdproc.dbgr = @dbg
|