Bug #4931

debug.rbでvarコマンドを実行するとTypeErrorで落ちる

Added by Kazuki Tsujimoto almost 3 years ago. Updated almost 3 years ago.

[ruby-dev:43946]
Status:Closed
Priority:Normal
Assignee:Hiroshi Nakamura
Category:lib
Target version:1.9.3
ruby -v:ruby 1.9.3dev (2011-06-26 trunk 32235) [x86_64-linux] Backport:

Description

=begin
辻本です。

debug.rbをロードしてvarコマンドを実行すると例外を吐いて落ちます。

$ ./ruby -Ilib -rdebug -e '0'
Debug.rb
Emacs support available.

-e:1:0
(rdb:1) var g
/home/ktsj/work/ruby-trunk/lib/debug.rb:150:in eval': can't convert Symbol into String (TypeError)
from /home/k_tsj/work/ruby-trunk/lib/debug.rb:150:in
block in var
list'
from /home/ktsj/work/ruby-trunk/lib/debug.rb:149:in each'
from /home/k_tsj/work/ruby-trunk/lib/debug.rb:149:in
var
list'
from /home/ktsj/work/ruby-trunk/lib/debug.rb:157:in debug_variable_info'
from /home/k_tsj/work/ruby-trunk/lib/debug.rb:478:in
block in debug
command'
from /home/ktsj/work/ruby-trunk/lib/debug.rb:240:in catch'
from /home/k_tsj/work/ruby-trunk/lib/debug.rb:240:in
debug
command'
from /home/ktsj/work/ruby-trunk/lib/debug.rb:691:in trace_func'
from /home/k_tsj/work/ruby-trunk/lib/debug.rb:905:in
block in <class:DEBUGGER
_>'
from -e:1:in `'

1.9からKernel#global_variablesなどがシンボルの配列を返すようになったのに
debug.rbが対応できていないのが原因です。

パッチです。

diff --git a/lib/debug.rb b/lib/debug.rb
index 4fb9d50..87a1826 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -146,7 +146,7 @@ class DEBUGGER__

  def var_list(ary, binding)
    ary.sort!
  • for v in ary
  • for v in ary.map{|s| s.to_s} stdout.printf " %s => %s\n", v, eval(v, binding).inspect end end =end

Associated revisions

Revision 32271
Added by Hiroshi Nakamura almost 3 years ago

  • lib/debug.rb (varlist): Command 'var *' did not work on 1.9(!). globalvariables, localvariables, and instancevariables returns Symbols from 1.9 and need to stringify before evaling it. See #4931.

History

#1 Updated by Hiroshi Nakamura almost 3 years ago

  • Status changed from Open to Assigned
  • Assignee set to Hiroshi Nakamura
  • Target version set to 1.9.3

#2 Updated by Hiroshi Nakamura almost 3 years ago

  • Status changed from Assigned to Closed

ありがとうございました。r32271で修正しました。なんと、1.9以後誰もつかってなかったんですねvarコマンド。。。orz

Also available in: Atom PDF