summaryrefslogtreecommitdiff
path: root/lib/debug.rb
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-18 07:55:45 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-06-18 07:55:45 +0000
commit942a54302de5bfa4665960947c403e1c0b6831ad (patch)
tree2a4be7c58259a21f0a3f04ca76ea2ee1774d00f5 /lib/debug.rb
parent31345380ac41f8b830104ea41b4b52e1e2b094a8 (diff)
* parse.y (yycompile): disable trace while creating ruby_debug_lines.
[ruby-talk:253586] * thread.c (ruby_suppress_tracing): new function to call a function with suppressing trace. * lib/debug.rb, lib/tracer.rb: for YARV. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@12569 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib/debug.rb')
-rw-r--r--lib/debug.rb106
1 files changed, 34 insertions, 72 deletions
diff --git a/lib/debug.rb b/lib/debug.rb
index 9ae119f8fb..1b5f2a2bb6 100644
--- a/lib/debug.rb
+++ b/lib/debug.rb
@@ -19,45 +19,6 @@ end
SCRIPT_LINES__ = {} unless defined? SCRIPT_LINES__
class DEBUGGER__
-class Mutex
- def initialize
- @locker = nil
- @waiting = []
- @locked = false;
- end
-
- def locked?
- @locked
- end
-
- def lock
- return if Thread.critical
- return if @locker == Thread.current
- while (Thread.critical = true; @locked)
- @waiting.push Thread.current
- Thread.stop
- end
- @locked = true
- @locker = Thread.current
- Thread.critical = false
- self
- end
-
- def unlock
- return if Thread.critical
- return unless @locked
- unless @locker == Thread.current
- raise RuntimeError, "unlocked by other"
- end
- Thread.critical = true
- t = @waiting.shift
- @locked = false
- @locker = nil
- Thread.critical = false
- t.run if t
- self
- end
-end
MUTEX = Mutex.new
class Context
@@ -118,13 +79,14 @@ class Context
end
def check_suspend
- return if Thread.critical
- while (Thread.critical = true; @suspend_next)
- DEBUGGER__.waiting.push Thread.current
- @suspend_next = false
- Thread.stop
+ while MUTEX.synchronize {
+ if @suspend_next
+ DEBUGGER__.waiting.push Thread.current
+ @suspend_next = false
+ true
+ end
+ }
end
- Thread.critical = false
end
def trace?
@@ -790,13 +752,12 @@ class << DEBUGGER__
end
def set_trace( arg )
- saved_crit = Thread.critical
- Thread.critical = true
- make_thread_list
- for th, in @thread_list
- context(th).set_trace arg
+ MUTEX.synchronize do
+ make_thread_list
+ for th, in @thread_list
+ context(th).set_trace arg
+ end
end
- Thread.critical = saved_crit
arg
end
@@ -805,31 +766,29 @@ class << DEBUGGER__
end
def suspend
- saved_crit = Thread.critical
- Thread.critical = true
- make_thread_list
- for th, in @thread_list
- next if th == Thread.current
- context(th).set_suspend
- end
- Thread.critical = saved_crit
+ MUTEX.synchronize do
+ make_thread_list
+ for th, in @thread_list
+ next if th == Thread.current
+ context(th).set_suspend
+ end
+ end
# Schedule other threads to suspend as soon as possible.
- Thread.pass unless Thread.critical
+ Thread.pass
end
def resume
- saved_crit = Thread.critical
- Thread.critical = true
- make_thread_list
- for th, in @thread_list
- next if th == Thread.current
- context(th).clear_suspend
- end
- waiting.each do |th|
- th.run
- end
- waiting.clear
- Thread.critical = saved_crit
+ MUTEX.synchronize do
+ make_thread_list
+ for th, in @thread_list
+ next if th == Thread.current
+ context(th).clear_suspend
+ end
+ waiting.each do |th|
+ th.run
+ end
+ waiting.clear
+ end
# Schedule other threads to restart as soon as possible.
Thread.pass
end
@@ -944,4 +903,7 @@ stdout.printf "Emacs support available.\n\n"
set_trace_func proc { |event, file, line, id, binding, klass, *rest|
DEBUGGER__.context.trace_func event, file, line, id, binding, klass
}
+VM::InstructionSequence.compile_option = {
+ trace_instruction: true
+}
end