1.1 --- a/src/share/vm/utilities/vmError.cpp Thu Feb 03 20:30:19 2011 -0800 1.2 +++ b/src/share/vm/utilities/vmError.cpp Tue Feb 08 17:20:45 2011 -0500 1.3 @@ -35,6 +35,7 @@ 1.4 #include "utilities/debug.hpp" 1.5 #include "utilities/decoder.hpp" 1.6 #include "utilities/defaultStream.hpp" 1.7 +#include "utilities/errorReporter.hpp" 1.8 #include "utilities/top.hpp" 1.9 #include "utilities/vmError.hpp" 1.10 1.11 @@ -769,6 +770,7 @@ 1.12 // then save detailed information in log file (verbose = true). 1.13 static bool out_done = false; // done printing to standard out 1.14 static bool log_done = false; // done saving error log 1.15 + static bool transmit_report_done = false; // done error reporting 1.16 static fdStream log; // error log 1.17 1.18 if (SuppressFatalErrorMessage) { 1.19 @@ -859,7 +861,7 @@ 1.20 bool copy_ok = 1.21 Arguments::copy_expand_pid(ErrorFile, strlen(ErrorFile), buffer, sizeof(buffer)); 1.22 if (copy_ok) { 1.23 - fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0666); 1.24 + fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); 1.25 } 1.26 } 1.27 1.28 @@ -870,7 +872,7 @@ 1.29 // so use the default name in the current directory 1.30 jio_snprintf(&buffer[len], sizeof(buffer)-len, "%shs_err_pid%u.log", 1.31 os::file_separator(), os::current_process_id()); 1.32 - fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0666); 1.33 + fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); 1.34 } 1.35 1.36 if (fd == -1) { 1.37 @@ -879,7 +881,7 @@ 1.38 if (tmpdir != NULL && tmpdir[0] != '\0') { 1.39 jio_snprintf(buffer, sizeof(buffer), "%s%shs_err_pid%u.log", 1.40 tmpdir, os::file_separator(), os::current_process_id()); 1.41 - fd = open(buffer, O_WRONLY | O_CREAT | O_TRUNC, 0666); 1.42 + fd = open(buffer, O_RDWR | O_CREAT | O_TRUNC, 0666); 1.43 } 1.44 } 1.45 1.46 @@ -892,6 +894,9 @@ 1.47 } else { 1.48 out.print_raw_cr("# Can not save log file, dump to screen.."); 1.49 log.set_fd(defaultStream::output_fd()); 1.50 + /* Error reporting currently needs dumpfile. 1.51 + * Maybe implement direct streaming in the future.*/ 1.52 + transmit_report_done = true; 1.53 } 1.54 } 1.55 1.56 @@ -900,6 +905,16 @@ 1.57 first_error->_current_step = 0; // reset current_step 1.58 first_error->_current_step_info = ""; // reset current_step string 1.59 1.60 + // Run error reporting to determine whether or not to report the crash. 1.61 + if (!transmit_report_done && should_report_bug(first_error->_id)) { 1.62 + transmit_report_done = true; 1.63 + FILE* hs_err = ::fdopen(log.fd(), "r"); 1.64 + if (NULL != hs_err) { 1.65 + ErrorReporter er; 1.66 + er.call(hs_err, buffer, O_BUFLEN); 1.67 + } 1.68 + } 1.69 + 1.70 if (log.fd() != defaultStream::output_fd()) { 1.71 close(log.fd()); 1.72 }