debugger 1.0.0.rc1

Sign up to get free protection for your applications and to get access to all the features.
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,35 @@
1
+ module Debugger
2
+
3
+ # Implements debugger "skip" command
4
+ class SkipCommand < Command
5
+ self.allow_in_control = true
6
+
7
+ def regexp
8
+ / ^\s*
9
+ sk(?:ip)? \s*
10
+ $
11
+ /ix
12
+ end
13
+
14
+ def execute
15
+ Debugger::skip_next_exception
16
+ print "ok\n"
17
+ end
18
+
19
+ class << self
20
+ def help_command
21
+ %w[skip]
22
+ end
23
+
24
+ def help(cmd)
25
+ %{
26
+ sk[ip]\tskip the next thrown exception
27
+
28
+ This is useful if you've explicitly caught an exception through
29
+ the "catch" command, and wish to pass the exception on to the
30
+ code that you're debugging.
31
+ }
32
+ end
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,36 @@
1
+ module Debugger
2
+ # Implements debugger "source" command.
3
+ class SourceCommand < Command
4
+ self.allow_in_control = true
5
+
6
+ def regexp
7
+ /^\s* so(?:urce)? \s+ (.+) $/x
8
+ end
9
+
10
+ def execute
11
+ file = File.expand_path(@match[1]).strip
12
+ unless File.exist?(file)
13
+ errmsg "Command file '#{file}' is not found\n"
14
+ return
15
+ end
16
+ if @state and @state.interface
17
+ @state.interface.command_queue += File.open(file).readlines
18
+ else
19
+ Debugger.run_script(file, @state)
20
+ end
21
+ end
22
+
23
+ class << self
24
+ def help_command
25
+ 'source'
26
+ end
27
+
28
+ def help(cmd)
29
+ %{
30
+ source FILE\texecutes a file containing debugger commands
31
+ }
32
+ end
33
+ end
34
+ end
35
+
36
+ end
@@ -0,0 +1,81 @@
1
+ module Debugger
2
+ # Mix-in module to assist in command parsing.
3
+ module SteppingFunctions # :nodoc:
4
+ def parse_stepping_args(command_name, match)
5
+ if match[1].nil?
6
+ force = Command.settings[:force_stepping]
7
+ elsif match[1] == '+'
8
+ force = true
9
+ elsif match[1] == '-'
10
+ force = false
11
+ end
12
+ steps = get_int(match[2], command_name, 1)
13
+ return [steps, force]
14
+ end
15
+ end
16
+ # Implements debugger "next" command.
17
+ class NextCommand < Command
18
+ self.allow_in_post_mortem = false
19
+ self.need_context = true
20
+
21
+ def regexp
22
+ /^\s* n(?:ext)?
23
+ ([+-])?(?:\s+(\S+))?
24
+ \s*$/x
25
+ end
26
+
27
+ def execute
28
+ steps, force = parse_stepping_args("Next", @match)
29
+ return unless steps
30
+ @state.context.step_over steps, @state.frame_pos, force
31
+ @state.proceed
32
+ end
33
+
34
+ class << self
35
+ def help_command
36
+ 'next'
37
+ end
38
+
39
+ def help(cmd)
40
+ %{
41
+ n[ext][+-]?[ nnn]\tstep over once or nnn times,
42
+ \t\t'+' forces to move to another line.
43
+ \t\t'-' is the opposite of '+' and disables the force_stepping setting.
44
+ }
45
+ end
46
+ end
47
+ end
48
+
49
+ # Implements debugger "step" command.
50
+ class StepCommand < Command
51
+ self.allow_in_post_mortem = false
52
+ self.need_context = true
53
+
54
+ def regexp
55
+ /^\s* s(?:tep)?
56
+ ([+-])?(?:\s+(\S+))?
57
+ \s*$/x
58
+ end
59
+
60
+ def execute
61
+ steps, force = parse_stepping_args("Step", @match)
62
+ return unless steps
63
+ @state.context.step(steps, force)
64
+ @state.proceed
65
+ end
66
+
67
+ class << self
68
+ def help_command
69
+ 'step'
70
+ end
71
+
72
+ def help(cmd)
73
+ %{
74
+ s[tep][+-]?[ nnn]\tstep (into methods) once or nnn times
75
+ \t\t'+' forces to move to another line.
76
+ \t\t'-' is the opposite of '+' and disables the force_stepping setting.
77
+ }
78
+ end
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,189 @@
1
+ module Debugger
2
+ module ThreadFunctions # :nodoc:
3
+ def display_context(c, show_top_frame=true)
4
+ c_flag = c.thread == Thread.current ? '+' : ' '
5
+ c_flag = '$' if c.suspended?
6
+ d_flag = c.ignored? ? '!' : ' '
7
+ print "%s%s", c_flag, d_flag
8
+ print "%d ", c.thnum
9
+ print "%s\t", c.thread.inspect
10
+ if c.stack_size > 0 and show_top_frame
11
+ print "%s:%d", c.frame_file(0), c.frame_line(0)
12
+ end
13
+ print "\n"
14
+ end
15
+
16
+ def parse_thread_num(subcmd, arg)
17
+ if '' == arg
18
+ errmsg "'%s' needs a thread number\n" % subcmd
19
+ nil
20
+ else
21
+ thread_num = get_int(arg, "thread #{subcmd}", 1)
22
+ return nil unless thread_num
23
+ get_context(thread_num)
24
+ end
25
+ end
26
+
27
+ def parse_thread_num_for_cmd(subcmd, arg)
28
+ c = parse_thread_num(subcmd, arg)
29
+ return nil unless c
30
+ case
31
+ when nil == c
32
+ errmsg "No such thread.\n"
33
+ when @state.context == c
34
+ errmsg "It's the current thread.\n"
35
+ when c.ignored?
36
+ errmsg "Can't #{subcmd} to the debugger thread #{arg}.\n"
37
+ else # Everything is okay
38
+ return c
39
+ end
40
+ return nil
41
+ end
42
+ end
43
+
44
+ class ThreadListCommand < Command # :nodoc:
45
+ self.allow_in_control = true
46
+
47
+ def regexp
48
+ /^\s*th(?:read)?\s+l(?:ist)?\s*$/
49
+ end
50
+
51
+ def execute
52
+ threads = Debugger.contexts.sort_by{|c| c.thnum}.each do |c|
53
+ display_context(c)
54
+ end
55
+ end
56
+
57
+ class << self
58
+ def help_command
59
+ 'thread'
60
+ end
61
+
62
+ def help(cmd)
63
+ %{
64
+ th[read] l[ist]\t\t\tlist all threads
65
+ }
66
+ end
67
+ end
68
+ end
69
+
70
+ class ThreadStopCommand < Command # :nodoc:
71
+ self.allow_in_control = true
72
+ self.allow_in_post_mortem = false
73
+ self.need_context = true
74
+
75
+ def regexp
76
+ /^\s*th(?:read)?\s+stop\s*(\S*)\s*$/
77
+ end
78
+
79
+ def execute
80
+ c = parse_thread_num_for_cmd("thread stop", @match[1])
81
+ return unless c
82
+ c.suspend
83
+ display_context(c)
84
+ end
85
+
86
+ class << self
87
+ def help_command
88
+ 'thread'
89
+ end
90
+
91
+ def help(cmd)
92
+ %{
93
+ th[read] stop <nnn>\t\tstop thread nnn
94
+ }
95
+ end
96
+ end
97
+ end
98
+
99
+ class ThreadResumeCommand < Command # :nodoc:
100
+ self.allow_in_post_mortem = false
101
+ self.allow_in_control = true
102
+ self.need_context = true
103
+
104
+ def regexp
105
+ /^\s*th(?:read)?\s+resume\s*(\S*)\s*$/
106
+ end
107
+
108
+ def execute
109
+ c = parse_thread_num_for_cmd("thread resume", @match[1])
110
+ return unless c
111
+ if !c.thread.stop?
112
+ print "Already running."
113
+ return
114
+ end
115
+ c.resume
116
+ display_context(c)
117
+ end
118
+
119
+ class << self
120
+ def help_command
121
+ 'thread'
122
+ end
123
+
124
+ def help(cmd)
125
+ %{
126
+ th[read] resume <nnn>\t\tresume thread nnn
127
+ }
128
+ end
129
+ end
130
+ end
131
+
132
+ # Thread switch Must come after "Thread resume" because "switch" is
133
+ # optional
134
+
135
+ class ThreadSwitchCommand < Command # :nodoc:
136
+ self.allow_in_control = true
137
+ self.allow_in_post_mortem = false
138
+ self.need_context = true
139
+
140
+ def regexp
141
+ /^\s*th(?:read)?\s*(?:sw(?:itch)?)?\s+(\S+)\s*$/
142
+ end
143
+
144
+ def execute
145
+ c = parse_thread_num_for_cmd("thread switch", @match[1])
146
+ return unless c
147
+ display_context(c)
148
+ c.stop_next = 1
149
+ c.thread.run
150
+ @state.proceed
151
+ end
152
+
153
+ class << self
154
+ def help_command
155
+ 'thread'
156
+ end
157
+
158
+ def help(cmd)
159
+ %{
160
+ th[read] [sw[itch]] <nnn>\tswitch thread context to nnn
161
+ }
162
+ end
163
+ end
164
+ end
165
+
166
+ class ThreadCurrentCommand < Command # :nodoc:
167
+ self.need_context = true
168
+
169
+ def regexp
170
+ /^\s*th(?:read)?\s*(?:cur(?:rent)?)?\s*$/
171
+ end
172
+
173
+ def execute
174
+ display_context(@state.context)
175
+ end
176
+
177
+ class << self
178
+ def help_command
179
+ 'thread'
180
+ end
181
+
182
+ def help(cmd)
183
+ %{
184
+ th[read] [cur[rent]]\t\tshow current thread
185
+ }
186
+ end
187
+ end
188
+ end
189
+ end
@@ -0,0 +1,36 @@
1
+ module Debugger
2
+ if RUBY_PLATFORM =~ /darwin/
3
+ class TextMateCommand < Command # :nodoc:
4
+ def regexp
5
+ /^\s*tm(?:ate)?(?:\s*(\d+))?$/
6
+ end
7
+
8
+ def execute
9
+ if @match[1]
10
+ frm_n = @match[1].to_i
11
+ if frm_n > @state.context.stack_size || frm_n == 0
12
+ print "Wrong frame number\n"
13
+ return
14
+ end
15
+ file, line = @state.context.frame_file(frm_n-1), @state.context.frame_line(frm_n-1)
16
+ else
17
+ file, line = @state.file, @state.line
18
+ end
19
+ %x|open 'txmt://open?url=file://#{File.expand_path(file)}&line=#{line}'|
20
+ end
21
+
22
+ class << self
23
+ def help_command
24
+ 'tmate'
25
+ end
26
+
27
+ def help(cmd)
28
+ %{
29
+ tm[ate] n\topens a current file in TextMate.
30
+ \t\tIt uses n-th frame if arg (n) is specifed.
31
+ }
32
+ end
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,57 @@
1
+ module Debugger
2
+ class TraceCommand < Command # :nodoc:
3
+ def regexp
4
+ /^\s* tr(?:ace)? (?: \s+ (\S+)) # on |off | var(iable)
5
+ (?: \s+ (\S+))? # (all | variable-name)?
6
+ (?: \s+ (\S+))? \s* # (stop | nostop)?
7
+ $/ix
8
+ end
9
+
10
+ def execute
11
+ if @match[1] =~ /on|off/
12
+ onoff = 'on' == @match[1]
13
+ if @match[2]
14
+ Debugger.current_context.tracing = onoff
15
+ print "Tracing %s all threads.\n" % (onoff ? 'on' : 'off')
16
+ else
17
+ Debugger.tracing = onoff
18
+ print "Tracing %s on current thread.\n" % (onoff ? 'on' : 'off')
19
+ end
20
+ elsif @match[1] =~ /var(?:iable)?/
21
+ varname=@match[2]
22
+ if debug_eval("defined?(#{varname})")
23
+ if @match[3] && @match[3] !~ /(:?no)?stop/
24
+ errmsg("expecting 'stop' or 'nostop'; got %s\n" % @match[3])
25
+ else
26
+ dbg_cmd = if @match[3] && (@match[3] !~ /nostop/)
27
+ 'debugger' else '' end
28
+ end
29
+ eval("
30
+ trace_var(:#{varname}) do |val|
31
+ print \"traced variable #{varname} has value \#{val}\n\"
32
+ #{dbg_cmd}
33
+ end")
34
+ else
35
+ errmsg "#{varname} is not a global variable.\n"
36
+ end
37
+ else
38
+ errmsg("expecting 'on', 'off', 'var' or 'variable'; got: %s\n" %
39
+ @match[1])
40
+ end
41
+ end
42
+
43
+ class << self
44
+ def help_command
45
+ 'trace'
46
+ end
47
+
48
+ def help(cmd)
49
+ %{
50
+ tr[ace] (on|off)\tset trace mode of current thread
51
+ tr[ace] (on|off) all\tset trace mode of all threads
52
+ tr[ace] var(iable) VARNAME [stop|nostop]\tset trace variable on VARNAME
53
+ }
54
+ end
55
+ end
56
+ end
57
+ end
@@ -0,0 +1,199 @@
1
+ module Debugger
2
+ module VarFunctions # :nodoc:
3
+ def var_list(ary, b = get_binding)
4
+ ary.sort!
5
+ for v in ary
6
+ begin
7
+ s = debug_eval(v, b).inspect
8
+ rescue
9
+ begin
10
+ s = debug_eval(v, b).to_s
11
+ rescue
12
+ s = "*Error in evaluation*"
13
+ end
14
+ end
15
+ if s.size > self.class.settings[:width]
16
+ s[self.class.settings[:width]-3 .. -1] = "..."
17
+ end
18
+ print "%s = %s\n", v, s
19
+ end
20
+ end
21
+ def var_class_self
22
+ obj = debug_eval('self')
23
+ var_list(obj.class.class_variables, get_binding)
24
+ end
25
+ end
26
+
27
+ # Implements the debugger 'var class' command.
28
+ class VarClassVarCommand < Command
29
+ def regexp
30
+ /^\s*v(?:ar)?\s+cl(?:ass)?/
31
+ end
32
+
33
+ def execute
34
+ unless @state.context
35
+ errmsg "can't get class variables here.\n"
36
+ return
37
+ end
38
+ var_class_self
39
+ end
40
+
41
+ class << self
42
+ def help_command
43
+ 'var'
44
+ end
45
+
46
+ def help(cmd)
47
+ %{
48
+ v[ar] cl[ass] \t\t\tshow class variables of self
49
+ }
50
+ end
51
+ end
52
+ end
53
+
54
+ class VarConstantCommand < Command # :nodoc:
55
+ def regexp
56
+ /^\s*v(?:ar)?\s+co(?:nst(?:ant)?)?\s+/
57
+ end
58
+
59
+ def execute
60
+ obj = debug_eval(@match.post_match)
61
+ if obj.kind_of? Module
62
+ constants = debug_eval("#{@match.post_match}.constants")
63
+ constants.sort!
64
+ for c in constants
65
+ next if c =~ /SCRIPT/
66
+ value = obj.const_get(c) rescue "ERROR: #{$!}"
67
+ print " %s => %p\n", c, value
68
+ end
69
+ else
70
+ print "Should be Class/Module: %s\n", @match.post_match
71
+ end
72
+ end
73
+
74
+ class << self
75
+ def help_command
76
+ 'var'
77
+ end
78
+
79
+ def help(cmd)
80
+ %{
81
+ v[ar] c[onst] <object>\t\tshow constants of object
82
+ }
83
+ end
84
+ end
85
+ end
86
+
87
+ class VarGlobalCommand < Command # :nodoc:
88
+ def regexp
89
+ /^\s*v(?:ar)?\s+g(?:lobal)?\s*$/
90
+ end
91
+
92
+ def execute
93
+ var_list(global_variables)
94
+ end
95
+
96
+ class << self
97
+ def help_command
98
+ 'var'
99
+ end
100
+
101
+ def help(cmd)
102
+ %{
103
+ v[ar] g[lobal]\t\t\tshow global variables
104
+ }
105
+ end
106
+ end
107
+ end
108
+
109
+ class VarInstanceCommand < Command # :nodoc:
110
+ def regexp
111
+ /^\s*v(?:ar)?\s+ins(?:tance)?\s*/
112
+ end
113
+
114
+ def execute
115
+ obj = debug_eval(@match.post_match.empty? ? 'self' : @match.post_match)
116
+ var_list(obj.instance_variables, obj.instance_eval{binding()})
117
+ end
118
+
119
+ class << self
120
+ def help_command
121
+ 'var'
122
+ end
123
+
124
+ def help(cmd)
125
+ %{
126
+ v[ar] i[nstance] <object>\tshow instance variables of object
127
+ }
128
+ end
129
+ end
130
+ end
131
+
132
+ # Implements the debugger 'var local' command.
133
+ class VarLocalCommand < Command
134
+ def regexp
135
+ /^\s*v(?:ar)?\s+l(?:ocal)?\s*$/
136
+ end
137
+
138
+ def execute
139
+ locals = @state.context.frame_locals(@state.frame_pos)
140
+ _self = @state.context.frame_self(@state.frame_pos)
141
+ locals.keys.sort.each do |name|
142
+ print " %s => %p\n", name, locals[name]
143
+ end
144
+ end
145
+
146
+ class << self
147
+ def help_command
148
+ 'var'
149
+ end
150
+
151
+ def help(cmd)
152
+ %{
153
+ v[ar] l[ocal]\t\t\tshow local variables
154
+ }
155
+ end
156
+ end
157
+ end
158
+
159
+ # Implements the debugger 'var inherit' command.
160
+ begin
161
+ require 'classtree'
162
+ have_classtree = true
163
+ rescue LoadError
164
+ have_classtree = false
165
+ end
166
+
167
+ class VarInheritCommand < Command
168
+ def regexp
169
+ /^\s*v(?:ar)?\s+ct\s*/
170
+ end
171
+
172
+ def execute
173
+ unless @state.context
174
+ errmsg "can't get object inheritance.\n"
175
+ return
176
+ end
177
+ puts @match.post_match
178
+ obj = debug_eval("#{@match.post_match}.classtree")
179
+ if obj
180
+ print obj
181
+ else
182
+ errmsg "Trouble getting object #{@match.post_match}\n"
183
+ end
184
+ end
185
+
186
+ class << self
187
+ def help_command
188
+ 'var'
189
+ end
190
+
191
+ def help(cmd)
192
+ %{
193
+ v[ar] ct\t\t\tshow class heirarchy of object
194
+ }
195
+ end
196
+ end
197
+ end if have_classtree
198
+
199
+ end