Author: martin
Date: 2007-01-19 11:11:41 -0500 (Fri, 19 Jan 2007)
New Revision: 71341

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/classes/DebuggerConfiguration.cs
   trunk/debugger/frontend/Command.cs
   trunk/debugger/frontend/Expression.cs
   trunk/debugger/frontend/Interpreter.cs
Log:
2007-01-19  Martin Baulig  <[EMAIL PROTECTED]>

        * classes/DebuggerConfiguration.cs
        (DebuggerConfiguration.BrokenThreading): New public property;
        enabled by default.

        * frontend/Interpreter.cs
        (Interpreter.RuntimeInvoke): New public method; use WaitAll() is
        `DebuggerConfiguration.BrokenThreading' is set.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2007-01-19 16:04:00 UTC (rev 71340)
+++ trunk/debugger/ChangeLog    2007-01-19 16:11:41 UTC (rev 71341)
@@ -1,5 +1,15 @@
 2007-01-19  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * classes/DebuggerConfiguration.cs
+       (DebuggerConfiguration.BrokenThreading): New public property;
+       enabled by default.
+
+       * frontend/Interpreter.cs
+       (Interpreter.RuntimeInvoke): New public method; use WaitAll() is
+       `DebuggerConfiguration.BrokenThreading' is set.
+
+2007-01-19  Martin Baulig  <[EMAIL PROTECTED]>
+
        * languages/mono/MonoLanguageBackend.cs: Don't crash if we don't
        have a symbol table.  This might happen if we for instance attach
        to a mono process which is running without --debug.

Modified: trunk/debugger/classes/DebuggerConfiguration.cs
===================================================================
--- trunk/debugger/classes/DebuggerConfiguration.cs     2007-01-19 16:04:00 UTC 
(rev 71340)
+++ trunk/debugger/classes/DebuggerConfiguration.cs     2007-01-19 16:11:41 UTC 
(rev 71341)
@@ -121,6 +121,7 @@
                }
 
                bool stay_in_thread;
+               bool broken_threading = true;
                bool load_native_symtabs;
                Hashtable module_groups;
 
@@ -213,5 +214,10 @@
                        get { return stay_in_thread; }
                        set { stay_in_thread = false; }
                }
+
+               public bool BrokenThreading {
+                       get { return broken_threading; }
+                       set { broken_threading = value; }
+               }
        }
 }

Modified: trunk/debugger/frontend/Command.cs
===================================================================
--- trunk/debugger/frontend/Command.cs  2007-01-19 16:04:00 UTC (rev 71340)
+++ trunk/debugger/frontend/Command.cs  2007-01-19 16:11:41 UTC (rev 71341)
@@ -806,8 +806,6 @@
                                handles [i] = threads [i].WaitHandle;
 
                        WaitHandle.WaitAll (handles);
-
-                       context.Interpreter.CheckLastEvent (CurrentThread);
                        return null;
                }
 
@@ -852,7 +850,7 @@
                        if (in_background)
                                return result;
 
-                       Thread ret = context.Interpreter.WaitAll (result, wait);
+                       Thread ret = context.Interpreter.WaitAll 
(result.Thread, result, wait);
                        if (ret == null)
                                return null;
 

