trepanning 0.1.2 → 0.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/ChangeLog +354 -0
- data/NEWS +21 -0
- data/Rakefile +27 -20
- data/app/cmd_parse.kpeg +20 -4
- data/app/cmd_parse.rb +11 -10
- data/app/cmd_parser.rb +119 -55
- data/app/complete.rb +1 -0
- data/app/core.rb +3 -3
- data/app/disassemble.rb +13 -3
- data/app/file.rb +2 -1
- data/app/frame.rb +3 -1
- data/app/mock.rb +3 -0
- data/app/options.rb +48 -31
- data/app/util.rb +50 -0
- data/interface/base_intf.rb +4 -0
- data/interface/client.rb +4 -0
- data/interface/script.rb +1 -1
- data/interface/server.rb +4 -0
- data/interface/user.rb +5 -0
- data/io/input.rb +3 -2
- data/io/null_output.rb +7 -1
- data/processor/breakpoint.rb +3 -2
- data/processor/command/base/subcmd.rb +1 -1
- data/processor/command/base/submgr.rb +4 -1
- data/processor/command/base/subsubcmd.rb +2 -2
- data/processor/command/base/subsubmgr.rb +1 -1
- data/processor/command/break.rb +7 -3
- data/processor/command/complete.rb +1 -0
- data/processor/command/continue.rb +1 -1
- data/processor/command/disassemble.rb +1 -1
- data/processor/command/edit.rb +35 -14
- data/processor/command/enable.rb +5 -3
- data/processor/command/eval.rb +35 -14
- data/processor/command/exit.rb +2 -0
- data/processor/command/help.rb +0 -9
- data/processor/command/help/command.txt +37 -27
- data/processor/command/help/examples.txt +16 -0
- data/processor/command/help/suffixes.txt +17 -0
- data/processor/command/info.rb +1 -1
- data/processor/command/info_subcmd/args.rb +7 -13
- data/processor/command/info_subcmd/breakpoints.rb +8 -2
- data/processor/command/info_subcmd/frame.rb +2 -0
- data/processor/command/info_subcmd/globals.rb +63 -0
- data/processor/command/info_subcmd/iseq.rb +3 -1
- data/processor/command/info_subcmd/locals.rb +16 -15
- data/processor/command/{show_subcmd → info_subcmd}/macro.rb +7 -7
- data/processor/command/info_subcmd/program.rb +2 -0
- data/processor/command/info_subcmd/registers.rb +5 -1
- data/processor/command/info_subcmd/registers_subcmd/dfp.rb +2 -3
- data/processor/command/info_subcmd/registers_subcmd/helper.rb +8 -9
- data/processor/command/info_subcmd/registers_subcmd/lfp.rb +10 -5
- data/processor/command/info_subcmd/registers_subcmd/pc.rb +9 -4
- data/processor/command/info_subcmd/registers_subcmd/sp.rb +4 -5
- data/processor/command/info_subcmd/ruby.rb +3 -1
- data/processor/command/info_subcmd/source.rb +78 -0
- data/processor/command/info_subcmd/stack.rb +23 -0
- data/processor/command/kill.rb +4 -6
- data/processor/command/list.rb +118 -120
- data/processor/command/macro.rb +1 -1
- data/processor/command/parsetree.rb +56 -0
- data/processor/command/pp.rb +40 -0
- data/processor/command/pr.rb +1 -2
- data/processor/command/quit.rb +2 -1
- data/processor/command/set_subcmd/abbrev.rb +24 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +1 -2
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +2 -3
- data/processor/command/set_subcmd/auto_subcmd/list.rb +2 -3
- data/processor/command/set_subcmd/highlight.rb +8 -2
- data/processor/command/set_subcmd/reload.rb +41 -0
- data/processor/command/set_subcmd/timer.rb +8 -18
- data/processor/command/set_subcmd/trace.rb +2 -2
- data/processor/command/set_subcmd/trace_subcmd/buffer.rb +2 -2
- data/processor/command/set_subcmd/trace_subcmd/print.rb +3 -3
- data/processor/command/{irb.rb → shell.rb} +9 -6
- data/processor/command/show_subcmd/abbrev.rb +19 -0
- data/processor/command/show_subcmd/directories.rb +21 -0
- data/processor/command/show_subcmd/hidelevel.rb +1 -1
- data/processor/command/show_subcmd/highlight.rb +2 -1
- data/processor/command/show_subcmd/reload.rb +17 -0
- data/processor/command/show_subcmd/timer.rb +17 -0
- data/processor/command/show_subcmd/trace_subcmd/buffer.rb +1 -1
- data/processor/command/source.rb +15 -14
- data/processor/command/tbreak.rb +20 -0
- data/processor/command/watchg.rb +114 -0
- data/processor/default.rb +43 -41
- data/processor/display.rb +3 -2
- data/processor/eval.rb +5 -3
- data/processor/eventbuf.rb +3 -2
- data/processor/frame.rb +12 -3
- data/processor/hook.rb +3 -2
- data/processor/load_cmds.rb +186 -179
- data/processor/location.rb +154 -159
- data/processor/main.rb +44 -16
- data/processor/mock.rb +0 -11
- data/processor/msg.rb +3 -1
- data/processor/running.rb +3 -2
- data/processor/validate.rb +25 -4
- data/processor/virtual.rb +32 -0
- data/test/data/debugger-stop.right +1 -0
- data/test/data/fname-with-blank.right +1 -0
- data/test/example/gcd.rb +1 -0
- data/test/functional/{test-trace-var.rb → test-watchg.rb} +15 -4
- data/test/unit/cmd-helper.rb +0 -3
- data/test/unit/test-app-cmd_parser.rb +2 -2
- data/test/unit/test-app-file.rb +1 -0
- data/test/unit/test-app-frame.rb +1 -1
- data/test/unit/test-app-util.rb +21 -0
- data/test/unit/test-base-cmd.rb +4 -6
- data/test/unit/test-base-subcmd.rb +1 -4
- data/test/unit/test-base-submgr.rb +1 -2
- data/test/unit/test-base-subsubcmd.rb +0 -4
- data/test/unit/test-cmd-edit.rb +33 -0
- data/test/unit/test-cmd-parse_list_cmd.rb +33 -0
- data/test/unit/test-completion.rb +1 -1
- data/test/unit/test-proc-frame.rb +4 -1
- data/test/unit/test-proc-load_cmds.rb +2 -1
- data/test/unit/test-proc-location.rb +9 -26
- data/test/unit/test-proc-main.rb +1 -4
- data/test/unit/test-proc-validate.rb +28 -18
- data/test/unit/test-subcmd-help.rb +0 -4
- data/trepanning.gemspec +1 -1
- metadata +27 -10
- data/processor/command/set_subcmd/trace_subcmd/var.rb +0 -57
data/processor/main.rb
CHANGED
|
@@ -12,7 +12,7 @@ end
|
|
|
12
12
|
require_relative '../app/brkptmgr'
|
|
13
13
|
|
|
14
14
|
class Trepan
|
|
15
|
-
class CmdProcessor
|
|
15
|
+
class CmdProcessor < VirtualCmdProcessor
|
|
16
16
|
|
|
17
17
|
# SEE ALSO attr's in require_relative's of loop above.
|
|
18
18
|
|
|
@@ -48,6 +48,8 @@ class Trepan
|
|
|
48
48
|
attr_accessor :prompt # String print before requesting input
|
|
49
49
|
attr_reader :settings # Hash[:symbol] of command
|
|
50
50
|
# processor settings
|
|
51
|
+
|
|
52
|
+
attr_accessor :traced_vars # list of traced global variables
|
|
51
53
|
|
|
52
54
|
# The following are used in to force stopping at a different line
|
|
53
55
|
# number. FIXME: could generalize to a position object.
|
|
@@ -91,6 +93,7 @@ class Trepan
|
|
|
91
93
|
@debug_nest = 1
|
|
92
94
|
@dbgr = core.dbgr
|
|
93
95
|
@hidelevels = {}
|
|
96
|
+
@interfaces = @dbgr.intf
|
|
94
97
|
@last_command = nil
|
|
95
98
|
@last_pos = [nil, nil, nil, nil, nil, nil]
|
|
96
99
|
@next_level = 32000
|
|
@@ -100,6 +103,7 @@ class Trepan
|
|
|
100
103
|
start_file = settings.delete(:start_file)
|
|
101
104
|
|
|
102
105
|
@settings = DEFAULT_SETTINGS.merge(settings)
|
|
106
|
+
@traced_vars = {}
|
|
103
107
|
@different_pos = @settings[:different]
|
|
104
108
|
|
|
105
109
|
# FIXME: Rework using a general "set substitute file" command and
|
|
@@ -119,7 +123,7 @@ class Trepan
|
|
|
119
123
|
|
|
120
124
|
# Run initialization routines for each of the "submodule"s.
|
|
121
125
|
# load_cmds has to come first.
|
|
122
|
-
%w(load_cmds breakpoint display eventbuf frame
|
|
126
|
+
%w(load_cmds breakpoint display eventbuf frame running validate
|
|
123
127
|
).each do |submod|
|
|
124
128
|
self.send("#{submod}_initialize")
|
|
125
129
|
end
|
|
@@ -206,7 +210,6 @@ class Trepan
|
|
|
206
210
|
@last_command = nil
|
|
207
211
|
print_location
|
|
208
212
|
else
|
|
209
|
-
msg "That's all folks..."
|
|
210
213
|
## FIXME: think of something better.
|
|
211
214
|
quit('quit!')
|
|
212
215
|
return true
|
|
@@ -226,6 +229,24 @@ class Trepan
|
|
|
226
229
|
@event = @core.event
|
|
227
230
|
|
|
228
231
|
@unconditional_prehooks.run
|
|
232
|
+
|
|
233
|
+
if 'trace-var' == @event
|
|
234
|
+
variable_name, value = @core.hook_arg
|
|
235
|
+
action = @traced_vars[variable_name]
|
|
236
|
+
msg "trace: #{variable_name} = #{value}"
|
|
237
|
+
case action
|
|
238
|
+
when nil
|
|
239
|
+
errmsg "No action recorded for variable. Using 'stop'."
|
|
240
|
+
when 'stop'
|
|
241
|
+
msg "Note: we are stopped *after* the above location."
|
|
242
|
+
when 'nostop'
|
|
243
|
+
print_location
|
|
244
|
+
return
|
|
245
|
+
else
|
|
246
|
+
errmsg "Internal error: unknown trace_var action #{action}"
|
|
247
|
+
end
|
|
248
|
+
end
|
|
249
|
+
|
|
229
250
|
if breakpoint?
|
|
230
251
|
@last_pos = [@frame.source_container, frame_line,
|
|
231
252
|
@stack_size, @current_thread, @event,
|
|
@@ -237,13 +258,10 @@ class Trepan
|
|
|
237
258
|
@prompt = compute_prompt
|
|
238
259
|
|
|
239
260
|
@leave_cmd_loop = false
|
|
240
|
-
print_location unless @settings[:traceprint]
|
|
241
|
-
if 'trace-var' == @event
|
|
242
|
-
msg "Note: we are stopped *after* the above location."
|
|
243
|
-
end
|
|
244
261
|
|
|
262
|
+
print_location unless @settings[:traceprint]
|
|
245
263
|
@eventbuf.add_mark if @settings[:tracebuffer]
|
|
246
|
-
|
|
264
|
+
|
|
247
265
|
@cmdloop_prehooks.run
|
|
248
266
|
while not @leave_cmd_loop do
|
|
249
267
|
begin
|
|
@@ -255,7 +273,7 @@ class Trepan
|
|
|
255
273
|
# If we are inside the script interface errmsg may fail.
|
|
256
274
|
begin
|
|
257
275
|
errmsg("Internal debugger error: #{exc.inspect}")
|
|
258
|
-
rescue
|
|
276
|
+
rescue IOError
|
|
259
277
|
$stderr.puts "Internal debugger error: #{exc.inspect}"
|
|
260
278
|
end
|
|
261
279
|
exception_dump(exc, @settings[:debugexcept], $!.backtrace)
|
|
@@ -278,7 +296,7 @@ class Trepan
|
|
|
278
296
|
commands = current_command.split(';;')
|
|
279
297
|
if commands.size > 1
|
|
280
298
|
current_command = commands.shift
|
|
281
|
-
@cmd_queue.unshift
|
|
299
|
+
@cmd_queue.unshift(*commands)
|
|
282
300
|
end
|
|
283
301
|
args = current_command.split
|
|
284
302
|
# Expand macros. FIXME: put in a procedure
|
|
@@ -309,7 +327,10 @@ class Trepan
|
|
|
309
327
|
else
|
|
310
328
|
@cmd_name
|
|
311
329
|
end
|
|
312
|
-
|
|
330
|
+
|
|
331
|
+
run_cmd_name = uniq_abbrev(@commands.keys, run_cmd_name) if
|
|
332
|
+
!@commands.member?(run_cmd_name) && @settings[:abbrev]
|
|
333
|
+
|
|
313
334
|
if @commands.member?(run_cmd_name)
|
|
314
335
|
cmd = @commands[run_cmd_name]
|
|
315
336
|
if ok_for_running(cmd, run_cmd_name, args.size-1)
|
|
@@ -324,17 +345,24 @@ class Trepan
|
|
|
324
345
|
# Eval anything that's not a command or has been
|
|
325
346
|
# requested to be eval'd
|
|
326
347
|
if settings[:autoeval] || eval_command
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
348
|
+
# eval_code(current_command, @settings[:maxstring])
|
|
349
|
+
begin
|
|
350
|
+
msg 'D=> ' + debug_eval_with_exception(current_command).inspect
|
|
351
|
+
return false
|
|
352
|
+
rescue NameError
|
|
353
|
+
end
|
|
331
354
|
end
|
|
355
|
+
undefined_command(cmd_name)
|
|
332
356
|
return false
|
|
333
357
|
end
|
|
334
358
|
|
|
335
359
|
# Error message when a command doesn't exist
|
|
336
360
|
def undefined_command(cmd_name)
|
|
337
|
-
|
|
361
|
+
begin
|
|
362
|
+
errmsg('Undefined command: "%s". Try "help".' % cmd_name)
|
|
363
|
+
rescue
|
|
364
|
+
$stderr.puts 'Undefined command: "%s". Try "help".' % cmd_name
|
|
365
|
+
end
|
|
338
366
|
end
|
|
339
367
|
|
|
340
368
|
# FIXME: Allow access to both Trepan::CmdProcessor and Trepan
|
data/processor/mock.rb
CHANGED
|
@@ -129,17 +129,6 @@ module MockDebugger
|
|
|
129
129
|
|
|
130
130
|
end
|
|
131
131
|
|
|
132
|
-
# To get Trepan::CmdProcessor defined and with the
|
|
133
|
-
# with the correct initialize parameters.
|
|
134
|
-
class Trepan
|
|
135
|
-
class << CmdProcessor
|
|
136
|
-
def initialize(core, settings={})
|
|
137
|
-
@core = core
|
|
138
|
-
@settings = settings
|
|
139
|
-
end
|
|
140
|
-
end
|
|
141
|
-
end
|
|
142
|
-
|
|
143
132
|
if __FILE__ == $0
|
|
144
133
|
dbgr = MockDebugger::MockDebugger.new
|
|
145
134
|
p dbgr.settings
|
data/processor/msg.rb
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
|
2
2
|
# I/O related command processor methods
|
|
3
3
|
require_relative '../app/util'
|
|
4
|
+
require_relative 'virtual'
|
|
4
5
|
class Trepan
|
|
5
|
-
class CmdProcessor
|
|
6
|
+
class CmdProcessor < VirtualCmdProcessor
|
|
7
|
+
|
|
6
8
|
attr_accessor :ruby_highlighter
|
|
7
9
|
|
|
8
10
|
def errmsg(message, opts={})
|
data/processor/running.rb
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
# Copyright (C) 2010 Rocky Bernstein <rockyb@rubyforge.net>
|
|
1
|
+
# Copyright (C) 2010, 2011 Rocky Bernstein <rockyb@rubyforge.net>
|
|
2
|
+
require_relative 'virtual'
|
|
2
3
|
class Trepan
|
|
3
|
-
class CmdProcessor
|
|
4
|
+
class CmdProcessor < VirtualCmdProcessor
|
|
4
5
|
|
|
5
6
|
attr_accessor :stop_condition # String or nil. When not nil
|
|
6
7
|
# this has to eval non-nil
|
data/processor/validate.rb
CHANGED
|
@@ -3,19 +3,25 @@
|
|
|
3
3
|
# Trepan command input validation routines. A String type is
|
|
4
4
|
# usually passed in as the argument to validation routines.
|
|
5
5
|
|
|
6
|
+
require 'rubygems'
|
|
7
|
+
require 'linecache'
|
|
8
|
+
|
|
9
|
+
require_relative '../app/cmd_parse'
|
|
6
10
|
require_relative '../app/condition'
|
|
7
11
|
require_relative '../app/file'
|
|
8
|
-
require_relative '../app/cmd_parse'
|
|
9
12
|
require_relative '../app/thread'
|
|
10
13
|
|
|
11
14
|
require_relative 'location' # for resolve_file_with_dir
|
|
12
15
|
require_relative 'msg' # for errmsg, msg
|
|
16
|
+
require_relative 'virtual'
|
|
13
17
|
|
|
14
18
|
class Trepan
|
|
15
|
-
class CmdProcessor
|
|
19
|
+
class CmdProcessor < VirtualCmdProcessor
|
|
16
20
|
|
|
17
21
|
attr_reader :dbgr_script_iseqs
|
|
18
22
|
attr_reader :dbgr_iseqs
|
|
23
|
+
attr_reader :file_exists_proc # Like File.exists? but checks using
|
|
24
|
+
# cached files
|
|
19
25
|
|
|
20
26
|
include Trepanning
|
|
21
27
|
include Trepan::ThreadHelper
|
|
@@ -166,6 +172,7 @@ class Trepan
|
|
|
166
172
|
return [nil, nil]
|
|
167
173
|
end
|
|
168
174
|
when :offset
|
|
175
|
+
position = position.position unless position.kind_of?(Fixnum)
|
|
169
176
|
if ary=iseq.offset2lines(position)
|
|
170
177
|
line_no = ary.first
|
|
171
178
|
vm_offset = position
|
|
@@ -269,7 +276,7 @@ class Trepan
|
|
|
269
276
|
begin
|
|
270
277
|
meth_for_parse_struct(meth, start_binding)
|
|
271
278
|
rescue NameError
|
|
272
|
-
errmsg("Can't
|
|
279
|
+
errmsg("Can't evaluate #{meth.name} to get a method")
|
|
273
280
|
return nil
|
|
274
281
|
end
|
|
275
282
|
end
|
|
@@ -290,7 +297,7 @@ class Trepan
|
|
|
290
297
|
info = parse_location(info) if info.kind_of?(String)
|
|
291
298
|
case info.container_type
|
|
292
299
|
when :fn
|
|
293
|
-
if meth = method?(info.container)
|
|
300
|
+
if (meth = method?(info.container)) && meth.iseq
|
|
294
301
|
return [meth, meth.iseq.source_container[1], info.position,
|
|
295
302
|
info.position_type]
|
|
296
303
|
else
|
|
@@ -327,6 +334,20 @@ class Trepan
|
|
|
327
334
|
def validate_initialize
|
|
328
335
|
## top_srcdir = File.expand_path(File.join(File.dirname(__FILE__), '..'))
|
|
329
336
|
## @dbgr_script_iseqs, @dbgr_iseqs = filter_scripts(top_srcdir)
|
|
337
|
+
@file_exists_proc = Proc.new {|filename|
|
|
338
|
+
if LineCache.cached?(filename) || LineCache.cached_script?(filename) ||
|
|
339
|
+
(File.readable?(filename) && !File.directory?(filename))
|
|
340
|
+
true
|
|
341
|
+
else
|
|
342
|
+
matches = find_scripts(filename)
|
|
343
|
+
if matches.size == 1
|
|
344
|
+
LineCache.remap_file(filename, matches[0])
|
|
345
|
+
true
|
|
346
|
+
else
|
|
347
|
+
false
|
|
348
|
+
end
|
|
349
|
+
end
|
|
350
|
+
}
|
|
330
351
|
end
|
|
331
352
|
end
|
|
332
353
|
end
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
# The class serves as the parent for Trepan::CmdProcessor which is
|
|
2
|
+
# quite large and spans over several files. By declaring "initialize"
|
|
3
|
+
# below, we have a consistent initialization routine and many of the
|
|
4
|
+
# others don't need to define "initialize".
|
|
5
|
+
|
|
6
|
+
# Also, simple versions of the I/O routines make it possible
|
|
7
|
+
# to do testing without having to bring in the whole "Interface"
|
|
8
|
+
# and I/O routines that trepanning (and "main.rb") use.
|
|
9
|
+
|
|
10
|
+
# Note that via this file we can change 'class Trepan' to 'module
|
|
11
|
+
# Trepan' or vice versa. So this takes effect on all of the places
|
|
12
|
+
# which subclass this. They use class Trepan::CmdProcessor <
|
|
13
|
+
# Trepan::VirtualCmdProcessor rather than breaking this down into to
|
|
14
|
+
# parts as below.
|
|
15
|
+
class Trepan
|
|
16
|
+
class VirtualCmdProcessor
|
|
17
|
+
attr_reader :settings
|
|
18
|
+
def initialize(core, settings={})
|
|
19
|
+
@core = core
|
|
20
|
+
@settings = settings
|
|
21
|
+
end
|
|
22
|
+
def errmsg(message)
|
|
23
|
+
puts "Error: #{message}"
|
|
24
|
+
end
|
|
25
|
+
def msg(message)
|
|
26
|
+
puts message
|
|
27
|
+
end
|
|
28
|
+
def section(message, opts={})
|
|
29
|
+
puts "Section: #{message}"
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
data/test/example/gcd.rb
CHANGED
|
@@ -4,14 +4,19 @@ require 'trace'
|
|
|
4
4
|
require_relative 'fn_helper'
|
|
5
5
|
|
|
6
6
|
# See that we hande "set trace var" properly
|
|
7
|
-
class
|
|
7
|
+
class TestWatchG < Test::Unit::TestCase
|
|
8
8
|
|
|
9
9
|
include FnTestHelper
|
|
10
10
|
include Trace
|
|
11
11
|
|
|
12
12
|
def test_basic
|
|
13
13
|
|
|
14
|
-
cmds = ['
|
|
14
|
+
cmds = ['watchg $my_var',
|
|
15
|
+
'watchg $my_var',
|
|
16
|
+
'continue', 'continue',
|
|
17
|
+
'watchg $my_var off',
|
|
18
|
+
'watchg $my_var off',
|
|
19
|
+
'continue']
|
|
15
20
|
d = strarray_setup(cmds)
|
|
16
21
|
d.core.step_events = TEST_STEP_EVENT_MASK
|
|
17
22
|
|
|
@@ -26,13 +31,19 @@ class TestTraceVar < Test::Unit::TestCase
|
|
|
26
31
|
d.stop
|
|
27
32
|
out = ['-- ',
|
|
28
33
|
'x = 1',
|
|
29
|
-
'Tracing variable $my_var.',
|
|
34
|
+
'Tracing for variable $my_var set to: stop.',
|
|
35
|
+
'** global variable $my_var is already traced with stop.',
|
|
36
|
+
'trace: $my_var = 5',
|
|
37
|
+
'Note: we are stopped *after* the above location.',
|
|
30
38
|
'$V ',
|
|
31
39
|
'$my_var = 5',
|
|
40
|
+
'trace: $my_var = 6',
|
|
32
41
|
'Note: we are stopped *after* the above location.',
|
|
33
42
|
'$V ',
|
|
34
43
|
'$my_var = 6',
|
|
35
|
-
'
|
|
44
|
+
'Removed trace for variable $my_var.',
|
|
45
|
+
'Warning: variable $my_var is not currently marked as traced.',
|
|
46
|
+
'Removed trace for variable $my_var.'
|
|
36
47
|
]
|
|
37
48
|
compare_output(out, d, cmds)
|
|
38
49
|
end
|
data/test/unit/cmd-helper.rb
CHANGED
|
@@ -2,11 +2,8 @@ require 'test/unit'
|
|
|
2
2
|
require 'thread_frame'
|
|
3
3
|
require_relative '../../app/core'
|
|
4
4
|
require_relative '../../app/mock'
|
|
5
|
-
require_relative '../../processor/main' # Have to include before frame!
|
|
6
|
-
# FIXME
|
|
7
5
|
require_relative '../../processor/frame'
|
|
8
6
|
|
|
9
|
-
|
|
10
7
|
module UnitHelper
|
|
11
8
|
|
|
12
9
|
def common_setup
|
|
@@ -4,7 +4,7 @@ require_relative '../../app/cmd_parser'
|
|
|
4
4
|
|
|
5
5
|
class TestAppCmdParser < Test::Unit::TestCase
|
|
6
6
|
def setup
|
|
7
|
-
@cp = CmdParse.new('', true)
|
|
7
|
+
@cp = CmdParse.new('', :debug=>true)
|
|
8
8
|
end
|
|
9
9
|
|
|
10
10
|
def test_parse_filename
|
|
@@ -14,7 +14,7 @@ class TestAppCmdParser < Test::Unit::TestCase
|
|
|
14
14
|
['this\ is\ another\ filename', 'this is another filename'],
|
|
15
15
|
['C\:filename', 'C:filename']
|
|
16
16
|
].each do |name, expect|
|
|
17
|
-
@cp.setup_parser(name, true)
|
|
17
|
+
@cp.setup_parser(name, :debug => true)
|
|
18
18
|
res = @cp._filename
|
|
19
19
|
assert_equal(expect, @cp.result)
|
|
20
20
|
end
|
data/test/unit/test-app-file.rb
CHANGED
data/test/unit/test-app-frame.rb
CHANGED
|
@@ -40,7 +40,7 @@ class TestAppFrame < Test::Unit::TestCase
|
|
|
40
40
|
|
|
41
41
|
def test_return
|
|
42
42
|
assert_equal(1, offset_for_return('return'))
|
|
43
|
-
assert_equal(
|
|
43
|
+
assert_equal(4, offset_for_return('c-return'))
|
|
44
44
|
assert_raises RuntimeError do
|
|
45
45
|
offset_for_return('c-call')
|
|
46
46
|
end
|
data/test/unit/test-app-util.rb
CHANGED
|
@@ -12,4 +12,25 @@ class TestAppUtil < Test::Unit::TestCase
|
|
|
12
12
|
string = "'The time has come to talk of many things.'"
|
|
13
13
|
assert_equal("'The tim... things.'", safe_repr(string, 17))
|
|
14
14
|
end
|
|
15
|
+
|
|
16
|
+
def test_abbrev
|
|
17
|
+
list = %w(disassemble disable distance up)
|
|
18
|
+
[['dis', 'dis'],
|
|
19
|
+
['disas', 'disassemble'],
|
|
20
|
+
['u', 'up'],
|
|
21
|
+
['upper', 'upper'],
|
|
22
|
+
['foo', 'foo']].each do |name, expect|
|
|
23
|
+
assert_equal expect, uniq_abbrev(list, name)
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def test_extract_expression
|
|
28
|
+
[['if condition("if")', 'condition("if")'],
|
|
29
|
+
['until until_termination', 'until_termination'],
|
|
30
|
+
['return return_value', 'return_value'],
|
|
31
|
+
['nothing_to_be.done', 'nothing_to_be.done'],
|
|
32
|
+
].each do |stmt, expect|
|
|
33
|
+
assert_equal expect, extract_expression(stmt)
|
|
34
|
+
end
|
|
35
|
+
end
|
|
15
36
|
end
|
data/test/unit/test-base-cmd.rb
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
require 'test/unit'
|
|
3
3
|
require_relative '../../processor/command/base/cmd'
|
|
4
4
|
|
|
5
|
-
class Trepan
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
completion %w(a aa ab ba aac)
|
|
10
|
-
end
|
|
5
|
+
class Trepan::Command::Test < Trepan::Command
|
|
6
|
+
NAME = 'test'
|
|
7
|
+
CATEGORY = 'testcategory'
|
|
8
|
+
completion %w(a aa ab ba aac)
|
|
11
9
|
end
|
|
12
10
|
|
|
13
11
|
class TestBaseCommand < Test::Unit::TestCase
|