Author: martin
Date: 2007-12-07 18:47:54 -0500 (Fri, 07 Dec 2007)
New Revision: 90973

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backend/MonoThreadManager.cs
   trunk/debugger/backend/ProcessServant.cs
   trunk/debugger/backend/ThreadDB.cs
Log:
2007-12-08  Martin Baulig  <[EMAIL PROTECTED]>

        * backend/ThreadDB.cs
        (ThreadDB.GetThreadInfo): Added `TargetMemoryAccess' argument;
        operate on that target.  This fixes the XSP issue.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2007-12-07 23:26:18 UTC (rev 90972)
+++ trunk/debugger/ChangeLog    2007-12-07 23:47:54 UTC (rev 90973)
@@ -1,3 +1,9 @@
+2007-12-08  Martin Baulig  <[EMAIL PROTECTED]>
+
+       * backend/ThreadDB.cs
+       (ThreadDB.GetThreadInfo): Added `TargetMemoryAccess' argument;
+       operate on that target.  This fixes the XSP issue.
+
 2007-12-07  Martin Baulig  <[EMAIL PROTECTED]>
 
        Unify registers on i386 and x86_64.

Modified: trunk/debugger/backend/MonoThreadManager.cs
===================================================================
--- trunk/debugger/backend/MonoThreadManager.cs 2007-12-07 23:26:18 UTC (rev 
90972)
+++ trunk/debugger/backend/MonoThreadManager.cs 2007-12-07 23:47:54 UTC (rev 
90973)
@@ -220,8 +220,7 @@
                                                      "{0} created gc thread: 
{1:x} {2}",
                                                      engine, tid, data);
 
-                                       engine = 
engine.ProcessServant.GetEngineByTID (tid);
-
+                                       engine = 
engine.ProcessServant.GetEngineByTID (inferior, tid);
                                        if (engine == null)
                                                throw new InternalError ();
 

Modified: trunk/debugger/backend/ProcessServant.cs
===================================================================
--- trunk/debugger/backend/ProcessServant.cs    2007-12-07 23:26:18 UTC (rev 
90972)
+++ trunk/debugger/backend/ProcessServant.cs    2007-12-07 23:47:54 UTC (rev 
90973)
@@ -183,7 +183,7 @@
                                mono_manager.ThreadCreated (new_thread);
 
                        if (!do_attach)
-                               get_thread_info (new_thread);
+                               get_thread_info (inferior, new_thread);
                        OnThreadCreatedEvent (new_thread);
                }
 
@@ -395,7 +395,7 @@
                                return;
                        }
 
