Class: Debugger::WhereCommand

Inherits:
Command
  • Object
show all
Defined in:
lib/ruby-debug/commands/frame.rb

Overview

Implements debugger “where” or “backtrace” command.

Constant Summary

Constants inherited from Command

Command::DEF_OPTIONS

Class Method Summary collapse

Instance Method Summary collapse

Methods inherited from Command

commands, #find, inherited, #initialize, load_commands, #match, method_missing, options, register_setting_get, register_setting_set, register_setting_var, settings, settings_map

Constructor Details

This class inherits a constructor from Debugger::Command

Class Method Details

.help(cmd) ⇒ Object



180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
# File 'lib/ruby-debug/commands/frame.rb', line 180

def help(cmd)
  s = if cmd == 'where'
    %{
      w[here]\tdisplay stack frames
      }
      else
    %{
      bt|backtrace\t\talias for where - display stack frames
   }
      end
  s += %{
Print the entire stack frame. Each frame is numbered, the most recent
frame is 0. frame number can be referred to in the "frame" command;
"up" and "down" add or subtract respectively to frame numbers shown.
The position of the current frame is marked with -->.  } 
end

.help_commandObject



176
177
178
# File 'lib/ruby-debug/commands/frame.rb', line 176

def help_command
  %w|where backtrace|
end

Instance Method Details

#executeObject



160
161
162
163
164
165
166
167
168
169
170
171
172
173
# File 'lib/ruby-debug/commands/frame.rb', line 160

def execute
  (0...@state.context.stack_size).each do |idx|
    if idx == @state.frame_pos
      print "--> "
    else
      print "    "
    end
    print_frame(idx)

  end
  if truncated_callstack?(@state.context, Debugger.start_sentinal)
#        print "Warning: saved frames may be incomplete; compare with caller(0).\n" 
  end
end

#regexpObject



156
157
158
# File 'lib/ruby-debug/commands/frame.rb', line 156

def regexp
  /^\s*(?:w(?:here)?|bt|backtrace)$/
end