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,40 @@
1
+ module Debugger
2
+ # Implements debugger "reload" command.
3
+ class ReloadCommand < Command
4
+ self.allow_in_control = true
5
+
6
+ register_setting_get(:reload_source_on_change) do
7
+ Debugger.reload_source_on_change
8
+ end
9
+ register_setting_set(:reload_source_on_change) do |value|
10
+ Debugger.reload_source_on_change = value
11
+ end
12
+
13
+ def regexp
14
+ /^\s*r(?:eload)?$/
15
+ end
16
+
17
+ def execute
18
+ Debugger.source_reload
19
+ print "Source code is reloaded. Automatic reloading is #{source_reloading}.\n"
20
+ end
21
+
22
+ private
23
+
24
+ def source_reloading
25
+ Debugger.reload_source_on_change ? 'on' : 'off'
26
+ end
27
+
28
+ class << self
29
+ def help_command
30
+ 'reload'
31
+ end
32
+
33
+ def help(cmd)
34
+ %{
35
+ r[eload]\tforces source code reloading
36
+ }
37
+ end
38
+ end
39
+ end
40
+ end
@@ -0,0 +1,90 @@
1
+ module Debugger
2
+ module SaveFunctions # :nodoc:
3
+
4
+ # Create a temporary file to write in if file is nil
5
+ def open_save
6
+ require "tempfile"
7
+ file = Tempfile.new("rdebug-save")
8
+ # We want close to not unlink, so redefine.
9
+ def file.close
10
+ @tmpfile.close if @tmpfile
11
+ end
12
+ return file
13
+ end
14
+ end
15
+
16
+ class SaveCommand < Command # :nodoc:
17
+ self.allow_in_control = true
18
+
19
+ def save_breakpoints(file)
20
+ Debugger.breakpoints.each do |b|
21
+ file.puts "break #{b.source}:#{b.pos}#{" if #{b.expr}" if b.expr}"
22
+ end
23
+ end
24
+
25
+ def save_catchpoints(file)
26
+ Debugger.catchpoints.keys.each do |c|
27
+ file.puts "catch #{c}"
28
+ end
29
+ end
30
+
31
+ def save_displays(file)
32
+ for d in @state.display
33
+ if d[0]
34
+ file.puts "display #{d[1]}"
35
+ end
36
+ end
37
+ end
38
+
39
+ def save_settings(file)
40
+ # FIXME put routine in set
41
+ %w(autoeval basename debuggertesting).each do |setting|
42
+ on_off = show_onoff(Command.settings[setting.to_sym])
43
+ file.puts "set #{setting} #{on_off}"
44
+ end
45
+ %w(autolist autoirb).each do |setting|
46
+ on_off = show_onoff(Command.settings[setting.to_sym] > 0)
47
+ file.puts "set #{setting} #{on_off}"
48
+ end
49
+ end
50
+
51
+ def regexp
52
+ /^\s* sa(?:ve)?
53
+ (?:\s+(.+))?
54
+ \s*$/ix
55
+ end
56
+
57
+ def execute
58
+ if not @match[1] or @match[1].strip.empty?
59
+ file = open_save()
60
+ else
61
+ file = open(@match[1], 'w')
62
+ end
63
+ save_breakpoints(file)
64
+ save_catchpoints(file)
65
+ # save_displays(file)
66
+ save_settings(file)
67
+ print "Saved to '#{file.path}'\n"
68
+ if @state and @state.interface
69
+ @state.interface.restart_file = file.path
70
+ end
71
+ file.close
72
+ end
73
+
74
+ class << self
75
+ def help_command
76
+ 'save'
77
+ end
78
+
79
+ def help(cmd)
80
+ %{
81
+ save [FILE]
82
+ Saves current debugger state to FILE as a script file.
83
+ This includes breakpoints, catchpoints, display expressions and some settings.
84
+ If no filename is given, we will fabricate one.
85
+
86
+ Use the 'source' command in another debug session to restore them.}
87
+ end
88
+ end
89
+ end
90
+ end
@@ -0,0 +1,221 @@
1
+ module Debugger
2
+ # Implements debugger "set" command.
3
+ class SetCommand < Command
4
+ SubcmdStruct2=Struct.new(:name, :min, :is_bool, :short_help,
5
+ :long_help) unless defined?(SubcmdStruct2)
6
+ Subcommands =
7
+ [
8
+ ['annotate', 2, false,
9
+ "Set annotation level",
10
+ "0 == normal;
11
+ 2 == output annotated suitably for use by programs that control
12
+ ruby-debug."],
13
+ ['args', 2, false,
14
+ "Set argument list to give program being debugged when it is started",
15
+ "Follow this command with any number of args, to be passed to the program."],
16
+ ['autoeval', 4, true,
17
+ "Evaluate every unrecognized command"],
18
+ ['autolist', 4, true,
19
+ "Execute 'list' command on every breakpoint"],
20
+ ['autoirb', 4, true,
21
+ "Invoke IRB on every stop"],
22
+ ['autoreload', 4, true,
23
+ "Reload source code when changed"],
24
+ ['basename', 1, true,
25
+ "Report file basename only showing file names"],
26
+ ['callstyle', 2, false,
27
+ "Set how you want call parameters displayed"],
28
+ ['debuggertesting', 8, false,
29
+ "Used when testing the debugger"],
30
+ ['forcestep', 2, true,
31
+ "Make sure 'next/step' commands always move to a new line"],
32
+ ['fullpath', 2, true,
33
+ "Display full file names in frames"],
34
+ ['history', 2, false,
35
+ "Generic command for setting command history parameters",
36
+ "set history filename -- Set the filename in which to record the command history
37
+ set history save -- Set saving of the history record on exit
38
+ set history size -- Set the size of the command history"],
39
+ ['linetrace+', 10, true,
40
+ "Set line execution tracing to show different lines"],
41
+ ['linetrace', 3, true,
42
+ "Set line execution tracing"],
43
+ ['listsize', 3, false,
44
+ "Set number of source lines to list by default"],
45
+ ['trace', 1, true,
46
+ "Display stack trace when 'eval' raises exception"],
47
+ ['width', 1, false,
48
+ "Number of characters the debugger thinks are in a line"],
49
+ ].map do |name, min, is_bool, short_help, long_help|
50
+ SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
51
+ end unless defined?(Subcommands)
52
+
53
+ self.allow_in_control = true
54
+
55
+ def regexp
56
+ /^set (?: \s+ (.*) )?$/ix
57
+ end
58
+
59
+ def execute
60
+ if not @match[1]
61
+ print "\"set\" must be followed by the name of an set command:\n"
62
+ print "List of set subcommands:\n\n"
63
+ for subcmd in Subcommands do
64
+ print "set #{subcmd.name} -- #{subcmd.short_help}\n"
65
+ end
66
+ else
67
+ args = @match[1].split(/[ \t]+/)
68
+ subcmd = args.shift
69
+ subcmd.downcase!
70
+ if subcmd =~ /^no/i
71
+ set_on = false
72
+ subcmd = subcmd[2..-1]
73
+ else
74
+ set_on = true
75
+ end
76
+ for try_subcmd in Subcommands do
77
+ if (subcmd.size >= try_subcmd.min) and
78
+ (try_subcmd.name[0..subcmd.size-1] == subcmd)
79
+ begin
80
+ if try_subcmd.is_bool
81
+ if args.size > 0
82
+ set_on = get_onoff(args[0])
83
+ end
84
+ end
85
+ case try_subcmd.name
86
+ when /^annotate$/
87
+ level = get_int(args[0], "Set annotate", 0, 3, 0)
88
+ if level
89
+ Debugger.annotate = level
90
+ else
91
+ return
92
+ end
93
+ if defined?(Debugger::RDEBUG_SCRIPT)
94
+ # rdebug was called initially. 1st arg is script name.
95
+ Command.settings[:argv][1..-1] = args
96
+ else
97
+ # rdebug wasn't called initially. 1st arg is not script name.
98
+ Command.settings[:argv] = args
99
+ end
100
+ when /^args$/
101
+ Command.settings[:argv][1..-1] = args
102
+ when /^autolist$/
103
+ Command.settings[:autolist] = (set_on ? 1 : 0)
104
+ when /^autoeval$/
105
+ Command.settings[:autoeval] = set_on
106
+ when /^basename$/
107
+ Command.settings[:basename] = set_on
108
+ when /^callstyle$/
109
+ if args[0]
110
+ arg = args[0].downcase.to_sym
111
+ case arg
112
+ when :short, :last
113
+ Command.settings[:callstyle] = arg
114
+ print "%s\n" % show_setting(try_subcmd.name)
115
+ return
116
+ end
117
+ end
118
+ print "Invalid call style #{arg}. Should be one of: " +
119
+ "'short' or 'last'.\n"
120
+ when /^trace$/
121
+ Command.settings[:stack_trace_on_error] = set_on
122
+ when /^fullpath$/
123
+ Command.settings[:full_path] = set_on
124
+ when /^autoreload$/
125
+ Command.settings[:reload_source_on_change] = set_on
126
+ when /^autoirb$/
127
+ Command.settings[:autoirb] = (set_on ? 1 : 0)
128
+ when /^debuggertesting$/
129
+ Command.settings[:debuggertesting] = set_on
130
+ if set_on
131
+ Command.settings[:basename] = true
132
+ end
133
+ when /^forcestep$/
134
+ self.class.settings[:force_stepping] = set_on
135
+ when /^history$/
136
+ if 2 == args.size
137
+ interface = @state.interface
138
+ case args[0]
139
+ when /^save$/
140
+ interface.history_save = get_onoff(args[1])
141
+ when /^size$/
142
+ interface.history_length = get_int(args[1],
143
+ "Set history size")
144
+ else
145
+ print "Invalid history parameter #{args[0]}. Should be 'save' or 'size'.\n"
146
+ end
147
+ else
148
+ print "Need two parameters for 'set history'; got #{args.size}.\n"
149
+ return
150
+ end
151
+ when /^linetrace\+$/
152
+ self.class.settings[:tracing_plus] = set_on
153
+ when /^linetrace$/
154
+ Debugger.tracing = set_on
155
+ when /^listsize$/
156
+ listsize = get_int(args[0], "Set listsize", 1, nil, 10)
157
+ if listsize
158
+ self.class.settings[:listsize] = listsize
159
+ else
160
+ return
161
+ end
162
+ when /^width$/
163
+ width = get_int(args[0], "Set width", 10, nil, 80)
164
+ if width
165
+ self.class.settings[:width] = width
166
+ ENV['COLUMNS'] = width.to_s
167
+ else
168
+ return
169
+ end
170
+ else
171
+ print "Unknown setting #{@match[1]}.\n"
172
+ return
173
+ end
174
+ print "%s\n" % show_setting(try_subcmd.name)
175
+ return
176
+ rescue RuntimeError
177
+ return
178
+ end
179
+ end
180
+ end
181
+ print "Unknown set command #{subcmd}\n"
182
+ end
183
+ end
184
+
185
+ class << self
186
+ def help_command
187
+ "set"
188
+ end
189
+
190
+ def help(args)
191
+ if args[1]
192
+ s = args[1]
193
+ subcmd = Subcommands.find do |try_subcmd|
194
+ (s.size >= try_subcmd.min) and
195
+ (try_subcmd.name[0..s.size-1] == s)
196
+ end
197
+ if subcmd
198
+ str = subcmd.short_help + '.'
199
+ str += "\n" + subcmd.long_help if subcmd.long_help
200
+ return str
201
+ else
202
+ return "Invalid 'set' subcommand '#{args[1]}'."
203
+ end
204
+ end
205
+ s = %{
206
+ Modifies parts of the ruby-debug environment. Boolean values take
207
+ on, off, 1 or 0.
208
+ You can see these environment settings with the \"show\" command.
209
+
210
+ --
211
+ List of set subcommands:
212
+ --
213
+ }
214
+ for subcmd in Subcommands do
215
+ s += "set #{subcmd.name} -- #{subcmd.short_help}\n"
216
+ end
217
+ return s
218
+ end
219
+ end
220
+ end
221
+ end
@@ -0,0 +1,247 @@
1
+ module Debugger
2
+ # Mix-in module to showing settings
3
+ module ShowFunctions # :nodoc:
4
+ def show_setting(setting_name)
5
+ case setting_name
6
+ when /^annotate$/
7
+ Debugger.annotate ||= 0
8
+ return ("Annotation level is #{Debugger.annotate}")
9
+ when /^args$/
10
+ if Command.settings[:argv] and Command.settings[:argv].size > 0
11
+ if defined?(Debugger::RDEBUG_SCRIPT)
12
+ # rdebug was called initially. 1st arg is script name.
13
+ args = Command.settings[:argv][1..-1].join(' ')
14
+ else
15
+ # rdebug wasn't called initially. 1st arg is not script name.
16
+ args = Command.settings[:argv].join(' ')
17
+ end
18
+ else
19
+ args = ''
20
+ end
21
+ return "Argument list to give program being debugged when it is started is \"#{args}\"."
22
+ when /^autolist$/
23
+ on_off = Command.settings[:autolist] > 0
24
+ return "autolist is #{show_onoff(on_off)}."
25
+ when /^autoeval$/
26
+ on_off = Command.settings[:autoeval]
27
+ return "autoeval is #{show_onoff(on_off)}."
28
+ when /^autoreload$/
29
+ on_off = Command.settings[:reload_source_on_change]
30
+ return "autoreload is #{show_onoff(on_off)}."
31
+ when /^autoirb$/
32
+ on_off = Command.settings[:autoirb] > 0
33
+ return "autoirb is #{show_onoff(on_off)}."
34
+ when /^basename$/
35
+ on_off = Command.settings[:basename]
36
+ return "basename is #{show_onoff(on_off)}."
37
+ when /^callstyle$/
38
+ style = Command.settings[:callstyle]
39
+ return "Frame call-display style is #{style}."
40
+ when /^commands(:?\s+(\d+))?$/
41
+ if @state.interface.readline_support?
42
+ s = '';
43
+ args = @match[1].split
44
+ if args[1]
45
+ first_line = args[1].to_i - 4
46
+ last_line = first_line + 10 - 1
47
+ if first_line > Readline::HISTORY.length
48
+ first_line = last_line = Readline::HISTORY.length
49
+ elsif first_line <= 0
50
+ first_line = 1
51
+ end
52
+ if last_line > Readline::HISTORY.length
53
+ last_line = Readline::HISTORY.length
54
+ end
55
+ i = first_line
56
+ commands = Readline::HISTORY.to_a[first_line..last_line]
57
+ else
58
+ if Readline::HISTORY.length > 10
59
+ commands = Readline::HISTORY.to_a[-10..-1]
60
+ i = Readline::HISTORY.length - 10
61
+ else
62
+ commands = Readline::HISTORY.to_a
63
+ i = 1
64
+ end
65
+ end
66
+ commands.each do |cmd|
67
+ s += ("%5d %s\n" % [i, cmd])
68
+ i += 1
69
+ end
70
+ else
71
+ s='No readline suport'
72
+ end
73
+ return s
74
+ when /^debuggertesting$/
75
+ on_off = Command.settings[:debuggertesting]
76
+ return "Currently testing the debugger is #{show_onoff(on_off)}."
77
+ when /^forcestep$/
78
+ on_off = self.class.settings[:force_stepping]
79
+ return "force-stepping is #{show_onoff(on_off)}."
80
+ when /^fullpath$/
81
+ on_off = Command.settings[:full_path]
82
+ return "Displaying frame's full file names is #{show_onoff(on_off)}."
83
+ when /^history(:?\s+(filename|save|size))?$/
84
+ args = @match[1].split
85
+ interface = @state.interface
86
+ if args[1]
87
+ show_save = show_size = show_filename = false
88
+ prefix = false
89
+ if args[1] == "save"
90
+ show_save = true
91
+ elsif args[1] == "size"
92
+ show_size = true
93
+ elsif args[1] == "filename"
94
+ show_filename = true
95
+ end
96
+ else
97
+ show_save = show_size = show_filename = true
98
+ prefix = true
99
+ end
100
+ s = []
101
+ if show_filename
102
+ msg = (prefix ? "filename: " : "") +
103
+ "The filename in which to record the command history is " +
104
+ "#{interface.histfile.inspect}"
105
+ s << msg
106
+ end
107
+ if show_save
108
+ msg = (prefix ? "save: " : "") +
109
+ "Saving of history save is #{show_onoff(interface.history_save)}."
110
+ s << msg
111
+ end
112
+ if show_size
113
+ msg = (prefix ? "size: " : "") +
114
+ "Debugger history size is #{interface.history_length}"
115
+ s << msg
116
+ end
117
+ return s.join("\n")
118
+ when /^linetrace$/
119
+ on_off = Debugger.tracing
120
+ return "line tracing is #{show_onoff(on_off)}."
121
+ when /^linetrace\+$/
122
+ on_off = Command.settings[:tracing_plus]
123
+ if on_off
124
+ return "line tracing style is different consecutive lines."
125
+ else
126
+ return "line tracing style is every line."
127
+ end
128
+ when /^listsize$/
129
+ listlines = Command.settings[:listsize]
130
+ return "Number of source lines to list by default is #{listlines}."
131
+ when /^port$/
132
+ return "server port is #{Debugger::PORT}."
133
+ when /^trace$/
134
+ on_off = Command.settings[:stack_trace_on_error]
135
+ return "Displaying stack trace is #{show_onoff(on_off)}."
136
+ when /^version$/
137
+ return "ruby-debug #{Debugger::VERSION}"
138
+ when /^width$/
139
+ return "width is #{self.class.settings[:width]}."
140
+ else
141
+ return "Unknown show subcommand #{setting_name}."
142
+ end
143
+ end
144
+ end
145
+
146
+ # Implements debugger "show" command.
147
+ class ShowCommand < Command
148
+
149
+ Subcommands =
150
+ [
151
+ ['annotate', 2, "Show annotation level",
152
+ "0 == normal; 2 == output annotated suitably for use by programs that control
153
+ ruby-debug."],
154
+ ['args', 2,
155
+ "Show argument list to give program being debugged when it is started",
156
+ "Follow this command with any number of args, to be passed to the program."],
157
+ ['autoeval', 4, "Show if unrecognized command are evaluated"],
158
+ ['autolist', 4, "Show if 'list' commands is run on breakpoints"],
159
+ ['autoirb', 4, "Show if IRB is invoked on debugger stops"],
160
+ ['autoreload', 4, "Show if source code is reloaded when changed"],
161
+ ['basename', 1, "Show if basename used in reporting files"],
162
+ ['callstyle', 2, "Show paramater style used showing call frames"],
163
+ ['commands', 2, "Show the history of commands you typed",
164
+ "You can supply a command number to start with."],
165
+ ['forcestep', 1, "Show if sure 'next/step' forces move to a new line"],
166
+ ['fullpath', 2, "Show if full file names are displayed in frames"],
167
+ ['history', 2, "Generic command for showing command history parameters",
168
+ "show history filename -- Show the filename in which to record the command history
169
+ show history save -- Show saving of the history record on exit
170
+ show history size -- Show the size of the command history"],
171
+ ['keep-frame-bindings', 1, "Save frame binding on each call"],
172
+ ['linetrace', 3, "Show line execution tracing"],
173
+ ['linetrace+', 10,
174
+ "Show if consecutive lines should be different are shown in tracing"],
175
+ ['listsize', 3, "Show number of source lines to list by default"],
176
+ ['port', 3, "Show server port"],
177
+ ['post-mortem', 3, "Show whether we go into post-mortem debugging on an uncaught exception"],
178
+ ['trace', 1,
179
+ "Show if a stack trace is displayed when 'eval' raises exception"],
180
+ ['version', 1,
181
+ "Show what version of the debugger this is"],
182
+ ['width', 1,
183
+ "Show the number of characters the debugger thinks are in a line"],
184
+ ].map do |name, min, short_help, long_help|
185
+ SubcmdStruct.new(name, min, short_help, long_help)
186
+ end unless defined?(Subcommands)
187
+
188
+ self.allow_in_control = true
189
+
190
+ def regexp
191
+ /^show (?: \s+ (.+) )?$/xi
192
+ end
193
+
194
+ def execute
195
+ if not @match[1]
196
+ print "\"show\" must be followed by the name of an show command:\n"
197
+ print "List of show subcommands:\n\n"
198
+ for subcmd in Subcommands do
199
+ print "show #{subcmd.name} -- #{subcmd.short_help}\n"
200
+ end
201
+ else
202
+ args = @match[1].split(/[ \t]+/)
203
+ param = args.shift
204
+ subcmd = find(Subcommands, param)
205
+ if subcmd
206
+ print "%s\n" % show_setting(subcmd.name)
207
+ else
208
+ print "Unknown show command #{param}\n"
209
+ end
210
+ end
211
+ end
212
+
213
+ class << self
214
+ def help_command
215
+ "show"
216
+ end
217
+
218
+ def help(args)
219
+ if args[1]
220
+ s = args[1]
221
+ subcmd = Subcommands.find do |try_subcmd|
222
+ (s.size >= try_subcmd.min) and
223
+ (try_subcmd.name[0..s.size-1] == s)
224
+ end
225
+ if subcmd
226
+ str = subcmd.short_help + '.'
227
+ str += "\n" + subcmd.long_help if subcmd.long_help
228
+ return str
229
+ else
230
+ return "Invalid 'show' subcommand '#{args[1]}'."
231
+ end
232
+ end
233
+ s = "
234
+ Generic command for showing things about the debugger.
235
+
236
+ --
237
+ List of show subcommands:
238
+ --
239
+ "
240
+ for subcmd in Subcommands do
241
+ s += "show #{subcmd.name} -- #{subcmd.short_help}\n"
242
+ end
243
+ return s
244
+ end
245
+ end
246
+ end
247
+ end