-                       thread_db.GetThreadInfo (delegate (int lwp, long tid) {
+                       thread_db.GetThreadInfo (target, delegate (int lwp, 
long tid) {
                                SingleSteppingEngine engine = 
(SingleSteppingEngine) thread_hash [lwp];
                                if (engine == null) {
                                        Report.Error ("Unknown thread {0} in 
{1}", lwp,
@@ -406,7 +406,7 @@
                        });
                }
 
-               void get_thread_info (SingleSteppingEngine engine)
+               void get_thread_info (Inferior inferior, SingleSteppingEngine 
engine)
                {
                        if (thread_db == null) {
                                Report.Error ("Failed to initialize thread_db 
on {0}: {1} {2}",
@@ -415,7 +415,7 @@
                        }
 
                        bool found = false;
-                       thread_db.GetThreadInfo (delegate (int lwp, long tid) {
+                       thread_db.GetThreadInfo (inferior, delegate (int lwp, 
long tid) {
                                if (lwp != engine.PID)
                                        return;
 
@@ -428,14 +428,32 @@
                                              engine.PID, start.CommandLine);
                }
 
-               internal SingleSteppingEngine GetEngineByTID (long tid)
+               internal SingleSteppingEngine GetEngineByTID (Inferior 
inferior, long tid)
                {
                        foreach (SingleSteppingEngine engine in 
thread_hash.Values) {
                                if (engine.TID == tid)
                                        return engine;
                        }
 
-                       return null;
+                       if (thread_db == null) {
+                               Report.Error ("Failed to initialize thread_db 
on {0}: {1} {2}",
+                                             start.CommandLine, start, 
Environment.StackTrace);
+                               throw new InternalError ();
+                       }
+
+                       SingleSteppingEngine result = null;
+                       thread_db.GetThreadInfo (inferior, delegate (int t_lwp, 
long t_tid) {
+                               if (tid != t_tid)
+                                       return;
+                               result = (SingleSteppingEngine) thread_hash 
[t_lwp];
+
+                       });
+
+                       if (result == null)
+                               Report.Error ("Cannot find thread {0:x} in {1}",
+                                             tid, start.CommandLine);
+
+                       return result;
                }
 
                public void Kill ()

Modified: trunk/debugger/backend/ThreadDB.cs
===================================================================
--- trunk/debugger/backend/ThreadDB.cs  2007-12-07 23:26:18 UTC (rev 90972)
+++ trunk/debugger/backend/ThreadDB.cs  2007-12-07 23:47:54 UTC (rev 90973)
@@ -8,6 +8,7 @@
                IntPtr handle;
                ProcessServant process;
                TargetMemoryAccess target;
+               DebuggerMutex mutex;
 
                enum PsErr {
                        Ok = 0,
@@ -42,30 +43,36 @@
                ReadMemoryFunc read_memory_func;
                WriteMemoryFunc write_memory_func;
 
-               protected ThreadDB (ProcessServant process, TargetMemoryAccess 
target)
+               protected ThreadDB (ProcessServant process)
                {
                        this.process = process;
-                       this.target = target;
 
+                       mutex = new DebuggerMutex ("thread_db_mutex");
+
                        global_lookup_func = new GlobalLookupFunc 
(global_lookup);
                        read_memory_func = new ReadMemoryFunc (read_memory);
                        write_memory_func = new WriteMemoryFunc (write_memory);
-
-                       handle = mono_debugger_thread_db_init (
-                               global_lookup_func, read_memory_func, 
write_memory_func);
                }
 
-               protected bool Initialize ()
+               protected bool Initialize (TargetMemoryAccess target)
                {
-                       handle = mono_debugger_thread_db_init (
-                               global_lookup_func, read_memory_func, 
write_memory_func);
-                       return handle != IntPtr.Zero;
+                       try {
+                               mutex.Lock ();
+                               this.target = target;
+
+                               handle = mono_debugger_thread_db_init (
+                                       global_lookup_func, read_memory_func, 
write_memory_func);
+                               return handle != IntPtr.Zero;
+                       } finally {
+                               this.target = null;
+                               mutex.Unlock ();
+                       }
                }
 
                public static ThreadDB Create (ProcessServant process, 
TargetMemoryAccess target)
                {
-                       ThreadDB db = new ThreadDB (process, target);
-                       if (!db.Initialize ())
+                       ThreadDB db = new ThreadDB (process);
+                       if (!db.Initialize (target))
                                return null;
 
                        return db;
@@ -80,18 +87,25 @@
                        return true;
                }
 
-               public void GetThreadInfo (GetThreadInfoFunc func)
+               public void GetThreadInfo (TargetMemoryAccess target, 
GetThreadInfoFunc func)
                {
-                       mono_debugger_thread_db_iterate_over_threads (
-                               handle, delegate (IntPtr th) {
-                                       long tid, tls, lwp;
-                                       if 
(!mono_debugger_thread_db_get_thread_info (
-                                                   th, out tid, out tls, out 
lwp))
-                                               return false;
+                       try {
+                               mutex.Lock ();
+                               this.target = target;
+                               mono_debugger_thread_db_iterate_over_threads (
+                                       handle, delegate (IntPtr th) {
+                                               long tid, tls, lwp;
+                                               if 
(!mono_debugger_thread_db_get_thread_info (
+                                                           th, out tid, out 
tls, out lwp))
+                                                       return false;
 
-                                       func ((int) lwp, tid);
-                                       return true;
-                       });
+                                               func ((int) lwp, tid);
+                                               return true;
+                                       });
+                       } finally {
+                               this.target = null;
+                               mutex.Unlock ();
+                       }
                }
 
                PsErr global_lookup (string obj_name, string sym_name, out long 
sym_addr)

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

Reply via email to