1077 report_and_die(message, "%s", "");
1078 }
1079
1080 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, const char* message,
1081 const char* detail_fmt, va_list detail_args)
1082 {
1083 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, 0);
1084 }
1085
1086 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
1087 VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
1088 report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
1089 }
1090
1091 void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
1092 Thread* thread, address pc, void* siginfo, void* context, const char* filename,
1093 int lineno, size_t size)
1094 {
1095 // Don't allocate large buffer on stack
1096 static char buffer[O_BUFLEN];
1097
1098 // How many errors occurred in error handler when reporting first_error.
1099 static int recursive_error_count;
1100
1101 // We will first print a brief message to standard out (verbose = false),
1102 // then save detailed information in log file (verbose = true).
1103 static bool out_done = false; // done printing to standard out
1104 static bool log_done = false; // done saving error log
1105 static bool transmit_report_done = false; // done error reporting
1106
1107 if (SuppressFatalErrorMessage) {
1108 os::abort(CreateCoredumpOnCrash);
1109 }
1110 intptr_t mytid = os::current_thread_id();
1111 if (first_error_tid == -1 &&
1112 Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) {
1113
1114 _id = id;
1115 _message = message;
1116 _thread = thread;
1163 os::die();
1164 }
1165
1166 jio_snprintf(buffer, sizeof(buffer),
1167 "[error occurred during error reporting %s, id 0x%x]",
1168 _current_step_info, _id);
1169 if (log.is_open()) {
1170 log.cr();
1171 log.print_raw_cr(buffer);
1172 log.cr();
1173 } else {
1174 out.cr();
1175 out.print_raw_cr(buffer);
1176 out.cr();
1177 }
1178 }
1179 }
1180
1181 // print to screen
1182 if (!out_done) {
1183 staticBufferStream sbs(buffer, sizeof(buffer), &out);
1184 report(&sbs, false);
1185
1186 out_done = true;
1187
1188 _current_step = 0;
1189 _current_step_info = "";
1190 }
1191
1192 // print to error log file
1193 if (!log_done) {
1194 // see if log file is already open
1195 if (!log.is_open()) {
1196 // open log file
1197 int fd = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer));
1198 if (fd != -1) {
1199 out.print_raw("# An error report file with more information is saved as:\n# ");
1200 out.print_raw_cr(buffer);
1201
1202 log.set_fd(fd);
1203 } else {
1204 out.print_raw_cr("# Can not save log file, dump to screen..");
1205 log.set_fd(defaultStream::output_fd());
1206 /* Error reporting currently needs dumpfile.
1207 * Maybe implement direct streaming in the future.*/
1208 transmit_report_done = true;
1209 }
1210 }
1211
1212 staticBufferStream sbs(buffer, O_BUFLEN, &log);
1213 report(&sbs, true);
1214 _current_step = 0;
1215 _current_step_info = "";
1216
1217 // Run error reporting to determine whether or not to report the crash.
1218 if (!transmit_report_done && should_report_bug(_id)) {
1219 transmit_report_done = true;
1220 const int fd2 = ::dup(log.fd());
1221 FILE* const hs_err = ::fdopen(fd2, "r");
1222 if (NULL != hs_err) {
1223 ErrorReporter er;
1224 er.call(hs_err, buffer, O_BUFLEN);
1225 }
1226 ::fclose(hs_err);
1227 }
1228
1229 if (log.fd() != defaultStream::output_fd()) {
1230 close(log.fd());
1231 }
1232
1233 log.set_fd(-1);
|
1077 report_and_die(message, "%s", "");
1078 }
1079
1080 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, const char* message,
1081 const char* detail_fmt, va_list detail_args)
1082 {
1083 report_and_die(INTERNAL_ERROR, message, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, 0);
1084 }
1085
1086 void VMError::report_and_die(Thread* thread, const char* filename, int lineno, size_t size,
1087 VMErrorType vm_err_type, const char* detail_fmt, va_list detail_args) {
1088 report_and_die(vm_err_type, NULL, detail_fmt, detail_args, thread, NULL, NULL, NULL, filename, lineno, size);
1089 }
1090
1091 void VMError::report_and_die(int id, const char* message, const char* detail_fmt, va_list detail_args,
1092 Thread* thread, address pc, void* siginfo, void* context, const char* filename,
1093 int lineno, size_t size)
1094 {
1095 // Don't allocate large buffer on stack
1096 static char buffer[O_BUFLEN];
1097 out.set_scratch_buffer(buffer, sizeof(buffer));
1098 log.set_scratch_buffer(buffer, sizeof(buffer));
1099
1100 // How many errors occurred in error handler when reporting first_error.
1101 static int recursive_error_count;
1102
1103 // We will first print a brief message to standard out (verbose = false),
1104 // then save detailed information in log file (verbose = true).
1105 static bool out_done = false; // done printing to standard out
1106 static bool log_done = false; // done saving error log
1107 static bool transmit_report_done = false; // done error reporting
1108
1109 if (SuppressFatalErrorMessage) {
1110 os::abort(CreateCoredumpOnCrash);
1111 }
1112 intptr_t mytid = os::current_thread_id();
1113 if (first_error_tid == -1 &&
1114 Atomic::cmpxchg_ptr(mytid, &first_error_tid, -1) == -1) {
1115
1116 _id = id;
1117 _message = message;
1118 _thread = thread;
1165 os::die();
1166 }
1167
1168 jio_snprintf(buffer, sizeof(buffer),
1169 "[error occurred during error reporting %s, id 0x%x]",
1170 _current_step_info, _id);
1171 if (log.is_open()) {
1172 log.cr();
1173 log.print_raw_cr(buffer);
1174 log.cr();
1175 } else {
1176 out.cr();
1177 out.print_raw_cr(buffer);
1178 out.cr();
1179 }
1180 }
1181 }
1182
1183 // print to screen
1184 if (!out_done) {
1185 report(&out, false);
1186
1187 out_done = true;
1188
1189 _current_step = 0;
1190 _current_step_info = "";
1191 }
1192
1193 // print to error log file
1194 if (!log_done) {
1195 // see if log file is already open
1196 if (!log.is_open()) {
1197 // open log file
1198 int fd = prepare_log_file(ErrorFile, "hs_err_pid%p.log", buffer, sizeof(buffer));
1199 if (fd != -1) {
1200 out.print_raw("# An error report file with more information is saved as:\n# ");
1201 out.print_raw_cr(buffer);
1202
1203 log.set_fd(fd);
1204 } else {
1205 out.print_raw_cr("# Can not save log file, dump to screen..");
1206 log.set_fd(defaultStream::output_fd());
1207 /* Error reporting currently needs dumpfile.
1208 * Maybe implement direct streaming in the future.*/
1209 transmit_report_done = true;
1210 }
1211 }
1212
1213 report(&log, true);
1214 _current_step = 0;
1215 _current_step_info = "";
1216
1217 // Run error reporting to determine whether or not to report the crash.
1218 if (!transmit_report_done && should_report_bug(_id)) {
1219 transmit_report_done = true;
1220 const int fd2 = ::dup(log.fd());
1221 FILE* const hs_err = ::fdopen(fd2, "r");
1222 if (NULL != hs_err) {
1223 ErrorReporter er;
1224 er.call(hs_err, buffer, O_BUFLEN);
1225 }
1226 ::fclose(hs_err);
1227 }
1228
1229 if (log.fd() != defaultStream::output_fd()) {
1230 close(log.fd());
1231 }
1232
1233 log.set_fd(-1);
|