commit-classpath
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[commit-cp] classpath ChangeLog gnu/classpath/jdwp/Jdwp.jav...


From: Keith Seitz
Subject: [commit-cp] classpath ChangeLog gnu/classpath/jdwp/Jdwp.jav...
Date: Fri, 16 Jun 2006 18:32:49 +0000

CVSROOT:        /sources/classpath
Module name:    classpath
Changes by:     Keith Seitz <keiths>    06/06/16 18:32:49

Modified files:
        .              : ChangeLog 
        gnu/classpath/jdwp: Jdwp.java 
        gnu/classpath/jdwp/transport: JdwpConnection.java 
        gnu/classpath/jdwp/processor: PacketProcessor.java 

Log message:
                * gnu/classpath/jdwp/Jdwp.java (_initLock): New field.
                (_initCount): New field.
                (Jdwp): Don't set isDebugging until fully initialized.
                (subcomponentInitialized): New method.
                (run): Wait for PacketProcessor and JdwpConnection to
                startup, then set isDebugging, and then let this thread
                die.
                * gnu/classpath/jdwp/transport/JdwpConnection.java
                (run): Add synchronization notification.
                * gnu/classpath/jdwp/processor/PacketProcessor.java
                (run): Likewise.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&r1=1.7851&r2=1.7852
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/classpath/jdwp/Jdwp.java?cvsroot=classpath&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java?cvsroot=classpath&r1=1.5&r2=1.6
http://cvs.savannah.gnu.org/viewcvs/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java?cvsroot=classpath&r1=1.5&r2=1.6

Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/classpath/classpath/ChangeLog,v
retrieving revision 1.7851
retrieving revision 1.7852
diff -u -b -r1.7851 -r1.7852
--- ChangeLog   16 Jun 2006 18:28:45 -0000      1.7851
+++ ChangeLog   16 Jun 2006 18:32:48 -0000      1.7852
@@ -1,3 +1,17 @@
+2006-06-16  Keith Seitz  <address@hidden>
+
+       * gnu/classpath/jdwp/Jdwp.java (_initLock): New field.
+       (_initCount): New field.
+       (Jdwp): Don't set isDebugging until fully initialized.
+       (subcomponentInitialized): New method.
+       (run): Wait for PacketProcessor and JdwpConnection to
+       startup, then set isDebugging, and then let this thread
+       die.
+       * gnu/classpath/jdwp/transport/JdwpConnection.java
+       (run): Add synchronization notification.
+       * gnu/classpath/jdwp/processor/PacketProcessor.java
+       (run): Likewise.
+
 2006-06-16  Tom Tromey  <address@hidden>
 
        * NEWS: Updated for JSR 166.

Index: gnu/classpath/jdwp/Jdwp.java
===================================================================
RCS file: /sources/classpath/classpath/gnu/classpath/jdwp/Jdwp.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- gnu/classpath/jdwp/Jdwp.java        16 Mar 2006 23:26:10 -0000      1.6
+++ gnu/classpath/jdwp/Jdwp.java        16 Jun 2006 18:32:48 -0000      1.7
@@ -56,6 +56,9 @@
 /**
  * Main interface from the virtual machine to the JDWP back-end.
  *
+ * The thread created by this class is only used for initialization.
+ * Once it exits, the JDWP backend is fully initialized.
+ *
  * @author Keith Seitz (address@hidden)
  */
 public class Jdwp
@@ -65,7 +68,8 @@
   private static Jdwp _instance = null;
 
   /**
-   * Are we debugging?
+   * Are we debugging? Only true if debugging
+   * *and* initialized.
    */
   public static boolean isDebugging = false;
 
@@ -89,13 +93,16 @@
   // A thread group for the JDWP threads
   private ThreadGroup _group;
 
+  // Initialization synchronization
+  private Object _initLock = new Object ();
+  private int _initCount = 0;
+
   /**
    * constructor
    */
   public Jdwp ()
   {
     _shutdown = false;
-    isDebugging = true;
     _instance = this;
   }
 
@@ -271,17 +278,45 @@
       }
   }
 
+  /**
+   * Allows subcomponents to specify that they are
+   * initialized.
+   *
+   * Subcomponents include JdwpConnection and PacketProcessor.
+   */
+  public void subcomponentInitialized ()
+  {
+    synchronized (_initLock)
+      {
+       ++_initCount;
+       _initLock.notify ();
+      }
+  }
+
   public void run ()
   {
     try
       {
        _doInitialization ();
+
+       /* We need a little internal synchronization here, so that
+          when this thread dies, the back-end will be fully initialized,
+          ready to start servicing the VM and debugger. */
+       synchronized (_initLock)
+         {
+           while (_initCount != 2)
+             _initLock.wait ();
+         }
+       _initLock = null;
       }
     catch (Throwable t)
       {
        System.out.println ("Exception in JDWP back-end: " + t);
        System.exit (1);
       }
+
+    // Now we are finally ready and initialized
+    isDebugging = true;
   }
 
   // A helper function to process the configure string "-Xrunjdwp:..."

Index: gnu/classpath/jdwp/transport/JdwpConnection.java
===================================================================
RCS file: 
/sources/classpath/classpath/gnu/classpath/jdwp/transport/JdwpConnection.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gnu/classpath/jdwp/transport/JdwpConnection.java    3 Sep 2005 00:22:30 
-0000       1.5
+++ gnu/classpath/jdwp/transport/JdwpConnection.java    16 Jun 2006 18:32:49 
-0000      1.6
@@ -1,5 +1,5 @@
 /* JdwpConnection.java -- A JDWP-speaking connection
-   Copyright (C) 2005 Free Software Foundation
+   Copyright (C) 2005, 2006 Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -165,6 +165,10 @@
    */
   public void run ()
   {
+    // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
+    // the JdwpConnection thread is ready.
+    Jdwp.getDefault().subcomponentInitialized ();
+
     while (!_shutdown)
       {
        try

Index: gnu/classpath/jdwp/processor/PacketProcessor.java
===================================================================
RCS file: 
/sources/classpath/classpath/gnu/classpath/jdwp/processor/PacketProcessor.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -b -r1.5 -r1.6
--- gnu/classpath/jdwp/processor/PacketProcessor.java   27 Jul 2005 19:04:14 
-0000      1.5
+++ gnu/classpath/jdwp/processor/PacketProcessor.java   16 Jun 2006 18:32:49 
-0000      1.6
@@ -1,6 +1,6 @@
 /* PacketProcessor.java -- a thread which processes command packets
    from the debugger
-   Copyright (C) 2005 Free Software Foundation
+   Copyright (C) 2005, 2006 Free Software Foundation
 
 This file is part of GNU Classpath.
 
@@ -137,6 +137,10 @@
    */
   public Object run ()
   {
+    // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that
+    // the PacketProcessor thread is ready.
+    Jdwp.getDefault().subcomponentInitialized ();
+       
     try
       {
         while (!_shutdown)
@@ -144,7 +148,7 @@
             _processOnePacket ();
           }
       }
-    catch (IOException ex)
+    catch (Exception ex)
       {
         ex.printStackTrace();
       }




reply via email to

[Prev in Thread] Current Thread [Next in Thread]