Blame 8049226-pr2960.patch

akashche 02bc7e
# HG changeset patch
akashche 02bc7e
# User dsamersoff
akashche 02bc7e
# Date 1409228402 25200
akashche 02bc7e
#      Thu Aug 28 05:20:02 2014 -0700
akashche 02bc7e
# Node ID f4c9545cd8a56a5fab74c95de3573623ba2b83c4
akashche 02bc7e
# Parent  13411144d46b50d0087f35eca2b8e827aae558f1
akashche 02bc7e
8049226, PR2960: com/sun/jdi/OptionTest.java test times out again
akashche 02bc7e
Summary: Don't call jni_FatalError if transport initialization fails
akashche 02bc7e
Reviewed-by: sspitsyn, sla
akashche 02bc7e
akashche 02bc7e
diff -r 13411144d46b -r f4c9545cd8a5 src/share/back/debugInit.c
akashche 02bc7e
--- openjdk/jdk/src/share/back/debugInit.c	Wed Jun 18 03:29:58 2014 -0700
akashche 02bc7e
+++ openjdk/jdk/src/share/back/debugInit.c	Thu Aug 28 05:20:02 2014 -0700
akashche 02bc7e
@@ -1013,7 +1013,7 @@
akashche 02bc7e
 atexit_finish_logging(void)
akashche 02bc7e
 {
akashche 02bc7e
     /* Normal exit(0) (not _exit()) may only reach here */
akashche 02bc7e
-    finish_logging(0);  /* Only first call matters */
akashche 02bc7e
+    finish_logging();  /* Only first call matters */
akashche 02bc7e
 }
akashche 02bc7e
 
akashche 02bc7e
 static jboolean
akashche 02bc7e
@@ -1301,43 +1301,49 @@
akashche 02bc7e
 void
akashche 02bc7e
 debugInit_exit(jvmtiError error, const char *msg)
akashche 02bc7e
 {
akashche 02bc7e
-    int exit_code = 0;
akashche 02bc7e
+    enum exit_codes { EXIT_NO_ERRORS = 0, EXIT_JVMTI_ERROR = 1, EXIT_TRANSPORT_ERROR = 2 };
akashche 02bc7e
 
akashche 02bc7e
-    /* Pick an error code */
akashche 02bc7e
-    if ( error != JVMTI_ERROR_NONE ) {
akashche 02bc7e
-        exit_code = 1;
akashche 02bc7e
-        if ( docoredump ) {
akashche 02bc7e
-            LOG_MISC(("Dumping core as requested by command line"));
akashche 02bc7e
-            finish_logging(exit_code);
akashche 02bc7e
-            abort();
akashche 02bc7e
-        }
akashche 02bc7e
+    // Prepare to exit. Log error and finish logging
akashche 02bc7e
+    LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error,
akashche 02bc7e
+                                               ((msg == NULL) ? "" : msg)));
akashche 02bc7e
+
akashche 02bc7e
+    // coredump requested by command line. Keep JVMTI data dirty
akashche 02bc7e
+    if (error != JVMTI_ERROR_NONE && docoredump) {
akashche 02bc7e
+        LOG_MISC(("Dumping core as requested by command line"));
akashche 02bc7e
+        finish_logging();
akashche 02bc7e
+        abort();
akashche 02bc7e
     }
akashche 02bc7e
 
akashche 02bc7e
-    if ( msg==NULL ) {
akashche 02bc7e
-        msg = "";
akashche 02bc7e
-    }
akashche 02bc7e
+    finish_logging();
akashche 02bc7e
 
