diff --git a/backends/Debugger.cs b/backends/Debugger.cs index ad01d994..59ea0e96 100644 --- a/backends/Debugger.cs +++ b/backends/Debugger.cs @@ -269,14 +269,14 @@ protected virtual void Dispose (bool disposing) // If this is a call to Dispose, dispose all managed resources. if (disposing) { - if (thread_manager != null) { - thread_manager.Dispose (); - thread_manager = null; - } if (symtab_manager != null) { symtab_manager.Dispose (); symtab_manager = null; } + if (thread_manager != null) { + thread_manager.Dispose (); + thread_manager = null; + } if (bfd_container != null) { bfd_container.Dispose (); bfd_container = null; diff --git a/backends/Process.cs b/backends/Process.cs index 4e927009..d0c68e4e 100644 --- a/backends/Process.cs +++ b/backends/Process.cs @@ -772,7 +772,10 @@ protected void check_disposed () protected virtual void DoDispose () { - engine.Dispose (); + if (engine != null) { + engine.Dispose (); + engine = null; + } } protected virtual void Dispose (bool disposing) diff --git a/backends/SingleSteppingEngine.cs b/backends/SingleSteppingEngine.cs index 85dac46c..db65ec03 100644 --- a/backends/SingleSteppingEngine.cs +++ b/backends/SingleSteppingEngine.cs @@ -1861,19 +1861,14 @@ private void check_disposed () protected virtual void Dispose (bool disposing) { // Check to see if Dispose has already been called. - lock (this) { - if (disposed) - return; - - disposed = true; - } - // If this is a call to Dispose, dispose all managed resources. if (disposing) { if (inferior != null) inferior.Kill (); inferior = null; } + + disposed = true; } public void Dispose () diff --git a/backends/ThreadManager.cs b/backends/ThreadManager.cs index a197bb15..9e25c34f 100644 --- a/backends/ThreadManager.cs +++ b/backends/ThreadManager.cs @@ -139,9 +139,11 @@ public void StartApplication (ProcessStart start) this.start = start; wait_thread = new Thread (new ThreadStart (start_wait_thread)); + wait_thread.IsBackground = true; wait_thread.Start (); inferior_thread = new Thread (new ThreadStart (start_inferior)); + inferior_thread.IsBackground = true; inferior_thread.Start (); } @@ -668,7 +670,8 @@ protected virtual void DoDispose () thread_hash.Values.CopyTo (threads, 0); for (int i = 0; i < threads.Length; i++) - threads [i].Kill (); + threads [i].Dispose (); + main_process.Dispose (); } private bool disposed = false; diff --git a/classes/SymbolTableManager.cs b/classes/SymbolTableManager.cs index 5afaa9e4..e6c38813 100644 --- a/classes/SymbolTableManager.cs +++ b/classes/SymbolTableManager.cs @@ -26,6 +26,7 @@ public SymbolTableManager () modules_loaded_event = new ManualResetEvent (true); update_completed_event = new ManualResetEvent (true); symtab_thread = new Thread (new ThreadStart (symtab_thread_start)); + symtab_thread.IsBackground = true; symtab_thread.Start (); }