@@ -2605,12 +2605,6 @@ J9::Options::fePreProcess(void * base)
26052605 PORT_ACCESS_FROM_JAVAVM (vm);
26062606 OMRPORT_ACCESS_FROM_J9PORT (PORTLIB);
26072607
2608- #if defined(DEBUG) || defined(PROD_WITH_ASSUMES)
2609- bool forceSuffixLogs = false ;
2610- #else
2611- bool forceSuffixLogs = true ;
2612- #endif
2613-
26142608 int32_t xxLateSCCDisclaimTime = J9::Options::getExternalOptionIndex (J9::ExternalOptions::XXLateSCCDisclaimTimeOption);
26152609 if (xxLateSCCDisclaimTime >= 0 )
26162610 {
@@ -2660,8 +2654,11 @@ J9::Options::fePreProcess(void * base)
26602654 self ()->setOption (TR_DisableTraps);
26612655 #endif
26622656
2663- if (forceSuffixLogs)
2664- self ()->setOption (TR_EnablePIDExtension);
2657+ #if !defined(DEBUG) && !defined(PROD_WITH_ASSUMES)
2658+ // Production (PROD) builds force the application of the log filename suffix
2659+ //
2660+ self ()->setOption (TR_ApplyLogFileNameSuffix);
2661+ #endif
26652662
26662663 if (jitConfig->runtimeFlags & J9JIT_CG_REGISTER_MAPS)
26672664 self ()->setOption (TR_RegisterMaps);
@@ -3592,7 +3589,6 @@ J9::Options::printPID()
35923589 }
35933590
35943591#if defined(J9VM_OPT_JITSERVER)
3595- void getTRPID (char *buf, size_t size);
35963592
35973593static void
35983594appendRegex (TR::SimpleRegex *®exPtr, uint8_t *&curPos)
@@ -3643,34 +3639,25 @@ std::string
36433639J9::Options::packOptions (const TR::Options *origOptions)
36443640 {
36453641 size_t logFileNameLength = 0 ;
3646- size_t suffixLogsFormatLength = 0 ;
36473642 size_t blockShufflingSequenceLength = 0 ;
36483643 size_t induceOSRLength = 0 ;
36493644
36503645 char buf[JITSERVER_LOG_FILENAME_MAX_SIZE];
3651- char *origLogFileName = NULL ;
3652- if (origOptions->_logFileName )
3653- {
3654- origLogFileName = origOptions->_logFileName ;
3655- char pidBuf[20 ];
3656- memset (pidBuf, 0 , sizeof (pidBuf));
3657- getTRPID (pidBuf, sizeof (pidBuf));
3658- logFileNameLength = strlen (origOptions->_logFileName ) + strlen (" ." ) + strlen (pidBuf) + strlen (" .server" ) + 1 ;
3659- // If logFileNameLength is greater than JITSERVER_LOG_FILENAME_MAX_SIZE, PID might not be appended to the log file name
3660- // and the log file name could be truncated as well.
3661- if (logFileNameLength > JITSERVER_LOG_FILENAME_MAX_SIZE)
3662- logFileNameLength = JITSERVER_LOG_FILENAME_MAX_SIZE;
3663- snprintf (buf, logFileNameLength, " %s.%s.server" , origOptions->_logFileName , pidBuf);
3664- }
3665- if (origOptions->_suffixLogsFormat )
3666- suffixLogsFormatLength = strlen (origOptions->_suffixLogsFormat ) + 1 ;
3646+ if (origOptions->getLogFileNameBase ())
3647+ {
3648+ char *fn = TR::Options::buildLogFileName (buf, JITSERVER_LOG_FILENAME_MAX_SIZE, origOptions->getLogFileNameBase (), -1 ,
3649+ " .%pid.server" , true );
3650+
3651+ TR_ASSERT_FATAL (fn, " Error building JitServer log filename" );
3652+ }
3653+
36673654 if (origOptions->_blockShufflingSequence )
36683655 blockShufflingSequenceLength = strlen (origOptions->_blockShufflingSequence ) + 1 ;
36693656 if (origOptions->_induceOSR )
36703657 induceOSRLength = strlen (origOptions->_induceOSR ) + 1 ;
36713658
36723659 // sizeof(bool) is reserved to pack J9JIT_RUNTIME_RESOLVE
3673- size_t totalSize = sizeof (TR::Options) + logFileNameLength + suffixLogsFormatLength + blockShufflingSequenceLength + induceOSRLength + sizeof (bool );
3660+ size_t totalSize = sizeof (TR::Options) + logFileNameLength + blockShufflingSequenceLength + induceOSRLength + sizeof (bool );
36743661
36753662 addRegexStringSize (origOptions->_disabledOptTransformations , totalSize);
36763663 addRegexStringSize (origOptions->_disabledInlineSites , totalSize);
@@ -3700,8 +3687,8 @@ J9::Options::packOptions(const TR::Options *origOptions)
37003687 TR::Options * options = (TR::Options *)optionsStr.data ();
37013688 memcpy (options, origOptions, sizeof (TR::Options));
37023689
3703- if (origOptions->_logFileName )
3704- options->_logFileName = buf;
3690+ if (origOptions->getLogFileNameBase () )
3691+ options->setLogFileNameBase ( buf) ;
37053692
37063693 uint8_t *curPos = ((uint8_t *)options) + sizeof (TR::Options);
37073694
@@ -3745,8 +3732,7 @@ J9::Options::packOptions(const TR::Options *origOptions)
37453732 // Append the data pointed by a pointer to the content and patch the pointer
37463733 // as a self-referring-pointer, or a relative pointer, which is
37473734 // the offset of the data with respect to the pointer.
3748- curPos = appendContent (options->_logFileName , curPos, logFileNameLength);
3749- curPos = appendContent (options->_suffixLogsFormat , curPos, suffixLogsFormatLength);
3735+ curPos = appendContent (options->_logFileNameBase , curPos, logFileNameLength);
37503736 curPos = appendContent (options->_blockShufflingSequence , curPos, blockShufflingSequenceLength);
37513737 curPos = appendContent (options->_induceOSR , curPos, induceOSRLength);
37523738
@@ -3769,10 +3755,8 @@ J9::Options::unpackOptions(char *clientOptions, size_t clientOptionsSize, TR::Co
37693755
37703756 // Convert relative pointers to absolute pointers
37713757 // pointer = address of field + offset
3772- if (options->_logFileName )
3773- options->_logFileName = (char *)((uint8_t *)&(options->_logFileName ) + (ptrdiff_t )options->_logFileName );
3774- if (options->_suffixLogsFormat )
3775- options->_suffixLogsFormat = (char *)((uint8_t *)&(options->_suffixLogsFormat ) + (ptrdiff_t )options->_suffixLogsFormat );
3758+ if (options->getLogFileNameBase ())
3759+ options->setLogFileNameBase ((char *)((uint8_t *)&(options->_logFileNameBase ) + (ptrdiff_t )options->_logFileNameBase ));
37763760 if (options->_blockShufflingSequence )
37773761 options->_blockShufflingSequence = (char *)((uint8_t *)&(options->_blockShufflingSequence ) + (ptrdiff_t )options->_blockShufflingSequence );
37783762 if (options->_induceOSR )
@@ -3836,12 +3820,12 @@ J9::Options::packLogFile(TR::FILE *fp)
38363820int
38373821J9::Options::writeLogFileFromServer (const std::string& logFileContent)
38383822 {
3839- if (logFileContent.empty () || !_logFileName )
3823+ if (logFileContent.empty () || !getLogFileNameBase () )
38403824 return 0 ;
38413825
38423826 char buf[JITSERVER_LOG_FILENAME_MAX_SIZE];
38433827 _fe->acquireLogMonitor ();
3844- snprintf (buf, sizeof (buf), " %s.%d.REMOTE" , _logFileName , ++_compilationSequenceNumber);
3828+ snprintf (buf, sizeof (buf), " %s.%d.REMOTE" , getLogFileNameBase () , ++_compilationSequenceNumber);
38453829 int sequenceNumber = _compilationSequenceNumber;
38463830 _fe->releaseLogMonitor ();
38473831
@@ -3856,10 +3840,12 @@ J9::Options::writeLogFileFromServer(const std::string& logFileContent)
38563840 }
38573841 return 0 ; // may overflow the buffer
38583842 }
3843+
38593844 char tmp[JITSERVER_LOG_FILENAME_MAX_SIZE];
3860- char * filename = _fe->getFormattedName (tmp, JITSERVER_LOG_FILENAME_MAX_SIZE, buf, _suffixLogsFormat, true );
3845+ char *fn = TR::Options::buildLogFileName (tmp, JITSERVER_LOG_FILENAME_MAX_SIZE, buf, -1 , TR::Options::getLogFileNameSuffix (), true );
3846+ TR_ASSERT_FATAL (fn, " Error building JitServer log filename" );
38613847
3862- TR::FILE *logFile = trfopen (filename , " wb" , false );
3848+ TR::FILE *logFile = trfopen (tmp , " wb" , false );
38633849 ::fputs (logFileContent.c_str(), logFile->_stream);
38643850 trfflush (logFile);
38653851 trfclose (logFile);
@@ -3877,18 +3863,18 @@ TR_Debug *createDebugObject(TR::Compilation *);
38773863void
38783864J9::Options::setLogFileForClientOptions (int suffixNumber)
38793865 {
3880- if (_logFileName )
3866+ if (getLogFileNameBase () )
38813867 {
38823868 _fe->acquireLogMonitor ();
38833869 if (suffixNumber)
38843870 {
3885- self ()->setOption (TR_EnablePIDExtension , true );
3871+ self ()->setOption (TR_ApplyLogFileNameSuffix , true );
38863872 self ()->openLogFileCreateLogger (suffixNumber);
38873873 }
38883874 else
38893875 {
38903876 _compilationSequenceNumber++;
3891- self ()->setOption (TR_EnablePIDExtension , false );
3877+ self ()->setOption (TR_ApplyLogFileNameSuffix , false );
38923878 self ()->openLogFileCreateLogger (_compilationSequenceNumber);
38933879 }
38943880
@@ -3979,3 +3965,5 @@ J9::Options::initialize()
39793965 {
39803966 self ()->OMR ::OptionsConnector::initialize ();
39813967 }
3968+
3969+ char *J9::Options::_logFileNameSuffix = " .%Y%m%d.%H%M%S.%pid" ;
0 commit comments