Skip to content

Commit

Permalink
respect ErrorFileToStdout and ErrorFileToStderr flags
Browse files Browse the repository at this point in the history
  • Loading branch information
dougxc committed Jun 29, 2021
1 parent 1720090 commit ba004ef
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 9 deletions.
23 changes: 15 additions & 8 deletions src/hotspot/share/jvmci/jvmci.cpp
Expand Up @@ -220,19 +220,26 @@ void JVMCI::fatal_log(const char* buf, size_t count) {
intx invalid_id = -1;
if (_fatal_log_init_thread == invalid_id && Atomic::cmpxchg(&_fatal_log_init_thread, invalid_id, current_thread_id) == invalid_id) {
static char name_buffer[O_BUFLEN];
int fd = VMError::prepare_log_file(JVMCINativeLibraryErrorFile, LIBJVMCI_ERR_FILE, true, name_buffer, sizeof(name_buffer));
if (fd != -1) {
FILE* fp = os::open(fd, "w");
if (fp != NULL) {
_fatal_log_stream = new fileStream(fp);
static fdStream log(-1);
if (ErrorFileToStdout) {
log.set_fd(1);
} else if (ErrorFileToStderr) {
log.set_fd(2);
} else {
int fd = VMError::prepare_log_file(JVMCINativeLibraryErrorFile, LIBJVMCI_ERR_FILE, true, name_buffer, sizeof(name_buffer));
if (fd != -1) {
_fatal_log_filename = name_buffer;
log.set_fd(fd);
} else {
int e = errno;
tty->print("Can't open file to dump JVMCI shared library crash data. Error: ");
tty->print("Can't open JVMCI shared library error report file. Error: ");
tty->print_raw_cr(os::strerror(e));
tty->print_cr("JVMCI shared library crash data will be written to console.");
_fatal_log_stream = tty;
tty->print_cr("JVMCI shared library error report will be written to console.");

// See notes in VMError::report_and_die about hard coding tty to 1
log.set_fd(1);
}
_fatal_log_stream = &log;
}
} else {
// Another thread won the race to initialize the stream. Give it time
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/share/utilities/vmError.cpp
Expand Up @@ -1589,7 +1589,7 @@ void VMError::report_and_die(int id, const char* message, const char* detail_fmt

#if INCLUDE_JVMCI
if (JVMCI::fatal_log_filename() != NULL) {
out.print_raw("#\n# The JVMCI shared library error data is saved as:\n# ");
out.print_raw("#\n# The JVMCI shared library error report file is saved as:\n# ");
out.print_raw_cr(JVMCI::fatal_log_filename());
}
#endif
Expand Down

0 comments on commit ba004ef

Please sign in to comment.