byebug 1.0.0 → 1.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 9de6831ec3ce9e27c6e2cca6a3e230f30d4c4498
4
+ data.tar.gz: 80c1890643664250f76be3332437054636223e6d
5
+ SHA512:
6
+ metadata.gz: e57c240bc36528ad61d3e44be7819b9e72effe76f61e8895b9e24a8df9ee9a4eabbed01a6edfb6e42529128a02a0b1233761af4f2cf49e0119b49e2bfb4507a5
7
+ data.tar.gz: 88ce74faec5aef2ae39487e9be5912b1da806e2c8b8fe4513fcb9b0859a1432cc4ab764f95522ba2f01df853ee1fe97d737dd849bc8b42a6b56497fb1986c567
data/.gitignore CHANGED
@@ -4,6 +4,8 @@ vendor/bundle
4
4
  doc
5
5
 
6
6
  .rvmrc
7
+ .ruby-version
8
+ .ruby-gemset
7
9
  .gdbinit
8
10
  .gdb_history
9
11
  .bundle
data/README.md CHANGED
@@ -1,5 +1,37 @@
1
- ## Description
1
+ # Byebug [![Build Status](https://secure.travis-ci.org/deivid-rodriguez/byebug.png)](http://travis-ci.org/deivid-rodriguez/byebug) [![Code Climate](https://codeclimate.com/github/deivid-rodriguez/byebug.png)](https://codeclimate.com/github/deivid-rodriguez/byebug) [![Dependency Status](https://gemnasium.com/deivid-rodriguez/byebug.png)](https://gemnasium.com/deivid-rodriguez/byebug)
2
2
 
