Module: Rib::Debugger::Imp

Included in:
Rib
Defined in:
lib/rib/extra/debugger.rb

Instance Method Summary collapse

Instance Method Details

#debugObject



83
84
85
86
87
88
# File 'lib/rib/extra/debugger.rb', line 83

def debug
  return if Rib::Debugger.disabled?
  ::Debugger.handler = Rib.shell
  ::Debugger.start
  ::Debugger.current_context.stop_frame = 0
end

#debugger_execute(command, args = [], name = command.capitalize, state = Rib.shell.debugger_state) ⇒ Object



123
124
125
126
127
128
129
130
131
# File 'lib/rib/extra/debugger.rb', line 123

def debugger_execute command, args=[], name=command.capitalize,
                     state=Rib.shell.debugger_state
  const = "#{name}Command"
  arg = if args.empty? then '' else " #{args.join(' ')}" end
  cmd = ::Debugger.const_get(const).new(state)
  cmd.match("#{command}#{arg}\n")
  cmd.execute
  Rib::Skip
end

#display(*args) ⇒ Object Also known as: disp



109
110
111
112
113
114
115
# File 'lib/rib/extra/debugger.rb', line 109

def display *args
  if args.empty?
    debugger_execute('display', args, 'Display')
  else
    debugger_execute('display', args, 'AddDisplay')
  end
end

#list(*args) ⇒ Object Also known as: ls



118
119
120
# File 'lib/rib/extra/debugger.rb', line 118

def list *args
  debugger_execute('list', args, 'List', Rib.shell.debugger_state.dup)
end

#step(times = 1) ⇒ Object



95
96
97
98
99
# File 'lib/rib/extra/debugger.rb', line 95

def step times=1
  ::Debugger.current_context.step(times)
  display
  throw :rib_exit, Rib::Skip
end

#watch(*strs) ⇒ Object

You can ‘Rib.watch` a number of expressions before calling `Rib.debug`



91
92
93
# File 'lib/rib/extra/debugger.rb', line 91

def watch *strs
  Rib.shell.debugger_watch.concat(strs)
end