ruby-debug 0.10.0 → 0.10.1

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 (152) hide show
  1. data/CHANGES +94 -2
  2. data/ChangeLog +5225 -0
  3. data/README +30 -1
  4. data/Rakefile +55 -24
  5. data/bin/rdebug +249 -128
  6. data/cli/ruby-debug/command.rb +30 -3
  7. data/cli/ruby-debug/commands/breakpoints.rb +54 -24
  8. data/cli/ruby-debug/commands/catchpoint.rb +13 -12
  9. data/cli/ruby-debug/commands/condition.rb +49 -0
  10. data/cli/ruby-debug/commands/continue.rb +32 -0
  11. data/cli/ruby-debug/commands/control.rb +19 -43
  12. data/cli/ruby-debug/commands/disassemble.RB +38 -0
  13. data/cli/ruby-debug/commands/display.rb +1 -1
  14. data/cli/ruby-debug/commands/edit.rb +48 -0
  15. data/cli/ruby-debug/commands/enable.rb +78 -35
  16. data/cli/ruby-debug/commands/eval.rb +6 -5
  17. data/cli/ruby-debug/commands/finish.rb +42 -0
  18. data/cli/ruby-debug/commands/frame.rb +64 -33
  19. data/cli/ruby-debug/commands/help.rb +19 -15
  20. data/cli/ruby-debug/commands/info.rb +295 -36
  21. data/cli/ruby-debug/commands/irb.rb +3 -1
  22. data/cli/ruby-debug/commands/list.rb +27 -50
  23. data/cli/ruby-debug/commands/quit.rb +38 -0
  24. data/cli/ruby-debug/commands/reload.rb +40 -0
  25. data/cli/ruby-debug/commands/save.rb +80 -0
  26. data/cli/ruby-debug/commands/{settings.rb → set.rb} +50 -12
  27. data/cli/ruby-debug/commands/show.rb +83 -27
  28. data/cli/ruby-debug/commands/source.rb +36 -0
  29. data/cli/ruby-debug/commands/stepping.rb +36 -72
  30. data/cli/ruby-debug/commands/threads.rb +32 -23
  31. data/cli/ruby-debug/commands/variables.rb +34 -4
  32. data/cli/ruby-debug/helper.rb +10 -75
  33. data/cli/ruby-debug/interface.rb +72 -9
  34. data/cli/ruby-debug/processor.rb +203 -100
  35. data/doc/rdebug.1 +7 -2
  36. data/rdbg.rb +33 -0
  37. data/test/{test-ruby-debug-base.rb → base/base.rb} +27 -29
  38. data/test/base/binding.rb +31 -0
  39. data/test/base/catchpoint.rb +26 -0
  40. data/test/base/load.rb +40 -0
  41. data/test/data/annotate.cmd +29 -0
  42. data/test/data/annotate.right +137 -0
  43. data/test/data/break_bad.cmd +18 -0
  44. data/test/data/break_bad.right +28 -0
  45. data/test/data/breakpoints.cmd +38 -0
  46. data/test/data/breakpoints.right +98 -0
  47. data/test/data/condition.cmd +28 -0
  48. data/test/data/condition.right +65 -0
  49. data/test/data/ctrl.cmd +23 -0
  50. data/test/data/ctrl.right +69 -0
  51. data/test/{display.cmd → data/display.cmd} +7 -1
  52. data/test/{display.right → data/display.right} +13 -6
  53. data/test/data/dollar-0.right +2 -0
  54. data/test/data/dollar-0a.right +2 -0
  55. data/test/data/dollar-0b.right +2 -0
  56. data/test/data/edit.cmd +12 -0
  57. data/test/data/edit.right +19 -0
  58. data/test/{breakpoints.cmd → data/emacs_basic.cmd} +0 -0
  59. data/test/{breakpoints.right → data/emacs_basic.right} +24 -12
  60. data/test/data/enable.cmd +20 -0
  61. data/test/data/enable.right +36 -0
  62. data/test/data/finish.cmd +16 -0
  63. data/test/data/finish.right +43 -0
  64. data/test/{frame.cmd → data/frame.cmd} +2 -0
  65. data/test/{frame.right → data/frame.right} +8 -2
  66. data/test/{help.cmd → data/help.cmd} +8 -0
  67. data/test/data/help.right +21 -0
  68. data/test/data/history.right +7 -0
  69. data/test/data/info-thread.cmd +13 -0
  70. data/test/data/info-thread.right +37 -0
  71. data/test/data/info-var-bug2.cmd +5 -0
  72. data/test/data/info-var-bug2.right +10 -0
  73. data/test/{info-var.cmd → data/info-var.cmd} +3 -3
  74. data/test/{info-var.right → data/info-var.right} +20 -15
  75. data/test/{info.cmd → data/info.cmd} +10 -1
  76. data/test/data/info.right +65 -0
  77. data/test/data/linetrace.cmd +6 -0
  78. data/test/data/linetrace.right +32 -0
  79. data/test/data/linetracep.cmd +7 -0
  80. data/test/data/linetracep.right +25 -0
  81. data/test/data/list.cmd +19 -0
  82. data/test/data/list.right +127 -0
  83. data/test/data/noquit.right +1 -0
  84. data/test/data/output.cmd +6 -0
  85. data/test/data/output.right +41 -0
  86. data/test/data/post-mortem-next.cmd +8 -0
  87. data/test/data/post-mortem-next.right +14 -0
  88. data/test/data/post-mortem-osx.right +31 -0
  89. data/test/data/post-mortem.cmd +13 -0
  90. data/test/data/post-mortem.right +31 -0
  91. data/test/{quit.cmd → data/quit.cmd} +2 -5
  92. data/test/data/quit.right +9 -0
  93. data/test/data/raise.cmd +11 -0
  94. data/test/data/raise.right +26 -0
  95. data/test/{setshow.cmd → data/setshow.cmd} +0 -1
  96. data/test/{setshow.right → data/setshow.right} +0 -1
  97. data/test/data/source.cmd +5 -0
  98. data/test/data/source.right +15 -0
  99. data/test/{stepping.cmd → data/stepping.cmd} +6 -2
  100. data/test/{stepping.right → data/stepping.right} +13 -3
  101. data/test/data/test-init-cygwin.right +7 -0
  102. data/test/data/test-init-osx.right +4 -0
  103. data/test/data/test-init.right +5 -0
  104. data/test/data/trace.right +23 -0
  105. data/test/dollar-0.rb +5 -0
  106. data/test/except-bug2.rb +7 -0
  107. data/test/gcd-dbg-nox.rb +31 -0
  108. data/test/gcd-dbg.rb +30 -0
  109. data/test/helper.rb +44 -14
  110. data/test/info-var-bug.rb +2 -0
  111. data/test/info-var-bug2.rb +2 -0
  112. data/test/null.rb +1 -0
  113. data/test/output.rb +2 -0
  114. data/test/pm-base.rb +22 -0
  115. data/test/pm.rb +11 -0
  116. data/test/raise.rb +3 -0
  117. data/test/tdebug.rb +88 -40
  118. data/test/test-annotate.rb +25 -0
  119. data/test/test-break-bad.rb +25 -0
  120. data/test/test-breakpoints.rb +14 -17
  121. data/test/test-condition.rb +25 -0
  122. data/test/test-ctrl.rb +54 -0
  123. data/test/test-display.rb +15 -15
  124. data/test/test-dollar-0.rb +39 -0
  125. data/test/test-edit.rb +26 -0
  126. data/test/test-emacs-basic.rb +26 -0
  127. data/test/test-enable.rb +25 -0
  128. data/test/test-finish.rb +34 -0
  129. data/test/test-frame.rb +15 -16
  130. data/test/test-help.rb +34 -18
  131. data/test/test-hist.rb +68 -0
  132. data/test/test-info-thread.rb +32 -0
  133. data/test/test-info-var.rb +28 -14
  134. data/test/test-info.rb +15 -17
  135. data/test/test-init.rb +41 -0
  136. data/test/test-list.rb +25 -0
  137. data/test/test-output.rb +26 -0
  138. data/test/test-pm.rb +46 -0
  139. data/test/test-quit.rb +19 -17
  140. data/test/test-raise.rb +25 -0
  141. data/test/test-setshow.rb +14 -13
  142. data/test/test-source.rb +25 -0
  143. data/test/test-stepping.rb +14 -14
  144. data/test/test-trace.rb +63 -0
  145. data/test/thread1.rb +26 -0
  146. metadata +125 -31
  147. data/cli/ruby-debug/commands/script.rb +0 -64
  148. data/runner.sh +0 -7
  149. data/test/help.right +0 -4
  150. data/test/info.right +0 -35
  151. data/test/quit.right +0 -22
  152. data/test/test-columnize.rb +0 -46
