debugger2 1.0.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +12 -0
- data/.travis.yml +3 -0
- data/AUTHORS +10 -0
- data/CHANGELOG.md +65 -0
- data/CONTRIBUTING.md +1 -0
- data/Gemfile +3 -0
- data/LICENSE +23 -0
- data/OLDER_CHANGELOG +334 -0
- data/OLD_CHANGELOG +5655 -0
- data/OLD_README +122 -0
- data/README.md +108 -0
- data/Rakefile +78 -0
- data/bin/rdebug +397 -0
- data/debugger2.gemspec +29 -0
- data/doc/.cvsignore +42 -0
- data/doc/Makefile.am +63 -0
- data/doc/emacs-notes.txt +38 -0
- data/doc/hanoi.rb +35 -0
- data/doc/primes.rb +28 -0
- data/doc/rdebug-emacs.texi +1030 -0
- data/doc/ruby-debug.texi +3791 -0
- data/doc/test-tri2.rb +18 -0
- data/doc/tri3.rb +8 -0
- data/doc/triangle.rb +12 -0
- data/emacs/Makefile.am +130 -0
- data/emacs/rdebug-annotate.el +385 -0
- data/emacs/rdebug-breaks.el +407 -0
- data/emacs/rdebug-cmd.el +92 -0
- data/emacs/rdebug-core.el +502 -0
- data/emacs/rdebug-dbg.el +62 -0
- data/emacs/rdebug-error.el +79 -0
- data/emacs/rdebug-fns.el +111 -0
- data/emacs/rdebug-frames.el +230 -0
- data/emacs/rdebug-gud.el +242 -0
- data/emacs/rdebug-help.el +104 -0
- data/emacs/rdebug-info.el +83 -0
- data/emacs/rdebug-layouts.el +180 -0
- data/emacs/rdebug-locring.el +118 -0
- data/emacs/rdebug-output.el +106 -0
- data/emacs/rdebug-regexp.el +118 -0
- data/emacs/rdebug-secondary.el +260 -0
- data/emacs/rdebug-shortkey.el +175 -0
- data/emacs/rdebug-source.el +568 -0
- data/emacs/rdebug-track.el +392 -0
- data/emacs/rdebug-varbuf.el +150 -0
- data/emacs/rdebug-vars.el +125 -0
- data/emacs/rdebug-watch.el +132 -0
- data/emacs/rdebug.el +326 -0
- data/emacs/test/elk-test.el +242 -0
- data/emacs/test/test-annotate.el +103 -0
- data/emacs/test/test-cmd.el +116 -0
- data/emacs/test/test-core.el +104 -0
- data/emacs/test/test-fns.el +65 -0
- data/emacs/test/test-frames.el +62 -0
- data/emacs/test/test-gud.el +35 -0
- data/emacs/test/test-indent.el +58 -0
- data/emacs/test/test-regexp.el +144 -0
- data/emacs/test/test-shortkey.el +61 -0
- data/ext/ruby_debug/breakpoint.c +630 -0
- data/ext/ruby_debug/extconf.rb +11 -0
- data/ext/ruby_debug/ruby_debug.c +2203 -0
- data/ext/ruby_debug/ruby_debug.h +151 -0
- data/lib/debugger.rb +5 -0
- data/lib/debugger/version.rb +5 -0
- data/lib/debugger2.rb +6 -0
- data/lib/ruby-debug-base.rb +307 -0
- data/lib/ruby-debug.rb +176 -0
- data/lib/ruby-debug/command.rb +227 -0
- data/lib/ruby-debug/commands/breakpoints.rb +153 -0
- data/lib/ruby-debug/commands/catchpoint.rb +55 -0
- data/lib/ruby-debug/commands/condition.rb +49 -0
- data/lib/ruby-debug/commands/continue.rb +38 -0
- data/lib/ruby-debug/commands/control.rb +107 -0
- data/lib/ruby-debug/commands/display.rb +120 -0
- data/lib/ruby-debug/commands/edit.rb +48 -0
- data/lib/ruby-debug/commands/enable.rb +202 -0
- data/lib/ruby-debug/commands/eval.rb +176 -0
- data/lib/ruby-debug/commands/finish.rb +42 -0
- data/lib/ruby-debug/commands/frame.rb +301 -0
- data/lib/ruby-debug/commands/help.rb +56 -0
- data/lib/ruby-debug/commands/info.rb +467 -0
- data/lib/ruby-debug/commands/irb.rb +123 -0
- data/lib/ruby-debug/commands/jump.rb +66 -0
- data/lib/ruby-debug/commands/kill.rb +51 -0
- data/lib/ruby-debug/commands/list.rb +94 -0
- data/lib/ruby-debug/commands/method.rb +84 -0
- data/lib/ruby-debug/commands/quit.rb +39 -0
- data/lib/ruby-debug/commands/reload.rb +40 -0
- data/lib/ruby-debug/commands/save.rb +90 -0
- data/lib/ruby-debug/commands/set.rb +223 -0
- data/lib/ruby-debug/commands/show.rb +247 -0
- data/lib/ruby-debug/commands/skip.rb +35 -0
- data/lib/ruby-debug/commands/source.rb +36 -0
- data/lib/ruby-debug/commands/stepping.rb +81 -0
- data/lib/ruby-debug/commands/threads.rb +189 -0
- data/lib/ruby-debug/commands/tmate.rb +36 -0
- data/lib/ruby-debug/commands/trace.rb +57 -0
- data/lib/ruby-debug/commands/variables.rb +199 -0
- data/lib/ruby-debug/debugger.rb +5 -0
- data/lib/ruby-debug/helper.rb +69 -0
- data/lib/ruby-debug/interface.rb +232 -0
- data/lib/ruby-debug/processor.rb +474 -0
- data/man/rdebug.1 +241 -0
- data/old_scripts/Makefile.am +14 -0
- data/old_scripts/README.md +2 -0
- data/old_scripts/autogen.sh +4 -0
- data/old_scripts/configure.ac +12 -0
- data/old_scripts/rdbg.rb +33 -0
- data/old_scripts/runner.sh +7 -0
- data/old_scripts/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/breakpoints_test.rb +366 -0
- data/test/conditions_test.rb +77 -0
- data/test/continue_test.rb +28 -0
- data/test/display_test.rb +143 -0
- data/test/edit_test.rb +55 -0
- data/test/eval_test.rb +94 -0
- data/test/examples/breakpoint1.rb +15 -0
- data/test/examples/breakpoint2.rb +7 -0
- data/test/examples/conditions.rb +4 -0
- data/test/examples/continue.rb +4 -0
- data/test/examples/display.rb +5 -0
- data/test/examples/edit.rb +3 -0
- data/test/examples/edit2.rb +3 -0
- data/test/examples/eval.rb +4 -0
- data/test/examples/finish.rb +20 -0
- data/test/examples/frame.rb +31 -0
- data/test/examples/help.rb +2 -0
- data/test/examples/info.rb +48 -0
- data/test/examples/info2.rb +3 -0
- data/test/examples/irb.rb +6 -0
- data/test/examples/jump.rb +14 -0
- data/test/examples/kill.rb +2 -0
- data/test/examples/list.rb +12 -0
- data/test/examples/method.rb +15 -0
- data/test/examples/post_mortem.rb +19 -0
- data/test/examples/quit.rb +2 -0
- data/test/examples/reload.rb +6 -0
- data/test/examples/restart.rb +6 -0
- data/test/examples/save.rb +3 -0
- data/test/examples/set.rb +3 -0
- data/test/examples/set_annotate.rb +12 -0
- data/test/examples/settings.rb +1 -0
- data/test/examples/show.rb +2 -0
- data/test/examples/source.rb +3 -0
- data/test/examples/stepping.rb +21 -0
- data/test/examples/thread.rb +32 -0
- data/test/examples/tmate.rb +10 -0
- data/test/examples/trace.rb +7 -0
- data/test/examples/trace_threads.rb +20 -0
- data/test/examples/variables.rb +26 -0
- data/test/finish_test.rb +49 -0
- data/test/frame_test.rb +140 -0
- data/test/help_test.rb +51 -0
- data/test/info_test.rb +326 -0
- data/test/irb_test.rb +82 -0
- data/test/jump_test.rb +70 -0
- data/test/kill_test.rb +49 -0
- data/test/list_test.rb +147 -0
- data/test/method_test.rb +72 -0
- data/test/post_mortem_test.rb +25 -0
- data/test/quit_test.rb +56 -0
- data/test/reload_test.rb +47 -0
- data/test/restart_test.rb +145 -0
- data/test/save_test.rb +94 -0
- data/test/set_test.rb +183 -0
- data/test/show_test.rb +294 -0
- data/test/source_test.rb +46 -0
- data/test/stepping_test.rb +122 -0
- data/test/support/breakpoint.rb +12 -0
- data/test/support/context.rb +14 -0
- data/test/support/matchers.rb +67 -0
- data/test/support/mocha_extensions.rb +71 -0
- data/test/support/processor.rb +7 -0
- data/test/support/test_dsl.rb +206 -0
- data/test/support/test_interface.rb +66 -0
- data/test/test_helper.rb +9 -0
- data/test/thread_test.rb +124 -0
- data/test/tmate_test.rb +45 -0
- data/test/trace_test.rb +156 -0
- data/test/variables_test.rb +116 -0
- metadata +319 -0
@@ -0,0 +1,40 @@
|
|
1
|
+
module Debugger
|
2
|
+
# Implements debugger "reload" command.
|
3
|
+
class ReloadCommand < Command
|
4
|
+
self.allow_in_control = true
|
5
|
+
|
6
|
+
register_setting_get(:reload_source_on_change) do
|
7
|
+
Debugger.reload_source_on_change
|
8
|
+
end
|
9
|
+
register_setting_set(:reload_source_on_change) do |value|
|
10
|
+
Debugger.reload_source_on_change = value
|
11
|
+
end
|
12
|
+
|
13
|
+
def regexp
|
14
|
+
/^\s*r(?:eload)?$/
|
15
|
+
end
|
16
|
+
|
17
|
+
def execute
|
18
|
+
Debugger.source_reload
|
19
|
+
print "Source code is reloaded. Automatic reloading is #{source_reloading}.\n"
|
20
|
+
end
|
21
|
+
|
22
|
+
private
|
23
|
+
|
24
|
+
def source_reloading
|
25
|
+
Debugger.reload_source_on_change ? 'on' : 'off'
|
26
|
+
end
|
27
|
+
|
28
|
+
class << self
|
29
|
+
def help_command
|
30
|
+
'reload'
|
31
|
+
end
|
32
|
+
|
33
|
+
def help(cmd)
|
34
|
+
%{
|
35
|
+
r[eload]\tforces source code reloading
|
36
|
+
}
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Debugger
|
2
|
+
module SaveFunctions # :nodoc:
|
3
|
+
|
4
|
+
# Create a temporary file to write in if file is nil
|
5
|
+
def open_save
|
6
|
+
require "tempfile"
|
7
|
+
file = Tempfile.new("rdebug-save")
|
8
|
+
# We want close to not unlink, so redefine.
|
9
|
+
def file.close
|
10
|
+
@tmpfile.close if @tmpfile
|
11
|
+
end
|
12
|
+
return file
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
class SaveCommand < Command # :nodoc:
|
17
|
+
self.allow_in_control = true
|
18
|
+
|
19
|
+
def save_breakpoints(file)
|
20
|
+
Debugger.breakpoints.each do |b|
|
21
|
+
file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def save_catchpoints(file)
|
26
|
+
Debugger.catchpoints.keys.each do |c|
|
27
|
+
file.puts "catch #{c}"
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
def save_displays(file)
|
32
|
+
for d in @state.display
|
33
|
+
if d[0]
|
34
|
+
file.puts "display #{d[1]}"
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def save_settings(file)
|
40
|
+
# FIXME put routine in set
|
41
|
+
%w(autoeval basename debuggertesting).each do |setting|
|
42
|
+
on_off = show_onoff(Command.settings[setting.to_sym])
|
43
|
+
file.puts "set #{setting} #{on_off}"
|
44
|
+
end
|
45
|
+
%w(autolist autoirb).each do |setting|
|
46
|
+
on_off = show_onoff(Command.settings[setting.to_sym] > 0)
|
47
|
+
file.puts "set #{setting} #{on_off}"
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
def regexp
|
52
|
+
/^\s* sa(?:ve)?
|
53
|
+
(?:\s+(.+))?
|
54
|
+
\s*$/ix
|
55
|
+
end
|
56
|
+
|
57
|
+
def execute
|
58
|
+
if not @match[1] or @match[1].strip.empty?
|
59
|
+
file = open_save()
|
60
|
+
else
|
61
|
+
file = open(@match[1], 'w')
|
62
|
+
end
|
63
|
+
save_breakpoints(file)
|
64
|
+
save_catchpoints(file)
|
65
|
+
# save_displays(file)
|
66
|
+
save_settings(file)
|
67
|
+
print "Saved to '#{file.path}'\n"
|
68
|
+
if @state and @state.interface
|
69
|
+
@state.interface.restart_file = file.path
|
70
|
+
end
|
71
|
+
file.close
|
72
|
+
end
|
73
|
+
|
74
|
+
class << self
|
75
|
+
def help_command
|
76
|
+
'save'
|
77
|
+
end
|
78
|
+
|
79
|
+
def help(cmd)
|
80
|
+
%{
|
81
|
+
save [FILE]
|
82
|
+
Saves current debugger state to FILE as a script file.
|
83
|
+
This includes breakpoints, catchpoints, display expressions and some settings.
|
84
|
+
If no filename is given, we will fabricate one.
|
85
|
+
|
86
|
+
Use the 'source' command in another debug session to restore them.}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -0,0 +1,223 @@
|
|
1
|
+
module Debugger
|
2
|
+
# Implements debugger "set" command.
|
3
|
+
class SetCommand < Command
|
4
|
+
SubcmdStruct2=Struct.new(:name, :min, :is_bool, :short_help,
|
5
|
+
:long_help) unless defined?(SubcmdStruct2)
|
6
|
+
Subcommands =
|
7
|
+
[
|
8
|
+
['annotate', 2, false,
|
9
|
+
"Set annotation level",
|
10
|
+
"0 == normal;
|
11
|
+
2 == output annotated suitably for use by programs that control
|
12
|
+
ruby-debug."],
|
13
|
+
['args', 2, false,
|
14
|
+
"Set argument list to give program being debugged when it is started",
|
15
|
+
"Follow this command with any number of args, to be passed to the program."],
|
16
|
+
['autoeval', 4, true,
|
17
|
+
"Evaluate every unrecognized command"],
|
18
|
+
['autolist', 4, true,
|
19
|
+
"Execute 'list' command on every breakpoint"],
|
20
|
+
['autoirb', 4, true,
|
21
|
+
"Invoke IRB on every stop"],
|
22
|
+
['autoreload', 4, true,
|
23
|
+
"Reload source code when changed"],
|
24
|
+
['basename', 1, true,
|
25
|
+
"Report file basename only showing file names"],
|
26
|
+
['callstyle', 2, false,
|
27
|
+
"Set how you want call parameters displayed"],
|
28
|
+
['debuggertesting', 8, false,
|
29
|
+
"Used when testing the debugger"],
|
30
|
+
['forcestep', 2, true,
|
31
|
+
"Make sure 'next/step' commands always move to a new line"],
|
32
|
+
['fullpath', 2, true,
|
33
|
+
"Display full file names in frames"],
|
34
|
+
['history', 2, false,
|
35
|
+
"Generic command for setting command history parameters",
|
36
|
+
"set history filename -- Set the filename in which to record the command history
|
37
|
+
set history save -- Set saving of the history record on exit
|
38
|
+
set history size -- Set the size of the command history"],
|
39
|
+
['linetrace+', 10, true,
|
40
|
+
"Set line execution tracing to show different lines"],
|
41
|
+
['linetrace', 3, true,
|
42
|
+
"Set line execution tracing"],
|
43
|
+
['listsize', 3, false,
|
44
|
+
"Set number of source lines to list by default"],
|
45
|
+
['trace', 1, true,
|
46
|
+
"Display stack trace when 'eval' raises exception"],
|
47
|
+
['width', 1, false,
|
48
|
+
"Number of characters the debugger thinks are in a line"],
|
49
|
+
].map do |name, min, is_bool, short_help, long_help|
|
50
|
+
SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
|
51
|
+
end unless defined?(Subcommands)
|
52
|
+
|
53
|
+
self.allow_in_control = true
|
54
|
+
|
55
|
+
def regexp
|
56
|
+
/^set (?: \s+ (.*) )?$/ix
|
57
|
+
end
|
58
|
+
|
59
|
+
def execute
|
60
|
+
if not @match[1]
|
61
|
+
print "\"set\" must be followed by the name of an set command:\n"
|
62
|
+
print "List of set subcommands:\n\n"
|
63
|
+
for subcmd in Subcommands do
|
64
|
+
print "set #{subcmd.name} -- #{subcmd.short_help}\n"
|
65
|
+
end
|
66
|
+
else
|
67
|
+
args = @match[1].split(/[ \t]+/)
|
68
|
+
subcmd = args.shift
|
69
|
+
subcmd.downcase!
|
70
|
+
if subcmd =~ /^no/i
|
71
|
+
set_on = false
|
72
|
+
subcmd = subcmd[2..-1]
|
73
|
+
else
|
74
|
+
set_on = true
|
75
|
+
end
|
76
|
+
for try_subcmd in Subcommands do
|
77
|
+
if (subcmd.size >= try_subcmd.min) and
|
78
|
+
(try_subcmd.name[0..subcmd.size-1] == subcmd)
|
79
|
+
begin
|
80
|
+
if try_subcmd.is_bool
|
81
|
+
if args.size > 0
|
82
|
+
set_on = get_onoff(args[0])
|
83
|
+
end
|
84
|
+
end
|
85
|
+
case try_subcmd.name
|
86
|
+
when /^annotate$/
|
87
|
+
level = get_int(args[0], "Set annotate", 0, 3, 0)
|
88
|
+
if level
|
89
|
+
Debugger.annotate = level
|
90
|
+
else
|
91
|
+
return
|
92
|
+
end
|
93
|
+
if defined?(Debugger::RDEBUG_SCRIPT)
|
94
|
+
# rdebug was called initially. 1st arg is script name.
|
95
|
+
Command.settings[:argv][1..-1] = args
|
96
|
+
else
|
97
|
+
# rdebug wasn't called initially. 1st arg is not script name.
|
98
|
+
Command.settings[:argv] = args
|
99
|
+
end
|
100
|
+
when /^args$/
|
101
|
+
Command.settings[:argv][1..-1] = args
|
102
|
+
when /^autolist$/
|
103
|
+
Command.settings[:autolist] = (set_on ? 1 : 0)
|
104
|
+
when /^autoeval$/
|
105
|
+
Command.settings[:autoeval] = set_on
|
106
|
+
when /^basename$/
|
107
|
+
Command.settings[:basename] = set_on
|
108
|
+
when /^callstyle$/
|
109
|
+
if args[0]
|
110
|
+
arg = args[0].downcase.to_sym
|
111
|
+
case arg
|
112
|
+
when :short, :last
|
113
|
+
Command.settings[:callstyle] = arg
|
114
|
+
print "%s\n" % show_setting(try_subcmd.name)
|
115
|
+
return
|
116
|
+
end
|
117
|
+
end
|
118
|
+
print "Invalid call style #{arg}. Should be one of: " +
|
119
|
+
"'short' or 'last'.\n"
|
120
|
+
when /^trace$/
|
121
|
+
Command.settings[:stack_trace_on_error] = set_on
|
122
|
+
when /^fullpath$/
|
123
|
+
Command.settings[:full_path] = set_on
|
124
|
+
when /^autoreload$/
|
125
|
+
Command.settings[:reload_source_on_change] = set_on
|
126
|
+
when /^autoirb$/
|
127
|
+
Command.settings[:autoirb] = (set_on ? 1 : 0)
|
128
|
+
when /^debuggertesting$/
|
129
|
+
Command.settings[:debuggertesting] = set_on
|
130
|
+
if set_on
|
131
|
+
Command.settings[:basename] = true
|
132
|
+
end
|
133
|
+
when /^forcestep$/
|
134
|
+
self.class.settings[:force_stepping] = set_on
|
135
|
+
when /^history$/
|
136
|
+
if 2 == args.size
|
137
|
+
interface = @state.interface
|
138
|
+
case args[0]
|
139
|
+
when /^save$/
|
140
|
+
interface.history_save = get_onoff(args[1])
|
141
|
+
when /^size$/
|
142
|
+
interface.history_length = get_int(args[1],
|
143
|
+
"Set history size")
|
144
|
+
when /^filename$/
|
145
|
+
interface.histfile = File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", args[1])
|
146
|
+
else
|
147
|
+
print "Invalid history parameter #{args[0]}. Should be 'filename', 'save' or 'size'.\n"
|
148
|
+
end
|
149
|
+
else
|
150
|
+
print "Need two parameters for 'set history'; got #{args.size}.\n"
|
151
|
+
return
|
152
|
+
end
|
153
|
+
when /^linetrace\+$/
|
154
|
+
self.class.settings[:tracing_plus] = set_on
|
155
|
+
when /^linetrace$/
|
156
|
+
Debugger.tracing = set_on
|
157
|
+
when /^listsize$/
|
158
|
+
listsize = get_int(args[0], "Set listsize", 1, nil, 10)
|
159
|
+
if listsize
|
160
|
+
self.class.settings[:listsize] = listsize
|
161
|
+
else
|
162
|
+
return
|
163
|
+
end
|
164
|
+
when /^width$/
|
165
|
+
width = get_int(args[0], "Set width", 10, nil, 80)
|
166
|
+
if width
|
167
|
+
self.class.settings[:width] = width
|
168
|
+
ENV['COLUMNS'] = width.to_s
|
169
|
+
else
|
170
|
+
return
|
171
|
+
end
|
172
|
+
else
|
173
|
+
print "Unknown setting #{@match[1]}.\n"
|
174
|
+
return
|
175
|
+
end
|
176
|
+
print "%s\n" % show_setting(try_subcmd.name)
|
177
|
+
return
|
178
|
+
rescue RuntimeError
|
179
|
+
return
|
180
|
+
end
|
181
|
+
end
|
182
|
+
end
|
183
|
+
print "Unknown set command #{subcmd}\n"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
187
|
+
class << self
|
188
|
+
def help_command
|
189
|
+
"set"
|
190
|
+
end
|
191
|
+
|
192
|
+
def help(args)
|
193
|
+
if args[1]
|
194
|
+
s = args[1]
|
195
|
+
subcmd = Subcommands.find do |try_subcmd|
|
196
|
+
(s.size >= try_subcmd.min) and
|
197
|
+
(try_subcmd.name[0..s.size-1] == s)
|
198
|
+
end
|
199
|
+
if subcmd
|
200
|
+
str = subcmd.short_help + '.'
|
201
|
+
str += "\n" + subcmd.long_help if subcmd.long_help
|
202
|
+
return str
|
203
|
+
else
|
204
|
+
return "Invalid 'set' subcommand '#{args[1]}'."
|
205
|
+
end
|
206
|
+
end
|
207
|
+
s = %{
|
208
|
+
Modifies parts of the ruby-debug environment. Boolean values take
|
209
|
+
on, off, 1 or 0.
|
210
|
+
You can see these environment settings with the \"show\" command.
|
211
|
+
|
212
|
+
--
|
213
|
+
List of set subcommands:
|
214
|
+
--
|
215
|
+
}
|
216
|
+
for subcmd in Subcommands do
|
217
|
+
s += "set #{subcmd.name} -- #{subcmd.short_help}\n"
|
218
|
+
end
|
219
|
+
return s
|
220
|
+
end
|
221
|
+
end
|
222
|
+
end
|
223
|
+
end
|
@@ -0,0 +1,247 @@
|
|
1
|
+
module Debugger
|
2
|
+
# Mix-in module to showing settings
|
3
|
+
module ShowFunctions # :nodoc:
|
4
|
+
def show_setting(setting_name)
|
5
|
+
case setting_name
|
6
|
+
when /^annotate$/
|
7
|
+
Debugger.annotate ||= 0
|
8
|
+
return ("Annotation level is #{Debugger.annotate}")
|
9
|
+
when /^args$/
|
10
|
+
if Command.settings[:argv] and Command.settings[:argv].size > 0
|
11
|
+
if defined?(Debugger::RDEBUG_SCRIPT)
|
12
|
+
# rdebug was called initially. 1st arg is script name.
|
13
|
+
args = Command.settings[:argv][1..-1].join(' ')
|
14
|
+
else
|
15
|
+
# rdebug wasn't called initially. 1st arg is not script name.
|
16
|
+
args = Command.settings[:argv].join(' ')
|
17
|
+
end
|
18
|
+
else
|
19
|
+
args = ''
|
20
|
+
end
|
21
|
+
return "Argument list to give program being debugged when it is started is \"#{args}\"."
|
22
|
+
when /^autolist$/
|
23
|
+
on_off = Command.settings[:autolist] > 0
|
24
|
+
return "autolist is #{show_onoff(on_off)}."
|
25
|
+
when /^autoeval$/
|
26
|
+
on_off = Command.settings[:autoeval]
|
27
|
+
return "autoeval is #{show_onoff(on_off)}."
|
28
|
+
when /^autoreload$/
|
29
|
+
on_off = Command.settings[:reload_source_on_change]
|
30
|
+
return "autoreload is #{show_onoff(on_off)}."
|
31
|
+
when /^autoirb$/
|
32
|
+
on_off = Command.settings[:autoirb] > 0
|
33
|
+
return "autoirb is #{show_onoff(on_off)}."
|
34
|
+
when /^basename$/
|
35
|
+
on_off = Command.settings[:basename]
|
36
|
+
return "basename is #{show_onoff(on_off)}."
|
37
|
+
when /^callstyle$/
|
38
|
+
style = Command.settings[:callstyle]
|
39
|
+
return "Frame call-display style is #{style}."
|
40
|
+
when /^commands(:?\s+(\d+))?$/
|
41
|
+
if @state.interface.readline_support?
|
42
|
+
s = '';
|
43
|
+
args = @match[1].split
|
44
|
+
if args[1]
|
45
|
+
first_line = args[1].to_i - 4
|
46
|
+
last_line = first_line + 10 - 1
|
47
|
+
if first_line > Readline::HISTORY.length
|
48
|
+
first_line = last_line = Readline::HISTORY.length
|
49
|
+
elsif first_line <= 0
|
50
|
+
first_line = 1
|
51
|
+
end
|
52
|
+
if last_line > Readline::HISTORY.length
|
53
|
+
last_line = Readline::HISTORY.length
|
54
|
+
end
|
55
|
+
i = first_line
|
56
|
+
commands = Readline::HISTORY.to_a[first_line..last_line]
|
57
|
+
else
|
58
|
+
if Readline::HISTORY.length > 10
|
59
|
+
commands = Readline::HISTORY.to_a[-10..-1]
|
60
|
+
i = Readline::HISTORY.length - 10
|
61
|
+
else
|
62
|
+
commands = Readline::HISTORY.to_a
|
63
|
+
i = 1
|
64
|
+
end
|
65
|
+
end
|
66
|
+
commands.each do |cmd|
|
67
|
+
s += ("%5d %s\n" % [i, cmd])
|
68
|
+
i += 1
|
69
|
+
end
|
70
|
+
else
|
71
|
+
s='No readline support'
|
72
|
+
end
|
73
|
+
return s
|
74
|
+
when /^debuggertesting$/
|
75
|
+
on_off = Command.settings[:debuggertesting]
|
76
|
+
return "Currently testing the debugger is #{show_onoff(on_off)}."
|
77
|
+
when /^forcestep$/
|
78
|
+
on_off = self.class.settings[:force_stepping]
|
79
|
+
return "force-stepping is #{show_onoff(on_off)}."
|
80
|
+
when /^fullpath$/
|
81
|
+
on_off = Command.settings[:full_path]
|
82
|
+
return "Displaying frame's full file names is #{show_onoff(on_off)}."
|
83
|
+
when /^history(:?\s+(filename|save|size))?$/
|
84
|
+
args = @match[1].split
|
85
|
+
interface = @state.interface
|
86
|
+
if args[1]
|
87
|
+
show_save = show_size = show_filename = false
|
88
|
+
prefix = false
|
89
|
+
if args[1] == "save"
|
90
|
+
show_save = true
|
91
|
+
elsif args[1] == "size"
|
92
|
+
show_size = true
|
93
|
+
elsif args[1] == "filename"
|
94
|
+
show_filename = true
|
95
|
+
end
|
96
|
+
else
|
97
|
+
show_save = show_size = show_filename = true
|
98
|
+
prefix = true
|
99
|
+
end
|
100
|
+
s = []
|
101
|
+
if show_filename
|
102
|
+
msg = (prefix ? "filename: " : "") +
|
103
|
+
"The filename in which to record the command history is " +
|
104
|
+
"#{interface.histfile.inspect}"
|
105
|
+
s << msg
|
106
|
+
end
|
107
|
+
if show_save
|
108
|
+
msg = (prefix ? "save: " : "") +
|
109
|
+
"Saving of history save is #{show_onoff(interface.history_save)}."
|
110
|
+
s << msg
|
111
|
+
end
|
112
|
+
if show_size
|
113
|
+
msg = (prefix ? "size: " : "") +
|
114
|
+
"Debugger history size is #{interface.history_length}"
|
115
|
+
s << msg
|
116
|
+
end
|
117
|
+
return s.join("\n")
|
118
|
+
when /^linetrace$/
|
119
|
+
on_off = Debugger.tracing
|
120
|
+
return "line tracing is #{show_onoff(on_off)}."
|
121
|
+
when /^linetrace\+$/
|
122
|
+
on_off = Command.settings[:tracing_plus]
|
123
|
+
if on_off
|
124
|
+
return "line tracing style is different consecutive lines."
|
125
|
+
else
|
126
|
+
return "line tracing style is every line."
|
127
|
+
end
|
128
|
+
when /^listsize$/
|
129
|
+
listlines = Command.settings[:listsize]
|
130
|
+
return "Number of source lines to list by default is #{listlines}."
|
131
|
+
when /^port$/
|
132
|
+
return "server port is #{Debugger::PORT}."
|
133
|
+
when /^trace$/
|
134
|
+
on_off = Command.settings[:stack_trace_on_error]
|
135
|
+
return "Displaying stack trace is #{show_onoff(on_off)}."
|
136
|
+
when /^version$/
|
137
|
+
return "ruby-debug #{Debugger::VERSION}"
|
138
|
+
when /^width$/
|
139
|
+
return "width is #{self.class.settings[:width]}."
|
140
|
+
else
|
141
|
+
return "Unknown show subcommand #{setting_name}."
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
# Implements debugger "show" command.
|
147
|
+
class ShowCommand < Command
|
148
|
+
|
149
|
+
Subcommands =
|
150
|
+
[
|
151
|
+
['annotate', 2, "Show annotation level",
|
152
|
+
"0 == normal; 2 == output annotated suitably for use by programs that control
|
153
|
+
ruby-debug."],
|
154
|
+
['args', 2,
|
155
|
+
"Show argument list to give program being debugged when it is started",
|
156
|
+
"Follow this command with any number of args, to be passed to the program."],
|
157
|
+
['autoeval', 4, "Show if unrecognized command are evaluated"],
|
158
|
+
['autolist', 4, "Show if 'list' commands is run on breakpoints"],
|
159
|
+
['autoirb', 4, "Show if IRB is invoked on debugger stops"],
|
160
|
+
['autoreload', 4, "Show if source code is reloaded when changed"],
|
161
|
+
['basename', 1, "Show if basename used in reporting files"],
|
162
|
+
['callstyle', 2, "Show paramater style used showing call frames"],
|
163
|
+
['commands', 2, "Show the history of commands you typed",
|
164
|
+
"You can supply a command number to start with."],
|
165
|
+
['forcestep', 1, "Show if sure 'next/step' forces move to a new line"],
|
166
|
+
['fullpath', 2, "Show if full file names are displayed in frames"],
|
167
|
+
['history', 2, "Generic command for showing command history parameters",
|
168
|
+
"show history filename -- Show the filename in which to record the command history
|
169
|
+
show history save -- Show saving of the history record on exit
|
170
|
+
show history size -- Show the size of the command history"],
|
171
|
+
['keep-frame-bindings', 1, "Save frame binding on each call"],
|
172
|
+
['linetrace', 3, "Show line execution tracing"],
|
173
|
+
['linetrace+', 10,
|
174
|
+
"Show if consecutive lines should be different are shown in tracing"],
|
175
|
+
['listsize', 3, "Show number of source lines to list by default"],
|
176
|
+
['port', 3, "Show server port"],
|
177
|
+
['post-mortem', 3, "Show whether we go into post-mortem debugging on an uncaught exception"],
|
178
|
+
['trace', 1,
|
179
|
+
"Show if a stack trace is displayed when 'eval' raises exception"],
|
180
|
+
['version', 1,
|
181
|
+
"Show what version of the debugger this is"],
|
182
|
+
['width', 1,
|
183
|
+
"Show the number of characters the debugger thinks are in a line"],
|
184
|
+
].map do |name, min, short_help, long_help|
|
185
|
+
SubcmdStruct.new(name, min, short_help, long_help)
|
186
|
+
end unless defined?(Subcommands)
|
187
|
+
|
188
|
+
self.allow_in_control = true
|
189
|
+
|
190
|
+
def regexp
|
191
|
+
/^show (?: \s+ (.+) )?$/xi
|
192
|
+
end
|
193
|
+
|
194
|
+
def execute
|
195
|
+
if not @match[1]
|
196
|
+
print "\"show\" must be followed by the name of an show command:\n"
|
197
|
+
print "List of show subcommands:\n\n"
|
198
|
+
for subcmd in Subcommands do
|
199
|
+
print "show #{subcmd.name} -- #{subcmd.short_help}\n"
|
200
|
+
end
|
201
|
+
else
|
202
|
+
args = @match[1].split(/[ \t]+/)
|
203
|
+
param = args.shift
|
204
|
+
subcmd = find(Subcommands, param)
|
205
|
+
if subcmd
|
206
|
+
print "%s\n" % show_setting(subcmd.name)
|
207
|
+
else
|
208
|
+
print "Unknown show command #{param}\n"
|
209
|
+
end
|
210
|
+
end
|
211
|
+
end
|
212
|
+
|
213
|
+
class << self
|
214
|
+
def help_command
|
215
|
+
"show"
|
216
|
+
end
|
217
|
+
|
218
|
+
def help(args)
|
219
|
+
if args[1]
|
220
|
+
s = args[1]
|
221
|
+
subcmd = Subcommands.find do |try_subcmd|
|
222
|
+
(s.size >= try_subcmd.min) and
|
223
|
+
(try_subcmd.name[0..s.size-1] == s)
|
224
|
+
end
|
225
|
+
if subcmd
|
226
|
+
str = subcmd.short_help + '.'
|
227
|
+
str += "\n" + subcmd.long_help if subcmd.long_help
|
228
|
+
return str
|
229
|
+
else
|
230
|
+
return "Invalid 'show' subcommand '#{args[1]}'."
|
231
|
+
end
|
232
|
+
end
|
233
|
+
s = "
|
234
|
+
Generic command for showing things about the debugger.
|
235
|
+
|
236
|
+
--
|
237
|
+
List of show subcommands:
|
238
|
+
--
|
239
|
+
"
|
240
|
+
for subcmd in Subcommands do
|
241
|
+
s += "show #{subcmd.name} -- #{subcmd.short_help}\n"
|
242
|
+
end
|
243
|
+
return s
|
244
|
+
end
|
245
|
+
end
|
246
|
+
end
|
247
|
+
end
|