From 0a2f8b61d47116a2f2e17f6026fd7f17c2f15878 Mon Sep 17 00:00:00 2001 From: matz Date: Mon, 28 Aug 2000 09:53:42 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/debug.rb | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) (limited to 'lib/debug.rb') diff --git a/lib/debug.rb b/lib/debug.rb index feb30c71db..97be752797 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -119,6 +119,15 @@ class DEBUGGER__ end end + def debug_silent_eval(str, binding) + begin + val = eval(str, binding) + val + rescue StandardError, ScriptError + nil + end + end + def var_list(ary, binding) ary.sort! if false # ary.size < 0 @@ -307,9 +316,9 @@ class DEBUGGER__ when /^\s*disp(?:lay)?\s+(.+)$/ exp = $1 - display.push.push [true, exp] - stdout.printf " %d: %s = %s\n", display.size, exp, - eval(exp, binding) rescue "--" + display.push [true, exp] + stdout.printf "%d: ", display.size + display_expression(exp, binding) when /^\s*disp(?:lay)?$/ display_expressions(binding) @@ -493,12 +502,17 @@ EOHELP n = 1 for d in display if d[0] - stdout.printf "%d: %s = %s\n", n, d[1], debug_eval(d[1], binding).to_s + stdout.printf "%d: ", n + display_expression(d[1], binding) end n += 1 end end + def display_expression(exp, binding) + stdout.printf "%s = %s\n", exp, debug_silent_eval(exp, binding).to_s + end + def frame_set_pos(file, line) if @frames[0] @frames[0][1] = file @@ -559,22 +573,25 @@ EOHELP end def check_break_points(file, pos, binding, id) + return false if break_points.empty? + MUTEX.lock file = File.basename(file) n = 1 for b in break_points if b[0] if b[1] == 0 and b[2] == file and b[3] == pos - MUTEX.lock stdout.printf "breakpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos return true - elsif b[1] == 1 and debug_eval(b[2], binding) - MUTEX.lock - stdout.printf "watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos - return true + elsif b[1] == 1 + if debug_silent_eval(b[2], binding) + stdout.printf "watchpoint %d, %s at %s:%s\n", n, debug_funcname(id), file, pos + return true + end end end n += 1 end + MUTEX.unlock return false end -- cgit v1.2.3