@@ -33,6 +33,8 @@ module IRB # :nodoc:
33
33
  end
34
34
 
35
35
  module Debugger
36
+
37
+ # Implements debugger "help" command.
36
38
  class IRBCommand < Command # :nodoc:
37
39
 
38
40
  register_setting_get(:autoirb) do
@@ -79,7 +81,7 @@ module Debugger
79
81
 
80
82
  def help(cmd)
81
83
  %{
82
- irb\tstarts an IRB session. (EXPERIMENTAL)
84
+ irb\tstarts an Interactive Ruby (IRB) session.
83
85
  }
84
86
  end
85
87
  end
@@ -1,5 +1,6 @@
1
1
  module Debugger
2
- class ListCommand < Command # :nodoc:
2
+ # Implements debugger "list" command.
3
+ class ListCommand < Command
3
4
 
4
5
  register_setting_get(:autolist) do
5
6
  ListCommand.always_run
@@ -9,7 +10,7 @@ module Debugger
9
10
  end
10
11
 
11
12
  def regexp
12
- /^\s*l(?:ist)?(?:\s*([-=])|\s+(.+))?$/
13
+ /^\s* l(?:ist)? (?:\s*([-=])|\s+(.+))? $/x
13
14
  end
14
15
 
15
16
  def execute
