Author: martin
Date: 2007-12-07 20:53:55 -0500 (Fri, 07 Dec 2007)
New Revision: 90983

Modified:
   trunk/debugger/ChangeLog
   trunk/debugger/backend/Inferior.cs
   trunk/debugger/backend/ProcessServant.cs
   trunk/debugger/backend/SingleSteppingEngine.cs
   trunk/debugger/backend/server/i386-arch.c
   trunk/debugger/backend/server/library.c
   trunk/debugger/backend/server/server.h
   trunk/debugger/backend/server/x86-arch.h
   trunk/debugger/backend/server/x86_64-arch.c
Log:
2007-12-08  Martin Baulig  <[EMAIL PROTECTED]>

        * backend/ProcessServant.cs
        (ProcessServant.ChildForked): Implement detach-after-fork, ie. not
        following fork().  At the moment, this can only be enabled in the
        configuration file
        [FIXME: add user-interface option to enable/disable this].

        * backend/Inferior.cs
        (Inferior.InitializeAfterFork): Added `bool follow_fork' argument.

        * backend/server/server.h
        (mono_debugger_server_init_after_fork): Added
        `gboolean follow_fork' argument; remove all breakpoints if false.



Modified: trunk/debugger/ChangeLog
===================================================================
--- trunk/debugger/ChangeLog    2007-12-08 01:45:28 UTC (rev 90982)
+++ trunk/debugger/ChangeLog    2007-12-08 01:53:55 UTC (rev 90983)
@@ -1,5 +1,20 @@
 2007-12-08  Martin Baulig  <[EMAIL PROTECTED]>
 
+       * backend/ProcessServant.cs
+       (ProcessServant.ChildForked): Implement detach-after-fork, ie. not
+       following fork().  At the moment, this can only be enabled in the
+       configuration file
+       [FIXME: add user-interface option to enable/disable this].
+
+       * backend/Inferior.cs
+       (Inferior.InitializeAfterFork): Added `bool follow_fork' argument.
+
+       * backend/server/server.h
+       (mono_debugger_server_init_after_fork): Added
+       `gboolean follow_fork' argument; remove all breakpoints if false.
+
+2007-12-08  Martin Baulig  <[EMAIL PROTECTED]>
+
        * classes/DebuggerConfiguration.cs
        (DebuggerConfiguration.FollowFork): New property.  Not yet implemented.
 

Modified: trunk/debugger/backend/Inferior.cs
===================================================================
--- trunk/debugger/backend/Inferior.cs  2007-12-08 01:45:28 UTC (rev 90982)
+++ trunk/debugger/backend/Inferior.cs  2007-12-08 01:53:55 UTC (rev 90983)
@@ -168,7 +168,7 @@
                static extern TargetError mono_debugger_server_get_application 
(IntPtr handle, out string exe_file, out string cwd, out int nargs, out IntPtr 
data);
 
                [DllImport("monodebuggerserver")]
-               static extern TargetError mono_debugger_server_init_after_fork 
(IntPtr handle);
+               static extern TargetError mono_debugger_server_init_after_fork 
(IntPtr handle, bool follow_fork);
 
                [DllImport("monodebuggerserver")]
                static extern TargetError mono_debugger_server_push_registers 
(IntPtr handle, out long new_rsp);
@@ -1284,10 +1284,11 @@
                        }
                }
 
-               public void InitializeAfterFork ()
+               public void InitializeAfterFork (bool follow_fork)
                {
-                       check_error (mono_debugger_server_init_after_fork 
(server_handle));
-                       breakpoint_manager.InitializeAfterFork (this);
+                       check_error (mono_debugger_server_init_after_fork 
(server_handle, follow_fork));
+                       if (follow_fork)
+                               breakpoint_manager.InitializeAfterFork (this);
                }
 
                public TargetAddress PushRegisters ()

Modified: trunk/debugger/backend/ProcessServant.cs
===================================================================
--- trunk/debugger/backend/ProcessServant.cs    2007-12-08 01:45:28 UTC (rev 
90982)
+++ trunk/debugger/backend/ProcessServant.cs    2007-12-08 01:53:55 UTC (rev 
90983)
@@ -168,6 +168,10 @@
                internal void ThreadCreated (Inferior inferior, int pid, bool 
do_attach)
                {
                        Inferior new_inferior = inferior.CreateThread ();
+                       if (do_attach)
+                               new_inferior.Attach (pid);
+                       else
+                               new_inferior.InitializeThread (pid);
 
                        SingleSteppingEngine new_thread = new 
SingleSteppingEngine (
                                manager, this, new_inferior, pid);
@@ -177,6 +181,7 @@
                        // Order is important: first add the new engine to the 
manager's hash table,
                        //                     then call inferior.Initialize() 
/ inferior.Attach().
                        manager.AddEngine (new_thread);
+
                        new_thread.StartThread (do_attach);
 
                        if ((mono_manager != null) && !do_attach)
@@ -193,7 +198,14 @@
 
                        Inferior new_inferior = Inferior.CreateInferior (
                                manager, new_process, new_process.ProcessStart);
+                       new_inferior.InitializeThread (pid);
 
+                       new_inferior.InitializeAfterFork 
(manager.Debugger.Configuration.FollowFork);
+                       if (!manager.Debugger.Configuration.FollowFork) {
+                               new_inferior.Detach ();
+                               return;
+                       }
+
                        SingleSteppingEngine new_thread = new 
SingleSteppingEngine (
                                manager, new_process, new_inferior, pid);
 
@@ -206,8 +218,6 @@
                        manager.AddEngine (new_thread);
                        new_thread.StartThread (false);
 
-                       new_inferior.InitializeAfterFork ();
-
                        manager.Debugger.OnProcessCreatedEvent (new_process);
                        new_process.OnThreadCreatedEvent (new_thread);
                }
