996 char buf[80];
997 *answer = JNI_FALSE;
998 /*LINTED*/
999 if (get_tok(pstr, buf, (int)sizeof(buf), ',')) {
1000 if (strcmp(buf, "y") == 0) {
1001 *answer = JNI_TRUE;
1002 return JNI_TRUE;
1003 } else if (strcmp(buf, "n") == 0) {
1004 *answer = JNI_FALSE;
1005 return JNI_TRUE;
1006 }
1007 }
1008 return JNI_FALSE;
1009 }
1010
1011 /* atexit() callback */
1012 static void
1013 atexit_finish_logging(void)
1014 {
1015 /* Normal exit(0) (not _exit()) may only reach here */
1016 finish_logging(0); /* Only first call matters */
1017 }
1018
1019 static jboolean
1020 parseOptions(char *options)
1021 {
1022 TransportSpec *currentTransport = NULL;
1023 char *end;
1024 char *current;
1025 int length;
1026 char *str;
1027 char *errmsg;
1028
1029 /* Set defaults */
1030 gdata->assertOn = DEFAULT_ASSERT_ON;
1031 gdata->assertFatal = DEFAULT_ASSERT_FATAL;
1032 logfile = DEFAULT_LOGFILE;
1033
1034 /* Options being NULL will end up being an error. */
1035 if (options == NULL) {
1036 options = "";
1284
1285 return JNI_TRUE;
1286
1287 syntax_error:
1288 ERROR_MESSAGE(("JDWP option syntax error: %s=%s", AGENTLIB, options));
1289 return JNI_FALSE;
1290
1291 bad_option_with_errmsg:
1292 ERROR_MESSAGE(("JDWP %s: %s=%s", errmsg, AGENTLIB, options));
1293 return JNI_FALSE;
1294
1295 bad_option_no_msg:
1296 ERROR_MESSAGE(("JDWP %s: %s=%s", "invalid option", AGENTLIB, options));
1297 return JNI_FALSE;
1298 }
1299
1300 /* All normal exit doors lead here */
1301 void
1302 debugInit_exit(jvmtiError error, const char *msg)
1303 {
1304 int exit_code = 0;
1305
1306 /* Pick an error code */
1307 if ( error != JVMTI_ERROR_NONE ) {
1308 exit_code = 1;
1309 if ( docoredump ) {
1310 LOG_MISC(("Dumping core as requested by command line"));
1311 finish_logging(exit_code);
1312 abort();
1313 }
1314 }
1315
1316 if ( msg==NULL ) {
1317 msg = "";
1318 }
1319
1320 LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error, msg));
1321
1322 if (gdata != NULL) {
1323 gdata->vmDead = JNI_TRUE;
1324
1325 /* Let's try and cleanup the JVMTI, if we even have one */
1326 if ( gdata->jvmti != NULL ) {
1327 /* Dispose of jvmti (gdata->jvmti becomes NULL) */
1328 disposeEnvironment(gdata->jvmti);
1329 }
1330 }
1331
1332 /* Finish up logging. We reach here if JDWP is doing the exiting. */
1333 finish_logging(exit_code); /* Only first call matters */
1334
1335 /* Let's give the JNI a FatalError if non-exit 0, which is historic way */
1336 if ( exit_code != 0 ) {
1337 JNIEnv *env = NULL;
1338 jniFatalError(env, msg, error, exit_code);
1339 }
1340
1341 /* Last chance to die, this kills the entire process. */
1342 forceExit(exit_code);
1343 }
|
996 char buf[80];
997 *answer = JNI_FALSE;
998 /*LINTED*/
999 if (get_tok(pstr, buf, (int)sizeof(buf), ',')) {
1000 if (strcmp(buf, "y") == 0) {
1001 *answer = JNI_TRUE;
1002 return JNI_TRUE;
1003 } else if (strcmp(buf, "n") == 0) {
1004 *answer = JNI_FALSE;
1005 return JNI_TRUE;
1006 }
1007 }
1008 return JNI_FALSE;
1009 }
1010
1011 /* atexit() callback */
1012 static void
1013 atexit_finish_logging(void)
1014 {
1015 /* Normal exit(0) (not _exit()) may only reach here */
1016 finish_logging(); /* Only first call matters */
1017 }
1018
1019 static jboolean
1020 parseOptions(char *options)
1021 {
1022 TransportSpec *currentTransport = NULL;
1023 char *end;
1024 char *current;
1025 int length;
1026 char *str;
1027 char *errmsg;
1028
1029 /* Set defaults */
1030 gdata->assertOn = DEFAULT_ASSERT_ON;
1031 gdata->assertFatal = DEFAULT_ASSERT_FATAL;
1032 logfile = DEFAULT_LOGFILE;
1033
1034 /* Options being NULL will end up being an error. */
1035 if (options == NULL) {
1036 options = "";
1284
1285 return JNI_TRUE;
1286
1287 syntax_error:
1288 ERROR_MESSAGE(("JDWP option syntax error: %s=%s", AGENTLIB, options));
1289 return JNI_FALSE;
1290
1291 bad_option_with_errmsg:
1292 ERROR_MESSAGE(("JDWP %s: %s=%s", errmsg, AGENTLIB, options));
1293 return JNI_FALSE;
1294
1295 bad_option_no_msg:
1296 ERROR_MESSAGE(("JDWP %s: %s=%s", "invalid option", AGENTLIB, options));
1297 return JNI_FALSE;
1298 }
1299
1300 /* All normal exit doors lead here */
1301 void
1302 debugInit_exit(jvmtiError error, const char *msg)
1303 {
1304 enum exit_codes { EXIT_NO_ERRORS = 0, EXIT_JVMTI_ERROR = 1, EXIT_TRANSPORT_ERROR = 2 };
1305
1306 // Prepare to exit. Log error and finish logging
1307 LOG_MISC(("Exiting with error %s(%d): %s", jvmtiErrorText(error), error,
1308 ((msg == NULL) ? "" : msg)));
1309
1310 // coredump requested by command line. Keep JVMTI data dirty
1311 if (error != JVMTI_ERROR_NONE && docoredump) {
1312 LOG_MISC(("Dumping core as requested by command line"));
1313 finish_logging();
1314 abort();
1315 }
1316
1317 finish_logging();
1318
1319 // Cleanup the JVMTI if we have one
1320 if (gdata != NULL) {
1321 gdata->vmDead = JNI_TRUE;
1322 if (gdata->jvmti != NULL) {
1323 // Dispose of jvmti (gdata->jvmti becomes NULL)
1324 disposeEnvironment(gdata->jvmti);
1325 }
1326 }
1327
1328 // We are here with no errors. Kill entire process and exit with zero exit code
1329 if (error == JVMTI_ERROR_NONE) {
1330 forceExit(EXIT_NO_ERRORS);
1331 return;
1332 }
1333
1334 // No transport initilized.
1335 // As we don't have any details here exiting with separate exit code
1336 if (error == AGENT_ERROR_TRANSPORT_INIT) {
1337 forceExit(EXIT_TRANSPORT_ERROR);
1338 return;
1339 }
1340
1341 // We have JVMTI error. Call hotspot jni_FatalError handler
1342 jniFatalError(NULL, msg, error, EXIT_JVMTI_ERROR);
1343
1344 // hotspot calls os:abort() so we should never reach code below,
1345 // but guard against possible hotspot changes
1346
1347 // Last chance to die, this kills the entire process.
1348 forceExit(EXIT_JVMTI_ERROR);
1349 }
|