akashche 02bc7e
-    LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error, msg));
akashche 02bc7e
-
akashche 02bc7e
+    // Cleanup the JVMTI if we have one
akashche 02bc7e
     if (gdata != NULL) {
akashche 02bc7e
         gdata->vmDead = JNI_TRUE;
akashche 02bc7e
-
akashche 02bc7e
-        /* Let's try and cleanup the JVMTI, if we even have one */
akashche 02bc7e
-        if ( gdata->jvmti != NULL ) {
akashche 02bc7e
-            /* Dispose of jvmti (gdata->jvmti becomes NULL) */
akashche 02bc7e
+        if (gdata->jvmti != NULL) {
akashche 02bc7e
+            // Dispose of jvmti (gdata->jvmti becomes NULL)
akashche 02bc7e
             disposeEnvironment(gdata->jvmti);
akashche 02bc7e
         }
akashche 02bc7e
     }
akashche 02bc7e
 
akashche 02bc7e
-    /* Finish up logging. We reach here if JDWP is doing the exiting. */
akashche 02bc7e
-    finish_logging(exit_code);  /* Only first call matters */
akashche 02bc7e
-
akashche 02bc7e
-    /* Let's give the JNI a FatalError if non-exit 0, which is historic way */
akashche 02bc7e
-    if ( exit_code != 0 ) {
akashche 02bc7e
-        JNIEnv *env = NULL;
akashche 02bc7e
-        jniFatalError(env, msg, error, exit_code);
akashche 02bc7e
+    // We are here with no errors. Kill entire process and exit with zero exit code
akashche 02bc7e
+    if (error == JVMTI_ERROR_NONE) {
akashche 02bc7e
+        forceExit(EXIT_NO_ERRORS);
akashche 02bc7e
+        return;
akashche 02bc7e
     }
akashche 02bc7e
 
akashche 02bc7e
-    /* Last chance to die, this kills the entire process. */
akashche 02bc7e
-    forceExit(exit_code);
akashche 02bc7e
+    // No transport initilized.
akashche 02bc7e
+    // As we don't have any details here exiting with separate exit code
akashche 02bc7e
+    if (error == AGENT_ERROR_TRANSPORT_INIT) {
akashche 02bc7e
+        forceExit(EXIT_TRANSPORT_ERROR);
akashche 02bc7e
+        return;
akashche 02bc7e
+    }
akashche 02bc7e
+
akashche 02bc7e
+    // We have JVMTI error. Call hotspot jni_FatalError handler
akashche 02bc7e
+    jniFatalError(NULL, msg, error, EXIT_JVMTI_ERROR);
akashche 02bc7e
+
akashche 02bc7e
+    // hotspot calls os:abort() so we should never reach code below,
akashche 02bc7e
+    // but guard against possible hotspot changes
akashche 02bc7e
+
akashche 02bc7e
+    // Last chance to die, this kills the entire process.
akashche 02bc7e
+    forceExit(EXIT_JVMTI_ERROR);
akashche 02bc7e
 }
akashche 02bc7e
diff -r 13411144d46b -r f4c9545cd8a5 src/share/back/log_messages.c
akashche 02bc7e
--- openjdk/jdk/src/share/back/log_messages.c	Wed Jun 18 03:29:58 2014 -0700
akashche 02bc7e
+++ openjdk/jdk/src/share/back/log_messages.c	Thu Aug 28 05:20:02 2014 -0700
akashche 02bc7e
@@ -230,7 +230,7 @@
akashche 02bc7e
 
akashche 02bc7e
 /* Finish up logging, flush output to the logfile. */
akashche 02bc7e
 void
akashche 02bc7e
-finish_logging(int exit_code)
akashche 02bc7e
+finish_logging()
akashche 02bc7e
 {
akashche 02bc7e
 #ifdef JDWP_LOGGING
akashche 02bc7e
     MUTEX_LOCK(my_mutex);
akashche 02bc7e
diff -r 13411144d46b -r f4c9545cd8a5 src/share/back/log_messages.h
akashche 02bc7e
--- openjdk/jdk/src/share/back/log_messages.h	Wed Jun 18 03:29:58 2014 -0700
akashche 02bc7e
+++ openjdk/jdk/src/share/back/log_messages.h	Thu Aug 28 05:20:02 2014 -0700
akashche 02bc7e
@@ -29,7 +29,7 @@
akashche 02bc7e
 /* LOG: Must be called like:  LOG_category(("anything")) or LOG_category((format,args)) */
akashche 02bc7e
 
akashche 02bc7e
 void setup_logging(const char *, unsigned);
akashche 02bc7e
-void finish_logging(int);
akashche 02bc7e
+void finish_logging();
akashche 02bc7e
 
akashche 02bc7e
 #define LOG_NULL ((void)0)
akashche 02bc7e