debugger 1.0.0.rc1
Sign up to get free protection for your applications and to get access to all the features.
- data/AUTHORS +10 -0
- data/CHANGES +334 -0
- data/ChangeLog +5655 -0
- data/INSTALL.SVN +154 -0
- data/LICENSE +23 -0
- data/Makefile.am +14 -0
- data/OLD_README +122 -0
- data/README.md +10 -0
- data/Rakefile +266 -0
- data/autogen.sh +4 -0
- data/bin/rdebug +398 -0
- data/cli/ruby-debug.rb +173 -0
- data/cli/ruby-debug/command.rb +228 -0
- data/cli/ruby-debug/commands/breakpoints.rb +153 -0
- data/cli/ruby-debug/commands/catchpoint.rb +55 -0
- data/cli/ruby-debug/commands/condition.rb +49 -0
- data/cli/ruby-debug/commands/continue.rb +38 -0
- data/cli/ruby-debug/commands/control.rb +107 -0
- data/cli/ruby-debug/commands/display.rb +120 -0
- data/cli/ruby-debug/commands/edit.rb +48 -0
- data/cli/ruby-debug/commands/enable.rb +202 -0
- data/cli/ruby-debug/commands/eval.rb +176 -0
- data/cli/ruby-debug/commands/finish.rb +42 -0
- data/cli/ruby-debug/commands/frame.rb +301 -0
- data/cli/ruby-debug/commands/help.rb +56 -0
- data/cli/ruby-debug/commands/info.rb +467 -0
- data/cli/ruby-debug/commands/irb.rb +123 -0
- data/cli/ruby-debug/commands/jump.rb +66 -0
- data/cli/ruby-debug/commands/kill.rb +51 -0
- data/cli/ruby-debug/commands/list.rb +94 -0
- data/cli/ruby-debug/commands/method.rb +84 -0
- data/cli/ruby-debug/commands/quit.rb +39 -0
- data/cli/ruby-debug/commands/reload.rb +40 -0
- data/cli/ruby-debug/commands/save.rb +90 -0
- data/cli/ruby-debug/commands/set.rb +221 -0
- data/cli/ruby-debug/commands/show.rb +247 -0
- data/cli/ruby-debug/commands/skip.rb +35 -0
- data/cli/ruby-debug/commands/source.rb +36 -0
- data/cli/ruby-debug/commands/stepping.rb +81 -0
- data/cli/ruby-debug/commands/threads.rb +189 -0
- data/cli/ruby-debug/commands/tmate.rb +36 -0
- data/cli/ruby-debug/commands/trace.rb +57 -0
- data/cli/ruby-debug/commands/variables.rb +199 -0
- data/cli/ruby-debug/debugger.rb +5 -0
- data/cli/ruby-debug/helper.rb +69 -0
- data/cli/ruby-debug/interface.rb +232 -0
- data/cli/ruby-debug/processor.rb +474 -0
- data/configure.ac +12 -0
- data/debugger.gemspec +24 -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/rdebug.1 +241 -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 +586 -0
- data/ext/ruby_debug/extconf.rb +49 -0
- data/ext/ruby_debug/ruby_debug.c +2624 -0
- data/ext/ruby_debug/ruby_debug.h +148 -0
- data/lib/ChangeLog +1065 -0
- data/lib/debugger.rb +7 -0
- data/lib/debugger/version.rb +3 -0
- data/lib/ruby-debug-base.rb +304 -0
- data/rdbg.rb +33 -0
- data/runner.sh +7 -0
- data/svn2cl_usermap +3 -0
- data/test/.cvsignore +1 -0
- data/test/base/base.rb +74 -0
- data/test/base/binding.rb +31 -0
- data/test/base/catchpoint.rb +26 -0
- data/test/base/load.rb +40 -0
- data/test/bp_loop_issue.rb +3 -0
- data/test/classes.rb +11 -0
- data/test/cli/commands/catchpoint_test.rb +36 -0
- data/test/cli/commands/unit/regexp.rb +42 -0
- data/test/config.yaml +8 -0
- data/test/data/annotate.cmd +29 -0
- data/test/data/annotate.right +139 -0
- data/test/data/break_bad.cmd +18 -0
- data/test/data/break_bad.right +28 -0
- data/test/data/break_loop_bug.cmd +5 -0
- data/test/data/break_loop_bug.right +15 -0
- data/test/data/breakpoints.cmd +38 -0
- data/test/data/breakpoints.right +98 -0
- data/test/data/catch.cmd +20 -0
- data/test/data/catch.right +49 -0
- data/test/data/catch2.cmd +19 -0
- data/test/data/catch2.right +65 -0
- data/test/data/catch3.cmd +11 -0
- data/test/data/catch3.right +37 -0
- data/test/data/condition.cmd +28 -0
- data/test/data/condition.right +65 -0
- data/test/data/ctrl.cmd +23 -0
- data/test/data/ctrl.right +70 -0
- data/test/data/display.cmd +24 -0
- data/test/data/display.right +44 -0
- data/test/data/dollar-0.right +2 -0
- data/test/data/dollar-0a.right +2 -0
- data/test/data/dollar-0b.right +2 -0
- data/test/data/edit.cmd +12 -0
- data/test/data/edit.right +19 -0
- data/test/data/emacs_basic.cmd +43 -0
- data/test/data/emacs_basic.right +106 -0
- data/test/data/enable.cmd +20 -0
- data/test/data/enable.right +36 -0
- data/test/data/finish.cmd +16 -0
- data/test/data/finish.right +31 -0
- data/test/data/frame.cmd +26 -0
- data/test/data/frame.right +55 -0
- data/test/data/help.cmd +20 -0
- data/test/data/help.right +21 -0
- data/test/data/history.right +7 -0
- data/test/data/info-thread.cmd +13 -0
- data/test/data/info-thread.right +37 -0
- data/test/data/info-var-bug2.cmd +5 -0
- data/test/data/info-var-bug2.right +10 -0
- data/test/data/info-var.cmd +23 -0
- data/test/data/info-var.right +52 -0
- data/test/data/info.cmd +21 -0
- data/test/data/info.right +65 -0
- data/test/data/jump.cmd +16 -0
- data/test/data/jump.right +56 -0
- data/test/data/jump2.cmd +16 -0
- data/test/data/jump2.right +44 -0
- data/test/data/linetrace.cmd +6 -0
- data/test/data/linetrace.right +23 -0
- data/test/data/list.cmd +19 -0
- data/test/data/list.right +127 -0
- data/test/data/method.cmd +10 -0
- data/test/data/method.right +21 -0
- data/test/data/methodsig.cmd +10 -0
- data/test/data/methodsig.right +20 -0
- data/test/data/next.cmd +22 -0
- data/test/data/next.right +61 -0
- data/test/data/noquit.right +1 -0
- data/test/data/output.cmd +6 -0
- data/test/data/output.right +31 -0
- data/test/data/pm-bug.cmd +7 -0
- data/test/data/pm-bug.right +12 -0
- data/test/data/post-mortem-next.cmd +8 -0
- data/test/data/post-mortem-next.right +14 -0
- data/test/data/post-mortem-osx.right +31 -0
- data/test/data/post-mortem.cmd +13 -0
- data/test/data/post-mortem.right +32 -0
- data/test/data/quit.cmd +6 -0
- data/test/data/quit.right +0 -0
- data/test/data/raise.cmd +11 -0
- data/test/data/raise.right +23 -0
- data/test/data/save.cmd +34 -0
- data/test/data/save.right +59 -0
- data/test/data/scope-var.cmd +42 -0
- data/test/data/scope-var.right +587 -0
- data/test/data/setshow.cmd +56 -0
- data/test/data/setshow.right +98 -0
- data/test/data/source.cmd +5 -0
- data/test/data/source.right +15 -0
- data/test/data/stepping.cmd +21 -0
- data/test/data/stepping.right +50 -0
- data/test/data/test-init-cygwin.right +7 -0
- data/test/data/test-init-osx.right +4 -0
- data/test/data/test-init.right +5 -0
- data/test/data/trace.right +14 -0
- data/test/dollar-0.rb +5 -0
- data/test/gcd-dbg-nox.rb +31 -0
- data/test/gcd-dbg.rb +30 -0
- data/test/gcd.rb +18 -0
- data/test/helper.rb +144 -0
- data/test/info-var-bug.rb +47 -0
- data/test/info-var-bug2.rb +2 -0
- data/test/jump.rb +14 -0
- data/test/jump2.rb +27 -0
- data/test/next.rb +18 -0
- data/test/null.rb +1 -0
- data/test/output.rb +2 -0
- data/test/pm-base.rb +22 -0
- data/test/pm-bug.rb +3 -0
- data/test/pm-catch.rb +12 -0
- data/test/pm-catch2.rb +27 -0
- data/test/pm-catch3.rb +47 -0
- data/test/pm.rb +11 -0
- data/test/raise.rb +3 -0
- data/test/rdebug-save.1 +7 -0
- data/test/runall +12 -0
- data/test/scope-var.rb +29 -0
- data/test/tdebug.rb +248 -0
- data/test/test-annotate.rb +25 -0
- data/test/test-break-bad.rb +37 -0
- data/test/test-breakpoints.rb +25 -0
- data/test/test-catch.rb +25 -0
- data/test/test-catch2.rb +25 -0
- data/test/test-catch3.rb +25 -0
- data/test/test-condition.rb +25 -0
- data/test/test-ctrl.rb +55 -0
- data/test/test-display.rb +26 -0
- data/test/test-dollar-0.rb +40 -0
- data/test/test-edit.rb +26 -0
- data/test/test-emacs-basic.rb +26 -0
- data/test/test-enable.rb +25 -0
- data/test/test-finish.rb +34 -0
- data/test/test-frame.rb +34 -0
- data/test/test-help.rb +60 -0
- data/test/test-hist.rb +68 -0
- data/test/test-info-thread.rb +32 -0
- data/test/test-info-var.rb +47 -0
- data/test/test-info.rb +26 -0
- data/test/test-init.rb +44 -0
- data/test/test-jump.rb +35 -0
- data/test/test-list.rb +25 -0
- data/test/test-method.rb +34 -0
- data/test/test-next.rb +25 -0
- data/test/test-output.rb +26 -0
- data/test/test-quit.rb +30 -0
- data/test/test-raise.rb +25 -0
- data/test/test-save.rb +31 -0
- data/test/test-scope-var.rb +25 -0
- data/test/test-setshow.rb +25 -0
- data/test/test-source.rb +25 -0
- data/test/test-stepping.rb +26 -0
- data/test/test-trace.rb +47 -0
- data/test/thread1.rb +26 -0
- data/test/trunc-call.rb +31 -0
- metadata +364 -0
@@ -0,0 +1,38 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
# Implements debugger "continue" command.
|
4
|
+
class ContinueCommand < Command
|
5
|
+
self.allow_in_post_mortem = true
|
6
|
+
self.need_context = false
|
7
|
+
def regexp
|
8
|
+
/^\s* c(?:ont(?:inue)?)? (?:\s+(.*))? $/x
|
9
|
+
end
|
10
|
+
|
11
|
+
def execute
|
12
|
+
if @match[1] && !@state.context.dead?
|
13
|
+
filename = File.expand_path(@state.file)
|
14
|
+
line_number = get_int(@match[1], "Continue", 0, nil, 0)
|
15
|
+
return unless line_number
|
16
|
+
unless LineCache.trace_line_numbers(filename).member?(line_number)
|
17
|
+
errmsg("Line %d is not a stopping point in file \"%s\".\n",
|
18
|
+
line_number, filename)
|
19
|
+
return
|
20
|
+
end
|
21
|
+
@state.context.set_breakpoint(filename, line_number)
|
22
|
+
end
|
23
|
+
@state.proceed
|
24
|
+
end
|
25
|
+
|
26
|
+
class << self
|
27
|
+
def help_command
|
28
|
+
'continue'
|
29
|
+
end
|
30
|
+
|
31
|
+
def help(cmd)
|
32
|
+
%{
|
33
|
+
c[ont[inue]][ nnn]\trun until program ends, hits a breakpoint or reaches line nnn
|
34
|
+
}
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,107 @@
|
|
1
|
+
module Debugger
|
2
|
+
class RestartCommand < Command # :nodoc:
|
3
|
+
self.allow_in_control = true
|
4
|
+
|
5
|
+
def regexp
|
6
|
+
/ ^\s*
|
7
|
+
(?:restart|R)
|
8
|
+
(?:\s+ (\S?.*\S))? \s*
|
9
|
+
$
|
10
|
+
/ix
|
11
|
+
end
|
12
|
+
|
13
|
+
def execute
|
14
|
+
if not defined? Debugger::PROG_SCRIPT
|
15
|
+
errmsg "Don't know name of debugged program\n"
|
16
|
+
return
|
17
|
+
end
|
18
|
+
prog_script = Debugger::PROG_SCRIPT
|
19
|
+
if not defined? Debugger::RDEBUG_SCRIPT
|
20
|
+
# FIXME? Should ask for confirmation?
|
21
|
+
print "Debugger was not called from the outset...\n"
|
22
|
+
rdebug_script = prog_script
|
23
|
+
else
|
24
|
+
rdebug_script = Debugger::RDEBUG_SCRIPT
|
25
|
+
end
|
26
|
+
begin
|
27
|
+
Dir.chdir(Debugger::INITIAL_DIR)
|
28
|
+
rescue
|
29
|
+
print "Failed to change initial directory #{Debugger::INITIAL_DIR}"
|
30
|
+
end
|
31
|
+
if not File.exist?(File.expand_path(prog_script))
|
32
|
+
errmsg "Ruby program #{prog_script} doesn't exist\n"
|
33
|
+
return
|
34
|
+
end
|
35
|
+
if not File.executable?(prog_script) and rdebug_script == prog_script
|
36
|
+
print "Ruby program #{prog_script} doesn't seem to be executable...\n"
|
37
|
+
print "We'll add a call to Ruby.\n"
|
38
|
+
ruby = begin defined?(Gem) ? Gem.ruby : "ruby" rescue "ruby" end
|
39
|
+
rdebug_script = "#{ruby} -I#{$:.join(' -I')} #{prog_script}"
|
40
|
+
else
|
41
|
+
rdebug_script += ' '
|
42
|
+
end
|
43
|
+
if @match[1]
|
44
|
+
argv = [prog_script] + @match[1].split(/[ \t]+/)
|
45
|
+
else
|
46
|
+
if not defined? Command.settings[:argv]
|
47
|
+
errmsg "Arguments have not been set. Use 'set args' to set them.\n"
|
48
|
+
return
|
49
|
+
else
|
50
|
+
argv = Command.settings[:argv]
|
51
|
+
end
|
52
|
+
end
|
53
|
+
args = argv.join(' ')
|
54
|
+
|
55
|
+
# An execv would be preferable to the "exec" below.
|
56
|
+
cmd = rdebug_script + args
|
57
|
+
print "Re exec'ing:\n\t#{cmd}\n"
|
58
|
+
exec cmd
|
59
|
+
rescue Errno::EOPNOTSUPP
|
60
|
+
print "Restart command is not available at this time.\n"
|
61
|
+
end
|
62
|
+
|
63
|
+
class << self
|
64
|
+
def help_command
|
65
|
+
'restart'
|
66
|
+
end
|
67
|
+
|
68
|
+
def help(cmd)
|
69
|
+
%{
|
70
|
+
restart|R [args]
|
71
|
+
Restart the program. This is a re-exec - all debugger state
|
72
|
+
is lost. If command arguments are passed those are used.
|
73
|
+
}
|
74
|
+
end
|
75
|
+
end
|
76
|
+
end
|
77
|
+
|
78
|
+
class InterruptCommand < Command # :nodoc:
|
79
|
+
self.allow_in_control = true
|
80
|
+
self.allow_in_post_mortem = false
|
81
|
+
self.event = false
|
82
|
+
self.need_context = true
|
83
|
+
|
84
|
+
def regexp
|
85
|
+
/^\s*i(?:nterrupt)?\s*$/
|
86
|
+
end
|
87
|
+
|
88
|
+
def execute
|
89
|
+
unless Debugger.interrupt_last
|
90
|
+
context = Debugger.thread_context(Thread.main)
|
91
|
+
context.interrupt
|
92
|
+
end
|
93
|
+
end
|
94
|
+
|
95
|
+
class << self
|
96
|
+
def help_command
|
97
|
+
'interrupt'
|
98
|
+
end
|
99
|
+
|
100
|
+
def help(cmd)
|
101
|
+
%{
|
102
|
+
i[nterrupt]\tinterrupt the program
|
103
|
+
}
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
module Debugger
|
2
|
+
module DisplayFunctions # :nodoc:
|
3
|
+
def display_expression(exp)
|
4
|
+
print "%s = %s\n", exp, debug_silent_eval(exp).to_s
|
5
|
+
end
|
6
|
+
|
7
|
+
def active_display_expressions?
|
8
|
+
@state.display.select{|d| d[0]}.size > 0
|
9
|
+
end
|
10
|
+
|
11
|
+
def print_display_expressions
|
12
|
+
n = 1
|
13
|
+
for d in @state.display
|
14
|
+
if d[0]
|
15
|
+
print "%d: ", n
|
16
|
+
display_expression(d[1])
|
17
|
+
end
|
18
|
+
n += 1
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
class AddDisplayCommand < Command # :nodoc:
|
24
|
+
def regexp
|
25
|
+
/^\s*disp(?:lay)?\s+(.+)$/
|
26
|
+
end
|
27
|
+
|
28
|
+
def execute
|
29
|
+
exp = @match[1]
|
30
|
+
@state.display.push [true, exp]
|
31
|
+
print "%d: ", @state.display.size
|
32
|
+
display_expression(exp)
|
33
|
+
end
|
34
|
+
|
35
|
+
class << self
|
36
|
+
def help_command
|
37
|
+
'display'
|
38
|
+
end
|
39
|
+
|
40
|
+
def help(cmd)
|
41
|
+
%{
|
42
|
+
disp[lay] <expression>\tadd expression into display expression list
|
43
|
+
}
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
class DisplayCommand < Command # :nodoc:
|
49
|
+
def self.always_run
|
50
|
+
Debugger.annotate = 0 unless Debugger.annotate
|
51
|
+
if Debugger.annotate > 1
|
52
|
+
0
|
53
|
+
else
|
54
|
+
2
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
def regexp
|
59
|
+
/^\s*disp(?:lay)?$/
|
60
|
+
end
|
61
|
+
|
62
|
+
def execute
|
63
|
+
print_display_expressions
|
64
|
+
end
|
65
|
+
|
66
|
+
class << self
|
67
|
+
def help_command
|
68
|
+
'display'
|
69
|
+
end
|
70
|
+
|
71
|
+
def help(cmd)
|
72
|
+
%{
|
73
|
+
disp[lay]\t\tdisplay expression list
|
74
|
+
}
|
75
|
+
end
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
class DeleteDisplayCommand < Command # :nodoc:
|
80
|
+
|
81
|
+
def regexp
|
82
|
+
/^\s* undisp(?:lay)? \s* (?:(\S+))?$/x
|
83
|
+
end
|
84
|
+
|
85
|
+
def execute
|
86
|
+
unless pos = @match[1]
|
87
|
+
if confirm("Clear all expressions? (y/n) ")
|
88
|
+
for d in @state.display
|
89
|
+
d[0] = false
|
90
|
+
end
|
91
|
+
end
|
92
|
+
else
|
93
|
+
pos = get_int(pos, "Undisplay")
|
94
|
+
return unless pos
|
95
|
+
if @state.display[pos-1]
|
96
|
+
@state.display[pos-1][0] = nil
|
97
|
+
else
|
98
|
+
errmsg "Display expression %d is not defined.\n", pos
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
class << self
|
104
|
+
def help_command
|
105
|
+
'undisplay'
|
106
|
+
end
|
107
|
+
|
108
|
+
def help(cmd)
|
109
|
+
%{
|
110
|
+
undisp[lay][ nnn]
|
111
|
+
Cancel some expressions to be displayed when program stops.
|
112
|
+
Arguments are the code numbers of the expressions to stop displaying.
|
113
|
+
No argument means cancel all automatic-display expressions.
|
114
|
+
"delete display" has the same effect as this command.
|
115
|
+
Do "info display" to see current list of code numbers.
|
116
|
+
}
|
117
|
+
end
|
118
|
+
end
|
119
|
+
end
|
120
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
module Debugger
|
2
|
+
class Edit < Command # :nodoc:
|
3
|
+
self.allow_in_control = true
|
4
|
+
def regexp
|
5
|
+
/^\s* ed(?:it)? (?:\s+(.*))?$/ix
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute
|
9
|
+
if not @match[1] or @match[1].strip.empty?
|
10
|
+
unless @state.context
|
11
|
+
errmsg "We are not in a state that has an associated file.\n"
|
12
|
+
return
|
13
|
+
end
|
14
|
+
file = @state.file
|
15
|
+
line_number = @state.line
|
16
|
+
elsif @pos_match = /([^:]+)[:]([0-9]+)/.match(@match[1])
|
17
|
+
file, line_number = @pos_match.captures
|
18
|
+
else
|
19
|
+
errmsg "Invalid file/line number specification: #{@match[1]}\n"
|
20
|
+
return
|
21
|
+
end
|
22
|
+
editor = ENV['EDITOR'] || 'ex'
|
23
|
+
if File.readable?(file)
|
24
|
+
system("#{editor} +#{line_number} #{file}")
|
25
|
+
else
|
26
|
+
errmsg "File \"#{file}\" is not readable.\n"
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
class << self
|
31
|
+
def help_command
|
32
|
+
'edit'
|
33
|
+
end
|
34
|
+
|
35
|
+
def help(cmd)
|
36
|
+
%{
|
37
|
+
Edit specified file.
|
38
|
+
|
39
|
+
With no argument, edits file containing most recent line listed.
|
40
|
+
Editing targets can also be specified in this:
|
41
|
+
FILE:LINENUM, to edit at that line in that file,
|
42
|
+
}
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
48
|
+
end # module Debugger
|
@@ -0,0 +1,202 @@
|
|
1
|
+
module Debugger
|
2
|
+
# Mix-in module to assist in command parsing.
|
3
|
+
module EnableDisableFunctions # :nodoc:
|
4
|
+
def enable_disable_breakpoints(is_enable, args)
|
5
|
+
breakpoints = Debugger.breakpoints.sort_by{|b| b.id }
|
6
|
+
largest = breakpoints.inject(0) do |tally, b|
|
7
|
+
tally = b.id if b.id > tally
|
8
|
+
end
|
9
|
+
if 0 == largest
|
10
|
+
errmsg "No breakpoints have been set.\n"
|
11
|
+
return
|
12
|
+
end
|
13
|
+
args.each do |pos|
|
14
|
+
pos = get_int(pos, "#{is_enable} breakpoints", 1, largest)
|
15
|
+
return nil unless pos
|
16
|
+
breakpoints.each do |b|
|
17
|
+
if b.id == pos
|
18
|
+
enabled = ("Enable" == is_enable)
|
19
|
+
if enabled
|
20
|
+
unless syntax_valid?(b.expr)
|
21
|
+
errmsg("Expression \"#{b.expr}\" syntactically incorrect; breakpoint remains disabled.\n")
|
22
|
+
break
|
23
|
+
end
|
24
|
+
end
|
25
|
+
b.enabled = ("Enable" == is_enable)
|
26
|
+
break
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
def enable_disable_display(is_enable, args)
|
33
|
+
if 0 == @state.display.size
|
34
|
+
errmsg "No display expressions have been set.\n"
|
35
|
+
return
|
36
|
+
end
|
37
|
+
args.each do |pos|
|
38
|
+
pos = get_int(pos, "#{is_enable} display", 1, @state.display.size)
|
39
|
+
return nil unless pos
|
40
|
+
@state.display[pos-1][0] = ("Enable" == is_enable)
|
41
|
+
end
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
46
|
+
class EnableCommand < Command # :nodoc:
|
47
|
+
Subcommands =
|
48
|
+
[
|
49
|
+
['breakpoints', 2, "Enable specified breakpoints",
|
50
|
+
"Give breakpoint numbers (separated by spaces) as arguments.
|
51
|
+
This is used to cancel the effect of the \"disable\" command."
|
52
|
+
],
|
53
|
+
['display', 2,
|
54
|
+
"Enable some expressions to be displayed when program stops",
|
55
|
+
"Arguments are the code numbers of the expressions to resume displaying.
|
56
|
+
Do \"info display\" to see current list of code numbers."],
|
57
|
+
].map do |name, min, short_help, long_help|
|
58
|
+
SubcmdStruct.new(name, min, short_help, long_help)
|
59
|
+
end unless defined?(Subcommands)
|
60
|
+
|
61
|
+
def regexp
|
62
|
+
/^\s* en(?:able)? (?:\s+(.*))?$/ix
|
63
|
+
end
|
64
|
+
|
65
|
+
def execute
|
66
|
+
if not @match[1]
|
67
|
+
errmsg "\"enable\" must be followed \"display\", \"breakpoints\"" +
|
68
|
+
" or breakpoint numbers.\n"
|
69
|
+
else
|
70
|
+
args = @match[1].split(/[ \t]+/)
|
71
|
+
param = args.shift
|
72
|
+
subcmd = find(Subcommands, param)
|
73
|
+
if subcmd
|
74
|
+
send("enable_#{subcmd.name}", args)
|
75
|
+
else
|
76
|
+
send("enable_breakpoints", args.unshift(param))
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def enable_breakpoints(args)
|
82
|
+
enable_disable_breakpoints("Enable", args)
|
83
|
+
end
|
84
|
+
|
85
|
+
def enable_display(args)
|
86
|
+
enable_disable_display("Enable", args)
|
87
|
+
end
|
88
|
+
|
89
|
+
class << self
|
90
|
+
def help_command
|
91
|
+
'enable'
|
92
|
+
end
|
93
|
+
|
94
|
+
def help(args)
|
95
|
+
if args[1]
|
96
|
+
s = args[1]
|
97
|
+
subcmd = Subcommands.find do |try_subcmd|
|
98
|
+
(s.size >= try_subcmd.min) and
|
99
|
+
(try_subcmd.name[0..s.size-1] == s)
|
100
|
+
end
|
101
|
+
if subcmd
|
102
|
+
str = subcmd.short_help + '.'
|
103
|
+
str += "\n" + subcmd.long_help if subcmd.long_help
|
104
|
+
return str
|
105
|
+
else
|
106
|
+
return "Invalid 'enable' subcommand '#{args[1]}'."
|
107
|
+
end
|
108
|
+
end
|
109
|
+
s = %{
|
110
|
+
Enable some things.
|
111
|
+
This is used to cancel the effect of the "disable" command.
|
112
|
+
--
|
113
|
+
List of enable subcommands:
|
114
|
+
--
|
115
|
+
}
|
116
|
+
for subcmd in Subcommands do
|
117
|
+
s += "enable #{subcmd.name} -- #{subcmd.short_help}\n"
|
118
|
+
end
|
119
|
+
return s
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
124
|
+
class DisableCommand < Command # :nodoc:
|
125
|
+
Subcommands =
|
126
|
+
[
|
127
|
+
['breakpoints', 1, "Disable some breakpoints",
|
128
|
+
"Arguments are breakpoint numbers with spaces in between.
|
129
|
+
A disabled breakpoint is not forgotten, but has no effect until reenabled."],
|
130
|
+
['display', 1, "Disable some display expressions when program stops",
|
131
|
+
"Arguments are the code numbers of the expressions to stop displaying.
|
132
|
+
Do \"info display\" to see current list of code numbers."],
|
133
|
+
].map do |name, min, short_help, long_help|
|
134
|
+
SubcmdStruct.new(name, min, short_help, long_help)
|
135
|
+
end unless defined?(Subcommands)
|
136
|
+
|
137
|
+
def regexp
|
138
|
+
/^\s* dis(?:able)? (?:\s+(.*))?$/ix
|
139
|
+
end
|
140
|
+
|
141
|
+
def execute
|
142
|
+
if not @match[1]
|
143
|
+
errmsg "\"disable\" must be followed \"display\", \"breakpoints\"" +
|
144
|
+
" or breakpoint numbers.\n"
|
145
|
+
else
|
146
|
+
args = @match[1].split(/[ \t]+/)
|
147
|
+
param = args.shift
|
148
|
+
subcmd = find(Subcommands, param)
|
149
|
+
if subcmd
|
150
|
+
send("disable_#{subcmd.name}", args)
|
151
|
+
else
|
152
|
+
send("disable_breakpoints", args.unshift(param))
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
def disable_breakpoints(args)
|
158
|
+
enable_disable_breakpoints("Disable", args)
|
159
|
+
end
|
160
|
+
|
161
|
+
def disable_display(args)
|
162
|
+
enable_disable_display("Disable", args)
|
163
|
+
end
|
164
|
+
|
165
|
+
class << self
|
166
|
+
def help_command
|
167
|
+
'disable'
|
168
|
+
end
|
169
|
+
|
170
|
+
def help(args)
|
171
|
+
if args[1]
|
172
|
+
s = args[1]
|
173
|
+
subcmd = Subcommands.find do |try_subcmd|
|
174
|
+
(s.size >= try_subcmd.min) and
|
175
|
+
(try_subcmd.name[0..s.size-1] == s)
|
176
|
+
end
|
177
|
+
if subcmd
|
178
|
+
str = subcmd.short_help + '.'
|
179
|
+
str += "\n" + subcmd.long_help if subcmd.long_help
|
180
|
+
return str
|
181
|
+
else
|
182
|
+
return "Invalid 'disable' subcommand '#{args[1]}'."
|
183
|
+
end
|
184
|
+
end
|
185
|
+
s = %{
|
186
|
+
Disable some things.
|
187
|
+
|
188
|
+
A disabled item is not forgotten, but has no effect until reenabled.
|
189
|
+
Use the "enable" command to have it take effect again.
|
190
|
+
--
|
191
|
+
List of disable subcommands:
|
192
|
+
--
|
193
|
+
}
|
194
|
+
for subcmd in Subcommands do
|
195
|
+
s += "disable #{subcmd.name} -- #{subcmd.short_help}\n"
|
196
|
+
end
|
197
|
+
return s
|
198
|
+
end
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
end # module Debugger
|