Class: Byebug::InfoCommand

Inherits:
Command
  • Object
show all
Includes:
InfoFunctions, Columnize
Defined in:
lib/byebug/commands/info.rb

Overview

Show info about different aspects of the debugger.

Constant Summary collapse

Subcommands =
[
  ['args', 1, 'Argument variables of current stack frame'],
  ['breakpoints', 1, 'Status of user-settable breakpoints',
   'Without argument, list info about all breakpoints. With an integer ' \
   'argument, list info on that breakpoint.'],
  ['catch', 3, 'Exceptions that can be caught in the current stack frame'],
  ['display', 2, 'Expressions to display when program stops'],
  ['file', 4, 'Info about a particular file read in',
   'File name, number of lines, possible breakpoints in the file, last ' \
   'modification time and sha1 digest are listed.'],
  ['line', 2, 'Line number and file name of current position in source ' \
              'file.'],
  ['program', 2, 'Execution status of the program']
].map do |name, min, help|
  Subcmd.new(name, min, help)
end

Class Method Summary collapse

Instance Method Summary collapse

Methods included from InfoFunctions

#info_args, #info_breakpoint, #info_breakpoints, #info_catch, #info_display, #info_file_basic, #info_file_breakpoints, #info_file_mtime, #info_file_sha1, #info_line, #info_program, #info_stop_reason

Methods included from FileFunctions

#get_line, #get_lines, #n_lines, #normalize

Methods inherited from Command

commands, find, format_subcmd, format_subcmds, help, inherited, #initialize, #match

Methods included from StringFunctions

#camelize, #prettify

Methods included from ParseFunctions

#get_int, #parse_steps, #syntax_valid?

Constructor Details

This class inherits a constructor from Byebug::Command

Class Method Details

.descriptionObject


196
197
198
199
200
201
202
# File 'lib/byebug/commands/info.rb', line 196

def description
  prettify <<-EOD
    info[ subcommand]

    Generic command for showing things about the program being debugged.
  EOD
end

.namesObject


192
193
194
# File 'lib/byebug/commands/info.rb', line 192

def names
  %w(info)
end

Instance Method Details

#executeObject


176
177
178
179
180
181
182
183
184
185
186
187
188
189
# File 'lib/byebug/commands/info.rb', line 176

def execute
  return puts(self.class.help) unless @match[1]

  args = @match[1].split(/[ \t]+/)
  param = args.shift
  subcmd = Command.find(Subcommands, param)
  return errmsg "Unknown info command #{param}\n" unless subcmd

  if @state.context
    send("info_#{subcmd.name}", *args)
  else
    errmsg "'info #{subcmd.name}' not available without a context.\n"
  end
end

#info_file(*args) ⇒ Object


152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
# File 'lib/byebug/commands/info.rb', line 152

def info_file(*args)
  file = args[0] || @state.file
  unless File.exist?(file)
    return errmsg(pr('info.errors.undefined_file', file: file))
  end

  puts <<-EOC.gsub(/^ {6}/, '')

    File #{info_file_basic(file)}

    Breakpoint line numbers:
    #{info_file_breakpoints(file)}

    Modification time: #{info_file_mtime(file)}

    Sha1 Signature: #{info_file_sha1(file)}

  EOC
end

#regexpObject


172
173
174
# File 'lib/byebug/commands/info.rb', line 172

def regexp
  /^\s* i(?:nfo)? (?:\s+(.+))? \s*$/x
end