rbx-trepanning 0.1.0-universal-rubinius-1.2 → 0.2.1-universal-rubinius-1.2
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.
- checksums.yaml +15 -0
- data/.gitignore +3 -0
- data/.travis.yml +4 -0
- data/ChangeLog +162 -0
- data/Gemfile +16 -0
- data/NEWS +15 -8
- data/README.md +72 -0
- data/Rakefile +16 -13
- data/app/client.rb +15 -4
- data/app/cmd_parse.kpeg +38 -40
- data/app/cmd_parse.rb +25 -20
- data/app/cmd_parser.rb +1030 -1036
- data/app/complete.rb +12 -12
- data/app/default.rb +6 -5
- data/app/display.rb +2 -2
- data/app/frame.rb +17 -4
- data/app/method.rb +11 -10
- data/app/options.rb +21 -22
- data/app/util.rb +17 -10
- data/interface/user.rb +2 -2
- data/io/input.rb +13 -3
- data/lib/trepanning.rb +22 -23
- data/processor.rb +32 -32
- data/processor/command.rb +32 -13
- data/processor/command/backtrace.rb +2 -16
- data/processor/command/base/submgr.rb +22 -14
- data/processor/command/base/subsubcmd.rb +11 -13
- data/processor/command/base/subsubmgr.rb +38 -19
- data/processor/command/disassemble.rb +11 -11
- data/processor/command/help.rb +24 -24
- data/processor/command/shell.rb +17 -17
- data/processor/default.rb +5 -2
- data/processor/frame.rb +37 -0
- data/processor/help.rb +9 -11
- data/processor/load_cmds.rb +53 -40
- data/processor/location.rb +2 -2
- data/processor/mock.rb +8 -9
- data/processor/subcmd.rb +12 -12
- data/rbx-trepanning.gemspec +4 -3
- data/sample/rocky-trepanx-colors.rb +1 -1
- data/test/example/factorial.rb +10 -0
- data/test/functional/fn_helper.rb +8 -7
- data/test/functional/test-break.rb +39 -5
- data/test/functional/test-recursive-bt.rb +105 -0
- data/test/integration/helper.rb +14 -14
- data/test/integration/test-quit.rb +8 -2
- data/test/unit/cmd-helper.rb +2 -2
- data/test/unit/test-base-subcmd.rb +14 -3
- data/test/unit/test-completion.rb +7 -3
- data/test/unit/test-io-tcpserver.rb +10 -5
- data/test/unit/test-proc-validate.rb +4 -4
- metadata +208 -113
- data/README.textile +0 -34
data/processor/command/shell.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require 'irb'
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
4
|
require_relative '../command'
|
@@ -13,10 +13,10 @@ class Trepan::Command::IRBCommand < Trepan::Command
|
|
13
13
|
starts an Interactive Ruby (IRB) session.
|
14
14
|
|
15
15
|
If -d is added you can get access to debugger frame the global variables
|
16
|
-
$trepan_frame and $trepan_cmdproc.
|
16
|
+
$trepan_frame and $trepan_cmdproc.
|
17
17
|
|
18
|
-
#{NAME} is extended with methods 'cont', 'ne', and, 'q', 'step' which
|
19
|
-
run the corresponding debugger commands 'continue', 'next', 'exit' and 'step'.
|
18
|
+
#{NAME} is extended with methods 'cont', 'ne', and, 'q', 'step' which
|
19
|
+
run the corresponding debugger commands 'continue', 'next', 'exit' and 'step'.
|
20
20
|
|
21
21
|
To issue a debugger command, inside #{NAME} nested inside a debugger use
|
22
22
|
'dbgr'. For example:
|
@@ -43,7 +43,7 @@ Here then is a loop to query VM stack values:
|
|
43
43
|
|
44
44
|
# This method runs the command
|
45
45
|
def run(args)
|
46
|
-
add_debugging =
|
46
|
+
add_debugging =
|
47
47
|
if args.size > 1
|
48
48
|
'-d' == args[1]
|
49
49
|
else
|
@@ -59,7 +59,7 @@ Here then is a loop to query VM stack values:
|
|
59
59
|
throw :IRB_EXIT, :cont if $trepan_in_irb
|
60
60
|
end
|
61
61
|
|
62
|
-
$trepan = @proc.dbgr
|
62
|
+
$trepan = @proc.dbgr
|
63
63
|
if add_debugging
|
64
64
|
$trepan_cmdproc = @proc
|
65
65
|
$trepan_frame = @proc.frame
|
@@ -72,32 +72,32 @@ Here then is a loop to query VM stack values:
|
|
72
72
|
:RC => true}
|
73
73
|
|
74
74
|
# ?? Should we set GNU readline to what we have,
|
75
|
-
# or let IRB make its own determination?
|
75
|
+
# or let IRB make its own determination?
|
76
76
|
|
77
|
-
# Save the Readline history and set the Readline completion function
|
78
|
-
# to be IRB's function
|
79
|
-
if Trepan::GNU_readline?
|
77
|
+
# Save the Readline history and set the Readline completion function
|
78
|
+
# to be IRB's function
|
79
|
+
if Trepan::GNU_readline?
|
80
80
|
@proc.intf.save_history if @proc.intf.respond_to?(:save_history)
|
81
81
|
require 'irb/completion'
|
82
82
|
Readline.completion_proc = IRB::InputCompletor::CompletionProc
|
83
83
|
end
|
84
84
|
|
85
|
-
# And just when you thought, we'd never get around to
|
85
|
+
# And just when you thought, we'd never get around to
|
86
86
|
# actually running irb...
|
87
87
|
cont = IRB.start_session(@proc.frame.binding, @proc, conf)
|
88
88
|
trap('SIGINT', save_trap) # Restore our old interrupt function.
|
89
89
|
|
90
|
-
# Restore the debuggers' Readline history and the Readline completion
|
90
|
+
# Restore the debuggers' Readline history and the Readline completion
|
91
91
|
# function
|
92
92
|
if Trepan::GNU_readline? && @proc.dbgr.completion_proc
|
93
93
|
@proc.intf.read_history if @proc.intf.respond_to?(:read_history)
|
94
|
-
Readline.completion_proc = @proc.dbgr.completion_proc
|
94
|
+
Readline.completion_proc = @proc.dbgr.completion_proc
|
95
95
|
end
|
96
96
|
|
97
97
|
# Respect any backtrace limit set in irb.
|
98
98
|
back_trace_limit = IRB.CurrentContext.back_trace_limit
|
99
99
|
if settings[:maxstack] != back_trace_limit
|
100
|
-
msg("\nSetting debugger's BACK_TRACE_LIMIT (%d) to match irb's last setting (%d)" %
|
100
|
+
msg("\nSetting debugger's BACK_TRACE_LIMIT (%d) to match irb's last setting (%d)" %
|
101
101
|
[settings[:maxstack], back_trace_limit])
|
102
102
|
settings[:maxstack]= IRB.CurrentContext.back_trace_limit
|
103
103
|
end
|
@@ -106,13 +106,13 @@ Here then is a loop to query VM stack values:
|
|
106
106
|
when :continue
|
107
107
|
@proc.continue
|
108
108
|
when :finish
|
109
|
-
@proc.finish
|
109
|
+
@proc.finish
|
110
110
|
when :next
|
111
|
-
@proc.step
|
111
|
+
@proc.step('next', 1, {})
|
112
112
|
when :quit
|
113
113
|
@proc.quit
|
114
114
|
when :step
|
115
|
-
@proc.step
|
115
|
+
@proc.step('step', 1, {})
|
116
116
|
else
|
117
117
|
@proc.print_location
|
118
118
|
end
|
data/processor/default.rb
CHANGED
@@ -1,9 +1,12 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require 'rubygems'; require 'require_relative'
|
3
3
|
require_relative '../app/default'
|
4
4
|
require_relative 'virtual'
|
5
5
|
class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
6
6
|
|
7
|
+
computed_displaywidth = (ENV['COLUMNS'] || '80').to_i
|
8
|
+
computed_displaywidth = 80 unless computed_displaywidth >= 10
|
9
|
+
|
7
10
|
DEFAULT_SETTINGS = {
|
8
11
|
:abbrev => true, # Allow abbreviations of debugger commands?
|
9
12
|
:autoeval => true, # Ruby eval non-debugger commands
|
@@ -33,7 +36,7 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
33
36
|
:maxstring => 150, # Strings which are larger than this
|
34
37
|
# will be truncated to this length when
|
35
38
|
# printed
|
36
|
-
:maxwidth =>
|
39
|
+
:maxwidth => computed_displaywidth,
|
37
40
|
:prompt => 'trepanx', # core part of prompt. Additional info like
|
38
41
|
# debug nesting and thread name is fixed
|
39
42
|
# and added on.
|
data/processor/frame.rb
CHANGED
@@ -137,6 +137,43 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
137
137
|
frame
|
138
138
|
end
|
139
139
|
|
140
|
+
def print_stack_trace(frame=top_frame, opts={})
|
141
|
+
last_frame = nil
|
142
|
+
# TODO: handle indirect recursion.
|
143
|
+
direct_recursion_count = 0
|
144
|
+
count = opts[:count]
|
145
|
+
verbose = opts[:verbose]
|
146
|
+
|
147
|
+
dbgr.each_frame(frame) do |frame|
|
148
|
+
if count and frame.number >= count
|
149
|
+
msg "(More stack frames follow...)" if count != stack_size
|
150
|
+
return
|
151
|
+
end
|
152
|
+
if frame.location_equal(last_frame)
|
153
|
+
direct_recursion_count += 1
|
154
|
+
else
|
155
|
+
if direct_recursion_count > 0
|
156
|
+
msg("... above line repeated #{direct_recursion_count} times")
|
157
|
+
direct_recursion_count = 0
|
158
|
+
end
|
159
|
+
prefix = (frame == @frame) ? '-->' : ' '
|
160
|
+
|
161
|
+
### FIXME: Move into a method.
|
162
|
+
msg "%s #%d %s" % [prefix, frame.number,
|
163
|
+
frame.describe(:show_ip => verbose,
|
164
|
+
:basename => settings[:basename])]
|
165
|
+
if verbose
|
166
|
+
frame.local_variables.each do |local|
|
167
|
+
msg " #{local} = #{frame.run(local.to_s).inspect}"
|
168
|
+
end
|
169
|
+
end
|
170
|
+
### End FIXME
|
171
|
+
|
172
|
+
end
|
173
|
+
last_frame = frame
|
174
|
+
end
|
175
|
+
end
|
176
|
+
|
140
177
|
def set_hide_level
|
141
178
|
max_stack_size = @dbgr.vm_locations.size
|
142
179
|
@hide_level =
|
data/processor/help.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
|
3
3
|
class Trepan
|
4
4
|
# class SubHelp
|
@@ -9,7 +9,7 @@ class Trepan
|
|
9
9
|
# end
|
10
10
|
|
11
11
|
# def load_sub_help_files(dir)
|
12
|
-
# Dir.glob(dir, '*.txt').each do |txt|
|
12
|
+
# Dir.glob(dir, '*.txt').each do |txt|
|
13
13
|
# basename = File.basename(txt, '.txt')
|
14
14
|
# @list << basename
|
15
15
|
# end
|
@@ -33,16 +33,14 @@ class Trepan
|
|
33
33
|
# The below was the simplest way I could find to do this since
|
34
34
|
# we are the super class but want to set the subclass's constant.
|
35
35
|
# defined? didn't seem to work here.
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
end
|
41
|
-
|
36
|
+
short_help = get_const(self.class, 'SHORT_HELP')
|
37
|
+
short_help = get_const(self.class, 'HELP') unless short_help
|
38
|
+
short_help = short_help.split("\n")[0].chomp('.')
|
39
|
+
|
42
40
|
' %-12s -- %s' %
|
43
|
-
[abbrev_stringify(obj_const(subcmd, :NAME),
|
41
|
+
[abbrev_stringify(obj_const(subcmd, :NAME),
|
44
42
|
obj_const(subcmd, :MIN_ABBREV)),
|
45
|
-
|
43
|
+
short_help]
|
46
44
|
end
|
47
45
|
|
48
46
|
# We were given cmd without a subcommand; cmd is something
|
@@ -77,7 +75,7 @@ Long description goes here.'
|
|
77
75
|
MIN_ABBREV = 1
|
78
76
|
NAME = File.basename(__FILE__)
|
79
77
|
def obj_const(obj, name)
|
80
|
-
obj.class.const_get(name)
|
78
|
+
obj.class.const_get(name)
|
81
79
|
end
|
82
80
|
def msg(mess)
|
83
81
|
puts mess
|
data/processor/load_cmds.rb
CHANGED
@@ -1,9 +1,10 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
-
# Copyright (C) 2010,
|
2
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
3
3
|
require 'tmpdir'
|
4
|
+
require 'redcard/rubinius'
|
4
5
|
|
5
6
|
# Part of Trepan::CmdProcess that loads up debugger commands from
|
6
|
-
# builtin and user directories.
|
7
|
+
# builtin and user directories.
|
7
8
|
# Sets @commands, @aliases, @macros
|
8
9
|
require 'rubygems'; require 'require_relative'
|
9
10
|
require_relative '../app/complete'
|
@@ -15,11 +16,11 @@ class Trepan
|
|
15
16
|
# indexed by alias name
|
16
17
|
attr_reader :commands # Hash[String] of command objects
|
17
18
|
# indexed by name
|
18
|
-
attr_reader :macros # Hash[String] of Proc objects
|
19
|
+
attr_reader :macros # Hash[String] of Proc objects
|
19
20
|
# indexed by macro name.
|
20
|
-
attr_reader :leading_str # leading part of string. Used in
|
21
|
+
attr_reader :leading_str # leading part of string. Used in
|
21
22
|
# command completion
|
22
|
-
|
23
|
+
|
23
24
|
# "initialize" for multi-file class. Called from main.rb's "initialize".
|
24
25
|
def load_cmds_initialize
|
25
26
|
@commands = {}
|
@@ -28,28 +29,43 @@ class Trepan
|
|
28
29
|
|
29
30
|
cmd_dirs = [ File.join(File.dirname(__FILE__), 'command') ]
|
30
31
|
cmd_dirs << @settings[:user_cmd_dir] if @settings[:user_cmd_dir]
|
31
|
-
cmd_dirs.each do |cmd_dir|
|
32
|
+
cmd_dirs.each do |cmd_dir|
|
32
33
|
load_debugger_commands(cmd_dir) if File.directory?(cmd_dir)
|
33
34
|
end
|
34
35
|
end
|
35
36
|
|
37
|
+
def get_class_aliases(klass)
|
38
|
+
if RedCard.check '1.9' and
|
39
|
+
klass.constants.member?(:ALIASES)
|
40
|
+
klass.const_get(:ALIASES)
|
41
|
+
elsif RedCard.check '1.8' and
|
42
|
+
klass.constants.member?('ALIASES')
|
43
|
+
klass.const_get('ALIASES')
|
44
|
+
else
|
45
|
+
[]
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
36
49
|
# Loads in debugger commands by require'ing each ruby file in the
|
37
|
-
# 'command' directory. Then a new instance of each class of the
|
50
|
+
# 'command' directory. Then a new instance of each class of the
|
38
51
|
# form Trepan::xxCommand is added to @commands and that array
|
39
52
|
# is returned.
|
40
53
|
def load_debugger_commands(file_or_dir)
|
41
54
|
if File.directory?(file_or_dir)
|
42
55
|
dir = File.expand_path(file_or_dir)
|
43
|
-
#
|
44
|
-
|
56
|
+
# Change $0 so it doesn't get in the way of __FILE__ = $0.
|
57
|
+
# In rubinius 2.0.0.rc1 (1.8.7 93c75658...) $0 is nil
|
58
|
+
# and this can cause an error when one restores $0 below.
|
59
|
+
# See https://github.com/rubinius/rubinius/issues/2450
|
60
|
+
old_dollar0 = $0 || '' #
|
45
61
|
$0 = ''
|
46
|
-
Dir.glob(File.join(dir, '*.rb')).each do |rb|
|
62
|
+
Dir.glob(File.join(dir, '*.rb')).each do |rb|
|
47
63
|
# We use require so that multiple calls have no effect.
|
48
64
|
require rb
|
49
65
|
end
|
50
66
|
$0 = old_dollar0
|
51
67
|
elsif File.readable?(file_or_dir)
|
52
|
-
# We use load in case we are reloading.
|
68
|
+
# We use load in case we are reloading.
|
53
69
|
# 'require' would not be effective here
|
54
70
|
load file_or_dir
|
55
71
|
else
|
@@ -60,12 +76,11 @@ class Trepan
|
|
60
76
|
klass = Trepan::Command.const_get(name)
|
61
77
|
cmd = klass.send(:new, self)
|
62
78
|
|
79
|
+
cmd_name = klass.const_get(:NAME)
|
80
|
+
|
63
81
|
# Add to list of commands and aliases.
|
64
82
|
cmd_name = klass.const_get(:NAME)
|
65
|
-
|
66
|
-
aliases= klass.const_get('ALIASES')
|
67
|
-
aliases.each {|a| @aliases[a] = cmd_name}
|
68
|
-
end
|
83
|
+
get_class_aliases(klass).each {|a| @aliases[a] = cmd_name}
|
69
84
|
@commands[cmd_name] = cmd
|
70
85
|
end
|
71
86
|
end
|
@@ -77,17 +92,14 @@ class Trepan
|
|
77
92
|
# command, but I don't know it. And eval works.
|
78
93
|
klass = self.instance_eval("Trepan::Command::#{command}")
|
79
94
|
cmd = klass.send(:new, self)
|
80
|
-
|
95
|
+
|
81
96
|
# Add to list of commands and aliases.
|
82
97
|
cmd_name = klass.const_get(:NAME)
|
83
|
-
|
84
|
-
aliases= klass.const_get(:ALIASES)
|
85
|
-
aliases.each {|a| @aliases[a] = cmd_name}
|
86
|
-
end
|
98
|
+
get_class_aliases.each {|a| @aliases[a] = cmd_name}
|
87
99
|
@commands[cmd_name] = cmd
|
88
100
|
end
|
89
101
|
|
90
|
-
# Looks up cmd_array[0] in @commands and runs that. We do lots of
|
102
|
+
# Looks up cmd_array[0] in @commands and runs that. We do lots of
|
91
103
|
# validity testing on cmd_array.
|
92
104
|
def run_cmd(cmd_array)
|
93
105
|
unless cmd_array.is_a?(Array)
|
@@ -95,12 +107,12 @@ class Trepan
|
|
95
107
|
return
|
96
108
|
end
|
97
109
|
if cmd_array.detect{|item| !item.is_a?(String)}
|
98
|
-
errmsg "run_cmd argument Array should only contain strings. " +
|
110
|
+
errmsg "run_cmd argument Array should only contain strings. " +
|
99
111
|
"Got #{cmd_array.inspect}"
|
100
112
|
return
|
101
113
|
end
|
102
114
|
if cmd_array.empty?
|
103
|
-
errmsg "run_cmd Array should have at least one item. " +
|
115
|
+
errmsg "run_cmd Array should have at least one item. " +
|
104
116
|
"Got: #{cmd_array.inspect}"
|
105
117
|
return
|
106
118
|
end
|
@@ -111,7 +123,7 @@ class Trepan
|
|
111
123
|
end
|
112
124
|
|
113
125
|
def save_commands(opts)
|
114
|
-
save_filename = opts[:filename] ||
|
126
|
+
save_filename = opts[:filename] ||
|
115
127
|
File.join(Dir.tmpdir, "trepanning-save-#{$$}.txt")
|
116
128
|
begin
|
117
129
|
save_file = File.open(save_filename, 'w')
|
@@ -125,16 +137,16 @@ class Trepan
|
|
125
137
|
cmd_obj.save_command if cmd_obj.respond_to?(:save_command)
|
126
138
|
next unless cmd_obj.is_a?(Trepan::SubcommandMgr)
|
127
139
|
cmd_obj.subcmds.subcmds.each do |subcmd_name, subcmd_obj|
|
128
|
-
save_file.puts subcmd_obj.save_command if
|
140
|
+
save_file.puts subcmd_obj.save_command if
|
129
141
|
subcmd_obj.respond_to?(:save_command)
|
130
142
|
next unless subcmd_obj.is_a?(Trepan::SubSubcommandMgr)
|
131
143
|
subcmd_obj.subcmds.subcmds.each do |subsubcmd_name, subsubcmd_obj|
|
132
|
-
save_file.puts subsubcmd_obj.save_command if
|
144
|
+
save_file.puts subsubcmd_obj.save_command if
|
133
145
|
subsubcmd_obj.respond_to?(:save_command)
|
134
146
|
end
|
135
147
|
end
|
136
148
|
end
|
137
|
-
save_file.puts "!FileUtils.rm #{save_filename.inspect}" if
|
149
|
+
save_file.puts "!FileUtils.rm #{save_filename.inspect}" if
|
138
150
|
opts[:erase]
|
139
151
|
save_file.close
|
140
152
|
|
@@ -181,16 +193,16 @@ class Trepan
|
|
181
193
|
def next_complete(str, next_blank_pos, cmd, last_token)
|
182
194
|
next_blank_pos, token = Trepan::Complete.next_token(str, next_blank_pos)
|
183
195
|
return [] if token.empty? && !last_token.empty?
|
184
|
-
|
185
|
-
if cmd.respond_to?(:complete_token_with_next)
|
196
|
+
|
197
|
+
if cmd.respond_to?(:complete_token_with_next)
|
186
198
|
match_pairs = cmd.complete_token_with_next(token)
|
187
199
|
return [] if match_pairs.empty?
|
188
|
-
if str[next_blank_pos..-1].rstrip.empty? &&
|
200
|
+
if str[next_blank_pos..-1].rstrip.empty? &&
|
189
201
|
(token.empty? || token == last_token)
|
190
202
|
return match_pairs.map { |completion, junk| completion }
|
191
203
|
else
|
192
204
|
if match_pairs.size == 1
|
193
|
-
return next_complete(str, next_blank_pos, match_pairs[0][1],
|
205
|
+
return next_complete(str, next_blank_pos, match_pairs[0][1],
|
194
206
|
last_token)
|
195
207
|
else
|
196
208
|
# FIXME: figure out what to do here.
|
@@ -202,7 +214,7 @@ class Trepan
|
|
202
214
|
elsif cmd.respond_to?(:complete)
|
203
215
|
matches = cmd.complete(token)
|
204
216
|
return [] if matches.empty?
|
205
|
-
if str[next_blank_pos..-1].rstrip.empty? &&
|
217
|
+
if str[next_blank_pos..-1].rstrip.empty? &&
|
206
218
|
(token.empty? || token == last_token)
|
207
219
|
return matches
|
208
220
|
else
|
@@ -224,14 +236,6 @@ if __FILE__ == $0
|
|
224
236
|
end
|
225
237
|
|
226
238
|
cmdproc = Trepan::CmdProcessor.new(nil)
|
227
|
-
cmddir = File.join(File.dirname(__FILE__), 'command')
|
228
|
-
cmdproc.instance_variable_set('@settings', {})
|
229
|
-
cmdproc.load_cmds_initialize
|
230
|
-
require 'columnize'
|
231
|
-
puts Columnize.columnize(cmdproc.commands.keys.sort)
|
232
|
-
puts '=' * 20
|
233
|
-
puts Columnize.columnize(cmdproc.aliases.keys.sort)
|
234
|
-
puts '=' * 20
|
235
239
|
|
236
240
|
def cmdproc.errmsg(mess)
|
237
241
|
puts "** #{mess}"
|
@@ -241,6 +245,15 @@ if __FILE__ == $0
|
|
241
245
|
puts mess
|
242
246
|
end
|
243
247
|
|
248
|
+
cmddir = File.join(File.dirname(__FILE__), 'command')
|
249
|
+
cmdproc.instance_variable_set('@settings', {})
|
250
|
+
cmdproc.load_cmds_initialize
|
251
|
+
require 'columnize'
|
252
|
+
puts Columnize.columnize(cmdproc.commands.keys.sort)
|
253
|
+
puts '=' * 20
|
254
|
+
puts Columnize.columnize(cmdproc.aliases.keys.sort)
|
255
|
+
puts '=' * 20
|
256
|
+
|
244
257
|
cmdproc.run_cmd('foo') # Invalid - not an Array
|
245
258
|
cmdproc.run_cmd([]) # Invalid - empty Array
|
246
259
|
cmdproc.run_cmd(['list', 5]) # Invalid - nonstring arg
|
data/processor/location.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
require 'rubygems';
|
3
3
|
require 'pathname' # For cleanpath
|
4
4
|
require 'linecache'
|
@@ -124,7 +124,7 @@ class Trepan::CmdProcessor < Trepan::VirtualCmdProcessor
|
|
124
124
|
vm_location = @frame.vm_location
|
125
125
|
filename = vm_location.method.active_path
|
126
126
|
line_no = @frame.line
|
127
|
-
static = vm_location.
|
127
|
+
static = vm_location.constant_scope
|
128
128
|
opts[:compiled_method] = top_scope(@frame.method)
|
129
129
|
|
130
130
|
if @frame.eval?
|
data/processor/mock.rb
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
# Copyright (C) 2010,
|
1
|
+
# Copyright (C) 2010-2011, 2013 Rocky Bernstein <rockyb@rubyforge.net>
|
2
2
|
# Mock setup for commands.
|
3
3
|
require 'rubygems'; require 'require_relative'
|
4
4
|
|
@@ -18,14 +18,14 @@ module MockDebugger
|
|
18
18
|
attr_accessor :intf # The way the outside world interfaces with us.
|
19
19
|
attr_reader :initial_dir # String. Current directory when program
|
20
20
|
# started. Used in restart program.
|
21
|
-
attr_accessor :restart_argv # How to restart us, empty or nil.
|
21
|
+
attr_accessor :restart_argv # How to restart us, empty or nil.
|
22
22
|
# Note restart[0] is typically $0.
|
23
23
|
attr_reader :settings # Hash[:symbol] of things you can configure
|
24
24
|
attr_accessor :processor
|
25
25
|
|
26
26
|
# FIXME: move more stuff of here and into Trepan::CmdProcessor
|
27
27
|
# These below should go into Trepan::CmdProcessor.
|
28
|
-
attr_reader :cmd_argstr, :cmd_name, :vm_locations, :current_frame,
|
28
|
+
attr_reader :cmd_argstr, :cmd_name, :vm_locations, :current_frame,
|
29
29
|
:debugee_thread, :completion_proc
|
30
30
|
|
31
31
|
def initialize(settings={:start_frame=>1})
|
@@ -45,7 +45,7 @@ module MockDebugger
|
|
45
45
|
@completion_proc = Proc.new{|str| str}
|
46
46
|
|
47
47
|
# Don't allow user commands in mocks.
|
48
|
-
## @core.processor.settings[:user_cmd_dir] = nil
|
48
|
+
## @core.processor.settings[:user_cmd_dir] = nil
|
49
49
|
|
50
50
|
end
|
51
51
|
|
@@ -54,7 +54,7 @@ module MockDebugger
|
|
54
54
|
end
|
55
55
|
end
|
56
56
|
|
57
|
-
# Common Mock debugger setup
|
57
|
+
# Common Mock debugger setup
|
58
58
|
def setup(name=nil, show_constants=true)
|
59
59
|
unless name
|
60
60
|
loc = Rubinius::VM.backtrace(1, true)[0]
|
@@ -72,7 +72,7 @@ module MockDebugger
|
|
72
72
|
cmdproc = Trepan::CmdProcessor.new(dbgr)
|
73
73
|
cmdproc.frame = dbgr.frame(0)
|
74
74
|
dbgr.processor = cmdproc
|
75
|
-
|
75
|
+
|
76
76
|
cmdproc.load_cmds_initialize
|
77
77
|
cmds = cmdproc.commands
|
78
78
|
cmd = cmds[name]
|
@@ -116,9 +116,8 @@ module MockDebugger
|
|
116
116
|
module_function :subsub_setup
|
117
117
|
|
118
118
|
def show_special_class_constants(cmd)
|
119
|
-
puts 'ALIASES: %s' % [cmd.
|
120
|
-
|
121
|
-
%w(CATEGORY MIN_ARGS MAX_ARGS
|
119
|
+
puts 'ALIASES: %s' % [cmd.proc.get_class_aliases(cmd.class).inspect]
|
120
|
+
%w(CATEGORY MIN_ARGS MAX_ARGS
|
122
121
|
NAME NEED_STACK SHORT_HELP).each do |name|
|
123
122
|
puts '%s: %s' % [name, cmd.class.const_get(name).inspect]
|
124
123
|
end
|