byebug 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (133) hide show
  1. data/.gitignore +10 -0
  2. data/.travis.yml +8 -0
  3. data/AUTHORS +10 -0
  4. data/CHANGELOG.md +2 -0
  5. data/CONTRIBUTING.md +1 -0
  6. data/Gemfile +3 -0
  7. data/LICENSE +20 -0
  8. data/README.md +5 -0
  9. data/Rakefile +28 -0
  10. data/bin/byebug +395 -0
  11. data/byebug.gemspec +29 -0
  12. data/doc/hanoi.rb +35 -0
  13. data/doc/primes.rb +28 -0
  14. data/doc/rdebug-emacs.texi +1030 -0
  15. data/doc/test-tri2.rb +18 -0
  16. data/doc/tri3.rb +8 -0
  17. data/doc/triangle.rb +12 -0
  18. data/ext/byebug/breakpoint.c +476 -0
  19. data/ext/byebug/byebug.c +512 -0
  20. data/ext/byebug/byebug.h +131 -0
  21. data/ext/byebug/context.c +424 -0
  22. data/ext/byebug/extconf.rb +21 -0
  23. data/ext/byebug/locker.c +53 -0
  24. data/lib/byebug.rb +404 -0
  25. data/lib/byebug/command.rb +232 -0
  26. data/lib/byebug/commands/breakpoints.rb +153 -0
  27. data/lib/byebug/commands/catchpoint.rb +56 -0
  28. data/lib/byebug/commands/condition.rb +49 -0
  29. data/lib/byebug/commands/continue.rb +38 -0
  30. data/lib/byebug/commands/control.rb +110 -0
  31. data/lib/byebug/commands/display.rb +122 -0
  32. data/lib/byebug/commands/edit.rb +48 -0
  33. data/lib/byebug/commands/enable.rb +202 -0
  34. data/lib/byebug/commands/eval.rb +176 -0
  35. data/lib/byebug/commands/finish.rb +43 -0
  36. data/lib/byebug/commands/frame.rb +303 -0
  37. data/lib/byebug/commands/help.rb +56 -0
  38. data/lib/byebug/commands/info.rb +462 -0
  39. data/lib/byebug/commands/irb.rb +123 -0
  40. data/lib/byebug/commands/jump.rb +66 -0
  41. data/lib/byebug/commands/kill.rb +51 -0
  42. data/lib/byebug/commands/list.rb +94 -0
  43. data/lib/byebug/commands/method.rb +84 -0
  44. data/lib/byebug/commands/quit.rb +39 -0
  45. data/lib/byebug/commands/reload.rb +40 -0
  46. data/lib/byebug/commands/save.rb +90 -0
  47. data/lib/byebug/commands/set.rb +210 -0
  48. data/lib/byebug/commands/show.rb +246 -0
  49. data/lib/byebug/commands/skip.rb +35 -0
  50. data/lib/byebug/commands/source.rb +36 -0
  51. data/lib/byebug/commands/stepping.rb +83 -0
  52. data/lib/byebug/commands/threads.rb +189 -0
  53. data/lib/byebug/commands/tmate.rb +36 -0
  54. data/lib/byebug/commands/trace.rb +56 -0
  55. data/lib/byebug/commands/variables.rb +199 -0
  56. data/lib/byebug/context.rb +58 -0
  57. data/lib/byebug/helper.rb +69 -0
  58. data/lib/byebug/interface.rb +223 -0
  59. data/lib/byebug/processor.rb +468 -0
  60. data/lib/byebug/version.rb +3 -0
  61. data/man/rdebug.1 +241 -0
  62. data/test/breakpoints_test.rb +357 -0
  63. data/test/conditions_test.rb +77 -0
  64. data/test/continue_test.rb +44 -0
  65. data/test/display_test.rb +141 -0
  66. data/test/edit_test.rb +56 -0
  67. data/test/eval_test.rb +92 -0
  68. data/test/examples/breakpoint1.rb +15 -0
  69. data/test/examples/breakpoint2.rb +7 -0
  70. data/test/examples/conditions.rb +4 -0
  71. data/test/examples/continue.rb +4 -0
  72. data/test/examples/display.rb +5 -0
  73. data/test/examples/edit.rb +3 -0
  74. data/test/examples/edit2.rb +3 -0
  75. data/test/examples/eval.rb +4 -0
  76. data/test/examples/finish.rb +20 -0
  77. data/test/examples/frame.rb +20 -0
  78. data/test/examples/frame_threads.rb +31 -0
  79. data/test/examples/help.rb +2 -0
  80. data/test/examples/info.rb +38 -0
  81. data/test/examples/info2.rb +3 -0
  82. data/test/examples/info_threads.rb +48 -0
  83. data/test/examples/irb.rb +6 -0
  84. data/test/examples/jump.rb +14 -0
  85. data/test/examples/kill.rb +2 -0
  86. data/test/examples/list.rb +12 -0
  87. data/test/examples/method.rb +15 -0
  88. data/test/examples/post_mortem.rb +19 -0
  89. data/test/examples/quit.rb +2 -0
  90. data/test/examples/reload.rb +6 -0
  91. data/test/examples/restart.rb +6 -0
  92. data/test/examples/save.rb +3 -0
  93. data/test/examples/set.rb +3 -0
  94. data/test/examples/set_annotate.rb +12 -0
  95. data/test/examples/settings.rb +1 -0
  96. data/test/examples/show.rb +2 -0
  97. data/test/examples/source.rb +3 -0
  98. data/test/examples/stepping.rb +21 -0
  99. data/test/examples/thread.rb +32 -0
  100. data/test/examples/tmate.rb +10 -0
  101. data/test/examples/trace.rb +7 -0
  102. data/test/examples/trace_threads.rb +20 -0
  103. data/test/examples/variables.rb +26 -0
  104. data/test/finish_test.rb +48 -0
  105. data/test/frame_test.rb +143 -0
  106. data/test/help_test.rb +50 -0
  107. data/test/info_test.rb +313 -0
  108. data/test/irb_test.rb +81 -0
  109. data/test/jump_test.rb +70 -0
  110. data/test/kill_test.rb +48 -0
  111. data/test/list_test.rb +145 -0
  112. data/test/method_test.rb +70 -0
  113. data/test/post_mortem_test.rb +27 -0
  114. data/test/quit_test.rb +56 -0
  115. data/test/reload_test.rb +44 -0
  116. data/test/restart_test.rb +164 -0
  117. data/test/save_test.rb +92 -0
  118. data/test/set_test.rb +177 -0
  119. data/test/show_test.rb +293 -0
  120. data/test/source_test.rb +45 -0
  121. data/test/stepping_test.rb +130 -0
  122. data/test/support/breakpoint.rb +13 -0
  123. data/test/support/context.rb +14 -0
  124. data/test/support/matchers.rb +67 -0
  125. data/test/support/mocha_extensions.rb +72 -0
  126. data/test/support/processor.rb +7 -0
  127. data/test/support/test_dsl.rb +206 -0
  128. data/test/support/test_interface.rb +68 -0
  129. data/test/test_helper.rb +10 -0
  130. data/test/tmate_test.rb +44 -0
  131. data/test/trace_test.rb +159 -0
  132. data/test/variables_test.rb +119 -0
  133. metadata +265 -0
@@ -0,0 +1,40 @@
1
+ module Byebug
2
+ # Implements byebug "reload" command.
3
+ class ReloadCommand < Command
4
+ self.allow_in_control = true
5
+
6
+ register_setting_get(:reload_source_on_change) do
7
+ Byebug.reload_source_on_change
8
+ end
9
+ register_setting_set(:reload_source_on_change) do |value|
10
+ Byebug.reload_source_on_change = value
11
+ end
12
+
13
+ def regexp
14
+ /^\s*r(?:eload)?$/
15
+ end
16
+
17
+ def execute
18
+ Byebug.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
+ Byebug.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 Byebug
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
+ Byebug.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
+ Byebug.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 byebugtesting).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 byebug 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,210 @@
1
+ module Byebug
2
+ # Implements byebug "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, "Set annotation level",
9
+ "0 == normal
10
+ 2 == output annotated suitably for use by programs that control byebug."],
11
+ ['args', 2, false,
12
+ "Set argument list to give program being debugged when it is started",
13
+ "Follow this command with any number of args, to be passed to the program."],
14
+ ['autoeval', 4, true, "Evaluate every unrecognized command"],
15
+ ['autolist', 4, true, "Execute 'list' command on every breakpoint"],
16
+ ['autoirb', 4, true, "Invoke IRB on every stop"],
17
+ ['autoreload', 4, true, "Reload source code when changed"],
18
+ ['basename', 1, true, "Report file basename only showing file names"],
19
+ ['callstyle', 2, false, "Set how you want call parameters displayed"],
20
+ ['byebugtesting', 8, false, "Used when testing the byebug"],
21
+ ['forcestep', 2, true,
22
+ "Make sure 'next/step' commands always move to a new line"],
23
+ ['fullpath', 2, true, "Display full file names in frames"],
24
+ ['history', 2, false,
25
+ "Generic command for setting command history parameters",
26
+ "set history filename -- Set the filename in which to record the command history
27
+ set history save -- Set saving of the history record on exit
28
+ set history size -- Set the size of the command history"],
29
+ ['linetrace+', 10, true,
30
+ "Set line execution tracing to show different lines"],
31
+ ['linetrace', 3, true, "Set line execution tracing"],
32
+ ['listsize', 3, false, "Set number of source lines to list by default"],
33
+ ['trace', 1, true, "Display stack trace when 'eval' raises exception"],
34
+ ['width', 1, false,
35
+ "Number of characters the byebug thinks are in a line"]
36
+ ].map do |name, min, is_bool, short_help, long_help|
37
+ SubcmdStruct2.new(name, min, is_bool, short_help, long_help)
38
+ end unless defined?(Subcommands)
39
+
40
+ self.allow_in_control = true
41
+
42
+ def regexp
43
+ /^set (?: \s+ (.*) )?$/ix
44
+ end
45
+
46
+ def execute
47
+ if not @match[1]
48
+ print "\"set\" must be followed by the name of an set command:\n"
49
+ print "List of set subcommands:\n\n"
50
+ for subcmd in Subcommands do
51
+ print "set #{subcmd.name} -- #{subcmd.short_help}\n"
52
+ end
53
+ else
54
+ args = @match[1].split(/[ \t]+/)
55
+ subcmd = args.shift
56
+ subcmd.downcase!
57
+ if subcmd =~ /^no/i
58
+ set_on = false
59
+ subcmd = subcmd[2..-1]
60
+ else
61
+ set_on = true
62
+ end
63
+ for try_subcmd in Subcommands do
64
+ if (subcmd.size >= try_subcmd.min) and
65
+ (try_subcmd.name[0..subcmd.size-1] == subcmd)
66
+ begin
67
+ if try_subcmd.is_bool
68
+ if args.size > 0
69
+ set_on = get_onoff(args[0])
70
+ end
71
+ end
72
+ case try_subcmd.name
73
+ when /^annotate$/
74
+ level = get_int(args[0], "Set annotate", 0, 3, 0)
75
+ if level
76
+ Byebug.annotate = level
77
+ else
78
+ return
79
+ end
80
+ if defined?(Byebug::RDEBUG_SCRIPT)
81
+ # rdebug was called initially. 1st arg is script name.
82
+ Command.settings[:argv][1..-1] = args
83
+ else
84
+ # rdebug wasn't called initially. 1st arg is not script name.
85
+ Command.settings[:argv] = args
86
+ end
87
+ when /^args$/
88
+ Command.settings[:argv][1..-1] = args
89
+ when /^autolist$/
90
+ Command.settings[:autolist] = (set_on ? 1 : 0)
91
+ when /^autoeval$/
92
+ Command.settings[:autoeval] = set_on
93
+ when /^basename$/
94
+ Command.settings[:basename] = set_on
95
+ when /^callstyle$/
96
+ if args[0]
97
+ arg = args[0].downcase.to_sym
98
+ case arg
99
+ when :short, :last
100
+ Command.settings[:callstyle] = arg
101
+ print "%s\n" % show_setting(try_subcmd.name)
102
+ return
103
+ end
104
+ end
105
+ print "Invalid call style #{arg}. Should be one of: " +
106
+ "'short' or 'last'.\n"
107
+ when /^trace$/
108
+ Command.settings[:stack_trace_on_error] = set_on
109
+ when /^fullpath$/
110
+ Command.settings[:full_path] = set_on
111
+ when /^autoreload$/
112
+ Command.settings[:reload_source_on_change] = set_on
113
+ when /^autoirb$/
114
+ Command.settings[:autoirb] = (set_on ? 1 : 0)
115
+ when /^byebugtesting$/
116
+ Command.settings[:byebugtesting] = set_on
117
+ if set_on
118
+ Command.settings[:basename] = true
119
+ end
120
+ when /^forcestep$/
121
+ self.class.settings[:force_stepping] = set_on
122
+ when /^history$/
123
+ if 2 == args.size
124
+ interface = @state.interface
125
+ case args[0]
126
+ when /^save$/
127
+ interface.history_save = get_onoff(args[1])
128
+ when /^size$/
129
+ interface.history_length = get_int(args[1],
130
+ "Set history size")
131
+ when /^filename$/
132
+ interface.histfile = File.join(ENV["HOME"]||ENV["HOMEPATH"]||".", args[1])
133
+ else
134
+ print "Invalid history parameter #{args[0]}. Should be 'filename', 'save' or 'size'.\n"
135
+ end
136
+ else
137
+ print "Need two parameters for 'set history'; got #{args.size}.\n"
138
+ return
139
+ end
140
+ when /^linetrace\+$/
141
+ self.class.settings[:tracing_plus] = set_on
142
+ when /^linetrace$/
143
+ Command.settings[:tracing] = set_on
144
+ when /^listsize$/
145
+ listsize = get_int(args[0], "Set listsize", 1, nil, 10)
146
+ if listsize
147
+ self.class.settings[:listsize] = listsize
148
+ else
149
+ return
150
+ end
151
+ when /^width$/
152
+ width = get_int(args[0], "Set width", 10, nil, 80)
153
+ if width
154
+ self.class.settings[:width] = width
155
+ ENV['COLUMNS'] = width.to_s
156
+ else
157
+ return
158
+ end
159
+ else
160
+ print "Unknown setting #{@match[1]}.\n"
161
+ return
162
+ end
163
+ print "%s\n" % show_setting(try_subcmd.name)
164
+ return
165
+ rescue RuntimeError
166
+ return
167
+ end
168
+ end
169
+ end
170
+ print "Unknown set command #{subcmd}\n"
171
+ end
172
+ end
173
+
174
+ class << self
175
+ def help_command
176
+ "set"
177
+ end
178
+
179
+ def help(args)
180
+ if args[1]
181
+ s = args[1]
182
+ subcmd = Subcommands.find do |try_subcmd|
183
+ (s.size >= try_subcmd.min) and
184
+ (try_subcmd.name[0..s.size-1] == s)
185
+ end
186
+ if subcmd
187
+ str = subcmd.short_help + '.'
188
+ str += "\n" + subcmd.long_help if subcmd.long_help
189
+ return str
190
+ else
191
+ return "Invalid 'set' subcommand '#{args[1]}'."
192
+ end
193
+ end
194
+ s = %{
195
+ Modifies parts of byebug environment. Boolean values take
196
+ on, off, 1 or 0.
197
+ You can see these environment settings with the \"show\" command.
198
+
199
+ --
200
+ List of set subcommands:
201
+ --
202
+ }
203
+ for subcmd in Subcommands do
204
+ s += "set #{subcmd.name} -- #{subcmd.short_help}\n"
205
+ end
206
+ return s
207
+ end
208
+ end
209
+ end
210
+ end
@@ -0,0 +1,246 @@
1
+ module Byebug
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
+ Byebug.annotate ||= 0
8
+ return ("Annotation level is #{Byebug.annotate}")
9
+ when /^args$/
10
+ if Command.settings[:argv] and Command.settings[:argv].size > 0
11
+ if defined?(Byebug::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 support'
72
+ end
73
+ return s
74
+ when /^byebugtesting$/
75
+ on_off = Command.settings[:byebugtesting]
76
+ return "Currently testing the byebug 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
+ "Byebug history size is #{interface.history_length}"
115
+ s << msg
116
+ end
117
+ return s.join("\n")
118
+ when /^linetrace$/
119
+ on_off = Command.settings[: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 #{Byebug::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 "byebug #{Byebug::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 byebug "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
+ byebug."],
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 byebug 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,
178
+ "Show whether we go into post-mortem debugging on an uncaught exception"],
179
+ ['trace', 1,
180
+ "Show if a stack trace is displayed when 'eval' raises exception"],
181
+ ['version', 1, "Show byebug's version"],
182
+ ['width', 1, "Show the number of characters byebug thinks are in a line"]
183
+ ].map do |name, min, short_help, long_help|
184
+ SubcmdStruct.new(name, min, short_help, long_help)
185
+ end unless defined?(Subcommands)
186
+
187
+ self.allow_in_control = true
188
+
189
+ def regexp
190
+ /^show (?: \s+ (.+) )?$/xi
191
+ end
192
+
193
+ def execute
194
+ if not @match[1]
195
+ print "\"show\" must be followed by the name of an show command:\n"
196
+ print "List of show subcommands:\n\n"
197
+ for subcmd in Subcommands do
198
+ print "show #{subcmd.name} -- #{subcmd.short_help}\n"
199
+ end
200
+ else
201
+ args = @match[1].split(/[ \t]+/)
202
+ param = args.shift
203
+ subcmd = find(Subcommands, param)
204
+ if subcmd
205
+ print "%s\n" % show_setting(subcmd.name)
206
+ else
207
+ print "Unknown show command #{param}\n"
208
+ end
209
+ end
210
+ end
211
+
212
+ class << self
213
+ def help_command
214
+ "show"
215
+ end
216
+
217
+ def help(args)
218
+ if args[1]
219
+ s = args[1]
220
+ subcmd = Subcommands.find do |try_subcmd|
221
+ (s.size >= try_subcmd.min) and
222
+ (try_subcmd.name[0..s.size-1] == s)
223
+ end
224
+ if subcmd
225
+ str = subcmd.short_help + '.'
226
+ str += "\n" + subcmd.long_help if subcmd.long_help
227
+ return str
228
+ else
229
+ return "Invalid 'show' subcommand '#{args[1]}'."
230
+ end
231
+ end
232
+ s = "
233
+ Generic command for showing things about the byebug.
234
+
235
+ --
236
+ List of show subcommands:
237
+ --
238
+ "
239
+ for subcmd in Subcommands do
240
+ s += "show #{subcmd.name} -- #{subcmd.short_help}\n"
241
+ end
242
+ return s
243
+ end
244
+ end
245
+ end
246
+ end