hotspot/src/share/vm/utilities/ostream.cpp
changeset 26135 82b516c550f7
parent 25715 d5a8dbdc5150
child 27471 6e56277909f1
child 27683 1d5707553fff
equal deleted inserted replaced
25956:99be217ac88d 26135:82b516c550f7
   350 stringStream::~stringStream() {}
   350 stringStream::~stringStream() {}
   351 
   351 
   352 xmlStream*   xtty;
   352 xmlStream*   xtty;
   353 outputStream* tty;
   353 outputStream* tty;
   354 outputStream* gclog_or_tty;
   354 outputStream* gclog_or_tty;
       
   355 CDS_ONLY(fileStream* classlist_file;) // Only dump the classes that can be stored into the CDS archive
   355 extern Mutex* tty_lock;
   356 extern Mutex* tty_lock;
   356 
   357 
   357 #define EXTRACHARLEN   32
   358 #define EXTRACHARLEN   32
   358 #define CURRENTAPPX    ".current"
   359 #define CURRENTAPPX    ".current"
   359 #define FILENAMEBUFLEN  1024
   360 #define FILENAMEBUFLEN  1024
   461   }
   462   }
   462   strcat(buf, tail);      // append rest of name, or all of name
   463   strcat(buf, tail);      // append rest of name, or all of name
   463   return buf;
   464   return buf;
   464 }
   465 }
   465 
   466 
   466 // log_name comes from -XX:LogFile=log_name or -Xloggc:log_name
   467 // log_name comes from -XX:LogFile=log_name, -Xloggc:log_name or
       
   468 // -XX:DumpLoadedClassList=<file_name>
   467 // in log_name, %p => pid1234 and
   469 // in log_name, %p => pid1234 and
   468 //              %t => YYYY-MM-DD_HH-MM-SS
   470 //              %t => YYYY-MM-DD_HH-MM-SS
   469 static const char* make_log_name(const char* log_name, const char* force_directory) {
   471 static const char* make_log_name(const char* log_name, const char* force_directory) {
   470   char timestr[32];
   472   char timestr[32];
   471   get_datetime_string(timestr, sizeof(timestr));
   473   get_datetime_string(timestr, sizeof(timestr));
  1101       gclog->time_stamp().update_to(tty->time_stamp().ticks());
  1103       gclog->time_stamp().update_to(tty->time_stamp().ticks());
  1102     }
  1104     }
  1103     gclog_or_tty = gclog;
  1105     gclog_or_tty = gclog;
  1104   }
  1106   }
  1105 
  1107 
       
  1108 #if INCLUDE_CDS
       
  1109   // For -XX:DumpLoadedClassList=<file> option
       
  1110   if (DumpLoadedClassList != NULL) {
       
  1111     const char* list_name = make_log_name(DumpLoadedClassList, NULL);
       
  1112     classlist_file = new(ResourceObj::C_HEAP, mtInternal)
       
  1113                          fileStream(list_name);
       
  1114     FREE_C_HEAP_ARRAY(char, list_name, mtInternal);
       
  1115   }
       
  1116 #endif
       
  1117 
  1106   // If we haven't lazily initialized the logfile yet, do it now,
  1118   // If we haven't lazily initialized the logfile yet, do it now,
  1107   // to avoid the possibility of lazy initialization during a VM
  1119   // to avoid the possibility of lazy initialization during a VM
  1108   // crash, which can affect the stability of the fatal error handler.
  1120   // crash, which can affect the stability of the fatal error handler.
  1109   defaultStream::instance->has_log_file();
  1121   defaultStream::instance->has_log_file();
  1110 }
  1122 }
  1113 // output and free resource.
  1125 // output and free resource.
  1114 void ostream_exit() {
  1126 void ostream_exit() {
  1115   static bool ostream_exit_called = false;
  1127   static bool ostream_exit_called = false;
  1116   if (ostream_exit_called)  return;
  1128   if (ostream_exit_called)  return;
  1117   ostream_exit_called = true;
  1129   ostream_exit_called = true;
       
  1130 #if INCLUDE_CDS
       
  1131   if (classlist_file != NULL) {
       
  1132     delete classlist_file;
       
  1133   }
       
  1134 #endif
  1118   if (gclog_or_tty != tty) {
  1135   if (gclog_or_tty != tty) {
  1119       delete gclog_or_tty;
  1136       delete gclog_or_tty;
  1120   }
  1137   }
  1121   {
  1138   {
  1122       // we temporaly disable PrintMallocFree here
  1139       // we temporaly disable PrintMallocFree here