debugger 1.0.0.rc1

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.
Files changed (261) hide show
  1. data/AUTHORS +10 -0
  2. data/CHANGES +334 -0
  3. data/ChangeLog +5655 -0
  4. data/INSTALL.SVN +154 -0
  5. data/LICENSE +23 -0
  6. data/Makefile.am +14 -0
  7. data/OLD_README +122 -0
  8. data/README.md +10 -0
  9. data/Rakefile +266 -0
  10. data/autogen.sh +4 -0
  11. data/bin/rdebug +398 -0
  12. data/cli/ruby-debug.rb +173 -0
  13. data/cli/ruby-debug/command.rb +228 -0
  14. data/cli/ruby-debug/commands/breakpoints.rb +153 -0
  15. data/cli/ruby-debug/commands/catchpoint.rb +55 -0
  16. data/cli/ruby-debug/commands/condition.rb +49 -0
  17. data/cli/ruby-debug/commands/continue.rb +38 -0
  18. data/cli/ruby-debug/commands/control.rb +107 -0
  19. data/cli/ruby-debug/commands/display.rb +120 -0
  20. data/cli/ruby-debug/commands/edit.rb +48 -0
  21. data/cli/ruby-debug/commands/enable.rb +202 -0
  22. data/cli/ruby-debug/commands/eval.rb +176 -0
  23. data/cli/ruby-debug/commands/finish.rb +42 -0
  24. data/cli/ruby-debug/commands/frame.rb +301 -0
  25. data/cli/ruby-debug/commands/help.rb +56 -0
  26. data/cli/ruby-debug/commands/info.rb +467 -0
  27. data/cli/ruby-debug/commands/irb.rb +123 -0
  28. data/cli/ruby-debug/commands/jump.rb +66 -0
  29. data/cli/ruby-debug/commands/kill.rb +51 -0
  30. data/cli/ruby-debug/commands/list.rb +94 -0
  31. data/cli/ruby-debug/commands/method.rb +84 -0
  32. data/cli/ruby-debug/commands/quit.rb +39 -0
  33. data/cli/ruby-debug/commands/reload.rb +40 -0
  34. data/cli/ruby-debug/commands/save.rb +90 -0
  35. data/cli/ruby-debug/commands/set.rb +221 -0
  36. data/cli/ruby-debug/commands/show.rb +247 -0
  37. data/cli/ruby-debug/commands/skip.rb +35 -0
  38. data/cli/ruby-debug/commands/source.rb +36 -0
  39. data/cli/ruby-debug/commands/stepping.rb +81 -0
  40. data/cli/ruby-debug/commands/threads.rb +189 -0
  41. data/cli/ruby-debug/commands/tmate.rb +36 -0
  42. data/cli/ruby-debug/commands/trace.rb +57 -0
  43. data/cli/ruby-debug/commands/variables.rb +199 -0
  44. data/cli/ruby-debug/debugger.rb +5 -0
  45. data/cli/ruby-debug/helper.rb +69 -0
  46. data/cli/ruby-debug/interface.rb +232 -0
  47. data/cli/ruby-debug/processor.rb +474 -0
  48. data/configure.ac +12 -0
  49. data/debugger.gemspec +24 -0
  50. data/doc/.cvsignore +42 -0
  51. data/doc/Makefile.am +63 -0
  52. data/doc/emacs-notes.txt +38 -0
  53. data/doc/hanoi.rb +35 -0
  54. data/doc/primes.rb +28 -0
  55. data/doc/rdebug-emacs.texi +1030 -0
  56. data/doc/rdebug.1 +241 -0
  57. data/doc/ruby-debug.texi +3791 -0
  58. data/doc/test-tri2.rb +18 -0
  59. data/doc/tri3.rb +8 -0
  60. data/doc/triangle.rb +12 -0
  61. data/emacs/Makefile.am +130 -0
  62. data/emacs/rdebug-annotate.el +385 -0
  63. data/emacs/rdebug-breaks.el +407 -0
  64. data/emacs/rdebug-cmd.el +92 -0
  65. data/emacs/rdebug-core.el +502 -0
  66. data/emacs/rdebug-dbg.el +62 -0
  67. data/emacs/rdebug-error.el +79 -0
  68. data/emacs/rdebug-fns.el +111 -0
  69. data/emacs/rdebug-frames.el +230 -0
  70. data/emacs/rdebug-gud.el +242 -0
  71. data/emacs/rdebug-help.el +104 -0
  72. data/emacs/rdebug-info.el +83 -0
  73. data/emacs/rdebug-layouts.el +180 -0
  74. data/emacs/rdebug-locring.el +118 -0
  75. data/emacs/rdebug-output.el +106 -0
  76. data/emacs/rdebug-regexp.el +118 -0
  77. data/emacs/rdebug-secondary.el +260 -0
  78. data/emacs/rdebug-shortkey.el +175 -0
  79. data/emacs/rdebug-source.el +568 -0
  80. data/emacs/rdebug-track.el +392 -0
  81. data/emacs/rdebug-varbuf.el +150 -0
  82. data/emacs/rdebug-vars.el +125 -0
  83. data/emacs/rdebug-watch.el +132 -0
  84. data/emacs/rdebug.el +326 -0
  85. data/emacs/test/elk-test.el +242 -0
  86. data/emacs/test/test-annotate.el +103 -0
  87. data/emacs/test/test-cmd.el +116 -0
  88. data/emacs/test/test-core.el +104 -0
  89. data/emacs/test/test-fns.el +65 -0
  90. data/emacs/test/test-frames.el +62 -0
  91. data/emacs/test/test-gud.el +35 -0
  92. data/emacs/test/test-indent.el +58 -0
  93. data/emacs/test/test-regexp.el +144 -0
  94. data/emacs/test/test-shortkey.el +61 -0
  95. data/ext/ruby_debug/breakpoint.c +586 -0
  96. data/ext/ruby_debug/extconf.rb +49 -0
  97. data/ext/ruby_debug/ruby_debug.c +2624 -0
  98. data/ext/ruby_debug/ruby_debug.h +148 -0
  99. data/lib/ChangeLog +1065 -0
  100. data/lib/debugger.rb +7 -0
  101. data/lib/debugger/version.rb +3 -0
  102. data/lib/ruby-debug-base.rb +304 -0
  103. data/rdbg.rb +33 -0
  104. data/runner.sh +7 -0
  105. data/svn2cl_usermap +3 -0
  106. data/test/.cvsignore +1 -0
  107. data/test/base/base.rb +74 -0
  108. data/test/base/binding.rb +31 -0
  109. data/test/base/catchpoint.rb +26 -0
  110. data/test/base/load.rb +40 -0
  111. data/test/bp_loop_issue.rb +3 -0
  112. data/test/classes.rb +11 -0
  113. data/test/cli/commands/catchpoint_test.rb +36 -0
  114. data/test/cli/commands/unit/regexp.rb +42 -0
  115. data/test/config.yaml +8 -0
  116. data/test/data/annotate.cmd +29 -0
  117. data/test/data/annotate.right +139 -0
  118. data/test/data/break_bad.cmd +18 -0
  119. data/test/data/break_bad.right +28 -0
  120. data/test/data/break_loop_bug.cmd +5 -0
  121. data/test/data/break_loop_bug.right +15 -0
  122. data/test/data/breakpoints.cmd +38 -0
  123. data/test/data/breakpoints.right +98 -0
  124. data/test/data/catch.cmd +20 -0
  125. data/test/data/catch.right +49 -0
  126. data/test/data/catch2.cmd +19 -0
  127. data/test/data/catch2.right +65 -0
  128. data/test/data/catch3.cmd +11 -0
  129. data/test/data/catch3.right +37 -0
  130. data/test/data/condition.cmd +28 -0
  131. data/test/data/condition.right +65 -0
  132. data/test/data/ctrl.cmd +23 -0
  133. data/test/data/ctrl.right +70 -0
  134. data/test/data/display.cmd +24 -0
  135. data/test/data/display.right +44 -0
  136. data/test/data/dollar-0.right +2 -0
  137. data/test/data/dollar-0a.right +2 -0
  138. data/test/data/dollar-0b.right +2 -0
  139. data/test/data/edit.cmd +12 -0
  140. data/test/data/edit.right +19 -0
  141. data/test/data/emacs_basic.cmd +43 -0
  142. data/test/data/emacs_basic.right +106 -0
  143. data/test/data/enable.cmd +20 -0
  144. data/test/data/enable.right +36 -0
  145. data/test/data/finish.cmd +16 -0
  146. data/test/data/finish.right +31 -0
  147. data/test/data/frame.cmd +26 -0
  148. data/test/data/frame.right +55 -0
  149. data/test/data/help.cmd +20 -0
  150. data/test/data/help.right +21 -0
  151. data/test/data/history.right +7 -0
  152. data/test/data/info-thread.cmd +13 -0
  153. data/test/data/info-thread.right +37 -0
  154. data/test/data/info-var-bug2.cmd +5 -0
  155. data/test/data/info-var-bug2.right +10 -0
  156. data/test/data/info-var.cmd +23 -0
  157. data/test/data/info-var.right +52 -0
  158. data/test/data/info.cmd +21 -0
  159. data/test/data/info.right +65 -0
  160. data/test/data/jump.cmd +16 -0
  161. data/test/data/jump.right +56 -0
  162. data/test/data/jump2.cmd +16 -0
  163. data/test/data/jump2.right +44 -0
  164. data/test/data/linetrace.cmd +6 -0
  165. data/test/data/linetrace.right +23 -0
  166. data/test/data/list.cmd +19 -0
  167. data/test/data/list.right +127 -0
  168. data/test/data/method.cmd +10 -0
  169. data/test/data/method.right +21 -0
  170. data/test/data/methodsig.cmd +10 -0
  171. data/test/data/methodsig.right +20 -0
  172. data/test/data/next.cmd +22 -0
  173. data/test/data/next.right +61 -0
  174. data/test/data/noquit.right +1 -0
  175. data/test/data/output.cmd +6 -0
  176. data/test/data/output.right +31 -0
  177. data/test/data/pm-bug.cmd +7 -0
  178. data/test/data/pm-bug.right +12 -0
  179. data/test/data/post-mortem-next.cmd +8 -0
  180. data/test/data/post-mortem-next.right +14 -0
  181. data/test/data/post-mortem-osx.right +31 -0
  182. data/test/data/post-mortem.cmd +13 -0
  183. data/test/data/post-mortem.right +32 -0
  184. data/test/data/quit.cmd +6 -0
  185. data/test/data/quit.right +0 -0
  186. data/test/data/raise.cmd +11 -0
  187. data/test/data/raise.right +23 -0
  188. data/test/data/save.cmd +34 -0
  189. data/test/data/save.right +59 -0
  190. data/test/data/scope-var.cmd +42 -0
  191. data/test/data/scope-var.right +587 -0
  192. data/test/data/setshow.cmd +56 -0
  193. data/test/data/setshow.right +98 -0
  194. data/test/data/source.cmd +5 -0
  195. data/test/data/source.right +15 -0
  196. data/test/data/stepping.cmd +21 -0
  197. data/test/data/stepping.right +50 -0
  198. data/test/data/test-init-cygwin.right +7 -0
  199. data/test/data/test-init-osx.right +4 -0
  200. data/test/data/test-init.right +5 -0
  201. data/test/data/trace.right +14 -0
  202. data/test/dollar-0.rb +5 -0
  203. data/test/gcd-dbg-nox.rb +31 -0
  204. data/test/gcd-dbg.rb +30 -0
  205. data/test/gcd.rb +18 -0
  206. data/test/helper.rb +144 -0
  207. data/test/info-var-bug.rb +47 -0
  208. data/test/info-var-bug2.rb +2 -0
  209. data/test/jump.rb +14 -0
  210. data/test/jump2.rb +27 -0
  211. data/test/next.rb +18 -0
  212. data/test/null.rb +1 -0
  213. data/test/output.rb +2 -0
  214. data/test/pm-base.rb +22 -0
  215. data/test/pm-bug.rb +3 -0
  216. data/test/pm-catch.rb +12 -0
  217. data/test/pm-catch2.rb +27 -0
  218. data/test/pm-catch3.rb +47 -0
  219. data/test/pm.rb +11 -0
  220. data/test/raise.rb +3 -0
  221. data/test/rdebug-save.1 +7 -0
  222. data/test/runall +12 -0
  223. data/test/scope-var.rb +29 -0
  224. data/test/tdebug.rb +248 -0
  225. data/test/test-annotate.rb +25 -0
  226. data/test/test-break-bad.rb +37 -0
  227. data/test/test-breakpoints.rb +25 -0
  228. data/test/test-catch.rb +25 -0
  229. data/test/test-catch2.rb +25 -0
  230. data/test/test-catch3.rb +25 -0
  231. data/test/test-condition.rb +25 -0
  232. data/test/test-ctrl.rb +55 -0
  233. data/test/test-display.rb +26 -0
  234. data/test/test-dollar-0.rb +40 -0
  235. data/test/test-edit.rb +26 -0
  236. data/test/test-emacs-basic.rb +26 -0
  237. data/test/test-enable.rb +25 -0
  238. data/test/test-finish.rb +34 -0
  239. data/test/test-frame.rb +34 -0
  240. data/test/test-help.rb +60 -0
  241. data/test/test-hist.rb +68 -0
  242. data/test/test-info-thread.rb +32 -0
  243. data/test/test-info-var.rb +47 -0
  244. data/test/test-info.rb +26 -0
  245. data/test/test-init.rb +44 -0
  246. data/test/test-jump.rb +35 -0
  247. data/test/test-list.rb +25 -0
  248. data/test/test-method.rb +34 -0
  249. data/test/test-next.rb +25 -0
  250. data/test/test-output.rb +26 -0
  251. data/test/test-quit.rb +30 -0
  252. data/test/test-raise.rb +25 -0
  253. data/test/test-save.rb +31 -0
  254. data/test/test-scope-var.rb +25 -0
  255. data/test/test-setshow.rb +25 -0
  256. data/test/test-source.rb +25 -0
  257. data/test/test-stepping.rb +26 -0
  258. data/test/test-trace.rb +47 -0
  259. data/test/thread1.rb +26 -0
  260. data/test/trunc-call.rb +31 -0
  261. 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