Modified: trunk/debugger/frontend/Expression.cs
===================================================================
--- trunk/debugger/frontend/Expression.cs       2007-01-19 16:04:00 UTC (rev 
71340)
+++ trunk/debugger/frontend/Expression.cs       2007-01-19 16:11:41 UTC (rev 
71341)
@@ -1552,11 +1552,10 @@
                protected TargetObject GetProperty (ScriptingContext context,
                                                    TargetPropertyInfo prop)
                {
-                       RuntimeInvokeResult result = 
context.CurrentThread.RuntimeInvoke (
-                               prop.Getter, InstanceObject, new TargetObject 
[0], true, false);
+                       RuntimeInvokeResult result = 
context.Interpreter.RuntimeInvoke (
+                               context.CurrentThread, prop.Getter, 
InstanceObject,
+                               new TargetObject [0], true, false);
 
-                       context.Interpreter.Wait (result);
-
                        if (result.ExceptionMessage != null)
                                throw new ScriptingException (
                                        "Invocation of `{0}' raised an 
exception: {1}",
@@ -2773,13 +2772,9 @@
                                Thread thread = context.CurrentThread;
                                RuntimeInvokeResult result;
 
-                               result = thread.RuntimeInvoke (method, 
instance, objs, true, debug);
+                               result = context.Interpreter.RuntimeInvoke (
+                                       thread, method, instance, objs, true, 
debug);
 
-                               context.Interpreter.Wait (result);
-
-                               if (debug)
-                                       context.Interpreter.CheckLastEvent 
(thread);
-
                                if (result.ExceptionMessage != null)
                                        throw new ScriptingException (
                                                "Invocation of `{0}' raised an 
exception: {1}",

Modified: trunk/debugger/frontend/Interpreter.cs
===================================================================
--- trunk/debugger/frontend/Interpreter.cs      2007-01-19 16:04:00 UTC (rev 
71340)
+++ trunk/debugger/frontend/Interpreter.cs      2007-01-19 16:11:41 UTC (rev 
71341)
@@ -298,7 +298,7 @@
                        }
                }
 
-               public void CheckLastEvent (Thread thread)
+               protected void CheckLastEvent (Thread thread)
                {
                        TargetEventArgs args = thread.GetLastTargetEvent ();
                        if (args == null)
@@ -461,7 +461,7 @@
                        return true;
                }
 
-               public Thread WaitAll (ThreadCommandResult result, bool wait)
+               public Thread WaitAll (Thread thread, CommandResult result, 
bool wait)
                {
                        if (result == null)
                                return null;
@@ -472,20 +472,23 @@
                        do {
                                ArrayList list = new ArrayList ();
                                foreach (Process process in Processes) {
-                                       foreach (Thread thread in 
process.GetThreads ()) {
-                                               if (thread.IsRunning)
-                                                       list.Add (thread);
-                                               else if ((thread.ThreadFlags & 
Thread.Flags.AutoRun) != 0) {
-                                                       thread.Continue ();
-                                                       list.Add (thread);
+                                       foreach (Thread t in process.GetThreads 
()) {
+                                               if (t == thread)
+                                                       continue;
+                                               else if (t.IsRunning)
+                                                       list.Add (t);
+                                               else if ((t.ThreadFlags & 
Thread.Flags.AutoRun) != 0) {
+                                                       t.Continue ();
+                                                       list.Add (t);
                                                }
                                        }
                                }
 
-                               WaitHandle[] handles = new WaitHandle 
[list.Count + 1];
+                               WaitHandle[] handles = new WaitHandle 
[list.Count + 2];
                                handles [0] = interrupt_event;
+                               handles [1] = result.CompletedEvent;
                                for (int i = 0; i < list.Count; i++)
-                                       handles [i + 1] = ((Thread) list 
[i]).WaitHandle;
+                                       handles [i + 2] = ((Thread) list 
[i]).WaitHandle;
 
                                int ret = WaitHandle.WaitAny (handles);
 
@@ -499,24 +502,27 @@
                                if (result.Result is Exception)
                                        throw (Exception) result.Result;
 
-                               stopped = (Thread) list [ret - 1];
+                               if (ret == 1)
+                                       stopped = thread;
+                               else
+                                       stopped = (Thread) list [ret - 2];
 
                                CheckLastEvent (stopped);
-                       } while (wait && (stopped != null) && (stopped != 
result.Thread));
+                       } while (wait && (stopped != null) && (stopped != 
thread));
 
                        foreach (Process process in Processes) {
-                               foreach (Thread thread in process.GetThreads 
()) {
-                                       if (thread == stopped)
+                               foreach (Thread t in process.GetThreads ()) {
+                                       if (t == stopped)
                                                continue;
                                        // Never touch immutable threads.
-                                       if ((thread.ThreadFlags & 
Thread.Flags.Immutable) != 0)
+                                       if ((t.ThreadFlags & 
Thread.Flags.Immutable) != 0)
                                                continue;
                                        // Background thread -> keep running.
-                                       if ((thread.ThreadFlags & 
Thread.Flags.Background) != 0)
+                                       if ((t.ThreadFlags & 
Thread.Flags.Background) != 0)
                                                continue;
 
                                        // Stop and set AutoRun.
-                                       thread.AutoStop ();
+                                       t.AutoStop ();
                                }
                        }
 
@@ -535,6 +541,31 @@
                        WaitHandle.WaitAny (handles);
                }
 
+               public RuntimeInvokeResult RuntimeInvoke (Thread thread,
+                                                         TargetFunctionType 
function,
+                                                         TargetClassObject 
object_argument,
+                                                         TargetObject[] 
param_objects,
+                                                         bool is_virtual, bool 
debug)
+               {
+                       RuntimeInvokeResult result = thread.RuntimeInvoke (
+                               function, object_argument, param_objects, 
is_virtual, debug);
+
+                       if (DebuggerConfiguration.BrokenThreading) {
+                               Thread ret = WaitAll (thread, result, false);
+                               if (ret != thread) {
+                                       result.Abort ();
+                                       return null;
+                               }
+                       } else {
+                               Wait (thread);
+
+                               if (debug)
+                                       CheckLastEvent (thread);
+                       }
+
+                       return result;
+               }
+
                public int Interrupt ()
                {
                        interrupt_event.Set ();

_______________________________________________
Mono-patches maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches

Reply via email to