analyzetool/commandlineengine/src/catallocs.cpp
branchRCL_3
changeset 49 7fdc9a71d314
parent 19 da2cedce4920
child 59 8ad140f3dd41
--- a/analyzetool/commandlineengine/src/catallocs.cpp	Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/commandlineengine/src/catallocs.cpp	Wed Sep 15 13:53:27 2010 +0300
@@ -36,14 +36,65 @@
 	}
 }
 
-void CATAllocs::AllocH( const string& sAllocHString )
+void CATAllocs::AllocH( const string& sAllocHString, const string& aTimeString )
 {
 	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocH");
 	string sAllocH( sAllocHString );
 	// Parse alloc & create new allocation.
 	CATAlloc alloc;
+	alloc.m_sTime = aTimeString;
 	string sAddress = GetStringUntilNextSpace( sAllocH, true );
-	alloc.m_sTime = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_iThreadId = GetStringUntilNextSpace ( sAllocH, true );
+	alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() );
+	// Insert call stack fragment as "first" 1 because we are header.
+	if ( alloc.m_iCSCount > 0 )
+		alloc.m_vCallStack.insert( pair<unsigned long,string>( 0, sAllocH ) );
+	// Add allocation
+	pair< map<string,CATAlloc>::iterator, bool> ret;
+	ret = m_vAllocs.insert( pair<string, CATAlloc>( sAddress, alloc ) );
+	if( ret.second == false )
+	{
+		// Allocation to this memory address was already added.
+		LOG_STRING( "CATAllocs: Allocating same address again, address: " << sAddress );
+	}
+}
+
+void CATAllocs::AllocF( const string& sAllocFString, const string& aTimeString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF");
+	string sAllocF( sAllocFString );
+	string sAddress = GetStringUntilNextSpace( sAllocF, true );
+	string sTime = aTimeString;
+	unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() );
+	string sCallSstack = sAllocF;
+	// Find correct allocation into which add call stack fragment.
+	map<string, CATAlloc>::iterator it;
+	it = m_vAllocs.find( sAddress );
+	// TODO: If cannot find, create new in cache.
+	if ( it == m_vAllocs.end() )
+	{
+		LOG_STRING( "CATAllocs: Allocate fragment without header: " << sAddress );
+		return;
+	}
+	pair< map<unsigned long,string>::iterator, bool> ret;
+	// Add call stack to it.
+	ret = it->second.m_vCallStack.insert( pair<unsigned long,string>( iNumber, sCallSstack ) );
+	if( ret.second == false )
+	{
+		LOG_STRING( "CATAllocs: Same allocation fragment again: " << sAddress );
+	}
+}
+
+// ReallocH.
+void CATAllocs::ReallocH( const string& sReallocHString, const string& aTimeString )
+{
+	LOG_LOW_FUNC_ENTRY("CATAllocs::ReallocH");
+	string sAllocH( sReallocHString );
+	// Parse alloc & create new allocation.
+	CATAlloc alloc;
+	string sAddress = GetStringUntilNextSpace( sAllocH, true );
+	alloc.m_sTime = aTimeString;
 	alloc.m_sSize = GetStringUntilNextSpace( sAllocH, true );
 	alloc.m_iCSCount = _httoi( string( GetStringUntilNextSpace( sAllocH, true ) ).c_str() );
 	// Insert call stack fragment as "first" 1 because we are header.
@@ -59,12 +110,13 @@
 	}
 }
 
-void CATAllocs::AllocF( const string& sAllocFString )
+// ReallocF.
+void CATAllocs::ReallocF( const string& sReallocFString, const string& aTimeString )
 {
-	LOG_LOW_FUNC_ENTRY("CATAllocs::AllocF");
-	string sAllocF( sAllocFString );
+	LOG_LOW_FUNC_ENTRY("CATAllocs::ReallocF");
+	string sAllocF( sReallocFString );
 	string sAddress = GetStringUntilNextSpace( sAllocF, true );
-	string sTime = GetStringUntilNextSpace( sAllocF, true );
+	string sTime = aTimeString;
 	unsigned long iNumber = _httoi( string( GetStringUntilNextSpace( sAllocF, true ) ).c_str() );
 	string sCallSstack = sAllocF;
 	// Find correct allocation into which add call stack fragment.
@@ -104,7 +156,7 @@
 }
 
 // FreeH.
-void CATAllocs::FreeH( const string& sFreeH )
+void CATAllocs::FreeH( const string& sFreeH, const string& aTimeString )
 {
 	LOG_LOW_FUNC_ENTRY("CATAllocs::FreeH");
 	// Current implementation does not use call stack of
@@ -112,6 +164,7 @@
 	string sFree( sFreeH );
 	string sKey = GetStringUntilNextSpace( sFree );
 	// Time stamp. (not used currently)
+	// Thread ID. (not used currently)
 	// Call stack count. (not used currently)
 	// Call stack data. (not used currently)
 
@@ -128,7 +181,7 @@
 }
 
 // FreeF.
-void CATAllocs::FreeF( const string& /* sFreeF */ )
+void CATAllocs::FreeF( const string& /* sFreeF */, const string& /* aTimeString */ )
 {
 	LOG_LOW_FUNC_ENTRY("CATAllocs::FreeF");
 	// Fragments are currently ignored.