@@ -19,8 +20,15 @@ module Debugger
19
20
  @state.previous_line + listsize : @state.line - (listsize/2)
20
21
  e = b + listsize - 1
21
22
  elsif @match[1] == '-'
22
- b = @state.previous_line ?
23
- @state.previous_line - listsize : @state.line - (listsize/2)
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
24
32
  e = b + listsize - 1
25
33
  elsif @match[1] == '='
26
34
  @state.previous_line = nil
@@ -36,8 +44,7 @@ module Debugger
36
44
  e = b + listsize - 1
37
45
  end
38
46
  end
39
- @state.previous_line = b
40
- display_list(b, e, @state.file, @state.line)
47
+ @state.previous_line = display_list(b, e, @state.file, @state.line)
41
48
  end
42
49
 
43
50
  class << self
@@ -58,13 +65,19 @@ module Debugger
58
65
 
59
66
  private
60
67
 
61
- def display_list(b, e, file, line)
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)
62
72
  print "[%d, %d] in %s\n", b, e, file
63
- if lines = Debugger.source_for(file)
64
- n = 0
65
- b.upto(e) do |n|
73
+ lines = LineCache::getlines(file,
74
+ Command.settings[:reload_source_on_change])
75
+ return @state.previous_line if b >= lines.size
76
+ if lines
77
+ e = lines.size if lines.size < e
78
+ [b, 1].max.upto(e) do |n|
66
79
  if n > 0 && lines[n-1]
67
- if n == line
80
+ if n == current
68
81
  print "=> %d %s\n", n, lines[n-1].chomp
69
82
  else
70
83
  print " %d %s\n", n, lines[n-1].chomp
@@ -72,46 +85,10 @@ module Debugger
72
85
  end
73
86
  end
74
87
  else
75
- print "No sourcefile available for %s\n", file
76
- end
77
- end
78
- end
79
-
80
- class ReloadCommand < Command # :nodoc:
81
- self.control = true
82
-
83
- register_setting_get(:reload_source_on_change) do
84
- Debugger.reload_source_on_change
85
- end
86
- register_setting_set(:reload_source_on_change) do |value|
87
- Debugger.reload_source_on_change = value
88
- end
89
-
90
- def regexp
91
- /^\s*r(?:eload)?$/
92
- end
93
-
94
- def execute
95
- Debugger.source_reload
96
- print "Source code is reloaded. Automatic reloading is #{source_reloading}.\n"
97
- end
98
-
99
- private
100
-
101
- def source_reloading
102
- Debugger.reload_source_on_change ? 'on' : 'off'
103
- end
104
-
105
- class << self
106
- def help_command
107
- 'reload'
108
- end
109
-
110
- def help(cmd)
111
- %{
112
- r[eload]\tforces source code reloading
113
- }
88
+ errmsg "No sourcefile available for %s\n", file
89
+ return @state.previous_line
114
90
  end
91
+ return e == lines.size ? @state.previous_line : b
115
92
  end
116
93
  end
117
94
  end
@@ -0,0 +1,38 @@
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" is given, we stop without asking further questions.
34
+ }
35
+ end
36
+ end
37
+ end
38
+ end
@@ -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,80 @@
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
+ file.puts "catch #{Debugger.catchpoint}" if Debugger.catchpoint
24
+ end
25
+
26
+ def save_displays(file)
27
+ for d in @state.display
28
+ if d[0]
29
+ file.puts "display #{d[1]}"
30
+ end
31
+ end
32
+ end
33
+
34
+ def save_settings(file)
35
+ # FIXME put routine in set
36
+ %w(autoeval basename debuggertesting).each do |setting|
37
+ on_off = show_onoff(Command.settings[setting.to_sym])
38
+ file.puts "set #{setting} #{on_off}"
39
+ end
40
+ %w(autolist autoirb).each do |setting|
41
+ on_off = show_onoff(Command.settings[setting.to_sym] > 0)
42
+ file.puts "set #{setting} #{on_off}"
43
+ end
44
+ end
45
+
46
+ def regexp
47
+ /^\s*sa(?:ve)?(?:\s+(.+))?$/
48
+ end
49
+
50
+ def execute
51
+ if not @match[1] or @match[1].strip.empty?
52
+ file = open_save()
53
+ else
54
+ file = open(@match[1], 'w')
55
+ end
56
+ save_breakpoints(file)
57
+ # save_displays(file)
58
+ save_settings(file)
59
+ print "Saved to '#{file.path}'\n"
60
+ if @state and @state.interface
61
+ @state.interface.restart_file = file.path
62
+ end
63
+ file.close
64
+ end
65
+
66
+ class << self
67
+ def help_command
68
+ 'save'
69
+ end
70
+
71
+ def help(cmd)
72
+ %{
73
+ save FILE\tsaves current debugger state to FILE as a script file.
74
+ This includes breakpoints, catchpoint, display expressions and some
75
+ settings.
76
+ }
77
+ end
78
+ end
79
+ end
80
+ end
@@ -1,14 +1,18 @@
1
1
  module Debugger
2
- class SetCommand < Command # :nodoc:
3
-
4
- SubcmdStruct=Struct.new(:name, :min, :is_bool, :short_help) unless
5
- defined?(SubcmdStruct)
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
6
  Subcommands =
7
7
  [
8
8
  ['annotate', 2, false,
9
- "Set annotation level."],
9
+ "Set annotation level",
10
+ "0 == normal;
11
+ 2 == output annotated suitably for use by programs that control
12
+ ruby-debug."],
10
13
  ['args', 2, false,
11
- "Set argument list to give program being debugged when it is started."],
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."],
12
16
  ['autoeval', 4, true,
13
17
  "Evaluate every unrecognized command"],
14
18
  ['autolist', 4, true,
@@ -28,7 +32,10 @@ module Debugger
28
32
  ['fullpath', 2, true,
29
33
  "Display full file names in frames"],
30
34
  ['history', 2, false,
31
- "Generic command for setting command history parameters."],
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"],
32
39
  ['keep-frame-bindings', 1, true,
33
40
  "Save frame binding on each call"],
34
41
  ['linetrace+', 10, true,
@@ -37,15 +44,17 @@ module Debugger
37
44
  "Set line execution tracing"],
38
45
  ['listsize', 3, false,
39
46
  "Set number of source lines to list by default"],
47
+ # ['post-mortem', 3, true,
48
+ # "Set whether we do post-mortem handling on an uncaught exception"],
40
49
  ['trace', 1, true,
41
50
  "Display stack trace when 'eval' raises exception"],
42
51
  ['width', 1, false,
43
52
  "Number of characters the debugger thinks are in a line"],
44
- ].map do |name, min, is_bool, short_help|
45
- SubcmdStruct.new(name, min, is_bool, short_help)
53
+ ].map do |name, min, is_bool, short_help, long_help|
54
+ SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
46
55
  end unless defined?(Subcommands)
47
56
 
48
- self.control = true
57
+ self.allow_in_control = true
49
58
 
50
59
  def regexp
51
60
  /^set (?: \s+ (.*) )?$/ix
@@ -85,7 +94,13 @@ module Debugger
85
94
  else
86
95
  return
87
96
  end
88
- Command.settings[:argv][1..-1] = args
97
+ if defined?(Debugger::RDEBUG_SCRIPT)
98
+ # rdebug was called initially. 1st arg is script name.
99
+ Command.settings[:argv][1..-1] = args
100
+ else
101
+ # rdebug wasn't called initially. 1st arg is not script name.
102
+ Command.settings[:argv] = args
103
+ end
89
104
  when /^args$/
90
105
  Command.settings[:argv][1..-1] = args
91
106
  when /^autolist$/
@@ -148,6 +163,15 @@ module Debugger
148
163
  else
