diff -r e26895079d7c -r 7fdc9a71d314 analyzetool/dynamicmemoryhook/src/analyzetoolallocator.cpp --- a/analyzetool/dynamicmemoryhook/src/analyzetoolallocator.cpp Wed Sep 15 00:19:18 2010 +0300 +++ b/analyzetool/dynamicmemoryhook/src/analyzetoolallocator.cpp Wed Sep 15 13:53:27 2010 +0300 @@ -37,27 +37,25 @@ // might leave. // ----------------------------------------------------------------------------- // -RAnalyzeToolAllocator::RAnalyzeToolAllocator( TBool aNotFirst, - RATStorageServer& aStorageServer, +RAnalyzeToolAllocator::RAnalyzeToolAllocator( TBool aNotFirst, RArray& aCodeblocks, RMutex& aMutex, TUint aProcessId, RAnalyzeTool& aAnalyzeTool, - TBool aStorageServerOpen, TUint32 aLogOption, TUint32 aAllocCallStackSize, - TUint32 aFreeCallStackSize ) : + TUint32 aFreeCallStackSize, + RATFileLog& aLogFile ) : RAnalyzeToolMemoryAllocator( aNotFirst ), - iStorageServer( aStorageServer ), iCodeblocks( aCodeblocks ), iMutex( aMutex ), iProcessId( aProcessId ), iThreadArray( KATMaxCallstackLength ), iAnalyzeTool( aAnalyzeTool ), - iStorageServerOpen( aStorageServerOpen ), iLogOption( aLogOption ), iAllocMaxCallStack( aAllocCallStackSize ), - iFreeMaxCallStack( aFreeCallStackSize ) + iFreeMaxCallStack( aFreeCallStackSize ), + iLogFile ( aLogFile ) { LOGSTR1( "ATMH RAnalyzeToolAllocator::RAnalyzeToolAllocator()" ); @@ -71,6 +69,16 @@ LOGSTR2( "ATMH Thread stack size: %x", params().iStackSize ); error = iThreadArray.Append( TThreadStack( RThread().Id(), params().iStackAddress + params().iStackSize ) ); + + if ( iLogOption == EATLogToTraceFast ) + { + // log thread added + ATFastLogThreadStarted( aProcessId, RThread().Id().operator TUint() ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogThreadStarted( RThread().Id().operator TUint() ); + } } __ASSERT_ALWAYS( KErrNone == error, AssertPanic( ECantAppendToTheArray ) ); @@ -85,6 +93,20 @@ { LOGSTR1( "ATMH RAnalyzeToolAllocator::~RAnalyzeToolAllocator()" ); + for( TInt i=0; iAlloc( aSize ); LOGSTR3( "ATMH RAnalyzeToolAllocator::Alloc() - aSize: %i, address: %x", aSize, (TUint32) p ); - // Don't collect call stack and log data - // if storage server not open or logging mode not fast. - if ( iStorageServerOpen || iLogOption == EATLogToTraceFast ) - { - // Reset the callstack - iCallStack.Reset(); - - // Find the current thread callstack start address - TUint32 stackstart( 0 ); - TBool found( FindCurrentThreadStack( stackstart ) ); - LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); - - TUint32 _sp; - __asm - { - mov [_sp], esp - } - - // Get codeblocks count - TInt blocksCount( iCodeblocks.Count() ); - TInt error( KErrNone ); - TUint arrayCounter = 0; - - for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 - { - TUint32 addr = (TUint32) *( (TUint32*) i ); - if ( ! IsAddressLoadedCode( addr ) ) - continue; - for ( TInt j = 0; j < blocksCount; j++ ) - { - if ( iCodeblocks[j].CheckAddress( addr ) ) - { - // To avoid recursive call to ReAlloc specifying granularity - // Add address to the callstack - iCallStack[arrayCounter] = ( addr ); - arrayCounter++; - break; - } - } - if ( arrayCounter == KATMaxCallstackLength || - arrayCounter == iAllocMaxCallStack ) - { - LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); - break; - } - } - // Log the memory allocation information - if ( iLogOption == EATLogToTraceFast ) - { - // Using fast mode. - ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize ); - } - else - { - // Using storage server. - error = iStorageServer.LogMemoryAllocated( (TUint32) p, - iCallStack, - aSize ); - if ( KErrNone != error ) - { - LOGSTR2( "ATMH LogMemoryAllocated error %i", error ); - switch ( error ) - { - case KErrNoMemory: - LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - KErrNoMemory case" ); - if ( iStorageServerOpen ) - { - iStorageServerOpen = EFalse; - LOGSTR1( "ATMH RAnalyzeToolMainAllocator::Alloc() - close iStorageServer" ); - iStorageServer.Close(); - } - break; - } - } - } - } + // Reset the callstack + iCallStack.Reset(); + + // Find the current thread callstack start address + TUint32 stackstart( 0 ); + TBool found( FindCurrentThreadStack( stackstart ) ); + LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); + + TUint32 _sp; + __asm + { + mov [_sp], esp + } + + // Get codeblocks count + TInt blocksCount( iCodeblocks.Count() ); + TInt error( KErrNone ); + TUint arrayCounter = 0; + + for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 + { + TUint32 addr = (TUint32) *( (TUint32*) i ); + if ( ! IsAddressLoadedCode( addr ) ) + continue; + for ( TInt j = 0; j < blocksCount; j++ ) + { + if ( iCodeblocks[j].CheckAddress( addr ) ) + { + // To avoid recursive call to ReAlloc specifying granularity + // Add address to the callstack + iCallStack[arrayCounter] = ( addr ); + arrayCounter++; + break; + } + } + if ( arrayCounter == KATMaxCallstackLength || + arrayCounter == iAllocMaxCallStack ) + { + LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); + break; + } + } + // Log the memory allocation information + if ( iLogOption == EATLogToTraceFast ) + { + // Using fast mode. + ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize, threadId ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogMemoryAllocated( (TUint32) p, iCallStack, aSize, threadId ); + } + // Release the mutex iMutex.Signal(); @@ -235,79 +236,59 @@ // Acquire the mutex iMutex.Wait(); + // get thread ID + TUint threadId = RThread().Id(); + // Alloc memory from the original allocator TAny* p = iAllocator->Alloc( aSize ); - - // Don't collect call stack and log data - // if storage server not open or logging mode not fast. - if ( iStorageServerOpen || iLogOption == EATLogToTraceFast ) - { - // Reset the callstack - iCallStack.Reset(); - // Find the current thread callstack start address - TUint32 stackstart( 0 ); - TBool found( FindCurrentThreadStack( stackstart ) ); - LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); - - // Get codeblocks count - TInt blocksCount( iCodeblocks.Count() ); - TInt error( KErrNone ); - TUint arrayCounter = 0; - - for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 - { - TUint32 addr = (TUint32) *( (TUint32*) i ); - if ( ! IsAddressLoadedCode( addr ) ) - continue; - for ( TInt j = 0; j < blocksCount; j++ ) - { - if ( iCodeblocks[j].CheckAddress( addr ) ) - { - // To avoid recursive call to ReAlloc specifying granularity - // Add address to the callstack - iCallStack[arrayCounter] = ( addr ); - arrayCounter++; - break; - } - } - if ( arrayCounter == KATMaxCallstackLength || - arrayCounter == iAllocMaxCallStack ) - { - LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); - break; - } - } - // Log the memory allocation information - if ( iLogOption == EATLogToTraceFast ) - { - // Fast mode. - ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize ); - } - else - { - // Using storage server. - error = iStorageServer.LogMemoryAllocated( (TUint32) p, - iCallStack, - aSize ); - if ( KErrNone != error ) - { - LOGSTR2( "ATMH LogMemoryAllocated error %i", error ); - switch ( error ) - { - case KErrNoMemory: - LOGSTR1( "ATMH RAnalyzeToolAllocator::Alloc() - KErrNoMemory case" ); - if ( iStorageServerOpen ) - { - iStorageServerOpen = EFalse; - LOGSTR1( "ATMH RAnalyzeToolAllocator::Alloc() - close iStorageServer" ); - iStorageServer.Close(); - } - break; - } - } - } - } + + // Reset the callstack + iCallStack.Reset(); + + // Find the current thread callstack start address + TUint32 stackstart( 0 ); + TBool found( FindCurrentThreadStack( stackstart ) ); + LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); + + // Get codeblocks count + TInt blocksCount( iCodeblocks.Count() ); + TUint arrayCounter = 0; + + for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 + { + TUint32 addr = (TUint32) *( (TUint32*) i ); + if ( ! IsAddressLoadedCode( addr ) ) + continue; + for ( TInt j = 0; j < blocksCount; j++ ) + { + if ( iCodeblocks[j].CheckAddress( addr ) ) + { + // To avoid recursive call to ReAlloc specifying granularity + // Add address to the callstack + iCallStack[arrayCounter] = ( addr ); + arrayCounter++; + break; + } + } + if ( arrayCounter == KATMaxCallstackLength || + arrayCounter == iAllocMaxCallStack ) + { + LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); + break; + } + } + // Log the memory allocation information + if ( iLogOption == EATLogToTraceFast ) + { + // Fast mode. + ATFastLogMemoryAllocated( iProcessId, (TUint32) p, iCallStack, aSize, threadId ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogMemoryAllocated( (TUint32) p, iCallStack, aSize, threadId ); + } + // Release the mutex iMutex.Signal(); @@ -329,76 +310,68 @@ // Acquire the mutex iMutex.Wait(); - // Don't collect or log data if storage server not open or logging mode not fast. - if ( iStorageServerOpen || iLogOption == EATLogToTraceFast ) - { - // Reset the callstack - iFreeCallStack.Reset(); - - // Check if trace logging mode because free call stack is not used in other log options. - if ( (iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast ) - && iFreeMaxCallStack > 0 ) - { - // Find the current thread callstack start address - TUint32 stackstart( 0 ); - TBool found( FindCurrentThreadStack( stackstart ) ); - LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); - TUint32 _sp; - - #ifdef __WINS__ - __asm - { - mov [_sp], esp - } - #else - _sp = __current_sp(); - #endif - - // Get codeblocks count - TInt blocksCount( iCodeblocks.Count() ); - TUint arrayCounter = 0; - - for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 - { - TUint32 addr = (TUint32) *( (TUint32*) i ); - if ( ! IsAddressLoadedCode( addr ) ) - continue; - for ( TInt j = 0; j < blocksCount; j++ ) - { - if ( iCodeblocks[j].CheckAddress( addr ) ) - { - // To avoid recursive call to ReAlloc specifying granularity - // Add address to the callstack - iFreeCallStack[arrayCounter] = addr; - arrayCounter++; - break; - } - } - if ( arrayCounter == KATMaxFreeCallstackLength || - arrayCounter == iFreeMaxCallStack ) - { - break; - } - } - LOGSTR2( "ATMH > iFreeCallStack count ( %i )", arrayCounter ); - } - - // Log freed memory. - if ( iLogOption == EATLogToTraceFast ) - { - // Using fast mode. - ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack ); - } - else - { - // Using storage server. - TInt err( iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack ) ); - if ( err != KErrNone ) - { - LOGSTR2( "ATMH > LogMemoryFreed err( %i )", err ); - } - } - } + // get thread ID + TUint threadId = RThread().Id(); + + // Reset the callstack + iFreeCallStack.Reset(); + + if ( iFreeMaxCallStack > 0 ) + { + // Find the current thread callstack start address + TUint32 stackstart( 0 ); + TBool found( FindCurrentThreadStack( stackstart ) ); + LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); + TUint32 _sp; + + #ifdef __WINS__ + __asm + { + mov [_sp], esp + } + #else + _sp = __current_sp(); + #endif + + // Get codeblocks count + TInt blocksCount( iCodeblocks.Count() ); + TUint arrayCounter = 0; + + for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 + { + TUint32 addr = (TUint32) *( (TUint32*) i ); + if ( ! IsAddressLoadedCode( addr ) ) + continue; + for ( TInt j = 0; j < blocksCount; j++ ) + { + if ( iCodeblocks[j].CheckAddress( addr ) ) + { + // To avoid recursive call to ReAlloc specifying granularity + // Add address to the callstack + iFreeCallStack[arrayCounter] = addr; + arrayCounter++; + break; + } + } + if ( arrayCounter == KATMaxFreeCallstackLength || + arrayCounter == iFreeMaxCallStack ) + { + break; + } + } + LOGSTR2( "ATMH > iFreeCallStack count ( %i )", arrayCounter ); + } + + // Log freed memory. + if ( iLogOption == EATLogToTraceFast ) + { + // Using fast mode. + ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack, threadId ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogMemoryFreed( (TUint32) aPtr, iFreeCallStack, threadId ); + } // Free the memory using original allocator iAllocator->Free( aPtr ); @@ -440,6 +413,15 @@ LOGSTR2( "ATMH Thread stack size: %x", params().iStackSize ); iThreadArray.Append( TThreadStack( RThread().Id(), params().iStackAddress + params().iStackSize ) ); + if ( iLogOption == EATLogToTraceFast ) + { + // log thread added + ATFastLogThreadStarted( RProcess().Id().operator TUint(), RThread().Id().operator TUint()); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogThreadStarted( RThread().Id().operator TUint() ); + } } } @@ -476,6 +458,16 @@ { // Remove the thread iThreadArray.Remove( i ); + if ( iLogOption == EATLogToTraceFast ) + { + // log thread removed + ATFastLogThreadEnded( RProcess().Id().operator TUint(), RThread().Id().operator TUint() ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogThreadEnded( RThread().Id().operator TUint() ); + } + break; } } @@ -497,6 +489,9 @@ // Acquire the mutex iMutex.Wait(); + + // get thread ID + TUint threadId = RThread().Id(); // Realloc the memory using original allocator TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode ); @@ -509,117 +504,61 @@ LOGSTR3( "ATMH RAnalyzeToolAllocator::ReAlloc() - aSize: %i, aMode: %i", aSize, aMode ); - // Don't collect or log data if storage server not open or logging mode fast. - if ( iStorageServerOpen || iLogOption == EATLogToTraceFast ) - { - // Reset the callstack - iReCallStack.Reset(); + + // Reset the callstack + iReCallStack.Reset(); - // Find the current thread callstack start address - TUint32 stackstart( 0 ); - TBool found( FindCurrentThreadStack( stackstart ) ); - LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); - - // Get current sp - TUint32 _sp( 0 ); - __asm - { - mov [_sp], esp - } - - // Get codeblocks count - TInt blocksCount( iCodeblocks.Count() ); - TInt error( KErrNone ); - TUint arrayCounter = 0; - - for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 - { - TUint32 addr = (TUint32) *( (TUint32*) i ); - if ( ! IsAddressLoadedCode( addr ) ) - continue; - for ( TInt j = 0; j < blocksCount; j++ ) - { - if ( iCodeblocks[j].CheckAddress( addr ) ) - { - // To avoid recursive call to ReAlloc specifying granularity - // Add address to the callstack - iReCallStack[arrayCounter] = addr; - arrayCounter++; - break; - } - } - if ( arrayCounter == KATMaxCallstackLength || - arrayCounter == iAllocMaxCallStack ) - { - LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); - break; - } - } - - // No need to report free if the aPtr was NULL - if ( aPtr != NULL ) - { - // Reset the free callstack - iFreeCallStack.Reset(); - - // if trace logging mode(s) we also log call stack in free. - if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast ) - && iFreeMaxCallStack > 0 ) - { - for ( TInt i = 0; i < arrayCounter; i++ ) - { - if ( i == KATMaxFreeCallstackLength || i == iFreeMaxCallStack ) - { - break; - } - iFreeCallStack[i] = iReCallStack[i]; - } - } - - // Try to remove old address from the storage server's - // leak array. If found it's removed from the array because system frees - // old address directly in the RHeap in ReAlloc case. - if ( iLogOption == EATLogToTraceFast ) - { - ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack ); - } - else - { - iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack ); - } - } - - // Log the memory allocation information - if ( iLogOption == EATLogToTraceFast ) - { - // Using fast mode. - ATFastLogMemoryAllocated( iProcessId, (TUint32) ptr, iFreeCallStack, aSize); - } - else - { - // Using storage server. - error = iStorageServer.LogMemoryAllocated( (TUint32) ptr, - iReCallStack, - aSize ); - if ( KErrNone != error ) - { - LOGSTR2( "ATMH LogMemoryAllocated ReAlloc error %i", error ); - switch ( error ) - { - case KErrNoMemory: - LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - KErrNoMemory case" ); - if ( iStorageServerOpen ) - { - iStorageServerOpen = EFalse; - LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - close iStorageServer" ); - iStorageServer.Close(); - } - break; - } - } - } - } - } + // Find the current thread callstack start address + TUint32 stackstart( 0 ); + TBool found( FindCurrentThreadStack( stackstart ) ); + LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); + + // Get current sp + TUint32 _sp( 0 ); + __asm + { + mov [_sp], esp + } + + // Get codeblocks count + TInt blocksCount( iCodeblocks.Count() ); + TInt error( KErrNone ); + TUint arrayCounter = 0; + + for ( TUint32 i = _sp; i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 + { + TUint32 addr = (TUint32) *( (TUint32*) i ); + if ( ! IsAddressLoadedCode( addr ) ) + continue; + for ( TInt j = 0; j < blocksCount; j++ ) + { + if ( iCodeblocks[j].CheckAddress( addr ) ) + { + // To avoid recursive call to ReAlloc specifying granularity + // Add address to the callstack + iReCallStack[arrayCounter] = addr; + arrayCounter++; + break; + } + } + if ( arrayCounter == KATMaxCallstackLength || + arrayCounter == iAllocMaxCallStack ) + { + LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); + break; + } + } + + if ( iLogOption == EATLogToTraceFast ) + { + // Using fast logging mode. + ATFastLogMemoryReallocated( iProcessId, (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogMemoryReallocated( (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId ); + } + } // Release the mutex iMutex.Signal(); @@ -641,6 +580,9 @@ // Acquire the mutex iMutex.Wait(); + + // get thread ID + TUint threadId = RThread().Id(); // Realloc the memory using original allocator TAny* ptr = iAllocator->ReAlloc( aPtr, aSize, aMode ); @@ -653,110 +595,55 @@ LOGSTR3( "ATMH RAnalyzeToolAllocator::ReAlloc() - aSize: %i, aMode: %i", aSize, aMode ); - // Don't collect or log data if storage server not open or logging mode fast. - if ( iStorageServerOpen || iLogOption == EATLogToTraceFast ) - { - // Reset the callstack - iReCallStack.Reset(); + // Reset the callstack + iReCallStack.Reset(); + + // Find the current thread callstack start address + TUint32 stackstart( 0 ); + TBool found( FindCurrentThreadStack( stackstart ) ); + LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); + + // Get codeblocks count + TInt blocksCount( iCodeblocks.Count() ); - // Find the current thread callstack start address - TUint32 stackstart( 0 ); - TBool found( FindCurrentThreadStack( stackstart ) ); - LOGSTR3( "ATMH > stackstart: %x , found = %i", stackstart, found ); - - // Get codeblocks count - TInt blocksCount( iCodeblocks.Count() ); - TInt error( KErrNone ); - TUint arrayCounter = 0; - - for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 - { - TUint32 addr = (TUint32) *( (TUint32*) i ); - if ( ! IsAddressLoadedCode( addr ) ) - continue; - for ( TInt j = 0; j < blocksCount; j++ ) - { - if ( iCodeblocks[j].CheckAddress( addr ) ) - { - // To avoid recursive call to ReAlloc specifying granularity - // Add address to the callstack - iReCallStack[arrayCounter] = ( addr ); - arrayCounter++; - break; - } - } - if ( arrayCounter == KATMaxCallstackLength || - arrayCounter == iAllocMaxCallStack ) - { - LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); - break; - } - } - - // No need to report free if the aPtr was NULL - if ( aPtr != NULL ) - { - // Reset the free callstack - iFreeCallStack.Reset(); - - // if trace logging mode(s) we also log call stack with free. - if ( ( iLogOption == EATUseDefault || iLogOption == EATLogToTrace || iLogOption == EATLogToTraceFast ) - && iFreeMaxCallStack > 0 ) - { - for ( TInt i = 0; i < arrayCounter; i++ ) - { - if ( i == iFreeCallStack.Count() ) - { - break; - } - iFreeCallStack[i] = iReCallStack[i]; - } - } - - // Try to remove old address from the storage server's - // leak array. If found it's removed from the array because system frees - // old address directly in the RHeap in ReAlloc case. - if ( iLogOption == EATLogToTraceFast ) - { - ATFastLogMemoryFreed( iProcessId, (TUint32) aPtr, iFreeCallStack ); - } - else - { - iStorageServer.LogMemoryFreed( (TUint32) aPtr, iFreeCallStack ); - } - } - - // Log the memory allocation information - if ( iLogOption == EATLogToTraceFast ) - { - // Using fast mode. - ATFastLogMemoryAllocated( iProcessId, (TUint32) ptr, iReCallStack, aSize ); - } - else - { - // Using storage server. - error = iStorageServer.LogMemoryAllocated( (TUint32) ptr, - iReCallStack, - aSize ); - if ( KErrNone != error ) - { - LOGSTR2( "ATMH LogMemoryAllocated ReAlloc error %i", error ); - switch ( error ) - { - case KErrNoMemory: - LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - KErrNoMemory case" ); - if ( iStorageServerOpen ) - { - iStorageServerOpen = EFalse; - LOGSTR1( "ATMH RAnalyzeToolAllocator::ReAlloc() - close iStorageServer" ); - iStorageServer.Close(); - } - break; - } - } - } - } - } + TUint arrayCounter = 0; + + for ( TUint32 i = __current_sp(); i < stackstart; i = i + KAddressLength )//lint !e1055 !e526 !e628 !e348 + { + TUint32 addr = (TUint32) *( (TUint32*) i ); + if ( ! IsAddressLoadedCode( addr ) ) + continue; + for ( TInt j = 0; j < blocksCount; j++ ) + { + if ( iCodeblocks[j].CheckAddress( addr ) ) + { + // To avoid recursive call to ReAlloc specifying granularity + // Add address to the callstack + iReCallStack[arrayCounter] = ( addr ); + arrayCounter++; + break; + } + } + if ( arrayCounter == KATMaxCallstackLength || + arrayCounter == iAllocMaxCallStack ) + { + LOGSTR2( "ATMH > Wanted CallStack items ready( %i )", arrayCounter ); + break; + } + } + + if ( iLogOption == EATLogToTraceFast ) + { + // Using fast logging mode. + ATFastLogMemoryReallocated( iProcessId, (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId ); + } + else if ( iLogOption == EATLogToFile ) + { + iLogFile.ATFileLogMemoryReallocated( (TUint32) aPtr, (TUint32) ptr, iReCallStack, aSize, threadId ); + } + + + } // Release the mutex iMutex.Signal();