summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authormatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-28 08:31:35 +0000
committermatz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2000-06-28 08:31:35 +0000
commit224e59c6f82c98da0d507cfae3b39c97b6769d51 (patch)
tree1e844ef7bb01533ce06310b79a92cd0c75a53ba1 /lib
parent1261c7e05550a72f3bb33eae75660142c6ea2a4e (diff)
matz
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@791 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r--lib/debug.rb25
-rw-r--r--lib/jcode.rb2
-rw-r--r--lib/matrix.rb4
-rw-r--r--lib/thwait.rb4
-rw-r--r--lib/tracer.rb4
5 files changed, 32 insertions, 7 deletions
diff --git a/lib/debug.rb b/lib/debug.rb
index 2f61e8d..d20d1eb 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 4926285..193f304 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 80d2814..9de7dcb 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 958163e..45d6a89 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 095173e..8ee14ce 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