diff options
author | Keith Seitz <keiths@redhat.com> | 2006-06-16 18:32:48 +0000 |
---|---|---|
committer | Keith Seitz <keiths@redhat.com> | 2006-06-16 18:32:48 +0000 |
commit | 7dbe98b580a589e2238d7eca21eac7d9ff926abb (patch) | |
tree | 661c459620273b2179facd92c037f9cda1e7b9d5 /gnu/classpath | |
parent | b1a6126d193244caeadc1ee6dd15b7bb7517c540 (diff) | |
download | classpath-7dbe98b580a589e2238d7eca21eac7d9ff926abb.tar.gz |
* 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.
Diffstat (limited to 'gnu/classpath')
-rw-r--r-- | gnu/classpath/jdwp/Jdwp.java | 39 | ||||
-rw-r--r-- | gnu/classpath/jdwp/processor/PacketProcessor.java | 8 | ||||
-rw-r--r-- | gnu/classpath/jdwp/transport/JdwpConnection.java | 6 |
3 files changed, 48 insertions, 5 deletions
diff --git a/gnu/classpath/jdwp/Jdwp.java b/gnu/classpath/jdwp/Jdwp.java index 7141214ef..81c86d7b1 100644 --- a/gnu/classpath/jdwp/Jdwp.java +++ b/gnu/classpath/jdwp/Jdwp.java @@ -56,6 +56,9 @@ import java.util.HashMap; /** * 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 (keiths@redhat.com) */ public class Jdwp @@ -65,7 +68,8 @@ public class Jdwp 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 @@ public class Jdwp // 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 @@ public class Jdwp } } + /** + * 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:..." diff --git a/gnu/classpath/jdwp/processor/PacketProcessor.java b/gnu/classpath/jdwp/processor/PacketProcessor.java index 9e281f217..4df3f4728 100644 --- a/gnu/classpath/jdwp/processor/PacketProcessor.java +++ b/gnu/classpath/jdwp/processor/PacketProcessor.java @@ -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 class PacketProcessor */ 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 @@ public class PacketProcessor _processOnePacket (); } } - catch (IOException ex) + catch (Exception ex) { ex.printStackTrace(); } diff --git a/gnu/classpath/jdwp/transport/JdwpConnection.java b/gnu/classpath/jdwp/transport/JdwpConnection.java index f008bbd00..82a2380bb 100644 --- a/gnu/classpath/jdwp/transport/JdwpConnection.java +++ b/gnu/classpath/jdwp/transport/JdwpConnection.java @@ -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 class JdwpConnection */ public void run () { + // Notify initialization thread (gnu.classpath.jdwp.Jdwp) that + // the JdwpConnection thread is ready. + Jdwp.getDefault().subcomponentInitialized (); + while (!_shutdown) { try |