Module: Rib::Debugger
- Extended by:
- Plugin
- Defined in:
- lib/rib/extra/debugger.rb
Defined Under Namespace
Modules: Imp
Constant Summary collapse
- ExcludedCommands =
%w[irb quit exit backtrace eval p pp ps]- WrappedCommands =
%w[help where edit reload]
Instance Attribute Summary
Attributes included from Plugin
Instance Method Summary collapse
-
#at_line(context, file, line) ⇒ Object
Callback for the debugger.
-
#before_loop ⇒ Object
————— Rib API —————.
- #debugger_state ⇒ Object
-
#debugger_watch ⇒ Object
————— Plugin API —————.
Methods included from Plugin
disable, disabled?, enable, enabled?, extended
Instance Method Details
#at_line(context, file, line) ⇒ Object
Callback for the debugger
49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
# File 'lib/rib/extra/debugger.rb', line 49 def at_line context, file, line return if Debugger.disabled? path = "#{file}:#{line}:in #{caller[1][/`.+?'/]}" msg0 = if Rib.const_defined?(:StripBacktrace) && StripBacktrace.enabled? StripBacktrace.strip_backtrace([path]) else [path] end msg1 = if Rib.const_defined?(:Color) && Color.enabled? Color.colorize_backtrace(msg0) else [msg0].flatten end Rib.say(msg1.first) if @debugger_state @debugger_state.context = context @debugger_state.file = file @debugger_state.line = line end Rib::Anchor.enable Rib.anchor(context.frame_binding(0), :prompt_anchor => false, :debugger_context => context, :debugger_file => file , :debugger_line => line , :debugger_state => @debugger_state, :debugger_watch => @debugger_watch) ::Debugger.stop rescue Exception => e Rib.warn("Error while calling at_line:\n #{format_error(e)}") end |
#before_loop ⇒ Object
————— Rib API —————
13 14 15 16 17 18 19 20 21 |
# File 'lib/rib/extra/debugger.rb', line 13 def before_loop return super if Debugger.disabled? ::Debugger.handler = self bound_object.extend(Imp) @debugger_state ||= config[:debugger_state] @debugger_watch ||= config[:debugger_watch] bound_object.display(debugger_watch.shift) until debugger_watch.empty? super end |
#debugger_state ⇒ Object
29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/rib/extra/debugger.rb', line 29 def debugger_state @debugger_state ||= config[:debugger_state] || ::Debugger::CommandProcessor::State.new{ |s| commands = ::Debugger::Command.commands.select{ |cmd| cmd.event && (!config[:debugger_context].dead? || cmd.allow_in_post_mortem) && !ExcludedCommands.include?([cmd.help_command].flatten.first) } s.context = config[:debugger_context] s.file = config[:debugger_file] s.line = config[:debugger_line] s.binding = config[:debugger_context].frame_binding(0) s.display = [] s.interface = ::Debugger::LocalInterface.new s.commands = commands } end |
#debugger_watch ⇒ Object
————— Plugin API —————
25 26 27 |
# File 'lib/rib/extra/debugger.rb', line 25 def debugger_watch @debugger_watch ||= [] end |