memspy/MemSpyClient/src/memspysession.cpp
changeset 22 a009639409f5
parent 17 67c6ff54ec25
child 34 7259cf1302ad
equal deleted inserted replaced
17:67c6ff54ec25 22:a009639409f5
    15 *
    15 *
    16 */
    16 */
    17 
    17 
    18 
    18 
    19 #include "memspysession.h"
    19 #include "memspysession.h"
       
    20 #include <memspyengineclientinterface.h>
       
    21 
    20 #include <memspy/api/memspyapiprocess.h>
    22 #include <memspy/api/memspyapiprocess.h>
    21 #include <memspy/api/memspyapikernelobject.h>
    23 #include <memspy/api/memspyapikernelobject.h>
    22 #include <memspy/api/memspyapikernelobjectitem.h>
    24 #include <memspy/api/memspyapikernelobjectitem.h>
       
    25 #include <memspy/api/memspyapithreadinfoitem.h>
    23 //KernelObjects
    26 //KernelObjects
    24 #include <memspy/driver/memspydriverenumerationsshared.h>
    27 #include <memspy/driver/memspydriverenumerationsshared.h>
    25 // IMPLEMENTATION
    28 // IMPLEMENTATION
    26 
    29 
    27 EXPORT_C RMemSpySession::RMemSpySession()
    30 EXPORT_C RMemSpySession::RMemSpySession()
    33     {
    36     {
    34 	TInt error(KErrNone);
    37 	TInt error(KErrNone);
    35 	
    38 	
    36 	for (TInt i=0; i<2; i++) // Two retries max
    39 	for (TInt i=0; i<2; i++) // Two retries max
    37 		{
    40 		{
    38 		TInt error = CreateSession(KMemSpyServer2, TVersion(KMemSpyVersion, 0, 0));
    41 		TInt error = CreateSession(KMemSpyServerName, TVersion(KMemSpyVersion, 0, 0));
    39 		
    42 		
    40 		if (error != KErrNotFound && error != KErrServerTerminated)
    43 		if (error != KErrNotFound && error != KErrServerTerminated)
    41 			return error;
    44 			return error;
    42 		
    45 		
    43 		error = StartServer();
    46 		error = StartServer();
    52 TInt RMemSpySession::StartServer()
    55 TInt RMemSpySession::StartServer()
    53 	{
    56 	{
    54 	RProcess server;
    57 	RProcess server;
    55 	_LIT(KCommand, "start");
    58 	_LIT(KCommand, "start");
    56 	const TUid KServerUid3 = {0xE5883BC2};
    59 	const TUid KServerUid3 = {0xE5883BC2};
    57 	TInt error = server.Create(KMemSpyServer2, KCommand);//, KServerUid3);
    60 	TInt error = server.Create(KMemSpyServerName, KCommand);//, KServerUid3);
    58 	
    61 	
    59 	if (error != KErrNone)
    62 	if (error != KErrNone)
    60 		return error;
    63 		return error;
    61 	
    64 	
    62 	TRequestStatus startStatus, stopStatus;
    65 	TRequestStatus startStatus, stopStatus;
   174 //	}
   177 //	}
   175 
   178 
   176 EXPORT_C void RMemSpySession::GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType)
   179 EXPORT_C void RMemSpySession::GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType)
   177 	{
   180 	{
   178 	TPckgBuf<TInt> count;
   181 	TPckgBuf<TInt> count;
   179 	User::LeaveIfError(SendReceive(EGetProcessCount, TIpcArgs(&count)));
   182 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcessCount, TIpcArgs(&count)));
   180 	
   183 	
   181 	TInt requestedCount = count();
   184 	TInt requestedCount = count();
   182 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyProcessData));
   185 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyProcessData));
   183 	TPtr8 bufferPtr(buffer->Des());
   186 	TPtr8 bufferPtr(buffer->Des());
   184 	
   187 	
   185 	User::LeaveIfError(SendReceive(EGetProcesses, TIpcArgs(&count, &bufferPtr)));
   188 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcesses, TIpcArgs(&count, &bufferPtr)));
   186 	aProcesses.Reset();
   189 	aProcesses.Reset();
   187 	
   190 	
   188 	TInt receivedCount = Min(count(), requestedCount);
   191 	TInt receivedCount = Min(count(), requestedCount);
   189 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyProcessData))
   192 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyProcessData))
   190 		{
   193 		{
   194 		}
   197 		}
   195 	CleanupStack::Pop(aProcesses.Count());
   198 	CleanupStack::Pop(aProcesses.Count());
   196 	CleanupStack::PopAndDestroy(buffer);
   199 	CleanupStack::PopAndDestroy(buffer);
   197 	}
   200 	}
   198 
   201 
       
   202 EXPORT_C TProcessId RMemSpySession::GetProcessIdByNameL(const TDesC& aProcessName)
       
   203 	{
       
   204 	TPckgBuf<TProcessId> procId;
       
   205 	User::LeaveIfError(SendReceive(EMemSpyClienServerOpGetProcessIdByName, 
       
   206 			TIpcArgs(&aProcessName, &procId)));
       
   207 	
       
   208 	return procId();
       
   209 	}
       
   210 
   199 EXPORT_C TInt RMemSpySession::ProcessSystemPermanentOrCritical( TProcessId aId, TBool aValue )
   211 EXPORT_C TInt RMemSpySession::ProcessSystemPermanentOrCritical( TProcessId aId, TBool aValue )
   200 	{
   212 	{
   201 	TPckgBuf<TProcessId> arg1( aId );
   213 	TPckgBuf<TProcessId> arg1( aId );
   202 	TPckgBuf<TBool> arg2( aValue );
   214 	TPckgBuf<TBool> arg2( aValue );
   203 	TIpcArgs args( &arg1, &arg2 );
   215 	TIpcArgs args( &arg1, &arg2 );
   204 		
   216 		
   205 	TInt error = SendReceive( EProcessSystemPermanentOrCritical, args );
   217 	TInt error = SendReceive( EMemSpyClientServerOpProcessSystemPermanentOrCritical, args );
   206 	
   218 	
   207 	return error;
   219 	return error;
   208 	}
   220 	}
   209 
   221 
   210 EXPORT_C TInt RMemSpySession::EndProcess( TProcessId aId, TEndType aType )
   222 EXPORT_C TInt RMemSpySession::EndProcess( TProcessId aId, TMemSpyEndType aType )
   211 	{
   223 	{
   212 	TPckgBuf<TProcessId> arg1( aId );
   224 	TPckgBuf<TProcessId> arg1( aId );
   213 	TPckgBuf<TEndType> arg2( aType );
   225 	TPckgBuf<TMemSpyEndType> arg2( aType );
   214 	TIpcArgs args( &arg1, &arg2 );
   226 	TIpcArgs args( &arg1, &arg2 );
   215 	
   227 	
   216 	TInt error = SendReceive( EEndProcess, args );
   228 	TInt error = SendReceive( EMemSpyClientServerOpEndProcess, args );
   217 	
   229 	
   218 	return error;
   230 	return error;
   219 	}
   231 	}
   220 
   232 
   221 EXPORT_C TInt RMemSpySession::SwitchToProcess( TProcessId aId, TBool aBrought )
   233 EXPORT_C TInt RMemSpySession::SwitchToProcess( TProcessId aId, TBool aBrought )
   222 	{
   234 	{
   223 	TPckgBuf<TProcessId> arg1( aId );
   235 	TPckgBuf<TProcessId> arg1( aId );
   224 	TPckgBuf<TBool> arg2( aBrought );
   236 	TPckgBuf<TBool> arg2( aBrought );
   225 	TIpcArgs args( &arg1, &arg2 );
   237 	TIpcArgs args( &arg1, &arg2 );
   226 	
   238 	
   227 	TInt error = SendReceive( ESwitchToProcess, args );
   239 	TInt error = SendReceive( EMemSpyClientServerOpSwitchToProcess, args );
   228 	
   240 	
   229 	return error;	
   241 	return error;	
   230 	}
   242 	}
   231 
   243 
   232 EXPORT_C void RMemSpySession::GetThreadsL(TProcessId aProcessId, RArray<CMemSpyApiThread*> &aThreads, TSortType aSortType)
   244 EXPORT_C void RMemSpySession::GetThreadsL(TProcessId aProcessId, RArray<CMemSpyApiThread*> &aThreads, TSortType aSortType)
   233 	{
   245 	{
   234 	TPckgBuf<TInt> count;
   246 	TPckgBuf<TInt> count;
   235 	TPckgBuf<TProcessId> pid(aProcessId);
   247 	TPckgBuf<TProcessId> pid(aProcessId);
   236 	User::LeaveIfError(SendReceive(EGetThreadCount, TIpcArgs(&count, &pid)));
   248 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetThreadCount, TIpcArgs(&count, &pid)));
   237 	
   249 	
   238 	TInt requestedCount = count();
   250 	TInt requestedCount = count();
   239 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyThreadData));
   251 	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyThreadData));
   240 	TPtr8 bufferPtr(buffer->Des());
   252 	TPtr8 bufferPtr(buffer->Des());
   241 	
   253 	
   242 	User::LeaveIfError(SendReceive(EGetThreads, TIpcArgs(&count, &bufferPtr, &pid)));
   254 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetThreads, TIpcArgs(&count, &bufferPtr, &pid)));
   243 	aThreads.Reset();
   255 	aThreads.Reset();
   244 	
   256 	
   245 	TInt receivedCount = Min(count(), requestedCount);
   257 	TInt receivedCount = Min(count(), requestedCount);
   246 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyThreadData))
   258 	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyThreadData))
   247 		{
   259 		{
   256 EXPORT_C void RMemSpySession::SetThreadPriorityL(TThreadId aId, TInt aPriority)
   268 EXPORT_C void RMemSpySession::SetThreadPriorityL(TThreadId aId, TInt aPriority)
   257 	{
   269 	{
   258 	TPckgBuf<TThreadId> arg1( aId );
   270 	TPckgBuf<TThreadId> arg1( aId );
   259 	TPckgBuf<TInt> arg2( aPriority );
   271 	TPckgBuf<TInt> arg2( aPriority );
   260 	
   272 	
   261 	User::LeaveIfError(SendReceive( ESetThreadPriority, TIpcArgs(&arg1, &arg2)));
   273 	User::LeaveIfError(SendReceive( EMemSpyClientServerOpSetThreadPriority, TIpcArgs(&arg1, &arg2)));
   262 	}
   274 	}
   263 
   275 
   264 EXPORT_C TInt RMemSpySession::ThreadSystemPermanentOrCritical( TThreadId aId, TBool aValue )
   276 EXPORT_C TInt RMemSpySession::ThreadSystemPermanentOrCritical( TThreadId aId, TBool aValue )
   265 	{
   277 	{
   266 	TPckgBuf<TThreadId> arg1( aId );
   278 	TPckgBuf<TThreadId> arg1( aId );
   267 	TPckgBuf<TBool> arg2( aValue );
   279 	TPckgBuf<TBool> arg2( aValue );
   268 	TIpcArgs args( &arg1, &arg2 );
   280 	TIpcArgs args( &arg1, &arg2 );
   269 	
   281 	
   270 	TInt error = SendReceive( EThreadSystemPermanentOrCritical, args );
   282 	TInt error = SendReceive( EMemSpyClientServerOpThreadSystemPermanentOrCritical, args );
   271 	
   283 	
   272 	return error;
   284 	return error;
   273 	}
   285 	}
   274 
   286 
   275 EXPORT_C TInt RMemSpySession::EndThread( TThreadId aId, TEndType aType )
   287 EXPORT_C TInt RMemSpySession::EndThread( TThreadId aId, TMemSpyEndType aType )
   276 	{
   288 	{
   277 	TPckgBuf<TThreadId> arg1( aId );
   289 	TPckgBuf<TThreadId> arg1( aId );
   278 	TPckgBuf<TEndType> arg2( aType );
   290 	TPckgBuf<TMemSpyEndType> arg2( aType );
   279 	TIpcArgs args( &arg1, &arg2 );
   291 	TIpcArgs args( &arg1, &arg2 );
   280 	
   292 	
   281 	TInt error = SendReceive( EEndThread, args );
   293 	TInt error = SendReceive( EMemSpyClientServerOpEndThread, args );
   282 	
   294 	
   283 	return error;
   295 	return error;
   284 	}
   296 	}
   285 
   297 
   286 EXPORT_C TInt RMemSpySession::SwitchToThread( TThreadId aId, TBool aBrought )
   298 EXPORT_C TInt RMemSpySession::SwitchToThread( TThreadId aId, TBool aBrought )
   287 	{
   299 	{
   288 	
   300 	TPckgBuf<TThreadId> arg1( aId );
   289 	}
   301 	TPckgBuf<TBool> arg2( aBrought );
   290 /*
   302 	TIpcArgs args( &arg1, &arg2 );
   291 EXPORT_C TInt RMemSpySession::TerminateThread( TThreadId aId )
   303 	
   292 	{
   304 	TInt error = SendReceive( EMemSpyClientServerOpSwitchToThread, args );
   293 	TPckgBuf<TThreadId> arg( aId );
   305 	
   294 	TIpcArgs args( &arg );
   306 	return error;	
   295 	
   307 	}
   296 	TInt error = SendReceive( ETerminateThread, args );
   308 
       
   309 EXPORT_C TInt RMemSpySession::GetInfoItemType( TInt aIndex, TThreadId aId, TMemSpyThreadInfoItemType &aType )
       
   310 	{
       
   311 	TPckgBuf<TInt> arg1( aIndex );
       
   312 	TPckgBuf<TThreadId> arg2( aId );
       
   313 	TPckgBuf<TMemSpyThreadInfoItemType> arg3;
       
   314 	TIpcArgs args( &arg1, &arg2, &arg3 );
       
   315 		
       
   316 	TInt error = SendReceive( EMemSpyClientServerOpGetInfoItemType, args );
       
   317 	
       
   318 	aType = arg3();
   297 	
   319 	
   298 	return error;
   320 	return error;
   299 	}
   321 	}
   300 */
   322 
   301 
   323 EXPORT_C void RMemSpySession::GetThreadInfoItems( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
   302 //inline void RMemSpySession::SortProcessesBy( TSortType aType )
   324 	{
   303 //	{
   325 	TPckgBuf<TThreadId> id( aId );	
   304 //	TPckgBuf<TSortType> In( aType );
   326 	TPckgBuf<TMemSpyThreadInfoItemType> type( aType );
   305 //	TIpcArgs args( &In );
   327 	TPckgBuf<TInt> count;	
   306 //	SendReceive( ESortProcessesBy, args );
   328 	
   307 //	}
   329 	TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItemsCount, TIpcArgs( &id, &type, &count ) );
   308 
   330 	TInt itemCount = count();
   309 //inline void RMemSpySession::OpenCloseCurrentProcess( TProcessId aId, TBool  aOpen )
   331 	
   310 //	{
   332 	if( error == KErrNone )
   311 //	TPckgBuf<TProcessId> In1( aId );
   333 		{		
   312 //	TPckgBuf<TBool> In2( aOpen );
   334 		if( itemCount == 0 )
   313 //	TIpcArgs args( &In1, &In2 );
   335 			{
   314 //	SendReceive( EOpenCloseCurrentProcess, args );
   336 			aInfoItems.Reset();
   315 //	}
   337 			}
       
   338 		else
       
   339 			{
       
   340 			HBufC8* buffer = HBufC8::NewLC( itemCount * sizeof(TMemSpyThreadInfoItemData) );
       
   341 			TPtr8 bufferPtr(buffer->Des());
       
   342 			
       
   343 			TPckgBuf<TInt> requestedCount( itemCount );
       
   344 			
       
   345 			TIpcArgs args( &requestedCount, &id, &type, &bufferPtr );
       
   346 			TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItems, args );
       
   347 		
       
   348 			for(TInt i=0, offset = 0; i < itemCount; i++, offset+=sizeof(TMemSpyThreadInfoItemData))
       
   349 				{
       
   350 				TPckgBuf<TMemSpyThreadInfoItemData> data;
       
   351 				data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadInfoItemData));
       
   352 				aInfoItems.AppendL(CMemSpyApiThreadInfoItem::NewL(data()));
       
   353 				}
       
   354 						
       
   355 			CleanupStack::PopAndDestroy(buffer);
       
   356 			}
       
   357 		}		
       
   358 	}
   316 
   359 
   317 //Kernel Objects specific operations
   360 //Kernel Objects specific operations
   318 EXPORT_C TInt RMemSpySession::GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
   361 EXPORT_C TInt RMemSpySession::GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
   319 	{		
   362 	{		
   320 	TPckgBuf<TInt> count;
   363 	TPckgBuf<TInt> count;
   321 	TInt error = SendReceive( EGetKernelObjectTypeCount, TIpcArgs(&count) );
   364 	TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjectCount, TIpcArgs(&count) );
   322 	
   365 	
   323 	if( error == KErrNone )
   366 	if( error == KErrNone )
   324 		{			
   367 		{			
   325 		TInt requestedCount = count();
   368 		TInt requestedCount = count();
   326 		HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyKernelObjectData));
   369 		HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyKernelObjectData));
   327 		TPtr8 bufferPtr(buffer->Des());
   370 		TPtr8 bufferPtr(buffer->Des());
   328 			
   371 			
   329 		TPckgBuf<TInt> count(requestedCount);
   372 		TPckgBuf<TInt> count(requestedCount);
   330 		TIpcArgs args( &count, &bufferPtr );
   373 		TIpcArgs args( &count, &bufferPtr );
   331 		TInt error = SendReceive( EGetKernelObjects, args );
   374 		TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjects, args );
   332 			
   375 			
   333 		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))
   334 			{
   377 			{
   335 			TPckgBuf<TMemSpyKernelObjectData> data;
   378 			TPckgBuf<TMemSpyKernelObjectData> data;
   336 			data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyKernelObjectData));
   379 			data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyKernelObjectData));
   344 
   387 
   345 EXPORT_C TInt RMemSpySession::GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
   388 EXPORT_C TInt RMemSpySession::GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
   346 	{
   389 	{
   347 	TPckgBuf<TInt> count;
   390 	TPckgBuf<TInt> count;
   348 	TPckgBuf<TMemSpyDriverContainerType> type(aForContainer);
   391 	TPckgBuf<TMemSpyDriverContainerType> type(aForContainer);
   349 	TInt error = SendReceive( EGetKernelObjectItemsCount, TIpcArgs(&count, &type) );
   392 	TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjectItemCount, TIpcArgs(&count, &type) );
   350 		
   393 		
   351 	if (error == KErrNone)
   394 	if (error == KErrNone)
   352 		{
   395 		{
   353 		TInt requestedCount = count();
   396 		TInt requestedCount = count();
   354 		HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyDriverHandleInfoGeneric));
   397 		HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyDriverHandleInfoGeneric));
   355 		TPtr8 bufferPtr(buffer->Des());
   398 		TPtr8 bufferPtr(buffer->Des());
   356 		
   399 		
   357 		TPckgBuf<TInt> count(requestedCount);
   400 		TPckgBuf<TInt> count(requestedCount);
   358 		TIpcArgs args( &count, &type, &bufferPtr );
   401 		TIpcArgs args( &count, &type, &bufferPtr );
   359 		TInt error = SendReceive( EGetKernelObjectItems, args );
   402 		TInt error = SendReceive( EMemSpyClientServerOpGetKernelObjectItems, args );
   360 		
   403 		
   361 		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))
   362 			{
   405 			{
   363 			TPckgBuf<TMemSpyDriverHandleInfoGeneric> data;
   406 			TPckgBuf<TMemSpyDriverHandleInfoGeneric> data;
   364 			data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyDriverHandleInfoGeneric));
   407 			data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyDriverHandleInfoGeneric));
   368 		CleanupStack::PopAndDestroy(buffer);				
   411 		CleanupStack::PopAndDestroy(buffer);				
   369 		}
   412 		}
   370 	return KErrNone;
   413 	return KErrNone;
   371 	}
   414 	}
   372 
   415 
       
   416 EXPORT_C void RMemSpySession::OutputAllContainerContents()
       
   417 	{
       
   418 	SendReceive( EMemSpyClientServerOpOutputAllContainerContents );
       
   419 	}
       
   420 
       
   421 
   373 //Heap specific operations
   422 //Heap specific operations
   374 EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeap()
   423 EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeap()
   375 	{
   424 	{
   376 	CMemSpyApiHeap* aHeap;
   425 	CMemSpyApiHeap* aHeap;
   377 	TInt error = KErrNone;
   426 	TInt error = KErrNone;
   378 	
   427 	
   379 	HBufC8* buffer = HBufC8::NewLC( sizeof(TMemSpyHeapData) );
   428 	HBufC8* buffer = HBufC8::NewLC( sizeof(TMemSpyHeapData) );
   380 	TPtr8 bufferPtr(buffer->Des());
   429 	TPtr8 bufferPtr(buffer->Des());
   381 	TIpcArgs args( &bufferPtr );
   430 	TIpcArgs args( &bufferPtr );
   382 	
   431 	
   383 	error = SendReceive( EGetHeap, args );
   432 	error = SendReceive( EMemSpyClientServerOpGetHeap, args );
   384 	
   433 	
   385 	if( error == KErrNone )
   434 	if( error == KErrNone )
   386 		{
   435 		{
   387 		TPckgBuf<TMemSpyHeapData> data;
   436 		TPckgBuf<TMemSpyHeapData> data;
   388 		data.Copy(bufferPtr.Ptr(), sizeof(TMemSpyHeapData));		
   437 		data.Copy(bufferPtr.Ptr(), sizeof(TMemSpyHeapData));		
   390 		}
   439 		}
   391 	CleanupStack::PopAndDestroy(buffer);
   440 	CleanupStack::PopAndDestroy(buffer);
   392 		
   441 		
   393 	return aHeap;
   442 	return aHeap;
   394 	}
   443 	}
       
   444 
       
   445 EXPORT_C void RMemSpySession::DumpKernelHeap()
       
   446 	{
       
   447 	SendReceive( EMemSpyClientServerOpDumpKernelHeap );
       
   448 	}
       
   449 
       
   450 EXPORT_C void RMemSpySession::OutputKernelHeapDataL(TMemSpyOutputType aOutputType)
       
   451 	{
       
   452 	SetOutputTypeL(aOutputType);
       
   453 	
       
   454 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
       
   455 			TIpcArgs(KMemSpyClientServerThreadIdKernel)));
       
   456 	
       
   457 	}
       
   458 EXPORT_C void RMemSpySession::OutputThreadHeapDataL(TMemSpyOutputType aOutputType, TThreadId aThreadId)
       
   459 	{
       
   460 	SetOutputTypeL(aOutputType);
       
   461 		
       
   462 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
       
   463 			TIpcArgs(aThreadId)));
       
   464 	}
       
   465 EXPORT_C void RMemSpySession::OutputThreadCellListL(TMemSpyOutputType aOutputType, TThreadId aThreadId)
       
   466 	{
       
   467 	SetOutputTypeL(aOutputType);
       
   468 			
       
   469 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsIncludesThreadId,
       
   470 			TIpcArgs(aThreadId)));
       
   471 	}
       
   472 
       
   473 EXPORT_C void RMemSpySession::OutputKernelObjectsL(TMemSpyOutputType aOutputType)
       
   474 	{
       
   475 	SetOutputTypeL(aOutputType);
       
   476 				
       
   477 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpEnumerateKernelContainerAll));
       
   478 	}
       
   479 
       
   480 EXPORT_C void RMemSpySession::OutputCompactStackInfoL(TMemSpyOutputType aOutputType)
       
   481 	{
       
   482 	SetOutputTypeL(aOutputType);
       
   483 					
       
   484 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpStackInfoCompact)); 
       
   485 	}
       
   486 
       
   487 EXPORT_C void RMemSpySession::OutputCompactHeapInfoL(TMemSpyOutputType aOutputType)
       
   488 	{
       
   489 	SetOutputTypeL(aOutputType);
       
   490 						
       
   491 	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapInfoCompact)); 
       
   492 	}
       
   493 
       
   494 void RMemSpySession::SetOutputTypeL(TMemSpyOutputType aOutputType)
       
   495 	{
       
   496 	TInt operation = aOutputType == EOutputTypeFile ?
       
   497 			EMemSpyClientServerOpSwitchOutputSinkFile :
       
   498 			EMemSpyClientServerOpSwitchOutputSinkTrace;
       
   499 	
       
   500 	User::LeaveIfError(SendReceive(operation));
       
   501 	}