< prev index next >

src/hotspot/share/jfr/recorder/repository/jfrEmergencyDump.cpp

Print this page

        

*** 44,53 **** --- 44,55 ---- static const char vm_oom_filename_fmt[] = "hs_oom_pid%p.jfr"; static const char vm_soe_filename_fmt[] = "hs_soe_pid%p.jfr"; static const char chunk_file_jfr_ext[] = ".jfr"; static const size_t iso8601_len = 19; // "YYYY-MM-DDTHH:MM:SS" + char JfrEmergencyDump::_dump_path[JVM_MAXPATHLEN] = {0}; + static fio_fd open_exclusivly(const char* path) { return os::open(path, O_CREAT | O_RDWR, S_IREAD | S_IWRITE); } static int file_sort(const char** const file1, const char** file2) {
*** 245,265 **** } } } } ! static const char* create_emergency_dump_path() { ! char* buffer = NEW_RESOURCE_ARRAY_RETURN_NULL(char, JVM_MAXPATHLEN); ! if (NULL == buffer) { ! return NULL; } ! const char* const cwd = os::get_current_directory(buffer, JVM_MAXPATHLEN); if (NULL == cwd) { return NULL; } size_t pos = strlen(cwd); ! const int fsep_len = jio_snprintf(&buffer[pos], JVM_MAXPATHLEN - pos, "%s", os::file_separator()); const char* filename_fmt = NULL; // fetch specific error cause switch (JfrJavaSupport::cause()) { case JfrJavaSupport::OUT_OF_MEMORY: filename_fmt = vm_oom_filename_fmt; --- 247,267 ---- } } } } ! const char* JfrEmergencyDump::create_emergency_dump_path() { ! if (*_dump_path != '\0') { ! return _dump_path; } ! ! const char* const cwd = os::get_current_directory(_dump_path, JVM_MAXPATHLEN); if (NULL == cwd) { return NULL; } size_t pos = strlen(cwd); ! const int fsep_len = jio_snprintf(&_dump_path[pos], JVM_MAXPATHLEN - pos, "%s", os::file_separator()); const char* filename_fmt = NULL; // fetch specific error cause switch (JfrJavaSupport::cause()) { case JfrJavaSupport::OUT_OF_MEMORY: filename_fmt = vm_oom_filename_fmt;
*** 268,317 **** filename_fmt = vm_soe_filename_fmt; break; default: filename_fmt = vm_error_filename_fmt; } - char* emergency_dump_path = NULL; pos += fsep_len; ! if (Arguments::copy_expand_pid(filename_fmt, strlen(filename_fmt), &buffer[pos], JVM_MAXPATHLEN - pos)) { ! const size_t emergency_filename_length = strlen(buffer); ! emergency_dump_path = NEW_RESOURCE_ARRAY_RETURN_NULL(char, emergency_filename_length + 1); ! if (NULL == emergency_dump_path) { ! return NULL; ! } ! strncpy(emergency_dump_path, buffer, emergency_filename_length + 1); ! } ! if (emergency_dump_path != NULL) { log_info(jfr)( // For user, should not be "jfr, system" ! "Attempting to recover JFR data, emergency jfr file: %s", emergency_dump_path); } ! return emergency_dump_path; } // Caller needs ResourceMark ! static const char* create_emergency_chunk_path(const char* repository_path) { assert(repository_path != NULL, "invariant"); const size_t repository_path_len = strlen(repository_path); // date time char date_time_buffer[32] = { 0 }; date_time(date_time_buffer, sizeof(date_time_buffer)); size_t date_time_len = strlen(date_time_buffer); size_t chunkname_max_len = repository_path_len // repository_base_path + 1 // "/" + date_time_len // date_time + strlen(chunk_file_jfr_ext) // .jfr + 1; - char* chunk_path = NEW_RESOURCE_ARRAY_RETURN_NULL(char, chunkname_max_len); - if (chunk_path == NULL) { - return NULL; - } // append the individual substrings ! jio_snprintf(chunk_path, chunkname_max_len, "%s%s%s%s", repository_path, os::file_separator(), date_time_buffer, chunk_file_jfr_ext); ! return chunk_path; } ! static fio_fd emergency_dump_file_descriptor() { ResourceMark rm; const char* const emergency_dump_path = create_emergency_dump_path(); return emergency_dump_path != NULL ? open_exclusivly(emergency_dump_path) : invalid_fd; } --- 270,312 ---- filename_fmt = vm_soe_filename_fmt; break; default: filename_fmt = vm_error_filename_fmt; } pos += fsep_len; ! Arguments::copy_expand_pid(filename_fmt, strlen(filename_fmt), &_dump_path[pos], JVM_MAXPATHLEN - pos); ! if (*_dump_path != '\0') { log_info(jfr)( // For user, should not be "jfr, system" ! "Attempting to recover JFR data, emergency jfr file: %s", _dump_path); } ! return _dump_path; } // Caller needs ResourceMark ! const char* JfrEmergencyDump::create_emergency_chunk_path(const char* repository_path) { assert(repository_path != NULL, "invariant"); + + if (*_dump_path != '\0') { + return _dump_path; + } + const size_t repository_path_len = strlen(repository_path); // date time char date_time_buffer[32] = { 0 }; date_time(date_time_buffer, sizeof(date_time_buffer)); size_t date_time_len = strlen(date_time_buffer); size_t chunkname_max_len = repository_path_len // repository_base_path + 1 // "/" + date_time_len // date_time + strlen(chunk_file_jfr_ext) // .jfr + 1; // append the individual substrings ! jio_snprintf(_dump_path, chunkname_max_len, "%s%s%s%s", repository_path, os::file_separator(), date_time_buffer, chunk_file_jfr_ext); ! return _dump_path; } ! fio_fd JfrEmergencyDump::emergency_dump_file_descriptor() { ResourceMark rm; const char* const emergency_dump_path = create_emergency_dump_path(); return emergency_dump_path != NULL ? open_exclusivly(emergency_dump_path) : invalid_fd; }
< prev index next >