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,123 @@
|
|
1
|
+
require 'irb'
|
2
|
+
|
3
|
+
module IRB # :nodoc:
|
4
|
+
module ExtendCommand # :nodoc:
|
5
|
+
class Continue # :nodoc:
|
6
|
+
def self.execute(conf)
|
7
|
+
throw :IRB_EXIT, :cont
|
8
|
+
end
|
9
|
+
end
|
10
|
+
class Next # :nodoc:
|
11
|
+
def self.execute(conf)
|
12
|
+
throw :IRB_EXIT, :next
|
13
|
+
end
|
14
|
+
end
|
15
|
+
class Step # :nodoc:
|
16
|
+
def self.execute(conf)
|
17
|
+
throw :IRB_EXIT, :step
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
ExtendCommandBundle.def_extend_command "cont", :Continue
|
22
|
+
ExtendCommandBundle.def_extend_command "n", :Next
|
23
|
+
ExtendCommandBundle.def_extend_command "step", :Step
|
24
|
+
|
25
|
+
def self.start_session(binding)
|
26
|
+
unless @__initialized
|
27
|
+
args = ARGV.dup
|
28
|
+
ARGV.replace([])
|
29
|
+
IRB.setup(nil)
|
30
|
+
ARGV.replace(args)
|
31
|
+
@__initialized = true
|
32
|
+
end
|
33
|
+
|
34
|
+
workspace = WorkSpace.new(binding)
|
35
|
+
|
36
|
+
irb = Irb.new(workspace)
|
37
|
+
|
38
|
+
@CONF[:IRB_RC].call(irb.context) if @CONF[:IRB_RC]
|
39
|
+
@CONF[:MAIN_CONTEXT] = irb.context
|
40
|
+
|
41
|
+
catch(:IRB_EXIT) do
|
42
|
+
irb.eval_input
|
43
|
+
end
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
module Debugger
|
48
|
+
|
49
|
+
# Implements debugger "irb" command.
|
50
|
+
class IRBCommand < Command
|
51
|
+
|
52
|
+
register_setting_get(:autoirb) do
|
53
|
+
IRBCommand.always_run
|
54
|
+
end
|
55
|
+
register_setting_set(:autoirb) do |value|
|
56
|
+
IRBCommand.always_run = value
|
57
|
+
end
|
58
|
+
|
59
|
+
def regexp
|
60
|
+
/^\s* irb
|
61
|
+
(?:\s+(-d))?
|
62
|
+
\s*$/x
|
63
|
+
end
|
64
|
+
|
65
|
+
def execute
|
66
|
+
unless @state.interface.kind_of?(LocalInterface)
|
67
|
+
print "Command is available only in local mode.\n"
|
68
|
+
throw :debug_error
|
69
|
+
end
|
70
|
+
|
71
|
+
save_trap = trap("SIGINT") do
|
72
|
+
throw :IRB_EXIT, :cont if $rdebug_in_irb
|
73
|
+
end
|
74
|
+
|
75
|
+
add_debugging = @match.is_a?(Array) && '-d' == @match[1]
|
76
|
+
$rdebug_state = @state if add_debugging
|
77
|
+
$rdebug_in_irb = true
|
78
|
+
cont = IRB.start_session(get_binding)
|
79
|
+
case cont
|
80
|
+
when :cont
|
81
|
+
@state.proceed
|
82
|
+
when :step
|
83
|
+
force = Command.settings[:force_stepping]
|
84
|
+
@state.context.step(1, force)
|
85
|
+
@state.proceed
|
86
|
+
when :next
|
87
|
+
force = Command.settings[:force_stepping]
|
88
|
+
@state.context.step_over(1, @state.frame_pos, force)
|
89
|
+
@state.proceed
|
90
|
+
else
|
91
|
+
file = @state.context.frame_file(0)
|
92
|
+
line = @state.context.frame_line(0)
|
93
|
+
CommandProcessor.print_location_and_text(file, line)
|
94
|
+
@state.previous_line = nil
|
95
|
+
end
|
96
|
+
|
97
|
+
ensure
|
98
|
+
$rdebug_in_irb = nil
|
99
|
+
$rdebug_state = nil if add_debugging
|
100
|
+
trap("SIGINT", save_trap) if save_trap
|
101
|
+
end
|
102
|
+
|
103
|
+
class << self
|
104
|
+
def help_command
|
105
|
+
'irb'
|
106
|
+
end
|
107
|
+
|
108
|
+
def help(cmd)
|
109
|
+
%{
|
110
|
+
irb [-d]\tstarts an Interactive Ruby (IRB) session.
|
111
|
+
|
112
|
+
If -d is added you can get access to debugger state via the global variable
|
113
|
+
$RDEBUG_state.
|
114
|
+
|
115
|
+
irb is extended with methods "cont", "n" and "step" which
|
116
|
+
run the corresponding debugger commands. In contrast to the real debugger
|
117
|
+
commands these commands don't allow command arguments.
|
118
|
+
}
|
119
|
+
end
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|
123
|
+
|
@@ -0,0 +1,66 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
# Implements debugger "jump" command
|
4
|
+
class JumpCommand < Command
|
5
|
+
self.allow_in_control = true
|
6
|
+
|
7
|
+
def numeric?(object)
|
8
|
+
true if Float(object) rescue false
|
9
|
+
end
|
10
|
+
|
11
|
+
def regexp
|
12
|
+
/ ^\s*
|
13
|
+
j(?:ump)? \s*
|
14
|
+
(?:\s+(\S+))?\s*
|
15
|
+
(?:\s+(\S+))?\s*
|
16
|
+
$
|
17
|
+
/ix
|
18
|
+
end
|
19
|
+
|
20
|
+
def execute
|
21
|
+
if !@match[1]
|
22
|
+
errmsg "\"jump\" must be followed by a line number\n"
|
23
|
+
return
|
24
|
+
end
|
25
|
+
if !numeric?(@match[1])
|
26
|
+
puts "Bad line number: " + @match[1]
|
27
|
+
return
|
28
|
+
end
|
29
|
+
line = @match[1].to_i
|
30
|
+
line = @state.context.frame_line(0) + line if @match[1][0] == '+' or @match[1][0] == '-'
|
31
|
+
if line == @state.context.frame_line(0)
|
32
|
+
CommandProcessor.print_location_and_text(@state.context.frame_file(0), line)
|
33
|
+
return
|
34
|
+
end
|
35
|
+
file = @match[2]
|
36
|
+
file = @state.context.frame_file(file.to_i) if numeric?(file)
|
37
|
+
file = @state.context.frame_file(0) if !file
|
38
|
+
case Debugger.current_context.jump(line, file)
|
39
|
+
when 0
|
40
|
+
@state.proceed
|
41
|
+
when 1
|
42
|
+
errmsg "Not possible to jump from here\n"
|
43
|
+
when 2
|
44
|
+
errmsg "Couldn't find debugged frame\n"
|
45
|
+
when 3
|
46
|
+
errmsg "Couldn't find active code at " + file + ":" + line.to_s + "\n"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class << self
|
51
|
+
def help_command
|
52
|
+
%w[jump]
|
53
|
+
end
|
54
|
+
|
55
|
+
def help(cmd)
|
56
|
+
%{
|
57
|
+
j[ump] line\tjump to line number (absolute)
|
58
|
+
j[ump] -line\tjump back to line (relative)
|
59
|
+
j[ump] +line\tjump ahead to line (relative)
|
60
|
+
|
61
|
+
Change the next line of code to be executed.
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
end
|
66
|
+
end
|
@@ -0,0 +1,51 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
# Implements debugger "kill" command
|
4
|
+
class KillCommand < Command
|
5
|
+
self.allow_in_control = true
|
6
|
+
|
7
|
+
def regexp
|
8
|
+
/ ^\s*
|
9
|
+
(?:kill) \s*
|
10
|
+
(?:\s+(\S+))?\s*
|
11
|
+
$
|
12
|
+
/ix
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
puts @match[1]
|
17
|
+
if @match[1]
|
18
|
+
signame = @match[1]
|
19
|
+
unless Signal.list.member?(signame)
|
20
|
+
errmsg("signal name #{signame} is not a signal I know about\n")
|
21
|
+
return false
|
22
|
+
end
|
23
|
+
if 'KILL' == signame
|
24
|
+
@state.interface.finalize
|
25
|
+
end
|
26
|
+
else
|
27
|
+
if not confirm("Really kill? (y/n) ")
|
28
|
+
return
|
29
|
+
else
|
30
|
+
signame = 'KILL'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
Process.kill(signame, Process.pid)
|
34
|
+
end
|
35
|
+
|
36
|
+
class << self
|
37
|
+
def help_command
|
38
|
+
%w[kill]
|
39
|
+
end
|
40
|
+
|
41
|
+
def help(cmd)
|
42
|
+
%{
|
43
|
+
kill [SIGNAL]
|
44
|
+
|
45
|
+
Send [signal] to Process.pid
|
46
|
+
Equivalent of Process.kill(Process.pid)
|
47
|
+
}
|
48
|
+
end
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
@@ -0,0 +1,94 @@
|
|
1
|
+
module Debugger
|
2
|
+
# Implements debugger "list" command.
|
3
|
+
class ListCommand < Command
|
4
|
+
|
5
|
+
register_setting_get(:autolist) do
|
6
|
+
ListCommand.always_run
|
7
|
+
end
|
8
|
+
register_setting_set(:autolist) do |value|
|
9
|
+
ListCommand.always_run = value
|
10
|
+
end
|
11
|
+
|
12
|
+
def regexp
|
13
|
+
/^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
listsize = Command.settings[:listsize]
|
18
|
+
if !@match || !(@match[1] || @match[2])
|
19
|
+
b = @state.previous_line ?
|
20
|
+
@state.previous_line + listsize : @state.line - (listsize/2)
|
21
|
+
e = b + listsize - 1
|
22
|
+
elsif @match[1] == '-'
|
23
|
+
b = if @state.previous_line
|
24
|
+
if @state.previous_line > 0
|
25
|
+
@state.previous_line - listsize
|
26
|
+
else
|
27
|
+
@state.previous_line
|
28
|
+
end
|
29
|
+
else
|
30
|
+
@state.line - (listsize/2)
|
31
|
+
end
|
32
|
+
e = b + listsize - 1
|
33
|
+
elsif @match[1] == '='
|
34
|
+
@state.previous_line = nil
|
35
|
+
b = @state.line - (listsize/2)
|
36
|
+
e = b + listsize -1
|
37
|
+
else
|
38
|
+
b, e = @match[2].split(/[-,]/)
|
39
|
+
if e
|
40
|
+
b = b.to_i
|
41
|
+
e = e.to_i
|
42
|
+
else
|
43
|
+
b = b.to_i - (listsize/2)
|
44
|
+
e = b + listsize - 1
|
45
|
+
end
|
46
|
+
end
|
47
|
+
@state.previous_line = display_list(b, e, @state.file, @state.line)
|
48
|
+
end
|
49
|
+
|
50
|
+
class << self
|
51
|
+
def help_command
|
52
|
+
'list'
|
53
|
+
end
|
54
|
+
|
55
|
+
def help(cmd)
|
56
|
+
%{
|
57
|
+
l[ist]\t\tlist forward
|
58
|
+
l[ist] -\tlist backward
|
59
|
+
l[ist] =\tlist current line
|
60
|
+
l[ist] nn-mm\tlist given lines
|
61
|
+
* NOTE - to turn on autolist, use 'set autolist'
|
62
|
+
}
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
private
|
67
|
+
|
68
|
+
# Show FILE from line B to E where CURRENT is the current line number.
|
69
|
+
# If we can show from B to E then we return B, otherwise we return the
|
70
|
+
# previous line @state.previous_line.
|
71
|
+
def display_list(b, e, file, current)
|
72
|
+
print "[%d, %d] in %s\n", b, e, file
|
73
|
+
lines = LineCache::getlines(file,
|
74
|
+
Command.settings[:reload_source_on_change])
|
75
|
+
if lines
|
76
|
+
return @state.previous_line if b >= lines.size
|
77
|
+
e = lines.size if lines.size < e
|
78
|
+
[b, 1].max.upto(e) do |n|
|
79
|
+
if n > 0 && lines[n-1]
|
80
|
+
if n == current
|
81
|
+
print "=> %d %s\n", n, lines[n-1].chomp
|
82
|
+
else
|
83
|
+
print " %d %s\n", n, lines[n-1].chomp
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
87
|
+
else
|
88
|
+
errmsg "No sourcefile available for %s\n", file
|
89
|
+
return @state.previous_line
|
90
|
+
end
|
91
|
+
return e == lines.size ? @state.previous_line : b
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'methodsig'
|
5
|
+
have_methodsig = true
|
6
|
+
rescue LoadError
|
7
|
+
have_methodsig = false
|
8
|
+
end
|
9
|
+
|
10
|
+
# Implements the debugger 'method sig' command.
|
11
|
+
class MethodSigCommand < Command
|
12
|
+
def regexp
|
13
|
+
/^\s*m(?:ethod)?\s+sig(?:nature)?\s+(\S+)\s*$/
|
14
|
+
end
|
15
|
+
|
16
|
+
def execute
|
17
|
+
obj = debug_eval('method(:%s)' % @match[1])
|
18
|
+
if obj.is_a?(Method)
|
19
|
+
begin
|
20
|
+
print "%s\n", obj.signature.to_s
|
21
|
+
rescue
|
22
|
+
errmsg("Can't get signature for '#{@match[1]}'\n")
|
23
|
+
end
|
24
|
+
else
|
25
|
+
errmsg("Can't make method out of '#{@match[1]}'\n")
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
class << self
|
30
|
+
def help_command
|
31
|
+
'method'
|
32
|
+
end
|
33
|
+
|
34
|
+
def help(cmd)
|
35
|
+
%{
|
36
|
+
m[ethod] sig[nature] <obj>\tshow the signature of a method
|
37
|
+
}
|
38
|
+
end
|
39
|
+
end
|
40
|
+
end if have_methodsig
|
41
|
+
|
42
|
+
# Implements the debugger 'method' command.
|
43
|
+
class MethodCommand < Command
|
44
|
+
def regexp
|
45
|
+
/^\s*m(?:ethod)?\s+((iv)|(i(:?nstance\s+)?)\s+)?/
|
46
|
+
end
|
47
|
+
|
48
|
+
def execute
|
49
|
+
if @match[1] == "iv"
|
50
|
+
obj = debug_eval(@match.post_match)
|
51
|
+
obj.instance_variables.sort.each do |v|
|
52
|
+
print "%s = %s\n", v, obj.instance_variable_get(v).inspect
|
53
|
+
end
|
54
|
+
elsif @match[1]
|
55
|
+
obj = debug_eval(@match.post_match)
|
56
|
+
print "%s\n", columnize(obj.methods.sort(),
|
57
|
+
self.class.settings[:width])
|
58
|
+
else
|
59
|
+
obj = debug_eval(@match.post_match)
|
60
|
+
unless obj.kind_of? Module
|
61
|
+
print "Should be Class/Module: %s\n", @match.post_match
|
62
|
+
else
|
63
|
+
print "%s\n", columnize(obj.instance_methods(false).sort(),
|
64
|
+
self.class.settings[:width])
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
class << self
|
70
|
+
def help_command
|
71
|
+
'method'
|
72
|
+
end
|
73
|
+
|
74
|
+
def help(cmd)
|
75
|
+
%{
|
76
|
+
m[ethod] i[nstance] <obj>\tshow methods of object
|
77
|
+
m[ethod] iv <obj>\t\tshow instance variables of object
|
78
|
+
m[ethod] <class|module>\t\tshow instance methods of class or module
|
79
|
+
}
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,39 @@
|
|
1
|
+
module Debugger
|
2
|
+
|
3
|
+
# Implements debugger "quit" command
|
4
|
+
class QuitCommand < Command
|
5
|
+
self.allow_in_control = true
|
6
|
+
|
7
|
+
def regexp
|
8
|
+
/ ^\s*
|
9
|
+
(?:q(?:uit)?|exit) \s*
|
10
|
+
(!|\s+unconditionally)? \s*
|
11
|
+
$
|
12
|
+
/ix
|
13
|
+
end
|
14
|
+
|
15
|
+
def execute
|
16
|
+
if @match[1] or confirm("Really quit? (y/n) ")
|
17
|
+
@state.interface.finalize
|
18
|
+
exit! # exit -> exit!: No graceful way to stop threads...
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class << self
|
23
|
+
def help_command
|
24
|
+
%w[quit exit]
|
25
|
+
end
|
26
|
+
|
27
|
+
def help(cmd)
|
28
|
+
%{
|
29
|
+
q[uit] [!|unconditionally]\texit from debugger.
|
30
|
+
exit[!]\talias to quit
|
31
|
+
|
32
|
+
Normally we prompt before exiting. However if the parameter
|
33
|
+
"unconditionally" or is given or suffixed with !, we stop
|
34
|
+
without asking further questions.
|
35
|
+
}
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|