From 224e59c6f82c98da0d507cfae3b39c97b6769d51 Mon Sep 17 00:00:00 2001 From: matz Date: Wed, 28 Jun 2000 08:31:35 +0000 Subject: matz git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- lib/debug.rb | 25 +++++++++++++++++++++++++ lib/jcode.rb | 2 +- lib/matrix.rb | 4 ++-- lib/thwait.rb | 4 ++-- lib/tracer.rb | 4 ++-- 5 files changed, 32 insertions(+), 7 deletions(-) (limited to 'lib') diff --git a/lib/debug.rb b/lib/debug.rb index 2f61e8da34..d20d1ebbfc 100644 --- a/lib/debug.rb +++ b/lib/debug.rb @@ -7,6 +7,14 @@ if $SAFE > 0 end SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__ +require 'tracer' +class Tracer + def Tracer.trace_func(*vars) + Single.trace_func *vars + end +end + + class DEBUGGER__ class Mutex def initialize @@ -80,6 +88,7 @@ class DEBUGGER__ @no_step = nil @frames = [] @finish_pos = 0 + @trace = false end def stop_next(n=1) @@ -216,6 +225,20 @@ class DEBUGGER__ end case input + when /^\s*tr(?:ace)?(?:\s+(on|off))?$/ + if !defined?( $1 ) + @trace = !@trace + elsif $1 == 'on' + @trace = true + else + @trace = false + end + if @trace + stdout.print "Trace on\n" + else + stdout.print "Trace off\n" + end + when /^\s*b(?:reak)?\s+((?:.*?+:)?.+)$/ pos = $1 if pos.index(":") @@ -445,6 +468,7 @@ Commands up[ nn] move to higher frame down[ nn] move to lower frame fin[ish] return to outer frame + tr[ace][ (on|off)] set trace mode q[uit] exit from debugger v[ar] g[lobal] show global variables v[ar] l[ocal] show local variables @@ -572,6 +596,7 @@ EOHELP end def trace_func(event, file, line, id, binding, klass) + Tracer.trace_func(event, file, line, id, binding) if @trace @file = file @line = line case event diff --git a/lib/jcode.rb b/lib/jcode.rb index 49262857a8..193f3042ff 100644 --- a/lib/jcode.rb +++ b/lib/jcode.rb @@ -189,7 +189,7 @@ class String end def each_char - if iterator? + if block_given? scan(/./m) do |x| yield x end diff --git a/lib/matrix.rb b/lib/matrix.rb index 80d28148ac..9de7dcb3a2 100644 --- a/lib/matrix.rb +++ b/lib/matrix.rb @@ -290,7 +290,7 @@ class Matrix end def row(i) - if iterator? + if block_given? for e in @rows[i] yield e @@ -301,7 +301,7 @@ class Matrix end def column(j) - if iterator? + if block_given? 0.upto(row_size - 1) do |i| yield @rows[i][j] diff --git a/lib/thwait.rb b/lib/thwait.rb index 958163edef..45d6a89713 100644 --- a/lib/thwait.rb +++ b/lib/thwait.rb @@ -48,7 +48,7 @@ class ThreadsWait def ThreadsWait.all_waits(*threads) tw = ThreadsWait.new(*threads) - if iterator? + if block_given? tw.all_waits do |th| yield th @@ -125,7 +125,7 @@ class ThreadsWait def all_waits until @threads.empty? th = next_wait - yield th if iterator? + yield th if block_given? end end end diff --git a/lib/tracer.rb b/lib/tracer.rb index 095173e53b..8ee14ce378 100644 --- a/lib/tracer.rb +++ b/lib/tracer.rb @@ -45,7 +45,7 @@ class Tracer end def on - if iterator? + if block_given? on begin yield @@ -126,7 +126,7 @@ class Tracer Single = new def Tracer.on - if iterator? + if block_given? Single.on{yield} else Single.on -- cgit v1.2.3