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 = NULL; 158 159 path = Jfr::get_emergency_dump_path(); 160 if (*path != '\0') { 161 out->print_raw_cr("# JFR data is saved as:"); 162 out->print_raw ("# "); 163 out->print_raw_cr(path); 164 out->print_raw_cr("#"); 165 } else { 166 path = Jfr::get_repository_path(); 167 if ((path != NULL) && (*path != '\0')) { 168 out->print_raw_cr("# JFR files might be saved in the repository:"); 169 out->print_raw ("# "); 170 out->print_raw_cr(path); 171 out->print_raw_cr("#"); 172 } 173 } 174 } 175 #endif 176 177 bool VMError::coredump_status; 178 char VMError::coredump_message[O_BUFLEN]; 179 180 void VMError::record_coredump_status(const char* message, bool status) { 181 coredump_status = status; 182 strncpy(coredump_message, message, sizeof(coredump_message)); 183 coredump_message[sizeof(coredump_message)-1] = 0; 184 } 185 186 // Return a string to describe the error 187 char* VMError::error_string(char* buf, int buflen) { 188 char signame_buf[64]; 189 const char *signame = os::exception_name(_id, signame_buf, sizeof(signame_buf)); 190 191 if (signame) { 192 jio_snprintf(buf, buflen, 193 "%s (0x%x) at pc=" PTR_FORMAT ", pid=%d, tid=" UINTX_FORMAT, 194 signame, _id, _pc, 195 os::current_process_id(), os::current_thread_id()); 196 } else if (_filename != NULL && _lineno > 0) { 627 frame fr = os::fetch_frame_from_context(_context); 628 fr.print_on_error(st, buf, sizeof(buf)); 629 st->cr(); 630 st->print_cr("#"); 631 } 632 633 STEP("printing core file information") 634 st->print("# "); 635 if (CreateCoredumpOnCrash) { 636 if (coredump_status) { 637 st->print("Core dump will be written. Default location: %s", coredump_message); 638 } else { 639 st->print("No core dump will be written. %s", coredump_message); 640 } 641 } else { 642 st->print("CreateCoredumpOnCrash turned off, no core file dumped"); 643 } 644 st->cr(); 645 st->print_cr("#"); 646 647 #if INCLUDE_JFR 648 STEP("printing jfr repository") 649 650 if (_verbose) { 651 print_jfr_path(st); 652 } 653 #endif 654 655 STEP("printing bug submit message") 656 657 if (should_report_bug(_id) && _verbose) { 658 print_bug_submit_message(st, _thread); 659 } 660 661 STEP("printing summary") 662 663 if (_verbose) { 664 st->cr(); 665 st->print_cr("--------------- S U M M A R Y ------------"); 666 st->cr(); 667 } 668 669 STEP("printing VM option summary") 670 671 if (_verbose) { 672 // VM options 673 Arguments::print_summary_on(st); 674 st->cr(); 1553 out.print_raw_cr(buffer); 1554 } else { 1555 out.print_raw_cr("# Can not save log file, dump to screen.."); 1556 fd_log = 1; 1557 } 1558 } 1559 log.set_fd(fd_log); 1560 } 1561 1562 report(&log, true); 1563 log_done = true; 1564 _current_step = 0; 1565 _current_step_info = ""; 1566 1567 if (fd_log > 3) { 1568 close(fd_log); 1569 fd_log = -1; 1570 } 1571 1572 log.set_fd(-1); 1573 out.print_raw_cr("#"); 1574 } 1575 1576 if (PrintNMTStatistics) { 1577 fdStream fds(fd_out); 1578 MemTracker::final_report(&fds); 1579 } 1580 1581 static bool skip_replay = ReplayCompiles; // Do not overwrite file during replay 1582 if (DumpReplayDataOnError && _thread && _thread->is_Compiler_thread() && !skip_replay) { 1583 skip_replay = true; 1584 ciEnv* env = ciEnv::current(); 1585 if (env != NULL) { 1586 const bool overwrite = false; // We do not overwrite an existing replay file. 1587 int fd = prepare_log_file(ReplayDataFile, "replay_pid%p.log", overwrite, buffer, sizeof(buffer)); 1588 if (fd != -1) { 1589 FILE* replay_data_file = os::open(fd, "w"); 1590 if (replay_data_file != NULL) { 1591 fileStream replay_data_stream(replay_data_file, /*need_close=*/true); 1592 env->dump_replay_data_unsafe(&replay_data_stream); 1593 out.print_raw("#\n# Compiler replay data is saved as:\n# "); 1594 out.print_raw_cr(buffer); 1595 } else { 1596 int e = errno; 1597 out.print_raw("#\n# Can't open file to dump replay data. Error: "); 1598 out.print_raw_cr(os::strerror(e)); 1599 } 1600 out.print_raw_cr("#"); 1601 } 1602 } 1603 } 1604 1605 #if INCLUDE_JFR 1606 static bool skip_jfr_repository = false; 1607 if (!skip_jfr_repository) { 1608 skip_jfr_repository = true; 1609 print_jfr_path(&out); 1610 out.print_raw_cr("#"); 1611 } 1612 #endif 1613 1614 static bool skip_bug_url = !should_report_bug(_id); 1615 if (!skip_bug_url) { 1616 skip_bug_url = true; 1617 print_bug_submit_message(&out, _thread); 1618 } 1619 1620 static bool skip_OnError = false; 1621 if (!skip_OnError && OnError && OnError[0]) { 1622 skip_OnError = true; 1623 1624 // Flush output and finish logs before running OnError commands. 1625 ostream_abort(); 1626 1627 out.print_raw_cr("#"); 1628 out.print_raw ("# -XX:OnError=\""); 1629 out.print_raw (OnError); 1630 out.print_raw_cr("\""); 1631 1632 char* cmd; 1633 const char* ptr = OnError; 1634 while ((cmd = next_OnError_command(buffer, sizeof(buffer), &ptr)) != NULL){ 1635 out.print_raw ("# Executing "); 1636 #if defined(LINUX) || defined(_ALLBSD_SOURCE) |