3
- Experimenting with github and ruby and mixing
4
- [debugger](https://github.com/cldwalker/debugger) and
5
- [debase](https://github.com/denofevil/debase) into a 2.0 compatible debugger.
3
+ A Ruby 2.0 debugger.
4
+
5
+
6
+ ## Install
7
+
8
+ Just type
9
+
10
+ $ gem install byebug
11
+
12
+ or if you use bundler, drop
13
+
14
+ gem 'byebug'
15
+
16
+ in your Gemfile
17
+
18
+
19
+ ## Usage
20
+
21
+ Wherever you want to start debugging, simply drop:
22
+
23
+ byebug
24
+
25
+ and the execution will stop and allow you to start debugging.
26
+
27
+ ## Credits
28
+
29
+ Everybody who has ever contributed to this forked and reforked piece of
30
+ software, specially:
31
+
32
+ * Kent Sibilev and Mark Moseley, original authors of
33
+ [ruby-debug](https://github.com/mark-moseley/ruby-debug).
34
+ * Gabriel Horner, [debugger](https://github.com/cldwalker/debugger)'s mantainer.
35
+ * Koichi Sasada, author of the new C debugging API for Ruby.
36
+ * Dennis Ushakov, author of [debase](https://github.com/denofevil/debase), the
37
+ starting point of this.
data/Rakefile CHANGED
@@ -2,6 +2,7 @@
2
2
  require 'rake/testtask'
3
3
  require 'rake/extensiontask'
4
4
  require 'rubygems/package_task'
5
+ require 'bundler/gem_tasks'
5
6
 
6
7
  Rake::ExtensionTask.new('byebug')
7
8
 
@@ -15,9 +16,6 @@ task :test do
15
16
  end
16
17
  end
17
18
 
18
- desc "Test everything - same as test."
19
- task :check => :test
20
-
21
19
  base_spec = eval(File.read('byebug.gemspec'), binding, 'byebug.gemspec')
22
20
 
23
21
  # Rake task to build the default package
data/bin/byebug CHANGED
@@ -14,14 +14,13 @@
14
14
  #
15
15
  #<tt>-A | --annotate</tt> <i>level</i>::
16
16
  # Set gdb-style annotation to <i>level</i>, a number. Additional
17
- # information is output automatically when program state is
18
- # changed. This can be used by front-ends such as GNU Emacs to post
19
- # this updated information without having to poll for it.
17
+ # information is output automatically when program state is changed. This
18
+ # can be used by front-ends such as GNU Emacs to post this updated
19
+ # information without having to poll for it.
20
20
  #
21
21
  #<tt>--client</tt>::
22
- # Connect to a remote byebug. Used with another rdebug invocation
23
- # using <tt>--server</tt>. See also <tt>--host</tt> and
24
- # <tt>--cport</tt> options
22
+ # Connect to a remote byebug. Used with another byebug invocation using
23
+ # <tt>--server</tt>. See also <tt>--host</tt> and <tt>--cport</tt> options
25
24
  #
26
25
  #<tt>--cport=</tt><i>port</i>::
27
26
  # Use port <i>port</i> for access to byebug control.
@@ -30,13 +29,12 @@
30
29
  # Set $DEBUG true.
31
30
  #
32
31
  #<tt>--emacs</tt>::
33
- # Activates full GNU Emacs mode. Is the equivalent of setting the
34
- # options <tt>--emacs-basic --annotate=3 --no-stop --no-control
35
- # --post-mortem</tt>.
32
+ # Activates full GNU Emacs mode. Is the equivalent of setting the options
33
+ # <tt>--emacs-basic --annotate=3 --no-stop --no-control --post-mortem</tt>.
36
34
  #
37
35
  #<tt>--emacs-basic</tt>::
38
- # Activates GNU Emacs mode. Byebug prompts are prefaced with two
39
- # octal 032 characters.
36
+ # Activates GNU Emacs mode. Byebug prompts are prefaced with two octal 032
37
+ # characters.
40
38
  #
41
39
  #<tt>-h | --host=</tt><i>host</i>::
42
40
  # Use host name <i>host</i> for remote debugging.
@@ -66,8 +64,7 @@
66
64
  # Show lines before executing them.
67
65
  #
68
66
  #<tt>--no-quit</tt>::
69
- # Do not quit when script terminates. Instead rerun the
70
- # program.
67
+ # Do not quit when script terminates. Instead rerun the program.
71
68
  #
72
69
  #<tt>--version</tt>::
73
70
  # Show the version number and exit.
@@ -76,24 +73,24 @@
76
73
  # Turn on verbose mode.
77
74
  #
78
75
  #<tt>--v</tt>::
79
- # Print the version number, then turn on verbose mode if
80
- # a script name is given. If no script name is given
81
- # just exit after printing the version number.
76
+ # Print the version number, then turn on verbose mode if a script name is
77
+ # given. If no script name is given just exit after printing the version
78
+ # number.
82
79
  #
83
80
  #<tt>--nx</tt>::
84
- # Don’t execute commands found in any initialization
85
- # files, e.g. <tt>.rdebugrc</tt>.
81
+ # Don’t execute commands found in any initialization files like
82
+ # <tt>.byebugrc</tt>.
86
83
  #
87
84
  #<tt>--keep-frame-binding</tt>::
88
85
  # Keep frame bindings.
89
86
  #
90
87
  #<tt>--script=</tt><i>file</i>::
91
- # Name of the script file to run
88
+ # Name of the script file to run.
92
89
  #
93
90
  #<tt>-s | --server</tt>::
94
- # Listen for remote connections. Another rdebug session
95
- # accesses using the <tt>--client</tt> option. See also the
96
- # <tt>--host</tt>, <tt>--port</tt> and <tt>--cport</tt> options
91
+ # Listen for remote connections. Another byebug session accesses using the
92
+ # <tt>--client</tt> option. See also the <tt>--host</tt>, <tt>--port</tt>
93
+ # and <tt>--cport</tt> options
97
94
  #
98
95
  #<tt>-w | --wait</tt>::
99
96
  # Wait for a client connection; implies <tt>-s</tt> option.
@@ -107,7 +104,7 @@ require File.dirname(__FILE__) + "/../lib/byebug"
107
104
 
108
105
  def debug_program(options)
109
106
  # Make sure Ruby script syntax checks okay.
110
- # Otherwise we get a load message that looks like rdebug has a problem.
107
+ # Otherwise we get a load message that looks like byebug has a problem.
111
108
  output = `ruby -c "#{Byebug::PROG_SCRIPT}" 2>&1`
112
109
  if $?.exitstatus != 0 and RUBY_PLATFORM !~ /mswin/
113
110
  puts output
@@ -212,7 +209,7 @@ EOB
212
209
  opts.on('--no-stop', 'Do not stop when script is loaded') do
213
210
  options.stop = false
214
211
  end
215
- opts.on('-nx', 'Not run byebug initialization files (e.g. .rdebugrc') do
212
+ opts.on('-nx', 'Not run byebug initialization files (e.g. .byebugrc') do
216
213
  options.nx = true
217
214
  end
218
215
  opts.on('-p', '--port PORT', Integer, 'Port used for remote debugging') do
@@ -289,8 +286,7 @@ unless defined?(OPTS_INITFILE)
289
286
  end
290
287
  begin
291
288
  initfile = File.join(HOME_DIR, OPTS_INITFILE)
292
- eval(File.read(initfile)) if
293
- File.exist?(initfile)
289
+ eval(File.read(initfile)) if File.exist?(initfile)
294
290
  rescue
295
291
  end
296
292
 
@@ -299,11 +295,11 @@ begin
299
295
  if not defined? Byebug::ARGV
300
296
  Byebug::ARGV = ARGV.clone
301
297
  end
302
- rdebug_path = File.expand_path($0)
298
+ byebug_path = File.expand_path($0)
303
299
  if RUBY_PLATFORM =~ /mswin/
304
- rdebug_path += '.cmd' unless rdebug_path =~ /\.cmd$/i
300
+ byebug_path += '.cmd' unless byebug_path =~ /\.cmd$/i
305
301
  end
306
- Byebug::RDEBUG_SCRIPT = rdebug_path
302
+ Byebug::RDEBUG_SCRIPT = byebug_path
307
303
  Byebug::RDEBUG_FILE = __FILE__
308
304
  Byebug::INITIAL_DIR = Dir.pwd
309
305
  opts.parse! ARGV
@@ -350,7 +346,7 @@ else
350
346
  # start control thread
351
347
  Byebug.start_control(options.host, options.cport) if options.control
352
348
 
353
- # load initrc script (e.g. .rdebugrc)
349
+ # load initrc script (e.g. .byebugrc)
354
350
  Byebug.run_init_script(StringIO.new) unless options.nx
355
351
 
356
352
  # run restore-settings startup script if specified
@@ -5,6 +5,7 @@ require File.dirname(__FILE__) + "/lib/byebug/version"
5
5
  Gem::Specification.new do |s|
6
6
  s.name = %q{byebug}
7
7
  s.version = Byebug::VERSION
8
+
8
9
  s.authors = ["David Rodríguez", "Kent Sibilev", "Mark Moseley"]
9
10
  s.email = "deivid.rodriguez@mail.com"
10
11
  s.homepage = "http://github.com/deivid-rodriguez/byebug"
@@ -14,16 +15,21 @@ Gem::Specification.new do |s|
14
15
  the rest of the gem was forked from debugger. The core component provides
15
16
  support that front-ends can build on. It provides breakpoint handling,
16
17
  bindings for stack frames among other things.}
17
- s.required_rubygems_version = ">= 1.3.6"
18
+
19
+ s.required_ruby_version = '>= 2.0.0'
20
+ s.required_rubygems_version = ">= 2.0.3"
21
+
18
22
  s.extra_rdoc_files = [ "README.md" ]
19
23
  s.files = `git ls-files`.split("\n")
20
24
  s.extensions << "ext/byebug/extconf.rb"
21
25
  s.executables = ["byebug"]
26
+
22
27
  s.add_dependency "columnize", "~> 0.3.6"
23
28
  s.add_dependency "debugger-linecache", '~> 1.2.0'
24
- s.add_development_dependency 'rake', '~> 10.0.3'
29
+ s.add_development_dependency 'rake', '~> 10.0.4'
25
30
  s.add_development_dependency 'rake-compiler', '~> 0.8.3'
26
31
  s.add_development_dependency 'mocha', '~> 0.13.3'
27
32
  s.add_development_dependency 'minitest', '~> 4.7.0'
33
+
28
34
  s.license = "BSD"
29
35
  end
@@ -95,7 +95,7 @@ module Byebug
95
95
  Breakpoint.remove breakpoints, id
96
96
  end
97
97
 
98
- def interface=(value) # :nodoc:
98
+ def interface=(value)
99
99
  handler.interface = value
100
100
  end
101
101
 
@@ -231,7 +231,7 @@ module Byebug
231
231
  socket.close
232
232
  end
233
233
 
234
- #
234
+ ##
235
235
  # Runs normal byebug initialization scripts.
236
236
  #
237
237
  # Reads and executes the commands from init file (if any) in the current
@@ -242,15 +242,15 @@ module Byebug
242
242
  #
243
243
  def run_init_script(out = handler.interface)
244
244
  cwd_script = File.expand_path(File.join(".", INITFILE))
245
- run_script(cwd_script, out) if File.exists?(script_file)
245
+ run_script(cwd_script, out) if File.exists?(cwd_script)
246
246
 
247
247
  home_script = File.expand_path(File.join(ENV['HOME'].to_s, INITFILE))
248
248
  if File.exists?(home_script) and cwd_script != home_script
249
- run_script(home_script_file, out)
249
+ run_script(home_script, out)
250
250
  end
251
251
  end
252
252
 
253
- #
253
+ ##
254
254
  # Runs a script file
255
255
  #
256
256
  def run_script(file, out = handler.interface, verbose=false)
@@ -367,6 +367,7 @@ class Module
367
367
  # EOD
368
368
  # end
369
369
  end
370
+
370
371
  module Kernel
371
372
 
372
373
  ##
@@ -4,6 +4,17 @@ require_relative 'helper'
4
4
 
5
5
  module Byebug
6
6
 
7
+ module CommandFunctions
8
+ ##
9
+ # Pad a string with dots at the end to fit :width setting
10
+ #
11
+ def pad_with_dots(string)
12
+ if string.size > Command.settings[:width]
13
+ string[Command.settings[:width]-3 .. -1] = "..."
14
+ end
15
+ end
16
+ end
17
+
7
18
  # Root dir for byebug
8
19
  BYEBUG_DIR = File.expand_path(File.dirname(__FILE__)) unless
9
20
  defined?(BYEBUG_DIR)
@@ -13,6 +24,15 @@ module Byebug
13
24
  SubcmdStruct = Struct.new(:name, :min, :short_help, :long_help) unless
14
25
  defined?(SubcmdStruct)
15
26
 
27
+ def print_subcommands
28
+ cmd_name = self.class.name.chomp("Command").downcase
29
+ errmsg "#{cmd_name} must be followed by the name of a subcommand.\n"
30
+ print "List of #{cmd_name} subcommands:\n\n"
31
+ for subcmd in Subcommands do
32
+ print "#{cmd_name} #{subcmd.name} -- #{subcmd.short_help}\n"
33
+ end
34
+ end
35
+
16
36
  include Columnize
17
37
 
18
38
  # Find param in subcmds. param id downcased and can be abbreviated
@@ -35,7 +55,7 @@ module Byebug
35
55
 
36
56
  DEF_OPTIONS = {
37
57
  :allow_in_control => false,
38
- :allow_in_post_mortem => true ,
58
+ :allow_in_post_mortem => false ,
39
59
  :event => true ,
40
60
  :always_run => 0 ,
41
61
  :unknown => false,
@@ -78,7 +98,7 @@ module Byebug
78
98
  private :settings_map
79
99
 
80
100
  def settings
81
- unless true and defined? @settings and @settings
101
+ unless defined? @settings and @settings
82
102
  @settings = Object.new
83
103
  map = settings_map
84
104
  c = class << @settings; self end
@@ -127,23 +147,19 @@ module Byebug
127
147
  end
128
148
  end
129
149
 
130
- register_setting_var(:basename, false) # use basename in showing files?
150
+ # Register default settings
151
+ register_setting_var(:basename, false)
131
152
  register_setting_var(:callstyle, :last)
132
153
  register_setting_var(:byebugtesting, false)
133
154
  register_setting_var(:force_stepping, false)
134
155
  register_setting_var(:full_path, true)
135
- register_setting_var(:listsize, 10) # number of lines in list command
156
+ register_setting_var(:autolist, 1)
157
+ register_setting_var(:listsize, 10)
136
158
  register_setting_var(:stack_trace_on_error, false)
137
- register_setting_var(:tracing_plus, false) # different linetrace lines?
138
-
139
- # width of line output. Use COLUMNS value if it exists and is not too large.
140
- width = ENV['COLUMNS'].to_i
141
- width = 80 unless width > 10
142
- register_setting_var(:width, width)
143
-
144
- if not defined? Byebug::ARGV
145
- Byebug::ARGV = ARGV.clone
146
- end
159
+ register_setting_var(:tracing_plus, false)
160
+ register_setting_var(:width,
161
+ ENV['COLUMNS'].to_i > 10 ? ENV['COLUMNS'].to_i : 80)
162
+ Byebug::ARGV = ARGV.clone unless defined? Byebug::ARGV
147
163
  register_setting_var(:argv, Byebug::ARGV)
148
164
 
149
165
  def initialize(state)
@@ -192,10 +208,6 @@ module Byebug
192
208
  @state.context.frame_binding(@state.frame_pos)
193
209
  end
194
210
 
195
- #def line_at(file, line)
196
- # Byebug.line_at(file, line)
197
- #end
198
-
199
211
  def get_context(thnum)
200
212
  Byebug.contexts.find{|c| c.thnum == thnum}
201
213
  end
@@ -28,12 +28,12 @@ module Byebug
28
28
  print "Ruby program #{Byebug::PROG_SCRIPT} not executable... " \
29
29
  "We'll add a call to Ruby.\n"
30
30
  ruby = begin defined?(Gem) ? Gem.ruby : "ruby" rescue "ruby" end
31
- rdebug_script = "#{ruby} -I#{$:.join(' -I')} #{Byebug::PROG_SCRIPT}"
31
+ byebug_script = "#{ruby} -I#{$:.join(' -I')} #{Byebug::PROG_SCRIPT}"
32
32
  else
33
- rdebug_script = Byebug::PROG_SCRIPT
33
+ byebug_script = Byebug::PROG_SCRIPT
34
34
  end
35
35
  else
36
- rdebug_script = Byebug::RDEBUG_SCRIPT
36
+ byebug_script = Byebug::RDEBUG_SCRIPT
37
37
  end
38
38
 
39
39
  begin
@@ -52,7 +52,7 @@ module Byebug
52
52
  argv = Command.settings[:argv]
53
53
  end
54
54
  end
55
- cmd = "#{rdebug_script} #{argv.compact.join(' ')}"
55
+ cmd = "#{byebug_script} #{argv.compact.join(' ')}"
56
56
 
57
57
  # An execv would be preferable to the "exec" below.
58
58
  print "Re exec'ing:\n\t#{cmd}\n"
@@ -109,19 +109,20 @@ module Byebug
109
109
  #end
110
110
  end
111
111
 
112
- # Check if call stack is truncated. This can happen if
113
- # Byebug.start is not called low enough in the call stack. An
114
- # array of additional callstack lines from caller is returned if
115
- # definitely truncated, false if not, and nil if we don't know.
112
+ ##
113
+ # Check if call stack is truncated. This can happen if Byebug.start is not
114
+ # called low enough in the call stack. An array of additional callstack
115
+ # lines from caller is returned if definitely truncated, false if not, and
116
+ # nil if we don't know.
116
117
  #
117
- # We determine truncation based on a passed in sentinal set via
118
- # caller which can be nil.
118
+ # We determine truncation based on a passed in sentinal set via caller which
119
+ # can be nil.
119
120
  #
120
- # First we see if we can find our position in caller. If so, then
121
- # we compare context position to that in caller using sentinal
122
- # as a place to start ignoring additional caller entries. sentinal
123
- # is set by rdebug, but if it's not set, i.e. nil then additional
124
- # entries are presumably ones that we haven't recorded in context
121
+ # First we see if we can find our position in caller. If so, then we compare
122
+ # context position to that in caller using sentinal as a place to start
123
+ # ignoring additional caller entries. sentinal is set by byebug, but if it's
124
+ # nil then additional entries are presumably ones that we haven't recorded
125
+ # in context
125
126
  def truncated_callstack?(context, sentinal=nil, cs=caller)
126
127
  recorded_size = context.stack_size
127
128
  to_find_fl = "#{context.frame_file(0)}:#{context.frame_line(0)}"
@@ -9,58 +9,56 @@ module Byebug
9
9
  if Byebug.catchpoints and not Byebug.catchpoints.empty?
10
10
  Byebug.catchpoints.each do |exception, hits|
11
11
  print "#{exception}: #{exception.is_a?(Class)}\n"
12
- #print "#{exception}\n"
13
12
  end
14
13
  else
15
14
  print "No exceptions set to be caught.\n"
16
15
  end
17
16
  end
17
+
18
18
  end
19
19
 
20
20
  # Implements byebug "info" command.
21
21
  class InfoCommand < Command
22
22
  self.allow_in_control = true
23
- Subcommands =
24
- [
25
- ['args', 1, 'Argument variables of current stack frame'],
26
- ['breakpoints', 1, 'Status of user-settable breakpoints',
27
- 'Without argument, list info about all breakpoints. With an integer ' \
28
- 'argument, list info on that breakpoint.'],
29
- ['catch', 3, 'Exceptions that can be caught in the current stack frame'],
30
- ['display', 2, 'Expressions to display when program stops'],
31
- ['file', 4, 'Info about a particular file read in',
32
- 'After the file name is supplied, you can list file attributes that ' \
33
- 'you wish to see. Attributes include: "all", "basic", "breakpoint", ' \
34
- '"lines", "mtime", "path" and "sha1".'],
35
- ['files', 5, 'File names and timestamps of files read in'],
36
- ['global_variables', 2, 'Global variables'],
37
- ['instance_variables', 2,
38
- 'Instance variables of the current stack frame'],
39
- ['line', 2,
40
- 'Line number and file name of current position in source file'],
41
- ['locals', 2, 'Local variables of the current stack frame'],
42
- ['program', 2, 'Execution status of the program'],
43
- ['stack', 2, 'Backtrace of the stack'],
44
- # ['thread', 6, 'List info about thread NUM',
45
- # 'If no thread number is given, we list info for all threads. ' \
46
- # '\'terse\' and \'verbose\' options are possible. If \'terse\', just ' \
47
- # 'give summary thread name information. See "help info threads" for ' \
48
- # 'more detail about this summary information. If \'verbose\' appended ' \
49
- # 'to the end of the command, then the entire stack trace is given for ' \
50
- # 'each thread.'],
51
- # ['threads', 7, 'information of currently-known threads',
52
- # 'This information includes whether the thread is the current thread ' \
53
- # '(+), it\'s suspended ($) or it\'s ignored (!), plus the thread ' \
54
- # 'number and the top stack item. If \'verbose\' is given then the ' \
55
- # 'entire stack frame is shown.'],
56
- ['variables', 1,
57
- 'Local and instance variables of the current stack frame']
23
+ Subcommands = [
24
+ ['args', 1, 'Argument variables of current stack frame'],
25
+ ['breakpoints', 1, 'Status of user-settable breakpoints',
26
+ 'Without argument, list info about all breakpoints. With an integer ' \
27
+ 'argument, list info on that breakpoint.'],
28
+ ['catch', 3, 'Exceptions that can be caught in the current stack frame'],
29
+ ['display', 2, 'Expressions to display when program stops'],
30
+ ['file', 4, 'Info about a particular file read in',
31
+ 'After the file name is supplied, you can list file attributes that ' \
32
+ 'you wish to see. Attributes include: "all", "basic", "breakpoint", ' \
33
+ '"lines", "mtime", "path" and "sha1".'],
34
+ ['files', 5, 'File names and timestamps of files read in'],
35
+ ['global_variables', 2, 'Global variables'],
36
+ ['instance_variables', 2,
37
+ 'Instance variables of the current stack frame'],
38
+ ['line', 2,
39
+ 'Line number and file name of current position in source file'],
40
+ ['locals', 2, 'Local variables of the current stack frame'],
41
+ ['program', 2, 'Execution status of the program'],
42
+ ['stack', 2, 'Backtrace of the stack'],
43
+ # ['thread', 6, 'List info about thread NUM',
44
+ # 'If no thread number is given, we list info for all threads. ' \
45
+ # '\'terse\' and \'verbose\' options are possible. If \'terse\', just ' \
46
+ # 'give summary thread name information. See "help info threads" for ' \
47
+ # 'more detail about this summary information. If \'verbose\' appended ' \
48
+ # 'to the end of the command, then the entire stack trace is given for ' \
49
+ # 'each thread.'],
50
+ # ['threads', 7, 'information of currently-known threads',
51
+ # 'This information includes whether the thread is the current thread ' \
52
+ # '(+), it\'s suspended ($) or it\'s ignored (!), plus the thread ' \
53
+ # 'number and the top stack item. If \'verbose\' is given then the ' \
54
+ # 'entire stack frame is shown.'],
55
+ ['variables', 1,
56
+ 'Local and instance variables of the current stack frame']
58
57
  ].map do |name, min, short_help, long_help|
59
58
  SubcmdStruct.new(name, min, short_help, long_help)
60
59
  end unless defined?(Subcommands)
61
60
 
62
- InfoFileSubcommands =
63
- [
61
+ InfoFileSubcommands = [
64
62
  ['all', 1, 'All file information available - breakpoints, lines, mtime' \
65
63
  ', path and sha1'],
66
64
  ['basic', 2, 'basic information - path, number of lines'],
@@ -74,9 +72,8 @@ module Byebug
74
72
  SubcmdStruct.new(name, min, short_help, long_help)
75
73
  end unless defined?(InfoFileSubcommands)
76
74
 
77
- # InfoThreadSubcommands =
78
- # [
79
- # ['terse', 1, 'summary information'],
75
+ # InfoThreadSubcommands = [
76
+ # ['terse', 1, 'summary information'],
80
77
  # ['verbose', 1, 'summary information and stack frame info'],
81
78
  # ].map do |name, min, short_help, long_help|
82
79
  # SubcmdStruct.new(name, min, short_help, long_help)
@@ -88,11 +85,7 @@ module Byebug
88
85
 
89
86
  def execute
90
87
  if !@match[1]
91
- errmsg "\"info\" must be followed by the name of an info command:\n"
92
- print "List of info subcommands:\n\n"
93
- for subcmd in Subcommands do
94
- print "info #{subcmd.name} -- #{subcmd.short_help}\n"
95
- end
88
+ print_subcommands
96
89
  else
97
90
  args = @match[1].split(/[ \t]+/)
98
91
  param = args.shift
@@ -114,9 +107,7 @@ module Byebug
114
107
  args = @state.context.frame_args(@state.frame_pos)
115
108
  args.each do |name|
116
109
  s = "#{name} = #{locals[name].inspect}"
117
- if s.size > self.class.settings[:width]
118
- s[self.class.settings[:width]-3 .. -1] = "..."
119
- end
110
+ pad_with_dots(s)
120
111
  print "#{s}\n"
121
112
  end
122
113
  end
@@ -278,9 +269,7 @@ module Byebug
278
269
  s = "*Error in evaluation*"
279
270
  end
280
271
  end
281
- if s.size > self.class.settings[:width]
282
- s[self.class.settings[:width]-3 .. -1] = "..."
283
- end
272
+ pad_with_dots(s)
284
273
  print "#{s}\n"
285
274
  end
286
275
  end
@@ -381,7 +370,7 @@ module Byebug
381
370
  errmsg "info global_variables not available here.\n"
382
371
  return
383
372
  end
384
- var_list(global_variables)
373
+ var_global
385
374
  end
386
375
 
387
376
  def info_variables(*args)
@@ -404,9 +393,7 @@ module Byebug
404
393
  s = "#{name} = *Error in evaluation*"
405
394
  end
406
395
  end
407
- if s.size > self.class.settings[:width]
408
- s[self.class.settings[:width]-3 .. -1] = "..."
409
- end
396
+ pad_with_dots(s)
410
397
  s.gsub!('%', '%%') # protect against printf format strings
411
398
  print "#{s}\n"
412
399
  end