--- a/analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp Wed Sep 15 00:19:18 2010 +0300
+++ b/analyzetool/dynamicmemoryhook/src/analyzetoolfastlog.cpp Wed Sep 15 13:53:27 2010 +0300
@@ -15,7 +15,6 @@
*
*/
-
#include <e32debug.h> // RDebug
#include <analyzetool/analyzetooltraceconstants.h>
#include "analyzetoolfastlog.h"
@@ -32,26 +31,51 @@
TInt ATFastLogProcessStarted( const TDesC8& aProcessName,
TUint aProcessId,
- TUint32 aIsDebug )
+ TUint32 aIsDebug,
+ const TDesC8& aAtoolVersion,
+ const TDesC8& aApiVersion )
{
LOGSTR1( "ATFL ATFastLogProcessStarted()" );
- // Convert process name to 16-bit descriptor.
- TBuf<KMaxProcessName> processName;
- processName.Copy( aProcessName );
- // Buffer to trace.
- TBuf<KProcessStartBufLength> buffer;
- // Format process name and id.
- buffer.Format( KProcessStart16, &processName, aProcessId );
- // Timestamp.
+
+ // PCS <Process name> <Process ID> <Time stamp> <Udeb> <Version>
+
+ //Buffer to trace
+ TBuf8<KProcessStartBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // PCS
+ buffer.Append( KProcessStart );
+ // process name
+ buffer.Append( aProcessName );
+ buffer.Append( KSpace );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+ // time stamp
buffer.AppendNum( CurrentTime(), EHex ) ;
- // Append udeb/urel information to the process start.
- buffer.Append( KSpaceTrace );
+ buffer.Append( KSpace );
+ // urel/udeb
buffer.AppendNum( aIsDebug, EHex );
- // Append version number.
- buffer.Append( KSpaceTrace );
+ buffer.Append( KSpace );
+ // version
buffer.AppendNum( KATTraceVersion, EHex );
- // Log to trace.
- RDebug::Print( KTraceMessage, aProcessId ,&buffer );
+ buffer.Append( KSpace );
+ // atool version
+ buffer.Append( aAtoolVersion );
+ buffer.Append( KSpace );
+ // ATAPI version
+ buffer.Append( aApiVersion );
+
+
+
+
+ RDebug::RawPrint( buffer );
+
return KErrNone;
}
@@ -59,21 +83,44 @@
TUint aHandleLeakCount )
{
LOGSTR1( "ATFL ATFastLogProcessEnded()" );
- // Handle leaks.
+
+ // PCE
+
if ( aHandleLeakCount > 0 )
- {
+ {
+ // HDL <Handle count>
+
// Buffer to trace.
- TBuf<KHandleLeakBufLength> buffer2;
- buffer2.Format( KHandleLeak16, &KUnknownModule16, aHandleLeakCount );
- // Trace it.
- RDebug::Print( KTraceMessage, aProcessId, &buffer2 );
- }
- // Process end trace.
- TBuf<KProcessEndBufLength> buffer;
- buffer.Format( KProcessEnd16, aProcessId );
- buffer.AppendNum( CurrentTime(), EHex);
- buffer.Append( KNewLineTrace );
- RDebug::Print( KTraceMessage, aProcessId, &buffer );
+ TBuf8<KHandleLeakBufLength> buffer2;
+
+ // AT indentifier
+ buffer2.Append( KATIdentifier );
+ // process id
+ buffer2.AppendNum( aProcessId, EHex );
+ buffer2.Append( KSpace );
+
+ // HDL
+ buffer2.Append( KHandleLeak );
+ // leak count
+ buffer2.AppendNum( aHandleLeakCount );
+
+ RDebug::RawPrint( buffer2 );
+ }
+
+ // Buffer to trace.
+ TBuf8<KProcessEndBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // PCE
+ buffer.Append( KProcessEnd );
+ RDebug::RawPrint( buffer );
+
+
return KErrNone;
}
@@ -83,15 +130,31 @@
TUint32 aEndAddress )
{
LOGSTR1( "ATFL ATFastLogDllLoaded()" );
- // Timestamp.
- TInt64 time = CurrentTime();
- // Convert dll name to 16-bit descriptor.
- TBuf<KMaxLibraryName> dll;
- dll.Copy( aDllName );
+
+ // DLL <DLL name> <Memory start address> <Memory end address>
+
// Buffer to trace.
- TBuf<KDllLoadBufLength> buffer;
- buffer.Format( KDllLoad16, &dll, time, aStartAddress, aEndAddress );
- RDebug::Print( KTraceMessage, aProcessId, &buffer );
+ TBuf8<KDllLoadBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // DLL
+ buffer.Append( KDllLoad );
+ // dll name
+ buffer.Append( aDllName );
+ buffer.Append( KSpace );
+ // start adress
+ buffer.AppendNum( aStartAddress, EHex );
+ buffer.Append( KSpace );
+ //end adress
+ buffer.AppendNum( aEndAddress, EHex );
+
+ RDebug::RawPrint( buffer );
+
return KErrNone;
}
@@ -99,67 +162,77 @@
TUint32 aEndAddress )
{
LOGSTR1( "ATFL ATFastLogDllUnloaded()" );
- // Timestamp.
- TInt64 time = CurrentTime();
- // Convert dll name to 16-bit descriptor.
- TBuf<KMaxLibraryName> dll;
- dll.Copy( aDllName );
+
+ // DLU <DLL name> <Memory start address> <Memory end address>
+
// Buffer to trace.
- TBuf<KDllLoadBufLength> buffer;
- buffer.Format( KDllUnload16, &dll, time, aStartAddress, aEndAddress );
- RDebug::Print( KTraceMessage, aProcessId, &buffer );
+ TBuf8<KDllUnloadBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // DLU
+ buffer.Append( KDllUnload );
+ // dll name
+ buffer.Append( aDllName );
+ buffer.Append( KSpace );
+ // start adress
+ buffer.AppendNum( aStartAddress, EHex );
+ buffer.Append( KSpace );
+ //end adress
+ buffer.AppendNum( aEndAddress, EHex );
+
+ RDebug::RawPrint( buffer );
+
return KErrNone;
}
TInt ATFastLogMemoryAllocated( TUint aProcessId, TUint32 aMemAddress,
TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
- TInt aSize )
+ TInt aSize, TUint aThreadId )
{
LOGSTR1( "ATFL ATFastLogMemoryAllocated()" );
- // ALLOCH <Memory address> <Time stamp> <Allocation size> <Call stack address count>
- // <Call stack address> <Call stack address> ...
-
- // Timestamp.
- TInt64 time = CurrentTime();
- // Trace buffer and pointer to it.
- TBufC<KMemAllocBufLength> buffer;
- TPtr ptr( buffer.Des() );
- // Append the tag implying a memory allocation line in the data file
- ptr.Append( KMemoryAllocHeader );
+ // ALH <Memory address> <Allocation size> <Thread ID>
+ // <Call stack address count> <Call stack address> <Call stack address> ...
+
+ // Buffer to trace.
+ TBuf8<KMemAllocBufLength> buffer;
- // Append the start address of this allocation in the 32-bit (max 8 characters)
- // hexadecimal text format.
- ptr.AppendNum( aMemAddress, EHex );
-
- // Append the current time in the 64-bit (max 16 characters) hexadecimal text
- // format
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( time, EHex );
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
- // Append the size of the allocation in the 32-bit (max 8 characters) hexadecimal
- // text format.
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( aSize, EHex );
-
+ // ALH
+ buffer.Append( KMemoryAllocHeader );
+ // memory adress
+ buffer.AppendNum( aMemAddress, EHex );
+ buffer.Append( KSpace );
+ // allocation size
+ buffer.AppendNum( aSize, EHex );
+ buffer.Append( KSpace );
+ // thread ID
+ buffer.AppendNum( aThreadId, EHex );
+ buffer.Append( KSpace );
+
// Search call stack for address count.
- TInt addrCount(0);
- for ( TInt j = 0; j < aCallstack.Count() ; j++ )
- {
- if ( aCallstack.At(j) == 0 )
- break;
- addrCount++;
- }
- // Current position in call stack.
- TInt addrPos( 0 );
+ TInt addrCount(0);
+ for ( TInt j = 0; j < aCallstack.Count() ; j++ )
+ {
+ if ( aCallstack.At(j) == 0 )
+ break;
+ addrCount++;
+ }
+ // Current position in call stack.
+ TInt addrPos( 0 );
- // Append address count.
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( addrCount, EHex );
-
- // Calculate last item length
- TInt lastItemLength( KTraceMessage().Length() + KHexa32Length +
- KSpaceLength + KNewlineLength );
+ // address count
+ buffer.AppendNum( addrCount, EHex );
TUint packetNumber( 1 );
@@ -167,132 +240,310 @@
// this memory allocation
for ( TInt j = 0; j < addrCount; j++ )
{
- // ALLOCF <Memory address> <Time stamp> <Packet number>
- // <Call stack address> <Call stack address> ...
- if ( ptr.Length() <= 0 )
- {
+ // ALF <Memory address> <Packet number> <Call stack address> <Call stack address> ...
+ if ( buffer.Length() <= 0 )
+ {
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
// Create alloc fragment message header
- ptr.Append( KMemoryAllocFragment );
- ptr.AppendNum( aMemAddress, EHex );
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( time, EHex );
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( packetNumber, EHex );
+ buffer.Append( KMemoryAllocFragment );
+ buffer.AppendNum( aMemAddress, EHex );
+ buffer.Append( KSpace );
+ buffer.AppendNum( packetNumber, EHex );
// Increase packet number
packetNumber++;
}
// Append call stack address.
- ptr.AppendFormat( KHexaNumberTrace, aCallstack.At( addrPos ) );
+ buffer.Append( KSpace );
+ buffer.AppendNum( aCallstack.At( addrPos ), EHex );
// Move the call stack position.
addrPos++;
// Check if buffer max length exceed
- if ( lastItemLength + ptr.Length() >= KMemAllocBufLength )
+ if ( KLastItemLength + buffer.Length() >= KMemAllocBufLength )
{
- ptr.Append( KNewLineTrace );
// Log through debug channel
- RDebug::Print( KTraceMessage, aProcessId, &buffer );
+ RDebug::RawPrint( buffer );
// Empty trace buffer
- ptr.Delete( 0, ptr.MaxLength() );
+ buffer.Delete( 0, buffer.MaxLength() );
}
}
// Send last message if exists.
- if ( ptr.Length() > 0 )
+ if ( buffer.Length() > 0 )
{
- ptr.Append( KNewLineTrace );
- RDebug::Print( KTraceMessage, aProcessId, &buffer);
+ RDebug::RawPrint( buffer );
}
+
return KErrNone;
}
TInt ATFastLogMemoryFreed( TUint aProcessId, TUint32 aMemAddress,
- TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack )
+ TFixedArray<TUint32, KATMaxFreeCallstackLength>& aFreeCallstack,
+ TUint aThreadId )
{
LOGSTR1( "ATFL ATFastLogMemoryFreed()" );
- // FREEH <Memory address> <Time tamp> <Call stack address count> <Call stack address>
- // <Call stack address> ...
-
- // Timestamp.
- TInt64 time = CurrentTime();
-
- // Trace buffer and pointer to it.
- TBufC<KMemFreedBufLength> buffer;
- TPtr ptr( buffer.Des() );
-
- // Append the tag implying a memory allocation line in the data file
- ptr.Append( KMemoryFreedHeader );
-
- // Append the start address of this allocation in the 32-bit (max 8 characters)
- // hexadecimal text format.
- ptr.AppendNum( aMemAddress, EHex );
+
+ // FRH <Memory address> <Thread ID> <Call stack address count>
+ // <Call stack address> <Call stack address> ...
+
+ // Buffer to trace.
+ TBuf8<KMemFreedBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // FRH
+ buffer.Append( KMemoryFreedHeader );
+
+ // Append the start address of this allocation in the 32-bit (max 8 characters)
+ // hexadecimal text format.
+ buffer.AppendNum( aMemAddress, EHex );
+ buffer.Append( KSpace );
+
+ // thread ID
+ buffer.AppendNum( aThreadId, EHex );
+ buffer.Append( KSpace );
+
+ // Search call stack for address count.
+ TInt addrCount(0);
+ for ( TInt j = 0; j < aFreeCallstack.Count() ; j++ )
+ {
+ if ( aFreeCallstack.At(j) == 0 )
+ break;
+ addrCount++;
+ }
+ // Current position in call stack.
+ TInt addrPos( 0 );
+
+ // address count.
+ buffer.AppendNum( addrCount, EHex );
+
+ TUint packetNumber( 1 );
+
+ // Go through all call stack's memory addresses associated with
+ // this memory allocation
+ for ( TInt j = 0; j < addrCount; j++ )
+ {
+ // FRF <Memory address> <Packet number>
+ // <Call stack address> <Call stack address> ...
+ if ( buffer.Length() <= 0 )
+ {
+ // Create alloc fragment message header
+ buffer.Append( KMemoryFreedFragment );
+ buffer.AppendNum( aMemAddress, EHex );
+ buffer.Append( KSpace );
+ buffer.AppendNum( packetNumber, EHex );
+ // Increase packet number
+ packetNumber++;
+ }
+
+ // Append call stack address.
+ buffer.Append( KSpace );
+ buffer.AppendNum( aFreeCallstack.At( addrPos ), EHex );
+
+ // Move the call stack position.
+ addrPos++;
+
+ // Check if buffer max length exceed
+ if ( KLastItemLength + buffer.Length() >= KMemFreedBufLength )
+ {
+ // Log through debug channel
+ RDebug::RawPrint( buffer );
+ // Empty trace buffer
+ buffer.Delete( 0, buffer.MaxLength() );
+ }
+ }
+ // Send last message if exists.
+ if ( buffer.Length() > 0 )
+ {
+ RDebug::RawPrint( buffer );
+ }
+
+ return KErrNone;
+ }
+
+TInt ATFastLogMemoryReallocated( TUint aProcessId, TUint32 aMemAddressFree, TUint32 aMemAddressAlloc,
+ TFixedArray<TUint32, KATMaxCallstackLength>& aCallstack,
+ TInt aSize, TUint aThreadId )
+ {
+ LOGSTR1( "ATFL ATFastLogMemoryReallocated()" );
- // Append timestamp;
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( time, EHex);
+ // RAH <Freed memory address> <Allocated memory address> <Allocation size> <Thread ID>
+ // <Call stack address count> <Call stack address> <Call stack address> ...
+
+ // Buffer to trace.
+ TBuf8<KMemReallocBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+ // RAH
+ buffer.Append( KMemoryReallocHeader );
+ // memory adress freed
+ buffer.AppendNum( aMemAddressFree, EHex );
+ buffer.Append( KSpace );
+ // memory adress allocated
+ buffer.AppendNum( aMemAddressAlloc, EHex );
+ buffer.Append( KSpace );
+ // allocation size
+ buffer.AppendNum( aSize, EHex );
+ buffer.Append( KSpace );
+ // thread ID
+ buffer.AppendNum( aThreadId, EHex );
+ buffer.Append( KSpace );
+
// Search call stack for address count.
- TInt addrCount(0);
- for ( TInt j = 0; j < aFreeCallstack.Count() ; j++ )
- {
- if ( aFreeCallstack.At(j) == 0 )
- break;
- addrCount++;
- }
- // Current position in call stack.
- TInt addrPos( 0 );
+ TInt addrCount(0);
+ for ( TInt j = 0; j < aCallstack.Count() ; j++ )
+ {
+ if ( aCallstack.At(j) == 0 )
+ break;
+ addrCount++;
+ }
+ // Current position in call stack.
+ TInt addrPos( 0 );
- // Append address count.
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( addrCount, EHex );
-
- // Calculate last item length
- TInt lastItemLength( KTraceMessage().Length() + KHexa32Length +
- KSpaceLength + KNewlineLength );
-
+ // address count
+ buffer.AppendNum( addrCount, EHex );
+
TUint packetNumber( 1 );
// Go through all call stack's memory addresses associated with
// this memory allocation
for ( TInt j = 0; j < addrCount; j++ )
{
- // ALLOCF <Memory address> <Time stamp> <Packet number>
+ // RAF <Freed memory address> <Allocated memory address> <Packet number>
// <Call stack address> <Call stack address> ...
- if ( ptr.Length() <= 0 )
- {
+ if ( buffer.Length() <= 0 )
+ {
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
// Create alloc fragment message header
- ptr.Append( KMemoryFreedFragment );
- ptr.AppendNum( aMemAddress, EHex );
- ptr.Append( KSpaceTrace );
- ptr.AppendNum( packetNumber, EHex );
+ buffer.Append( KMemoryReallocFragment );
+ // memory adress freed
+ buffer.AppendNum( aMemAddressFree, EHex );
+ buffer.Append( KSpace );
+ // memory adress allocated
+ buffer.AppendNum( aMemAddressAlloc, EHex );
+ buffer.Append( KSpace );
+ // packet number
+ buffer.AppendNum( packetNumber, EHex );
// Increase packet number
packetNumber++;
}
// Append call stack address.
- ptr.AppendFormat( KHexaNumberTrace, aFreeCallstack.At( addrPos ) );
+ buffer.Append( KSpace );
+ buffer.AppendNum( aCallstack.At( addrPos ), EHex );
// Move the call stack position.
addrPos++;
// Check if buffer max length exceed
- if ( lastItemLength + ptr.Length() >= KMemFreedBufLength )
+ if ( KLastItemLength + buffer.Length() >= KMemAllocBufLength )
{
- ptr.Append( KNewLineTrace );
// Log through debug channel
- RDebug::Print( KTraceMessage, aProcessId, &buffer );
+ RDebug::RawPrint( buffer );
// Empty trace buffer
- ptr.Delete( 0, ptr.MaxLength() );
+ buffer.Delete( 0, buffer.MaxLength() );
}
}
// Send last message if exists.
- if ( ptr.Length() > 0 )
+ if ( buffer.Length() > 0 )
{
- ptr.Append( KNewLineTrace );
- RDebug::Print( KTraceMessage, aProcessId, &buffer);
+ RDebug::RawPrint( buffer);
}
- return KErrNone;
+
+ return KErrNone;
+ }
+
+TInt ATFastLogThreadStarted( TUint aProcessId, TUint aThreadId )
+ {
+ LOGSTR1( "ATFL ATFastLogThreadStarted()" );
+
+ // TDS <Thread ID>
+
+ //Buffer to trace
+ TBuf8<KThreadStartBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // TDS
+ buffer.Append( KThreadStart );
+ // thread ID
+ buffer.AppendNum( aThreadId, EHex );
+
+ RDebug::RawPrint( buffer );
+
+ return KErrNone;
}
+TInt ATFastLogThreadEnded( TUint aProcessId, TUint64 aThreadId )
+ {
+ LOGSTR1( "ATFL ATFastLogThreadEnded()" );
+
+ // TDE <Thread ID>
+
+ //Buffer to trace
+ TBuf8<KThreadEndBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+ // process id
+ buffer.AppendNum( aProcessId, EHex );
+ buffer.Append( KSpace );
+
+ // TDE
+ buffer.Append( KThreadEnd );
+ // thread ID
+ buffer.AppendNum( aThreadId, EHex );
+
+ RDebug::RawPrint( buffer );
+
+ return KErrNone;
+ }
+
+TInt ATFastLogDeviceInfo( const TDesC8& aS60Version, const TDesC8& aChecksum)
+ {
+ LOGSTR1( "ATFL ATFastLogVersionsInfo()" );
+
+ //Buffer to trace
+ TBuf8<KVersionsInfoBufLength> buffer;
+
+ // AT indentifier
+ buffer.Append( KATIdentifier );
+
+ // VER
+ buffer.Append( KVersionsInfo );
+
+ // sw version
+ buffer.Append(aS60Version);
+ buffer.Append(KSpace);
+ // rom checksum
+ buffer.Append(aChecksum);
+
+ RDebug::RawPrint( buffer );
+
+ return KErrNone;
+ }