6988950: JDWP exit error JVMTI_ERROR_WRONG_PHASE(112)
authorsspitsyn
Tue, 11 Nov 2014 21:46:02 -0800
changeset 27739 d185cfc165df
parent 27738 f0c7aa4a7afd
child 27740 cce1f2b78182
child 27786 3c04b0fead02
6988950: JDWP exit error JVMTI_ERROR_WRONG_PHASE(112) Summary: Synchronize the jdwp VirtualMachine command functions with the VM_DEATH event Reviewed-by: dcubed, dsamersoff, dholmes
jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c
--- a/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c	Mon Nov 10 15:06:13 2014 -0500
+++ b/jdk/src/jdk.jdwp.agent/share/native/libjdwp/debugLoop.c	Tue Nov 11 21:46:02 2014 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1998, 2005, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -45,7 +45,7 @@
 
 static volatile struct PacketList *cmdQueue;
 static jrawMonitorID cmdQueueLock;
-static jrawMonitorID resumeLock;
+static jrawMonitorID vmDeathLock;
 static jboolean transportError;
 
 static jboolean
@@ -60,28 +60,17 @@
     }
 }
 
-static jboolean
-resumeCommand(jdwpCmdPacket *cmd)
-{
-    if ( (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)) &&
-         (cmd->cmd == JDWP_COMMAND(VirtualMachine, Resume)) ) {
-        return JNI_TRUE;
-    } else {
-        return JNI_FALSE;
-    }
-}
-
 void
 debugLoop_initialize(void)
 {
-    resumeLock = debugMonitorCreate("JDWP Resume Lock");
+    vmDeathLock = debugMonitorCreate("JDWP VM_DEATH Lock");
 }
 
 void
 debugLoop_sync(void)
 {
-    debugMonitorEnter(resumeLock);
-    debugMonitorExit(resumeLock);
+    debugMonitorEnter(vmDeathLock);
+    debugMonitorExit(vmDeathLock);
 }
 
 /*
@@ -136,14 +125,14 @@
             jboolean replyToSender = JNI_TRUE;
 
             /*
-             * For VirtualMachine.Resume commands we hold the resumeLock
+             * For VirtualMachine commands we hold the vmDeathLock
              * while executing and replying to the command. This ensures
-             * that a Resume after VM_DEATH will be allowed to complete
+             * that a VM command after VM_DEATH will be allowed to complete
              * before the thread posting the VM_DEATH continues VM
              * termination.
              */
-            if (resumeCommand(cmd)) {
-                debugMonitorEnter(resumeLock);
+            if (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)){
+                debugMonitorEnter(vmDeathLock);
             }
 
             /* Initialize the input and output streams */
@@ -181,10 +170,10 @@
             }
 
             /*
-             * Release the resumeLock as the reply has been posted.
+             * Release the vmDeathLock as the reply has been posted.
              */
-            if (resumeCommand(cmd)) {
-                debugMonitorExit(resumeLock);
+            if (cmd->cmdSet == JDWP_COMMAND_SET(VirtualMachine)){
+               debugMonitorExit(vmDeathLock);
             }
 
             inStream_destroy(&in);