1 |
# HG changeset patch |
2 |
# User dsamersoff |
3 |
# Date 1409228402 25200 |
4 |
# Thu Aug 28 05:20:02 2014 -0700 |
5 |
# Node ID f4c9545cd8a56a5fab74c95de3573623ba2b83c4 |
6 |
# Parent 13411144d46b50d0087f35eca2b8e827aae558f1 |
7 |
8049226, PR2960: com/sun/jdi/OptionTest.java test times out again |
8 |
Summary: Don't call jni_FatalError if transport initialization fails |
9 |
Reviewed-by: sspitsyn, sla |
10 |
|
11 |
diff -r 13411144d46b -r f4c9545cd8a5 src/share/back/debugInit.c |
12 |
--- openjdk/jdk/src/share/back/debugInit.c Wed Jun 18 03:29:58 2014 -0700 |
13 |
+++ openjdk/jdk/src/share/back/debugInit.c Thu Aug 28 05:20:02 2014 -0700 |
14 |
@@ -1013,7 +1013,7 @@ |
15 |
atexit_finish_logging(void) |
16 |
{ |
17 |
/* Normal exit(0) (not _exit()) may only reach here */ |
18 |
- finish_logging(0); /* Only first call matters */ |
19 |
+ finish_logging(); /* Only first call matters */ |
20 |
} |
21 |
|
22 |
static jboolean |
23 |
@@ -1301,43 +1301,49 @@ |
24 |
void |
25 |
debugInit_exit(jvmtiError error, const char *msg) |
26 |
{ |
27 |
- int exit_code = 0; |
28 |
+ enum exit_codes { EXIT_NO_ERRORS = 0, EXIT_JVMTI_ERROR = 1, EXIT_TRANSPORT_ERROR = 2 }; |
29 |
|
30 |
- /* Pick an error code */ |
31 |
- if ( error != JVMTI_ERROR_NONE ) { |
32 |
- exit_code = 1; |
33 |
- if ( docoredump ) { |
34 |
- LOG_MISC(("Dumping core as requested by command line")); |
35 |
- finish_logging(exit_code); |
36 |
- abort(); |
37 |
- } |
38 |
+ // Prepare to exit. Log error and finish logging |
39 |
+ LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error, |
40 |
+ ((msg == NULL) ? "" : msg))); |
41 |
+ |
42 |
+ // coredump requested by command line. Keep JVMTI data dirty |
43 |
+ if (error != JVMTI_ERROR_NONE && docoredump) { |
44 |
+ LOG_MISC(("Dumping core as requested by command line")); |
45 |
+ finish_logging(); |
46 |
+ abort(); |
47 |
} |
48 |
|
49 |
- if ( msg==NULL ) { |
50 |
- msg = ""; |
51 |
- } |
52 |
+ finish_logging(); |
53 |
|
54 |
- LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error, msg)); |
55 |
- |
56 |
+ // Cleanup the JVMTI if we have one |
57 |
if (gdata != NULL) { |
58 |
gdata->vmDead = JNI_TRUE; |
59 |
- |
60 |
- /* Let's try and cleanup the JVMTI, if we even have one */ |
61 |
- if ( gdata->jvmti != NULL ) { |
62 |
- /* Dispose of jvmti (gdata->jvmti becomes NULL) */ |
63 |
+ if (gdata->jvmti != NULL) { |
64 |
+ // Dispose of jvmti (gdata->jvmti becomes NULL) |
65 |
disposeEnvironment(gdata->jvmti); |
66 |
} |
67 |
} |
68 |
|
69 |
- /* Finish up logging. We reach here if JDWP is doing the exiting. */ |
70 |
- finish_logging(exit_code); /* Only first call matters */ |
71 |
- |
72 |
- /* Let's give the JNI a FatalError if non-exit 0, which is historic way */ |
73 |
- if ( exit_code != 0 ) { |
74 |
- JNIEnv *env = NULL; |
75 |
- jniFatalError(env, msg, error, exit_code); |
76 |
+ // We are here with no errors. Kill entire process and exit with zero exit code |
77 |
+ if (error == JVMTI_ERROR_NONE) { |
78 |
+ forceExit(EXIT_NO_ERRORS); |
79 |
+ return; |
80 |
} |
81 |
|
82 |
- /* Last chance to die, this kills the entire process. */ |
83 |
- forceExit(exit_code); |
84 |
+ // No transport initilized. |
85 |
+ // As we don't have any details here exiting with separate exit code |
86 |
+ if (error == AGENT_ERROR_TRANSPORT_INIT) { |
87 |
+ forceExit(EXIT_TRANSPORT_ERROR); |
88 |
+ return; |
89 |
+ } |
90 |
+ |
91 |
+ // We have JVMTI error. Call hotspot jni_FatalError handler |
92 |
+ jniFatalError(NULL, msg, error, EXIT_JVMTI_ERROR); |
93 |
+ |
94 |
+ // hotspot calls os:abort() so we should never reach code below, |
95 |
+ // but guard against possible hotspot changes |
96 |
+ |
97 |
+ // Last chance to die, this kills the entire process. |
98 |
+ forceExit(EXIT_JVMTI_ERROR); |
99 |
} |
100 |
diff -r 13411144d46b -r f4c9545cd8a5 src/share/back/log_messages.c |
101 |
--- openjdk/jdk/src/share/back/log_messages.c Wed Jun 18 03:29:58 2014 -0700 |
102 |
+++ openjdk/jdk/src/share/back/log_messages.c Thu Aug 28 05:20:02 2014 -0700 |
103 |
@@ -230,7 +230,7 @@ |
104 |
|
105 |
/* Finish up logging, flush output to the logfile. */ |
106 |
void |
107 |
-finish_logging(int exit_code) |
108 |
+finish_logging() |
109 |
{ |
110 |
#ifdef JDWP_LOGGING |
111 |
MUTEX_LOCK(my_mutex); |
112 |
diff -r 13411144d46b -r f4c9545cd8a5 src/share/back/log_messages.h |
113 |
--- openjdk/jdk/src/share/back/log_messages.h Wed Jun 18 03:29:58 2014 -0700 |
114 |
+++ openjdk/jdk/src/share/back/log_messages.h Thu Aug 28 05:20:02 2014 -0700 |
115 |
@@ -29,7 +29,7 @@ |
116 |
/* LOG: Must be called like: LOG_category(("anything")) or LOG_category((format,args)) */ |
117 |
|
118 |
void setup_logging(const char *, unsigned); |
119 |
-void finish_logging(int); |
120 |
+void finish_logging(); |
121 |
|
122 |
#define LOG_NULL ((void)0) |
123 |
|