memspy/MemSpyClient/src/memspysession.cpp
changeset 34 7259cf1302ad
parent 22 a009639409f5
equal deleted inserted replaced
33:0d72cc2a29a3 34:7259cf1302ad
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "memspysession.h"
    19 #include "memspysession.h"
       
    20 
    20 #include <memspyengineclientinterface.h>
    21 #include <memspyengineclientinterface.h>
    21 
    22 // API
    22 #include <memspy/api/memspyapiprocess.h>
    23 #include <memspy/engine/memspyprocessdata.h>
    23 #include <memspy/api/memspyapikernelobject.h>
    24 #include <memspy/engine/memspythreaddata.h> 
    24 #include <memspy/api/memspyapikernelobjectitem.h>
    25 #include <memspy/engine/memspykernelobjectdata.h>
    25 #include <memspy/api/memspyapithreadinfoitem.h>
    26 #include <memspy/engine/memspyheapdata.h>
       
    27 #include <memspy/engine/memspymemorytrackingcycledata.h>
    26 //KernelObjects
    28 //KernelObjects
    27 #include <memspy/driver/memspydriverenumerationsshared.h>
    29 #include <memspy/driver/memspydriverenumerationsshared.h>
    28 // IMPLEMENTATION
    30 // IMPLEMENTATION
    29 
    31 
    30 EXPORT_C RMemSpySession::RMemSpySession()
    32 EXPORT_C RMemSpySession::RMemSpySession()
    93 
    95 
    94 	// Everything went OK
    96 	// Everything went OK
    95 	return KErrNone;
    97 	return KErrNone;
    96 	}
    98 	}
    97 
    99 
    98 //inline void RMemSpySession::Close()
       
    99 //    {
       
   100 //    RSessionBase::Close();
       
   101 //    }
       
   102 //
       
   103 //inline TMemSpySinkType RMemSpySession::GetSinkType()
       
   104 //	{
       
   105 //	TPckgBuf<TMemSpySinkType> OutBuf;
       
   106 //	TIpcArgs args( &OutBuf );
       
   107 //	SendReceive( EGetSinkType, args );
       
   108 //	return OutBuf();
       
   109 //	}
       
   110 //
       
   111 //inline void RMemSpySession::OutputKernelObjects()
       
   112 //	{
       
   113 //	SendReceive( EOutputKernelObjects );
       
   114 //	}
       
   115 //
       
   116 //inline void RMemSpySession::OutputToDebug()
       
   117 //	{
       
   118 //	SendReceive( EOutputToDebug );
       
   119 //	}
       
   120 //
       
   121 //inline void RMemSpySession::OutputToFile()
       
   122 //	{
       
   123 //	SendReceive( EOutputToFile );
       
   124 //	}
       
   125 //
       
   126 //inline void RMemSpySession::SetServerTimeOutStatus( TUint32 aValue, TBool aEnabled )
       
   127 //	{
       
   128 //	TPckgBuf<TUint32> In1(aValue);
       
   129 //	TPckgBuf<TBool> In2(aEnabled);
       
   130 //	TIpcArgs args( &In1, &In2 );
       
   131 //	SendReceive( ESetServerTimeOutStatus, args );	
       
   132 //	}
       
   133 
       
   134 //inline void RMemSpySession::OutputProcessInfo( TMemSpyProcess aProcess )
       
   135 //	{
       
   136 //	TProcessId iId = aProcess.iId;
       
   137 //	TPckgBuf<TProcessId> In( iId );
       
   138 //	TIpcArgs args( &In );
       
   139 //	SendReceive( EOutputProcessInfo, args );
       
   140 //	}
       
   141 
       
   142 ////Processes operations
       
   143 //inline TInt RMemSpySession::ProcessesCount()
       
   144 //	{
       
   145 //	TPckgBuf<TInt> Out;
       
   146 //	TIpcArgs args( &Out );
       
   147 //	SendReceive( EProcessesCount, args );
       
   148 //	return Out();
       
   149 //	}
       
   150 //
       
   151 //inline TMemSpyProcess RMemSpySession::GetProcessByIndex( TInt aIndex )
       
   152 //	{
       
   153 //	TPckgBuf<TInt> In( aIndex );
       
   154 //	TPckgBuf<TMemSpyProcess> Out;
       
   155 //	TIpcArgs args( &In, &Out );
       
   156 //	SendReceive( EProcessByIndex, args );
       
   157 //	return Out();
       
   158 //	}
       
   159 //
       
   160 //inline TInt RMemSpySession::ProcessIndexById( TProcessId aId )
       
   161 //	{
       
   162 //	TPckgBuf<TProcessId> In( aId );
       
   163 //	TPckgBuf<TInt> Out;
       
   164 //	TIpcArgs args( &In, &Out );
       
   165 //	SendReceive( EProcessIndexById, args );
       
   166 //	return Out();
       
   167 //	}
       
   168 //
       
   169 //inline TBool RMemSpySession::ProcessIsDead( TMemSpyProcess aProcess )
       
   170 //	{
       
   171 //	TProcessId iId = aProcess.iId;
       
   172 //	TPckgBuf<TProcessId> In( iId );
       
   173 //	TPckgBuf<TBool> Out;
       
   174 //	TIpcArgs args( &In, &Out );
       
   175 //	SendReceive( EProcessIsDead, args );
       
   176 //	return Out();
       
   177 //	}
       
   178 
       
   179 EXPORT_C void RMemSpySession::GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType)
   100 EXPORT_C void RMemSpySession::GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType)
   180 	{
   101 	{
   181 	TPckgBuf<TInt> count;
   102 	TPckgBuf<TInt> count;
   182 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcessCount, TIpcArgs(&count)));
   103 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcessCount, TIpcArgs(&count)));
   183 	
   104 	
   318 	aType = arg3();
   239 	aType = arg3();
   319 	
   240 	
   320 	return error;
   241 	return error;
   321 	}
   242 	}
   322 
   243 
   323 EXPORT_C void RMemSpySession::GetThreadInfoItems( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
   244 EXPORT_C void RMemSpySession::GetThreadInfoItemsL( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
   324 	{
   245 	{
   325 	TPckgBuf<TThreadId> id( aId );	
   246 	TPckgBuf<TThreadId> id( aId );	
   326 	TPckgBuf<TMemSpyThreadInfoItemType> type( aType );
   247 	TPckgBuf<TMemSpyThreadInfoItemType> type( aType );
   327 	TPckgBuf<TInt> count;	
   248 	TPckgBuf<TInt> count;	
   328 	
   249 	
   342 			
   263 			
   343 			TPckgBuf<TInt> requestedCount( itemCount );
   264 			TPckgBuf<TInt> requestedCount( itemCount );
   344 			
   265 			
   345 			TIpcArgs args( &requestedCount, &id, &type, &bufferPtr );
   266 			TIpcArgs args( &requestedCount, &id, &type, &bufferPtr );
   346 			TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItems, args );
   267 			TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItems, args );
       
   268 			
       
   269 			aInfoItems.Reset();
   347 		
   270 		
   348 			for(TInt i=0, offset = 0; i < itemCount; i++, offset+=sizeof(TMemSpyThreadInfoItemData))
   271 			for(TInt i=0, offset = 0; i < itemCount; i++, offset+=sizeof(TMemSpyThreadInfoItemData))
   349 				{
   272 				{
   350 				TPckgBuf<TMemSpyThreadInfoItemData> data;
   273 				TPckgBuf<TMemSpyThreadInfoItemData> data;
   351 				data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadInfoItemData));
   274 				data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadInfoItemData));
   352 				aInfoItems.AppendL(CMemSpyApiThreadInfoItem::NewL(data()));
   275 				aInfoItems.AppendL(CMemSpyApiThreadInfoItem::NewLC(data()));
   353 				}
   276 				}
   354 						
   277 			
       
   278 			CleanupStack::Pop(aInfoItems.Count());
   355 			CleanupStack::PopAndDestroy(buffer);
   279 			CleanupStack::PopAndDestroy(buffer);
   356 			}
   280 			}
   357 		}		
   281 		}
       
   282 	
       
   283 	User::LeaveIfError(error);
       
   284 	}
       
   285 
       
   286 EXPORT_C TInt RMemSpySession::GetThreadInfoItems( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
       
   287 	{
       
   288 	TRAPD(error, GetThreadInfoItemsL(aInfoItems, aId, aType));
       
   289 	return error;
   358 	}
   290 	}
   359 
   291 
   360 //Kernel Objects specific operations
   292 //Kernel Objects specific operations
   361 EXPORT_C TInt RMemSpySession::GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
   293 EXPORT_C void RMemSpySession::GetKernelObjectsL( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
   362 	{		
   294 	{		
   363 	TPckgBuf<TInt> count;
   295 	TPckgBuf<TInt> count;
   364 	TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjectCount, TIpcArgs(&count) );
   296 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectCount, TIpcArgs(&count) ));
   365 	
   297 	
   366 	if( error == KErrNone )
   298 	TInt requestedCount = count();
   367 		{			
   299 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyKernelObjectData));
   368 		TInt requestedCount = count();
   300 	TPtr8 bufferPtr(buffer->Des());
   369 		HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyKernelObjectData));
   301 		
   370 		TPtr8 bufferPtr(buffer->Des());
   302 	TIpcArgs args( &count, &bufferPtr );
   371 			
   303 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjects, args ));
   372 		TPckgBuf<TInt> count(requestedCount);
   304 	
   373 		TIpcArgs args( &count, &bufferPtr );
   305 	aKernelObjects.Reset();
   374 		TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjects, args );
   306 	
   375 			
   307 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyKernelObjectData))
   376 		for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyKernelObjectData))
   308 		{
   377 			{
   309 		TPckgBuf<TMemSpyKernelObjectData> data;
   378 			TPckgBuf<TMemSpyKernelObjectData> data;
   310 		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyKernelObjectData));
   379 			data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyKernelObjectData));
   311 		aKernelObjects.AppendL(CMemSpyApiKernelObject::NewLC(data()));
   380 			aKernelObjects.AppendL(CMemSpyApiKernelObject::NewL(data()));
   312 		}
   381 			}
   313 	
   382 				
   314 	CleanupStack::Pop(aKernelObjects.Count());
   383 		CleanupStack::PopAndDestroy(buffer);						
   315 	CleanupStack::PopAndDestroy(buffer);
   384 		}	
   316 	}
   385 	return KErrNone;		
   317 
   386 	}
   318 EXPORT_C TInt RMemSpySession::GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
   387 
   319 	{
   388 EXPORT_C TInt RMemSpySession::GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
   320 	TRAPD(error, GetKernelObjectsL(aKernelObjects));
       
   321 	return error;
       
   322 	}
       
   323 
       
   324 EXPORT_C void RMemSpySession::GetKernelObjectItemsL( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
   389 	{
   325 	{
   390 	TPckgBuf<TInt> count;
   326 	TPckgBuf<TInt> count;
   391 	TPckgBuf<TMemSpyDriverContainerType> type(aForContainer);
   327 	TPckgBuf<TMemSpyDriverContainerType> type(aForContainer);
   392 	TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjectItemCount, TIpcArgs(&count, &type) );
   328 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectItemCount, TIpcArgs(&count, &type) ));
   393 		
   329 
   394 	if (error == KErrNone)
   330 	TInt requestedCount = count();
   395 		{
   331 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyDriverHandleInfoGeneric));
   396 		TInt requestedCount = count();
   332 	TPtr8 bufferPtr(buffer->Des());
   397 		HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyDriverHandleInfoGeneric));
   333 	
   398 		TPtr8 bufferPtr(buffer->Des());
   334 	TIpcArgs args( &count, &type, &bufferPtr );
   399 		
   335 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectItems, args ));
   400 		TPckgBuf<TInt> count(requestedCount);
   336 	
   401 		TIpcArgs args( &count, &type, &bufferPtr );
   337 	aKernelObjectItems.Reset();
   402 		TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjectItems, args );
   338 	
   403 		
   339 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyDriverHandleInfoGeneric))
   404 		for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyDriverHandleInfoGeneric))
   340 		{
   405 			{
   341 		TPckgBuf<TMemSpyDriverHandleInfoGeneric> data;
   406 			TPckgBuf<TMemSpyDriverHandleInfoGeneric> data;
   342 		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyDriverHandleInfoGeneric));
   407 			data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyDriverHandleInfoGeneric));
   343 		aKernelObjectItems.AppendL( CMemSpyApiKernelObjectItem::NewLC( data() ) );
   408 			aKernelObjectItems.AppendL( CMemSpyApiKernelObjectItem::NewL( data() ) );
   344 		}
   409 			}
   345 	CleanupStack::Pop(aKernelObjectItems.Count());
   410 						
   346 	CleanupStack::PopAndDestroy(buffer);
   411 		CleanupStack::PopAndDestroy(buffer);				
   347 	}
   412 		}
   348 
   413 	return KErrNone;
   349 EXPORT_C TInt RMemSpySession::GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
       
   350 	{
       
   351 	TRAPD(error, GetKernelObjectItemsL(aKernelObjectItems, aForContainer));
       
   352 	return error;
       
   353 	}
       
   354 
       
   355 EXPORT_C void RMemSpySession::GetMemoryTrackingCyclesL(RArray<CMemSpyApiMemoryTrackingCycle*>& aCycles)
       
   356 	{
       
   357 	TPckgBuf<TInt> count;
       
   358 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycleCount, TIpcArgs(&count) ));
       
   359 	
       
   360 	TInt requestedCount = count();
       
   361 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyMemoryTrackingCycleData));
       
   362 	TPtr8 bufferPtr(buffer->Des());
       
   363 		
       
   364 	TIpcArgs args( &count, &bufferPtr );
       
   365 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycles, args ));
       
   366 	
       
   367 	aCycles.Reset();
       
   368 	
       
   369 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyMemoryTrackingCycleData))
       
   370 		{
       
   371 		TPckgBuf<TMemSpyMemoryTrackingCycleData> data;
       
   372 		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyMemoryTrackingCycleData));
       
   373 		aCycles.AppendL(CMemSpyApiMemoryTrackingCycle::NewLC(data()));
       
   374 		}
       
   375 	
       
   376 	CleanupStack::Pop(aCycles.Count());
       
   377 	CleanupStack::PopAndDestroy(buffer);
   414 	}
   378 	}
   415 
   379 
   416 EXPORT_C void RMemSpySession::OutputAllContainerContents()
   380 EXPORT_C void RMemSpySession::OutputAllContainerContents()
   417 	{
   381 	{
   418 	SendReceive( EMemSpyClientServerOpOutputAllContainerContents );
   382 	SendReceive( EMemSpyClientServerOpOutputAllContainerContents );
   419 	}
   383 	}
   420 
   384 
   421 
   385 
   422 //Heap specific operations
   386 //Heap specific operations
   423 EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeap()
   387 
       
   388 EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeapL()
   424 	{
   389 	{
   425 	CMemSpyApiHeap* aHeap;
   390 	CMemSpyApiHeap* aHeap;
   426 	TInt error = KErrNone;
       
   427 	
   391 	
   428 	HBufC8* buffer = HBufC8::NewLC( sizeof(TMemSpyHeapData) );
   392 	HBufC8* buffer = HBufC8::NewLC( sizeof(TMemSpyHeapData) );
   429 	TPtr8 bufferPtr(buffer->Des());
   393 	TPtr8 bufferPtr(buffer->Des());
   430 	TIpcArgs args( &bufferPtr );
   394 	TIpcArgs args( &bufferPtr );
   431 	
   395 	
   432 	error = SendReceive( EMemSpyClientServerOpGetHeap, args );
   396 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetHeap, args ));
   433 	
   397 	
   434 	if( error == KErrNone )
   398 	TPckgBuf<TMemSpyHeapData> data;
   435 		{
   399 	data.Copy(bufferPtr.Ptr(), sizeof(TMemSpyHeapData));		
   436 		TPckgBuf<TMemSpyHeapData> data;
   400 	aHeap = CMemSpyApiHeap::NewL( data() );
   437 		data.Copy(bufferPtr.Ptr(), sizeof(TMemSpyHeapData));		
   401 	
   438 		aHeap = CMemSpyApiHeap::NewL( data() );
       
   439 		}
       
   440 	CleanupStack::PopAndDestroy(buffer);
   402 	CleanupStack::PopAndDestroy(buffer);
   441 		
   403 		
   442 	return aHeap;
   404 	return aHeap;
   443 	}
   405 	}
   444 
   406 
       
   407 EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeap()
       
   408 	{
       
   409 	CMemSpyApiHeap *result = NULL;
       
   410 	TRAPD(error, result = GetHeapL());
       
   411 	return error == KErrNone ? result : NULL;
       
   412 	}
       
   413 
   445 EXPORT_C void RMemSpySession::DumpKernelHeap()
   414 EXPORT_C void RMemSpySession::DumpKernelHeap()
   446 	{
   415 	{
   447 	SendReceive( EMemSpyClientServerOpDumpKernelHeap );
   416 	SendReceive( EMemSpyClientServerOpDumpKernelHeap );
   448 	}
   417 	}
   449 
   418 
   450 EXPORT_C void RMemSpySession::OutputKernelHeapDataL(TMemSpyOutputType aOutputType)
   419 EXPORT_C void RMemSpySession::OutputKernelHeapDataL()
   451 	{
   420 	{		
   452 	SetOutputTypeL(aOutputType);
       
   453 	
       
   454 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
   421 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
   455 			TIpcArgs(KMemSpyClientServerThreadIdKernel)));
   422 			TIpcArgs(KMemSpyClientServerThreadIdKernel)));
   456 	
   423 	
   457 	}
   424 	}
   458 EXPORT_C void RMemSpySession::OutputThreadHeapDataL(TMemSpyOutputType aOutputType, TThreadId aThreadId)
   425 
   459 	{
   426 EXPORT_C void RMemSpySession::OutputKernelHeapData(TRequestStatus& aStatus)
   460 	SetOutputTypeL(aOutputType);
   427 	{
   461 		
   428 	SendReceive(EMemSpyClientServerOpHeapData,
       
   429 		TIpcArgs(KMemSpyClientServerThreadIdKernel),
       
   430 		aStatus);
       
   431 	}
       
   432 
       
   433 EXPORT_C void RMemSpySession::OutputThreadHeapDataL( TThreadId aThreadId)
       
   434 	{			
   462 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
   435 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
   463 			TIpcArgs(aThreadId)));
   436 			TIpcArgs(aThreadId)));
   464 	}
   437 	}
   465 EXPORT_C void RMemSpySession::OutputThreadCellListL(TMemSpyOutputType aOutputType, TThreadId aThreadId)
   438 
   466 	{
   439 EXPORT_C void RMemSpySession::OutputThreadHeapDataL(const TDesC& aThreadName)
   467 	SetOutputTypeL(aOutputType);
   440 	{	
   468 			
   441 	const TIpcArgs args( &aThreadName );
       
   442 	        
       
   443 	User::LeaveIfError( SendReceive( EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadName, args ));	
       
   444 	}
       
   445 
       
   446 EXPORT_C void RMemSpySession::OutputThreadCellListL(TThreadId aThreadId)
       
   447 	{	
   469 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsIncludesThreadId,
   448 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsIncludesThreadId,
   470 			TIpcArgs(aThreadId)));
   449 			TIpcArgs(aThreadId)));
   471 	}
   450 	}
   472 
   451 
   473 EXPORT_C void RMemSpySession::OutputKernelObjectsL(TMemSpyOutputType aOutputType)
   452 EXPORT_C void RMemSpySession::OutputHeapInfoUserL(TThreadId aThreadId)
   474 	{
   453 	{
   475 	SetOutputTypeL(aOutputType);
   454 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpHeapInfo | KMemSpyOpFlagsIncludesThreadId,
   476 				
   455 			TIpcArgs(aThreadId)));
       
   456 	}
       
   457 
       
   458 EXPORT_C void RMemSpySession::SwitchOutputSinkL( TMemSpySinkType aType )
       
   459 	{
       
   460 	TInt op;
       
   461 	if( aType == ESinkTypeFile )
       
   462 		op = EMemSpyClientServerOpSwitchOutputSinkFile;
       
   463 	else
       
   464 		op = EMemSpyClientServerOpSwitchOutputSinkTrace;
       
   465 			
       
   466 	User::LeaveIfError(SendReceive( op ));
       
   467 	}
       
   468 
       
   469 EXPORT_C void RMemSpySession::SwitchOutputToTraceL()
       
   470 	{
       
   471 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSwitchOutputSinkTrace));
       
   472 	}
       
   473     
       
   474 EXPORT_C void RMemSpySession::SwitchOutputToFileL(const TDesC& aRootFolder)
       
   475 	{
       
   476 	TIpcArgs args;
       
   477 	if (aRootFolder.Length())
       
   478 		{
       
   479 		args.Set(0, &aRootFolder);
       
   480 		}
       
   481 	
       
   482 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSwitchOutputSinkFile, args));
       
   483 	}
       
   484 
       
   485 EXPORT_C void RMemSpySession::OutputStackInfoL(TThreadId aThreadId)
       
   486 	{
       
   487 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpStackInfo | KMemSpyOpFlagsIncludesThreadId,
       
   488 			TIpcArgs(aThreadId)));
       
   489 	}
       
   490 
       
   491 EXPORT_C void RMemSpySession::OutputStackDataL(TThreadId aThreadId, TMemSpyDriverDomainType aType )
       
   492 	{
       
   493 	TInt op;
       
   494 	if( aType == EMemSpyDriverDomainUser )
       
   495 		op = EMemSpyClientServerOpStackDataUser;
       
   496 	else
       
   497 		op = EMemSpyClientServerOpStackDataKernel;
       
   498 	
       
   499 	User::LeaveIfError(SendReceive( op | KMemSpyOpFlagsIncludesThreadId,
       
   500 			TIpcArgs(aThreadId, aType)));
       
   501 		
       
   502 	}
       
   503 
       
   504 EXPORT_C void RMemSpySession::OutputThreadInfoHandlesL(TThreadId aThreadId)
       
   505 	{
       
   506 	TPckgBuf<TThreadId> id(aThreadId);
       
   507 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpOutputInfoHandles, TIpcArgs( &id )));	
       
   508 	}
       
   509 
       
   510 EXPORT_C void RMemSpySession::OutputAOListL(TThreadId aId, TMemSpyThreadInfoItemType aType)
       
   511 	{
       
   512 	TPckgBuf<TThreadId> id(aId);
       
   513 	TPckgBuf<TMemSpyThreadInfoItemType> type(aType);
       
   514 	
       
   515 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpOutputAOList, TIpcArgs( &id, &type )));
       
   516 	}
       
   517 
       
   518 EXPORT_C void RMemSpySession::OutputKernelObjectsL()
       
   519 	{
   477 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpEnumerateKernelContainerAll));
   520 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpEnumerateKernelContainerAll));
   478 	}
   521 	}
   479 
   522 
   480 EXPORT_C void RMemSpySession::OutputCompactStackInfoL(TMemSpyOutputType aOutputType)
   523 EXPORT_C void RMemSpySession::OutputCompactStackInfoL()
   481 	{
   524 	{
   482 	SetOutputTypeL(aOutputType);
       
   483 					
       
   484 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpStackInfoCompact)); 
   525 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpStackInfoCompact)); 
   485 	}
   526 	}
   486 
   527 
   487 EXPORT_C void RMemSpySession::OutputCompactHeapInfoL(TMemSpyOutputType aOutputType)
   528 EXPORT_C void RMemSpySession::OutputCompactHeapInfoL()
   488 	{
   529 	{
   489 	SetOutputTypeL(aOutputType);
       
   490 						
       
   491 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapInfoCompact)); 
   530 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapInfoCompact)); 
   492 	}
   531 	}
   493 
   532 // Asynchronous operations
   494 void RMemSpySession::SetOutputTypeL(TMemSpyOutputType aOutputType)
   533 EXPORT_C void RMemSpySession::OutputPhoneInfo(TRequestStatus& aStatus)
   495 	{
   534 	{	
   496 	TInt operation = aOutputType == EOutputTypeFile ?
   535 	SendReceive(EMemSpyClientServerOpSummaryInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
   497 			EMemSpyClientServerOpSwitchOutputSinkFile :
   536 	}
   498 			EMemSpyClientServerOpSwitchOutputSinkTrace;
   537 
   499 	
   538 EXPORT_C void RMemSpySession::OutputDetailedPhoneInfo(TRequestStatus& aStatus)
   500 	User::LeaveIfError(SendReceive(operation));
   539 	{	
   501 	}
   540 	SendReceive(EMemSpyClientServerOpSummaryInfoDetailed | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   541 	}
       
   542 
       
   543 EXPORT_C void RMemSpySession::OutputHeapInfo(TRequestStatus& aStatus)
       
   544 	{	
       
   545 	SendReceive(EMemSpyClientServerOpHeapInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   546 	}
       
   547 
       
   548 EXPORT_C void RMemSpySession::OutputCompactHeapInfo(TRequestStatus& aStatus)
       
   549 	{	
       
   550 	SendReceive(EMemSpyClientServerOpHeapInfoCompact | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   551 	}
       
   552 
       
   553 EXPORT_C void RMemSpySession::OutputHeapCellListing(TRequestStatus& aStatus)
       
   554 	{	
       
   555 	SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   556 	}
       
   557 
       
   558 EXPORT_C void RMemSpySession::OutputHeapData(TRequestStatus& aStatus)
       
   559 	{	
       
   560 	SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   561 	}
       
   562 
       
   563 // synchronous version of the operation - for CLI
       
   564 EXPORT_C void RMemSpySession::OutputHeapData()
       
   565 	{
       
   566 	SendReceive(EMemSpyClientServerOpHeapData);
       
   567 	}
       
   568 
       
   569 EXPORT_C void RMemSpySession::OutputStackInfo(TRequestStatus& aStatus)
       
   570 	{	
       
   571 	SendReceive(EMemSpyClientServerOpStackInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   572 	}
       
   573 
       
   574 EXPORT_C void RMemSpySession::OutputCompactStackInfo(TRequestStatus& aStatus)
       
   575 	{	
       
   576 	SendReceive(EMemSpyClientServerOpStackInfoCompact | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   577 	}
       
   578 
       
   579 EXPORT_C void RMemSpySession::OutputUserStackData(TRequestStatus& aStatus)
       
   580 	{	
       
   581 	SendReceive(EMemSpyClientServerOpStackDataUser | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   582 	}
       
   583 
       
   584 EXPORT_C void RMemSpySession::OutputKernelStackData(TRequestStatus& aStatus)
       
   585 	{	
       
   586 	SendReceive(EMemSpyClientServerOpStackDataKernel | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
       
   587 	}
       
   588 
       
   589 // Synchronous operations
       
   590 EXPORT_C void RMemSpySession::OutputPhoneInfo()
       
   591 	{	
       
   592 	SendReceive( EMemSpyClientServerOpSummaryInfo , TIpcArgs() );
       
   593 	}
       
   594 
       
   595 EXPORT_C void RMemSpySession::SetSwmtConfig( TMemSpyEngineHelperSysMemTrackerConfig aConfig )
       
   596 	{
       
   597 	TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig> config(aConfig);
       
   598 	TIpcArgs args( &config );
       
   599 	
       
   600 	SendReceive( EMemSpyClientServerOpSetSwmtConfig, args) ;
       
   601 	}
       
   602 
       
   603 EXPORT_C void RMemSpySession::SetSwmtAutoStartProcessList( CArrayFixFlat<TUid>* aList )
       
   604 	{
       
   605 	TInt count = aList->Count();
       
   606 	TIpcArgs args( &aList, &count );
       
   607 	
       
   608 	SendReceive( EMemSpyClientServerOpSetSwmtAutoStartProcessList, args );
       
   609 	}
       
   610 
       
   611 EXPORT_C void RMemSpySession::SwmtResetTracking()
       
   612 	{
       
   613 	SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingReset );
       
   614 	}
       
   615 
       
   616 EXPORT_C void RMemSpySession::GetOutputSink( TMemSpySinkType aType )
       
   617 	{
       
   618 	TPckgBuf<TMemSpySinkType> type( aType );
       
   619 	TIpcArgs args( &type );
       
   620 	
       
   621 	SendReceive( EMemSpyClientServerOpGetOutputSink, args );
       
   622 	}
       
   623 
       
   624 EXPORT_C void RMemSpySession::NotifyDeviceWideOperationProgress(TMemSpyDeviceWideOperationProgress &aProgress, TRequestStatus &aStatus)
       
   625 	{
       
   626 	SendReceive(EMemSpyClientServerOpNotifyDeviceWideOperationProgress | KMemSpyOpFlagsAsyncOperation,
       
   627 			TIpcArgs(&aProgress.iProgress, &aProgress.iDescription), 
       
   628 			aStatus);
       
   629 	}
       
   630 
       
   631 EXPORT_C void RMemSpySession::CancelDeviceWideOperationL()
       
   632 	{
       
   633 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpCancelDeviceWideOperation));
       
   634 	}
       
   635 
       
   636 // SWMT operations
       
   637 EXPORT_C void RMemSpySession::SetSwmtCategoriesL(TInt aCategories)
       
   638 	{
       
   639 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet,
       
   640 			TIpcArgs(aCategories)));
       
   641 	}
       
   642 
       
   643 EXPORT_C void RMemSpySession::SetSwmtHeapDumpsEnabledL(TBool aEnabled)
       
   644 	{
       
   645 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpSet,
       
   646 			TIpcArgs(aEnabled)));
       
   647 	}
       
   648 
       
   649 EXPORT_C TBool RMemSpySession::IsSwmtRunningL()
       
   650 	{
       
   651 	TPckgBuf<TBool> ret;
       
   652 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpIsSwmtRunning, TIpcArgs(&ret)));
       
   653 	
       
   654 	return ret();
       
   655 	}
       
   656 
       
   657 EXPORT_C void RMemSpySession::StartSwmtTimerL(TInt aPeriod)
       
   658 	{
       
   659 	SetSwmtTimerIntervalL(aPeriod);
       
   660 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart));
       
   661 	}
       
   662 
       
   663 EXPORT_C void RMemSpySession::StartSwmtTimerL()
       
   664 	{
       
   665 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart));
       
   666 	}
       
   667 
       
   668 EXPORT_C void RMemSpySession::SetSwmtTimerIntervalL(TInt aPeriod)
       
   669 	{
       
   670 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet,
       
   671 			TIpcArgs(aPeriod)));
       
   672 	}
       
   673 
       
   674 EXPORT_C void RMemSpySession::StopSwmtTimerL()
       
   675 	{
       
   676 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop));
       
   677 	}
       
   678 
       
   679 
       
   680 EXPORT_C void RMemSpySession::ForceSwmtUpdateL()
       
   681 	{
       
   682 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate));
       
   683 	}
       
   684 
       
   685 EXPORT_C void RMemSpySession::ForceSwmtUpdate(TRequestStatus& aStatus)
       
   686 	{
       
   687 	SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate, 
       
   688 			TIpcArgs(),
       
   689 			aStatus);
       
   690 	}
       
   691 
       
   692 EXPORT_C void RMemSpySession::SetSwmtFilter( const TDesC& aFilter )
       
   693 	{	
       
   694 	TIpcArgs args( &aFilter );
       
   695 	User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet, args ) );
       
   696 	}
       
   697 
       
   698 EXPORT_C TInt TMemSpyDeviceWideOperationProgress::Progress() const 
       
   699 	{
       
   700 	return iProgress();
       
   701 	}
       
   702 
       
   703 EXPORT_C const TDesC& TMemSpyDeviceWideOperationProgress::Description() const
       
   704 	{
       
   705 	return iDescription;
       
   706 	}