149
164
  return
150
165
  end
166
+ # when /^post-mortem$/
167
+ # unless Debugger.post_mortem? == set_on
168
+ # if set_on
169
+ # Debugger.post_mortem
170
+ # else
171
+ # errmsg "Can't turn off post-mortem once it is on.\n"
172
+ # return
173
+ # end
174
+ # end
151
175
  when /^width$/
152
176
  width = get_int(args[0], "Set width", 10, nil, 80)
153
177
  if width
@@ -176,7 +200,21 @@ module Debugger
176
200
  "set"
177
201
  end
178
202
 
179
- def help(cmd)
203
+ def help(args)
204
+ if args[1]
205
+ s = args[1]
206
+ subcmd = Subcommands.find do |try_subcmd|
207
+ (s.size >= try_subcmd.min) and
208
+ (try_subcmd.name[0..s.size-1] == s)
209
+ end
210
+ if subcmd
211
+ str = subcmd.short_help + '.'
212
+ str += "\n" + subcmd.long_help if subcmd.long_help
213
+ return str
214
+ else
215
+ return "Invalid 'set' subcommand '#{args[1]}'."
216
+ end
217
+ end
180
218
  s = %{
181
219
  Modifies parts of the ruby-debug environment. Boolean values take
182
220
  on, off, 1 or 0.
@@ -8,7 +8,13 @@ module Debugger
8
8
  return ("Annotation level is #{Debugger.annotate}")
9
9
  when /^args$/
10
10
  if Command.settings[:argv] and Command.settings[:argv].size > 0
11
- args = Command.settings[:argv][1..-1].join(' ')
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
12
18
  else
13
19
  args = ''
14
20
  end
@@ -31,6 +37,36 @@ module Debugger
31
37
  when /^callstyle$/
32
38
  style = Command.settings[:callstyle]
33
39
  return "Frame call-display style is #{style}."
40
+ when /^commands(:?\s+(\d+))?$/
41
+ s = '';
42
+ args = @match[1].split
43
+ if args[1]
44
+ first_line = args[1].to_i - 4
45
+ last_line = first_line + 10 - 1
46
+ if first_line > Readline::HISTORY.length
47
+ first_line = last_line = Readline::HISTORY.length
48
+ elsif first_line <= 0
49
+ first_line = 1
50
+ end
51
+ if last_line > Readline::HISTORY.length
52
+ last_line = Readline::HISTORY.length
53
+ end
54
+ i = first_line
55
+ commands = Readline::HISTORY.to_a[first_line..last_line]
56
+ else
57
+ if Readline::HISTORY.length > 10
58
+ commands = Readline::HISTORY.to_a[-10..-1]
59
+ i = Readline::HISTORY.length - 10
60
+ else
61
+ commands = Readline::HISTORY.to_a
62
+ i = 1
63
+ end
64
+ end
65
+ commands.each do |cmd|
66
+ s += ("%5d %s\n" % [i, cmd])
67
+ i += 1
68
+ end
69
+ return s
34
70
  when /^debuggertesting$/
35
71
  on_off = Command.settings[:debuggertesting]
36
72
  return "Currently testing the debugger is #{show_onoff(on_off)}."
@@ -94,7 +130,7 @@ module Debugger
94
130
  when /^port$/
95
131
  return "server port is #{Debugger::PORT}."
96
132
  when /^post-mortem$/
97
- on_off = Debugger.post_mortem
133
+ on_off = Debugger.post_mortem?
98
134
  return "post-mortem handling is #{show_onoff(on_off)}."
99
135
  when /^trace$/
100
136
  on_off = Command.settings[:stack_trace_on_error]
@@ -109,41 +145,49 @@ module Debugger
109
145
  end
110
146
  end
111
147
 
112
- class ShowCommand < Command # :nodoc:
148
+ # Implements debugger "show" command.
149
+ class ShowCommand < Command
113
150
 
114
- SubcmdStruct=Struct.new(:name, :min, :short_help) unless
115
- defined?(SubcmdStruct)
116
151
  Subcommands =
117
152
  [
118
- ['annotate', 2, "Show annotation level"],
153
+ ['annotate', 2, "Show annotation level",
154
+ "0 == normal; 2 == output annotated suitably for use by programs that control
155
+ ruby-debug."],
119
156
  ['args', 2,
120
- "Show argument list to give program being debugged when it is started"],
121
- ['autoeval', 4, "Show if unrecognized command are evaluated"],
122
- ['autolist', 4, "Show if 'list' commands is run on breakpoints"],
123
- ['autoirb', 4, "Show if IRB is invoked on debugger stops"],
157
+ "Show argument list to give program being debugged when it is started",
158
+ "Follow this command with any number of args, to be passed to the program."],
159
+ ['autoeval', 4, "Show if unrecognized command are evaluated"],
160
+ ['autolist', 4, "Show if 'list' commands is run on breakpoints"],
161
+ ['autoirb', 4, "Show if IRB is invoked on debugger stops"],
124
162
  ['autoreload', 4, "Show if source code is reloaded when changed"],
125
- ['basename', 1, "Show if basename used in reporting files"],
163
+ ['basename', 1, "Show if basename used in reporting files"],
126
164
  ['callstyle', 2, "Show paramater style used showing call frames"],
165
+ ['commands', 2, "Show the history of commands you typed",
166
+ "You can supply a command number to start with."],
127
167
  ['forcestep', 1, "Show if sure 'next/step' forces move to a new line"],
128
- ['fullpath', 2, "Show if full file names are displayed in frames"],
129
- ['history', 2, "Generic command for showing command history parameters"],
168
+ ['fullpath', 2, "Show if full file names are displayed in frames"],
169
+ ['history', 2, "Generic command for showing command history parameters",
170
+ "show history filename -- Show the filename in which to record the command history
171
+ show history save -- Show saving of the history record on exit
172
+ show history size -- Show the size of the command history"],
130
173
  ['keep-frame-bindings', 1, "Save frame binding on each call"],
131
174
  ['linetrace', 3, "Show line execution tracing"],
132
175
  ['linetrace+', 10,
133
176
  "Show if consecutive lines should be different are shown in tracing"],
134
177
  ['listsize', 3, "Show number of source lines to list by default"],
135
- ['port', 1, "Show server port"],
178
+ ['port', 3, "Show server port"],
179
+ ['post-mortem', 3, "Show whether we go into post-mortem debugging on an uncaught exception"],
136
180
  ['trace', 1,
137
181
  "Show if a stack trace is displayed when 'eval' raises exception"],
138
182
  ['version', 1,
139
183
  "Show what version of the debugger this is"],
140
184
  ['width', 1,
141
185
  "Show the number of characters the debugger thinks are in a line"],
142
- ].map do |name, min, short_help|
143
- SubcmdStruct.new(name, min, short_help)
186
+ ].map do |name, min, short_help, long_help|
187
+ SubcmdStruct.new(name, min, short_help, long_help)
144
188
  end unless defined?(Subcommands)
145
189
 
146
- self.control = true
190
+ self.allow_in_control = true
147
191
 
148
192
  def regexp
149
193
  /^show (?: \s+ (.+) )?$/xi
@@ -157,16 +201,14 @@ module Debugger
157
201
  print "show #{subcmd.name} -- #{subcmd.short_help}\n"
158
202
  end
159
203
  else
160
- subcmd, arg = @match[1].split(/[ \t]+/)
161
- subcmd.downcase!
162
- for try_subcmd in Subcommands do
163
- if (subcmd.size >= try_subcmd.min) and
164
- (try_subcmd.name[0..subcmd.size-1] == subcmd)
165
- print "%s\n" % show_setting(try_subcmd.name)
166
- return
167
- end
204
+ args = @match[1].split(/[ \t]+/)
205
+ param = args.shift
206
+ subcmd = find(Subcommands, param)
207
+ if subcmd
208
+ print "%s\n" % show_setting(subcmd.name)
209
+ else
210
+ print "Unknown show command #{param}\n"
168
211
  end
169
- print "Unknown show command #{subcmd}\n"
170
212
  end
171
213
  end
172
214
 
@@ -175,7 +217,21 @@ module Debugger
175
217
  "show"
176
218
  end
177
219
 
178
- def help(cmd)
220
+ def help(args)
221
+ if args[1]
222
+ s = args[1]
223
+ subcmd = Subcommands.find do |try_subcmd|
224
+ (s.size >= try_subcmd.min) and
225
+ (try_subcmd.name[0..s.size-1] == s)
226
+ end
227
+ if subcmd
228
+ str = subcmd.short_help + '.'
229
+ str += "\n" + subcmd.long_help if subcmd.long_help
230
+ return str
231
+ else
232
+ return "Invalid 'show' subcommand '#{args[1]}'."
233
+ end
234
+ end
179
235
  s = "
180
236
  Generic command for showing things about the debugger.
181
237