Sha256: ceb0f7771e3225b27742f99c36f3ab0964768b9668c04f57d357c4e9d767f669

Contents?: true

Size: 1.72 KB

Versions: 41

Compression:

Stored size: 1.72 KB

Contents

module Debugger
  class TraceCommand < Command # :nodoc:
    def regexp
      /^\s* tr(?:ace)? (?: \s+ (\S+))         # on |off | var(iable)
                       (?: \s+ (\S+))?        # (all | variable-name)?
                       (?: \s+ (\S+))? \s*    # (stop | nostop)? 
       $/ix
    end

    def execute
      if @match[1] =~ /on|off/
        onoff = 'on' == @match[1] 
        if @match[2]
          Debugger.current_context.tracing = onoff
          print "Tracing %s all threads.\n" % (onoff ? 'on' : 'off')
        else
          Debugger.tracing = onoff
          print "Tracing %s on current thread.\n"  % (onoff ? 'on' : 'off')
        end
      elsif @match[1] =~ /var(?:iable)?/
        varname=@match[2]
        if debug_eval("defined?(#{varname})")
          if @match[3] && @match[3] !~ /(:?no)?stop/
            errmsg("expecting 'stop' or 'nostop'; got %s\n" % @match[3])
          else
            dbg_cmd = if @match[3] && (@match[3] !~ /nostop/) 
                        'debugger' else '' end
          end
          eval("
           trace_var(:#{varname}) do |val|
              print \"traced variable #{varname} has value \#{val}\n\"
              #{dbg_cmd}
           end")
        else
          errmsg "#{varname} is not a global variable.\n"
        end
      else 
        errmsg("expecting 'on', 'off', 'var' or 'variable'; got: %s\n" %
               @match[1])
      end
    end

    class << self
      def help_command
        'trace'
      end

      def help(cmd)
        %{
          tr[ace] (on|off)\tset trace mode of current thread
          tr[ace] (on|off) all\tset trace mode of all threads
          tr[ace] var(iable) VARNAME [stop|nostop]\tset trace variable on VARNAME
        }
      end
    end
  end
end

Version data entries

41 entries across 41 versions & 9 rubygems

Version Path
ruby-debug-0.11.0 cli/ruby-debug/commands/trace.rb
logstash-output-icinga-1.1.0 vendor/jruby/1.9/gems/ruby-debug-0.10.6/cli/ruby-debug/commands/trace.rb
ruby-debug-0.10.6 cli/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc9 cli/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc8 cli/ruby-debug/commands/trace.rb
candlepin-api-0.4.0 bundle/ruby/1.8/gems/ruby-debug-0.10.4/cli/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc7 cli/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc5 cli/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc4 cli/ruby-debug/commands/trace.rb
debugger-1.2.4 lib/ruby-debug/commands/trace.rb
debugger-1.2.3 lib/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc3 cli/ruby-debug/commands/trace.rb
debugger-1.2.2 lib/ruby-debug/commands/trace.rb
debugger-1.2.1 lib/ruby-debug/commands/trace.rb
debugger-1.2.0 lib/ruby-debug/commands/trace.rb
ruby-debug-0.10.5.rc2 cli/ruby-debug/commands/trace.rb
debugger-1.1.4 lib/ruby-debug/commands/trace.rb
debugger-1.1.3 lib/ruby-debug/commands/trace.rb
debugger-1.1.2 lib/ruby-debug/commands/trace.rb
debugger-1.1.1 lib/ruby-debug/commands/trace.rb