--- a/analyzetool/commandlineengine/src/CATBase.cpp Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/CATBase.cpp Wed Sep 15 13:53:27 2010 +0300
@@ -144,7 +144,7 @@
{
LOG_LOW_FUNC_ENTRY("CATBase::GetPathOrFileName");
string sRet;
- size_t iPos = sInput.size();
+ size_t iPos = sInput.size()-1;
sInput = ChangeSlashToBackSlash( sInput );
@@ -228,6 +228,30 @@
}
// -----------------------------------------------------------------------------
+// CATBase::GetStringUntilMainId
+// Function returns string from begin of given string until next atool's main id <AT>,
+// characters until next main id are removed from sInput string.
+// -----------------------------------------------------------------------------
+string CATBase::GetStringUntilMainId( string& sInput, bool bEraseFromInput )
+{
+ LOG_LOW_FUNC_ENTRY("CATBase::GetStringUntilMainId");
+ string sTemp( sInput );
+ size_t iSize = sTemp.find(MAIN_ID);
+ if( iSize != string::npos )
+ {
+ sTemp.resize( iSize );
+ if( bEraseFromInput )
+ sInput.erase( 0, (iSize) );
+ }
+ else
+ {
+ if ( bEraseFromInput )
+ sInput.clear();
+ }
+ return sTemp;
+}
+
+// -----------------------------------------------------------------------------
// CATBase::ChangeSlashToBackSlash
// Function changes all BackSlash characters to Slash character from
// given string.
@@ -245,6 +269,73 @@
return sInput;
}
+
+// -----------------------------------------------------------------------------
+// CATBase::ParseTimeStamp
+// Function returns time parsed from start of trace message
+// -----------------------------------------------------------------------------
+unsigned __int64 CATBase::ParseTimeStamp( string sLineStart )
+{
+ unsigned __int64 iTime(0);
+
+ int iHours(0), iMinutes(0), iSeconds(0), iMiliseconds(0), iMicroseconds(0);
+ int iErr(0), iRet(0);
+
+ TrimString( sLineStart );
+ string sTimeString = GetStringUntilNextSpace( sLineStart );
+
+ // Get time
+ int iPos = sTimeString.find( ":" );
+ if( iPos != string::npos ) // ':' found, this is timestamp from fastTrace/traceViewer
+ {
+ // possible formats
+ // hh:mm:ss - seconds (ft)
+ // hh:mm:ss:mmm - miliseconds (ft/tw)
+ // hh:mm:ss:mmmmmm - microseconds (ft/tw)
+ // hh:mm:ss:nnnnnnnnn - nanoseconds (ft) - ignore last 3digits
+
+ iRet = sscanf_s( sTimeString.c_str(), "%d:%d:%d.%3d%3d", &iHours, &iMinutes, &iSeconds, &iMiliseconds, &iMicroseconds );
+ if( iRet == 5 || iRet == 4 )
+ {
+ // get microseconds
+ iTime = ( ( ( iHours*60 + iMinutes )*60 + iSeconds )*1000 + iMiliseconds )*1000 + iMicroseconds;
+ }
+ else
+ {
+ iErr = true;
+ }
+ }
+ else if( sTimeString.find( "." ) != string::npos ) // epoc timestamp in format ssss.mmm
+ {
+ iRet = sscanf_s( sTimeString.c_str(), "%d.%d", &iSeconds, &iMiliseconds );
+ if( iRet == 2 )
+ {
+ // get microseconds
+ iTime = ( ( ( iHours*60 + iMinutes )*60 + iSeconds )*1000 + iMiliseconds )*1000 + iMicroseconds;
+ }
+ else
+ {
+ iErr = true;
+ }
+ }
+ else // timestamp in microseconds from binary log file or from ft
+ {
+ iRet = sscanf_s( sTimeString.c_str(), "%016I64x", &iTime);
+ if( iRet == 1 )
+ {
+ }
+ else
+ {
+ iErr = true;
+ }
+ }
+
+ if( iErr )
+ cout << "Error, can not read timestamp.\n";
+
+ return iTime;
+}
+
// -----------------------------------------------------------------------------
// CATBase::FileExists
// Check if given file exists.
@@ -876,6 +967,7 @@
bool CATBase::CreateTemporaryCpp( const string& sId,
const string& sPath
,const string& sS60FileName
+ ,const string& sS60FilePath
,int iLogOption
,int iIsDebug
,int iAllocCallStackSize
@@ -911,6 +1003,8 @@
out << "\nconst TInt ATTempFreeCallStackSize(" << iFreeCallStackSize << ");";
// Log file name
out << "\n_LIT( ATTempLogFileName, \"" << sS60FileName << "\" );";
+ // Log file path
+ out << "\n_LIT( ATTempLogFilePath, \"" << sS60FilePath << "\" );";
// Version number
out << "\n_LIT( ATTempVersion, \"" << ATOOL_COMPATIBILITY_STRING << "\" );";
// Variable functions use enumeration values that are defined in memoryhook (customuser.h)
@@ -924,7 +1018,8 @@
ELogOption = 3,
EDebug = 4,
EAllocCallStackSize = 5,
- EFreeCallStackSize = 6
+ EFreeCallStackSize = 6,
+ ELogFilePath = 7
};
*/
out << "\nTInt GetInt( const TUint8 aType )";
@@ -944,6 +1039,7 @@
out << "\n{";
out << "\ncase 1: return ATTempLogFileName();";
out << "\ncase 2: return ATTempVersion();";
+ out << "\ncase 7: return ATTempLogFilePath();";
out << "\ndefault: return KNullDesC();";
out << "\n}";
out << "\n}";
@@ -955,15 +1051,24 @@
out << sS60FileName;
out << "\" );\n";
+ out << "\n_LIT( KFilePath, \"";
+ out << sS60FilePath;
+ out << "\" );\n";
+
// Hardcoded version number for support.
out << "\n/* The AnalyzeTool version number used. */";
- out << "\n_LIT( KAtoolVersion, \"1.7.5;1.9.1\" );\n";
+ out << "\n_LIT( KAtoolVersion, \"1.7.6;1.10.0\" );\n";
out << "\nconst TFileName LogFileName()";
out << "\n {";
out << "\n return TFileName( KFileName() );";
out << "\n }";
+ out << "\nconst TPath LogFilePath()";
+ out << "\n {";
+ out << "\n return TPath( KFilePath() );";
+ out << "\n }";
+
out << "\nTUint32 AllocCallStackSize()";
out << "\n {";
out << "\n return TUint32( ";
@@ -1034,6 +1139,36 @@
return false;
}
+// -----------------------------------------------------------------------------
+// CATBase::IsBinaryLogFile
+// -----------------------------------------------------------------------------
+bool CATBase::IsBinaryLogFile( string sFile )
+{
+ LOG_FUNC_ENTRY("CATBase::IsDataFile");
+ // Check that sFile not empty
+ if ( sFile.empty() || sFile.length() < 1 )
+ return false;
+
+ // Temporary line char array.
+ char cLineFromFile[MAX_LINE_LENGTH];
+ //Open file
+ ifstream in( sFile.c_str() );
+
+ //File open ok?
+ if( !in.good() )
+ return false;
+
+ //Read all lines
+ in.getline( cLineFromFile, MAX_LINE_LENGTH );
+
+ string sLineFromFile( cLineFromFile );
+ in.close();
+
+ if( sLineFromFile.find( "ATOOL_BINARY_FILE_VERSION" ) != string::npos )
+ return true;
+ else
+ return false;
+}
// -----------------------------------------------------------------------------
// CATBase::ParseStringToVector