131 const char *url = Arguments::java_vendor_url_bug(); 132 if (url == NULL || *url == '\0') 133 url = JDK_Version::runtime_vendor_vm_bug_url(); 134 if (url != NULL && *url != '\0') { 135 out->print_raw_cr("# If you would like to submit a bug report, please visit:"); 136 out->print_raw ("# "); 137 out->print_raw_cr(url); 138 } 139 // If the crash is in native code, encourage user to submit a bug to the 140 // provider of that code. 141 if (thread && thread->is_Java_thread() && 142 !thread->is_hidden_from_external_view()) { 143 JavaThread* jt = (JavaThread*)thread; 144 if (jt->thread_state() == _thread_in_native) { 145 out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug."); 146 } 147 } 148 out->print_raw_cr("#"); 149 } 150 151 bool VMError::coredump_status; 152 char VMError::coredump_message[O_BUFLEN]; 153 154 void VMError::record_coredump_status(const char* message, bool status) { 155 coredump_status = status; 156 strncpy(coredump_message, message, sizeof(coredump_message)); 157 coredump_message[sizeof(coredump_message)-1] = 0; 158 } 159 160 // Return a string to describe the error 161 char* VMError::error_string(char* buf, int buflen) { 162 char signame_buf[64]; 163 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf)); 164 165 if (signame) { 166 jio_snprintf(buf, buflen, 167 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, 168 signame, _id, _pc, 169 os::current_process_id(), os::current_thread_id()); 170 } else if (_filename != NULL && _lineno > 0) { 601 frame fr = os::fetch_frame_from_context(_context); 602 fr.print_on_error(st, buf, sizeof(buf)); 603 st->cr(); 604 st->print_cr("#"); 605 } 606 607 STEP("printing core file information") 608 st->print("# "); 609 if (CreateCoredumpOnCrash) { 610 if (coredump_status) { 611 st->print("Core dump will be written. Default location: %s", coredump_message); 612 } else { 613 st->print("No core dump will be written. %s", coredump_message); 614 } 615 } else { 616 st->print("CreateCoredumpOnCrash turned off, no core file dumped"); 617 } 618 st->cr(); 619 st->print_cr("#"); 620 621 STEP("printing bug submit message") 622 623 if (should_report_bug(_id) && _verbose) { 624 print_bug_submit_message(st, _thread); 625 } 626 627 STEP("printing summary") 628 629 if (_verbose) { 630 st->cr(); 631 st->print_cr("--------------- S U M M A R Y ------------"); 632 st->cr(); 633 } 634 635 STEP("printing VM option summary") 636 637 if (_verbose) { 638 // VM options 639 Arguments::print_summary_on(st); 640 st->cr(); 1519 out.print_raw_cr(buffer); 1520 } else { 1521 out.print_raw_cr("# Can not save log file, dump to screen.."); 1522 fd_log = 1; 1523 } 1524 } 1525 log.set_fd(fd_log); 1526 } 1527 1528 report(&log, true); 1529 log_done = true; 1530 _current_step = 0; 1531 _current_step_info = ""; 1532 1533 if (fd_log > 3) { 1534 close(fd_log); 1535 fd_log = -1; 1536 } 1537 1538 log.set_fd(-1); 1539 } 1540 1541 if (PrintNMTStatistics) { 1542 fdStream fds(fd_out); 1543 MemTracker::final_report(&fds); 1544 } 1545 1546 static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay 1547 if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { 1548 skip_replay = true; 1549 ciEnv* env = ciEnv::current(); 1550 if (env != NULL) { 1551 const bool overwrite = false; // We do not overwrite an existing replay file. 1552 int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer)); 1553 if (fd != -1) { 1554 FILE* replay_data_file = os::open(fd, "w"); 1555 if (replay_data_file != NULL) { 1556 fileStream replay_data_stream(replay_data_file, /*need_close=*/true); 1557 env->dump_replay_data_unsafe(&replay_data_stream); 1558 out.print_raw("#\n# Compiler replay data is saved as:\n# "); 1559 out.print_raw_cr(buffer); 1560 } else { 1561 int e = errno; 1562 out.print_raw("#\n# Can't open file to dump replay data. Error: "); 1563 out.print_raw_cr(os::strerror(e)); 1564 } 1565 } 1566 } 1567 } 1568 1569 static bool skip_bug_url = !should_report_bug(_id); 1570 if (!skip_bug_url) { 1571 skip_bug_url = true; 1572 1573 out.print_raw_cr("#"); 1574 print_bug_submit_message(&out, _thread); 1575 } 1576 1577 static bool skip_OnError = false; 1578 if (!skip_OnError && OnError && OnError[0]) { 1579 skip_OnError = true; 1580 1581 // Flush output and finish logs before running OnError commands. 1582 ostream_abort(); 1583 1584 out.print_raw_cr("#"); 1585 out.print_raw ("# -XX:OnError=\""); 1586 out.print_raw (OnError); 1587 out.print_raw_cr("\""); 1588 1589 char* cmd; 1590 const char* ptr = OnError; 1591 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1592 out.print_raw ("# Executing "); 1593 #if defined(LINUX) || defined(_ALLBSD_SOURCE) | 131 const char *url = Arguments::java_vendor_url_bug(); 132 if (url == NULL || *url == '\0') 133 url = JDK_Version::runtime_vendor_vm_bug_url(); 134 if (url != NULL && *url != '\0') { 135 out->print_raw_cr("# If you would like to submit a bug report, please visit:"); 136 out->print_raw ("# "); 137 out->print_raw_cr(url); 138 } 139 // If the crash is in native code, encourage user to submit a bug to the 140 // provider of that code. 141 if (thread && thread->is_Java_thread() && 142 !thread->is_hidden_from_external_view()) { 143 JavaThread* jt = (JavaThread*)thread; 144 if (jt->thread_state() == _thread_in_native) { 145 out->print_cr("# The crash happened outside the Java Virtual Machine in native code.\n# See problematic frame for where to report the bug."); 146 } 147 } 148 out->print_raw_cr("#"); 149 } 150 151 #if INCLUDE_JFR 152 static void print_jfr_path(outputStream *out) { 153 if (out == NULL) { 154 return; 155 } 156 157 const char *path = Jfr::get_emergency_dump_path(); 158 if (*path != '\0') { 159 out->print_raw_cr("# JFR data is saved as:"); 160 out->print_raw ("# "); 161 out->print_raw_cr(path); 162 out->print_raw_cr("#"); 163 } else { 164 path = Jfr::get_repository_path(); 165 if ((path != NULL) && (*path != '\0')) { 166 out->print_raw_cr("# JFR files might be saved in the repository:"); 167 out->print_raw ("# "); 168 out->print_raw_cr(path); 169 out->print_raw_cr("#"); 170 } 171 } 172 } 173 #endif 174 175 bool VMError::coredump_status; 176 char VMError::coredump_message[O_BUFLEN]; 177 178 void VMError::record_coredump_status(const char* message, bool status) { 179 coredump_status = status; 180 strncpy(coredump_message, message, sizeof(coredump_message)); 181 coredump_message[sizeof(coredump_message)-1] = 0; 182 } 183 184 // Return a string to describe the error 185 char* VMError::error_string(char* buf, int buflen) { 186 char signame_buf[64]; 187 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf)); 188 189 if (signame) { 190 jio_snprintf(buf, buflen, 191 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, 192 signame, _id, _pc, 193 os::current_process_id(), os::current_thread_id()); 194 } else if (_filename != NULL && _lineno > 0) { 625 frame fr = os::fetch_frame_from_context(_context); 626 fr.print_on_error(st, buf, sizeof(buf)); 627 st->cr(); 628 st->print_cr("#"); 629 } 630 631 STEP("printing core file information") 632 st->print("# "); 633 if (CreateCoredumpOnCrash) { 634 if (coredump_status) { 635 st->print("Core dump will be written. Default location: %s", coredump_message); 636 } else { 637 st->print("No core dump will be written. %s", coredump_message); 638 } 639 } else { 640 st->print("CreateCoredumpOnCrash turned off, no core file dumped"); 641 } 642 st->cr(); 643 st->print_cr("#"); 644 645 #if INCLUDE_JFR 646 STEP("printing jfr repository") 647 648 if (_verbose) { 649 print_jfr_path(st); 650 } 651 #endif 652 653 STEP("printing bug submit message") 654 655 if (should_report_bug(_id) && _verbose) { 656 print_bug_submit_message(st, _thread); 657 } 658 659 STEP("printing summary") 660 661 if (_verbose) { 662 st->cr(); 663 st->print_cr("--------------- S U M M A R Y ------------"); 664 st->cr(); 665 } 666 667 STEP("printing VM option summary") 668 669 if (_verbose) { 670 // VM options 671 Arguments::print_summary_on(st); 672 st->cr(); 1551 out.print_raw_cr(buffer); 1552 } else { 1553 out.print_raw_cr("# Can not save log file, dump to screen.."); 1554 fd_log = 1; 1555 } 1556 } 1557 log.set_fd(fd_log); 1558 } 1559 1560 report(&log, true); 1561 log_done = true; 1562 _current_step = 0; 1563 _current_step_info = ""; 1564 1565 if (fd_log > 3) { 1566 close(fd_log); 1567 fd_log = -1; 1568 } 1569 1570 log.set_fd(-1); 1571 out.print_raw_cr("#"); 1572 } 1573 1574 if (PrintNMTStatistics) { 1575 fdStream fds(fd_out); 1576 MemTracker::final_report(&fds); 1577 } 1578 1579 static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay 1580 if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { 1581 skip_replay = true; 1582 ciEnv* env = ciEnv::current(); 1583 if (env != NULL) { 1584 const bool overwrite = false; // We do not overwrite an existing replay file. 1585 int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer)); 1586 if (fd != -1) { 1587 FILE* replay_data_file = os::open(fd, "w"); 1588 if (replay_data_file != NULL) { 1589 fileStream replay_data_stream(replay_data_file, /*need_close=*/true); 1590 env->dump_replay_data_unsafe(&replay_data_stream); 1591 out.print_raw("#\n# Compiler replay data is saved as:\n# "); 1592 out.print_raw_cr(buffer); 1593 } else { 1594 int e = errno; 1595 out.print_raw("#\n# Can't open file to dump replay data. Error: "); 1596 out.print_raw_cr(os::strerror(e)); 1597 } 1598 out.print_raw_cr("#"); 1599 } 1600 } 1601 } 1602 1603 #if INCLUDE_JFR 1604 static bool skip_jfr_repository = false; 1605 if (!skip_jfr_repository) { 1606 skip_jfr_repository = true; 1607 print_jfr_path(&out); 1608 out.print_raw_cr("#"); 1609 } 1610 #endif 1611 1612 static bool skip_bug_url = !should_report_bug(_id); 1613 if (!skip_bug_url) { 1614 skip_bug_url = true; 1615 print_bug_submit_message(&out, _thread); 1616 } 1617 1618 static bool skip_OnError = false; 1619 if (!skip_OnError && OnError && OnError[0]) { 1620 skip_OnError = true; 1621 1622 // Flush output and finish logs before running OnError commands. 1623 ostream_abort(); 1624 1625 out.print_raw_cr("#"); 1626 out.print_raw ("# -XX:OnError=\""); 1627 out.print_raw (OnError); 1628 out.print_raw_cr("\""); 1629 1630 char* cmd; 1631 const char* ptr = OnError; 1632 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1633 out.print_raw ("# Executing "); 1634 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |