Author: toshok
Date: 2005-04-26 20:06:38 -0400 (Tue, 26 Apr 2005)
New Revision: 43634

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backends/ThreadManager.cs
   trunk/debugger/classes/SymbolTableManager.cs
Log:
2005-04-26  Chris Toshok  <[EMAIL PROTECTED]>

        [ fixes bug #61196 ]
        * classes/SymbolTableManager.cs: rework the Dispose stuff so that
        it doesn't use Thread.Abort.

        * backends/ThreadManager.cs: same.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2005-04-26 23:54:33 UTC (rev 43633)
+++ trunk/debugger/ChangeLog    2005-04-27 00:06:38 UTC (rev 43634)
@@ -1,3 +1,11 @@
+2005-04-26  Chris Toshok  <[EMAIL PROTECTED]>
+
+       [ fixes bug #61196 ]
+       * classes/SymbolTableManager.cs: rework the Dispose stuff so that
+       it doesn't use Thread.Abort.
+
+       * backends/ThreadManager.cs: same.
+
 2005-04-24  Chris Toshok  <[EMAIL PROTECTED]>
 
        * frontend/Command.cs (SetCommand): override DoResolve and

Modified: trunk/debugger/backends/ThreadManager.cs
===================================================================
--- trunk/debugger/backends/ThreadManager.cs    2005-04-26 23:54:33 UTC (rev 
43633)
+++ trunk/debugger/backends/ThreadManager.cs    2005-04-27 00:06:38 UTC (rev 
43634)
@@ -66,7 +66,7 @@
                Process main_process;
 
                DebuggerEvent start_event;
-               DebuggerEvent completed_event;
+               DebuggerAutoResetEvent completed_event;
                DebuggerMutex command_mutex;
                bool sync_command_running;
                bool abort_requested;
@@ -450,7 +450,6 @@
 
                        lock (this) {
                                current_command = command;
-                               // completed_event.Reset ();
                                sync_command_running = true;
                                engine_event.Set ();
                        }
@@ -505,6 +504,11 @@
 
                        Report.Debug (DebugFlags.Wait, "ThreadManager woke up");
 
+                       if (abort_requested) {
+                               Report.Debug (DebugFlags.Wait, "Abort 
requested");
+                               return;
+                       }
+
                        int status;
                        SingleSteppingEngine event_engine;
 
@@ -516,7 +520,7 @@
                                current_event_status = 0;
                        }
 
-                       if ((event_engine != null) && !abort_requested) {
+                       if (event_engine != null) {
                                try {
                                        event_engine.ProcessEvent (status);
                                } catch (ThreadAbortException) {
@@ -569,11 +573,6 @@
                                return;
                        }
 
-                       if (abort_requested) {
-                               Report.Debug (DebugFlags.Wait, "Abort 
requested");
-                               return;
-                       }
-
                        Command command;
                        lock (this) {
                                command = current_command;
@@ -621,80 +620,55 @@
 
                void start_wait_thread ()
                {
-                       while (!abort_requested) {
-                               wait_thread_main ();
-                       }
-               }
+                       while (true) {
+                               Report.Debug (DebugFlags.Wait, "Wait thread 
sleeping");
+                               wait_event.Wait ();
 
-               void wait_thread_main ()
-               {
-                       Report.Debug (DebugFlags.Wait, "Wait thread sleeping");
-                       wait_event.Wait ();
+                               Report.Debug (DebugFlags.Wait, "Wait thread 
waiting");
 
-               again:
-                       Report.Debug (DebugFlags.Wait, "Wait thread waiting");
+                               if (abort_requested) {
+                                       Report.Debug (DebugFlags.Wait, "Abort 
requested");
+                                       return;
+                               }
 
-                       //
-                       // Wait until we got an event from the target or a 
command from the user.
-                       //
+                               //
+                               // Wait until we got an event from the target 
or a command from the user.
+                               //
 
-                       int pid, status;
-                       pid = mono_debugger_server_global_wait (out status);
+                               int pid, status;
+                               pid = mono_debugger_server_global_wait (out 
status);
 
-                       Report.Debug (DebugFlags.Wait,
-                                     "Wait thread received event: {0} {1:x}",
-                                     pid, status);
+                               Report.Debug (DebugFlags.Wait,
+                                             "Wait thread received event: {0} 
{1:x}",
+                                             pid, status);
 
-                       //
-                       // Note: `pid' is basically just an unique number which 
identifies the
-                       //       SingleSteppingEngine of this event.
-                       //
+                               //
+                               // Note: `pid' is basically just an unique 
number which identifies the
+                               //       SingleSteppingEngine of this event.
+                               //
 
-                       if (pid > 0) {
-                               SingleSteppingEngine event_engine = 
(SingleSteppingEngine) thread_hash [pid];
-                               if (event_engine == null)
-                                       throw new InternalError ("Got event 
{0:x} for unknown pid {1}",
-                                                                status, pid);
+                               if (pid > 0) {
+                                       SingleSteppingEngine event_engine = 
(SingleSteppingEngine) thread_hash [pid];
+                                       if (event_engine == null)
+                                               throw new InternalError ("Got 
event {0:x} for unknown pid {1}",
+                                                                        
status, pid);
 
-                               lock (this) {
-                                       if (current_event != null)
-                                               throw new InternalError ();
+                                       lock (this) {
+                                               if (current_event != null)
+                                                       throw new InternalError 
();
 
-                                       current_event = event_engine;
-                                       current_event_status = status;
-                                       engine_event.Set ();
+                                               current_event = event_engine;
+                                               current_event_status = status;
+                                               engine_event.Set ();
+                                       }
                                }
                        }
-
-                       if (abort_requested) {
-                               Report.Debug (DebugFlags.Wait, "Abort 
requested");
-                               return;
-                       }
                }
 
                //
                // IDisposable
                //
 
-               protected virtual void DoDispose ()
-               {
-                       if (inferior_thread != null) {
-                               if (inferior_thread != Thread.CurrentThread)
-                                       inferior_thread.Abort ();
-                       }
-                       if (wait_thread != null)
-                               wait_thread.Abort ();
-
-                       SingleSteppingEngine[] threads = new 
SingleSteppingEngine [thread_hash.Count];
-                       thread_hash.Values.CopyTo (threads, 0);
-
-                       for (int i = 0; i < threads.Length; i++)
-                               threads [i].Dispose ();
-
-                       if (main_process != null)
-                               main_process.Dispose ();
-               }
-
                private bool disposed = false;
 
                private void check_disposed ()
@@ -711,12 +685,21 @@
                                        return;
 
                                abort_requested = true;
+                               wait_event.Set();
+                               engine_event.Set();
                                disposed = true;
                        }
 
                        // If this is a call to Dispose, dispose all managed 
resources.
                        if (disposing) {
-                               DoDispose ();
+                               SingleSteppingEngine[] threads = new 
SingleSteppingEngine [thread_hash.Count];
+                               thread_hash.Values.CopyTo (threads, 0);
+
+                               for (int i = 0; i < threads.Length; i++)
+                                       threads [i].Dispose ();
+
+                               if (main_process != null)
+                                       main_process.Dispose ();
                        }
                }
 

Modified: trunk/debugger/classes/SymbolTableManager.cs
===================================================================
--- trunk/debugger/classes/SymbolTableManager.cs        2005-04-26 23:54:33 UTC 
(rev 43633)
+++ trunk/debugger/classes/SymbolTableManager.cs        2005-04-27 00:06:38 UTC 
(rev 43634)
@@ -10,6 +10,8 @@
        // </summary>
        public class SymbolTableManager : IDisposable
        {
+               bool symtab_thread_exit;
+
                Thread symtab_thread;
                DebuggerAutoResetEvent symtab_reload_event;
                DebuggerManualResetEvent symtabs_loaded_event;
@@ -169,22 +171,24 @@
 
                void symtab_thread_start ()
                {
-                       try {
                                symtab_thread_main ();
-                       } catch (ThreadAbortException) {
+
                                symtabs_loaded_event.Set ();
                                modules_loaded_event.Set ();
                                update_completed_event.Set ();
                                symtab_update_in_progress = false;
                                module_update_in_progress = false;
                                symtab_thread = null;
-                       }
                }
 
                void symtab_thread_main ()
                {
                        while (true) {
                                symtab_reload_event.Wait ();
+
+                               if (symtab_thread_exit)
+                                       return;
+
                                ICollection my_new_modules;
 
                                lock (this) {
@@ -262,7 +266,8 @@
                        if (!this.disposed) {
                                if (disposing) {
                                        if (symtab_thread != null) {
-                                               symtab_thread.Abort ();
+                                               symtab_thread_exit = true;
+                                               symtab_reload_event.Set ();
                                                symtab_thread = null;
                                        }
                                }

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

Reply via email to