@@ -238,6 +248,7 @@
                        bfd_container = new BfdContainer (this);
 
                        Inferior new_inferior = Inferior.CreateInferior 
(manager, this, start);
+                       new_inferior.InitializeThread (inferior.PID);
 
                        SingleSteppingEngine new_thread = new 
SingleSteppingEngine (
                                manager, this, new_inferior, inferior.PID);

Modified: trunk/debugger/backend/SingleSteppingEngine.cs
===================================================================
--- trunk/debugger/backend/SingleSteppingEngine.cs      2007-12-08 01:45:28 UTC 
(rev 90982)
+++ trunk/debugger/backend/SingleSteppingEngine.cs      2007-12-08 01:53:55 UTC 
(rev 90983)
@@ -119,11 +119,6 @@
 
                public CommandResult StartThread (bool do_attach)
                {
-                       if (do_attach)
-                               inferior.Attach (pid);
-                       else
-                               inferior.InitializeThread (pid);
-
                        CommandResult result = new ThreadCommandResult (thread);
                        if (do_attach)
                                current_operation = new OperationInitialize 
(this, result);

Modified: trunk/debugger/backend/server/i386-arch.c
===================================================================
--- trunk/debugger/backend/server/i386-arch.c   2007-12-08 01:45:28 UTC (rev 
90982)
+++ trunk/debugger/backend/server/i386-arch.c   2007-12-08 01:53:55 UTC (rev 
90983)
@@ -930,7 +930,7 @@
 }
 
 static ServerCommandError
-server_ptrace_init_after_fork (ServerHandle *handle)
+server_ptrace_init_after_fork (ServerHandle *handle, gboolean follow_fork)
 {
        GPtrArray *breakpoints;
        int i;
@@ -941,7 +941,7 @@
        for (i = 0; i < breakpoints->len; i++) {
                BreakpointInfo *info = g_ptr_array_index (breakpoints, i);
 
-               if (info->dr_index >= 0)
+               if (!follow_fork || (info->dr_index >= 0))
                        do_disable (handle, info);
        }
 

Modified: trunk/debugger/backend/server/library.c
===================================================================
--- trunk/debugger/backend/server/library.c     2007-12-08 01:45:28 UTC (rev 
90982)
+++ trunk/debugger/backend/server/library.c     2007-12-08 01:53:55 UTC (rev 
90983)
@@ -413,12 +413,12 @@
 }
 
 ServerCommandError
-mono_debugger_server_init_after_fork (ServerHandle *handle)
+mono_debugger_server_init_after_fork (ServerHandle *handle, gboolean 
follow_fork)
 {
        if (!global_vtable->init_after_fork)
                return COMMAND_ERROR_NOT_IMPLEMENTED;
 
-       return (* global_vtable->init_after_fork) (handle);
+       return (* global_vtable->init_after_fork) (handle, follow_fork);
 }
 
 ServerCommandError

Modified: trunk/debugger/backend/server/server.h
===================================================================
--- trunk/debugger/backend/server/server.h      2007-12-08 01:45:28 UTC (rev 
90982)
+++ trunk/debugger/backend/server/server.h      2007-12-08 01:53:55 UTC (rev 
90983)
@@ -358,7 +358,8 @@
                                                       guint32          *nargs,
                                                       gchar          
***cmdline_args);
 
-       ServerCommandError    (* init_after_fork)     (ServerHandle      
*handle);
+       ServerCommandError    (* init_after_fork)     (ServerHandle      
*handle,
+                                                      gboolean           
follow_fork);
 
        ServerCommandError    (* push_registers)      (ServerHandle      
*handle,
                                                       guint64           
*new_rsp);
@@ -579,7 +580,8 @@
                                          gchar             ***cmdline_args);
 
 ServerCommandError
-mono_debugger_server_init_after_fork     (ServerHandle        *handle);
+mono_debugger_server_init_after_fork     (ServerHandle        *handle,
+                                         gboolean             follow_fork);
 
 ServerCommandError
 mono_debugger_server_push_registers      (ServerHandle        *handle,

Modified: trunk/debugger/backend/server/x86-arch.h
===================================================================
--- trunk/debugger/backend/server/x86-arch.h    2007-12-08 01:45:28 UTC (rev 
90982)
+++ trunk/debugger/backend/server/x86-arch.h    2007-12-08 01:53:55 UTC (rev 
90983)
@@ -73,7 +73,7 @@
 x86_arch_get_registers (ServerHandle *handle);
 
 static ServerCommandError
-server_ptrace_init_after_fork (ServerHandle *handle);
+server_ptrace_init_after_fork (ServerHandle *handle, gboolean follow_fork);
 
 #if defined(__i386__)
 #include "i386-arch.h"

Modified: trunk/debugger/backend/server/x86_64-arch.c
===================================================================
--- trunk/debugger/backend/server/x86_64-arch.c 2007-12-08 01:45:28 UTC (rev 
90982)
+++ trunk/debugger/backend/server/x86_64-arch.c 2007-12-08 01:53:55 UTC (rev 
90983)
@@ -696,7 +696,7 @@
 }
 
 static ServerCommandError
-server_ptrace_init_after_fork (ServerHandle *handle)
+server_ptrace_init_after_fork (ServerHandle *handle, gboolean follow_fork)
 {
        GPtrArray *breakpoints;
        int i;
@@ -707,7 +707,7 @@
        for (i = 0; i < breakpoints->len; i++) {
                BreakpointInfo *info = g_ptr_array_index (breakpoints, i);
 
-               if (info->dr_index >= 0)
+               if (!follow_fork || (info->dr_index >= 0))
                        do_disable (handle, info);
        }
 

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

Reply via email to