rails debugger 几个命令

Info

显示相关信息

  • info args # Argument variables of current stack frame

       [7, 16] in /Users/wanghao/Work/common_divisor.rb  
       7      if(x < y)  
       8        return  gcd2(y , x)  
       9      elsif(y == 0)  
       10        return x  
       11      else  
    => 12        return gcd2(x - y , y)  
       13      end  
       14    end  
       15
       16    def gcd3(x ,y)  
    (rdb:1) info args  
    x = 1071  
    y = 462  
    (rdb:1) show line  
    line tracing is off  
    (rdb:1) info line  
    Line 12 of "/Users/wanghao/Work/common_divisor.rb"  
    (rdb:1) info stack  
    --> #0 CommonDivisor.gcd2(x#Fixnum,...)  
           at line /Users/wanghao/Work/common_divisor.rb:12  
        #1  at line /Users/wanghao/Work/common_divisor.rb:52  
    
  • info breakpoints # 显示当前所有断点的状态

    (rdb:1) info breakpoints
      Num Enb What
      1   y   at /Users/wanghao/Work/common_divisor.rb:51
      2   y   at /Users/wanghao/Work/common_divisor.rb:51
      3   y   at /Users/wanghao/Work/common_divisor.rb:3
    
  • info catch # 可以被捕获的Exceptions,通过catch命令设定

  • info display # 程序结束时的输出

  • info file # 关于读取文件的内容

  • info files # 关于读取文件的时间和名字等信息

  • info global_variables # 所有全局变量

  • info instance_variables # 当前frame的示例变量

  • info line # 当前文件的当前行有关信息

        [4, 13] in /Users/wanghao/Work/common_divisor.rb
        4    end
        5
        6    def gcd2(x , y)
        7      if(x < y)
        8        return  gcd2(y , x)
     => 9      elsif(y == 0)  
       10        return x
       11      else
       12        return gcd2(x - y , y)
       13      end  
       (rdb:1) info line
        Line 9 of "/Users/wanghao/Work/common_divisor.rb"
        (rdb:1) info stack
        --> #0 CommonDivisor.gcd2(x#Fixnum,...)
        at line /Users/wanghao/Work/common_divisor.rb:9
        #1  at line /Users/wanghao/Work/common_divisor.rb:52
    
  • info locals # 局部变量信息

    (rdb:1) info locals
        x = 1071
        y = 462
    
  • info program # 程序执行状态信息

  • info stack # 相关stack信息

    (rdb:1) info stack
    --> #0 CommonDivisor.gcd(x#Fixnum,...)
        at line /Users/wanghao/Work/common_divisor.rb:3
    #1 CommonDivisor.gcd(x#Fixnum,...)
        at line /Users/wanghao/Work/common_divisor.rb:3
    #2  at line /Users/wanghao/Work/common_divisor.rb:51
    
  • info thread # Thread相关信息

  • info threads # Thread相关信息
    (rdb:1) info threads
    + 1 # /Users/wanghao/Work/common_divisor.rb:3
    !2 #

  • info variables # 局部变量示例变量信息

    self = ...  
    x = 462  
    y = 147  
    
Set

设定ruby-debug的环境,Boolean变量可以设定为on off或者1 0 设定变量可以用show显示

  • set annotate # 设定注释等级

  • set args # 设定变量列表,用来传递给运行环境

  • set autoeval # 在不能直接输出的表达式,进行eval计算

      (rdb:1) set autoeval 0
       autoeval is off
      (rdb:1) fib2
      *** Unknown command: "fib2".  Try "help".
      (rdb:1) fib1
      *** Unknown command: "fib1".  Try "help".
      (rdb:1)
      (rdb:1) fib1=0\; fib2=1\; 5.times {|temp| temp=fib1\; fib1=fib2\; fib2 += temp }
      *** Unknown command: "fib1=0; fib2=1; 5.times {|temp| temp=fib1; fib1=fib2; fib2 += temp }".  Try "help".
      (rdb:1) set autoeval 1
      autoeval is on
      (rdb:1) fib1=0\; fib2=1\; 5.times {|temp| temp=fib1\; fib1=fib2\; fib2 += temp }
      5
      (rdb:1) fib1
      5
      (rdb:1) fib2
      8
    
  • set autolist # 在每个breakpoint时执行list

  • set autoirb # 任何时候只要stop则执行irb

  • set autoreload # 当代码有修改的时候,从新load

  • set basename # 设定basename只显示文件名

  • set callstyle # 设定显示变量格式

  • set debuggertesting # 用于测试debugger自身

  • set forcestep # 保证'next/step'命令总是能向新行移动

  • set fullpath # 在frames中显示文件的完整路径名

  • set history # Generic command for setting command history parameters

  • set keep-frame-bindings # Save frame binding on each call

  • set linetrace+ # Set line execution tracing to show different lines

  • set linetrace # Set line execution tracing

  • set listsize # Set number of source lines to list by default

  • set trace # Display stack trace when 'eval' raises exception

  • set width # Number of characters the debugger thinks are in a line

Thread

用于线程操作

th[read] l[ist] # 列出所有的线程
th[read] stop # 停止指定线程
th[read] resume # 恢复指定线程
th[read] [sw[itch]] # 切换执行环境到指定线程
th[read] [cur[rent]] # 显示当前线程

Trace

tr[ace] (on|off) set trace mode of current thread
tr[ace] (on|off) all set trace mode of all threads

你可能感兴趣的:(rails debugger 几个命令)