summaryrefslogtreecommitdiff
path: root/lib/debug.rb
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-28 09:53:42 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-08-28 09:53:42 +0000
commit0a2f8b61d47116a2f2e17f6026fd7f17c2f15878 (patch)
tree04d1097b4a3e8e795f16306fe9f350a57a0f0057 /lib/debug.rb
parentdf9d49d0881d9596b9b7d23dbd42950d5048bd9d (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@906 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/debug.rb')
-rw-r--r--lib/debug.rb35
1 files changed, 26 insertions, 9 deletions
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