perfsrv/memspy/MemSpyClient/src/memspysession.cpp
author hgs
Wed, 29 Sep 2010 17:45:35 +0300
changeset 54 a151135b0cf9
parent 52 c2f44e33b468
child 62 1c2bb2fc7c87
permissions -rw-r--r--
201039
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
51
hgs
parents:
diff changeset
     1
/*
hgs
parents:
diff changeset
     2
* Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). 
hgs
parents:
diff changeset
     3
* All rights reserved.
hgs
parents:
diff changeset
     4
* This component and the accompanying materials are made available
hgs
parents:
diff changeset
     5
* under the terms of "Eclipse Public License v1.0"
hgs
parents:
diff changeset
     6
* which accompanies this distribution, and is available
hgs
parents:
diff changeset
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
hgs
parents:
diff changeset
     8
*
hgs
parents:
diff changeset
     9
* Initial Contributors:
hgs
parents:
diff changeset
    10
* Nokia Corporation - initial contribution.
hgs
parents:
diff changeset
    11
*
hgs
parents:
diff changeset
    12
* Contributors:
hgs
parents:
diff changeset
    13
*
hgs
parents:
diff changeset
    14
* Description:
hgs
parents:
diff changeset
    15
*
hgs
parents:
diff changeset
    16
*/
hgs
parents:
diff changeset
    17
hgs
parents:
diff changeset
    18
hgs
parents:
diff changeset
    19
#include "memspysession.h"
hgs
parents:
diff changeset
    20
hgs
parents:
diff changeset
    21
#include <memspyengineclientinterface.h>
hgs
parents:
diff changeset
    22
// API
hgs
parents:
diff changeset
    23
#include <memspy/engine/memspyprocessdata.h>
hgs
parents:
diff changeset
    24
#include <memspy/engine/memspythreaddata.h> 
hgs
parents:
diff changeset
    25
#include <memspy/engine/memspykernelobjectdata.h>
hgs
parents:
diff changeset
    26
#include <memspy/engine/memspyheapdata.h>
hgs
parents:
diff changeset
    27
#include <memspy/engine/memspymemorytrackingcycledata.h>
hgs
parents:
diff changeset
    28
//KernelObjects
hgs
parents:
diff changeset
    29
#include <memspy/driver/memspydriverenumerationsshared.h>
hgs
parents:
diff changeset
    30
// Servers
hgs
parents:
diff changeset
    31
#include <memspy/engine/memspyserverdata.h>
hgs
parents:
diff changeset
    32
// ECom
hgs
parents:
diff changeset
    33
#include <memspy/engine/memspyecomdata.h>
52
hgs
parents: 51
diff changeset
    34
// Window groups
hgs
parents: 51
diff changeset
    35
#include <memspy/engine/memspyenginehelperwindowserver.h>
51
hgs
parents:
diff changeset
    36
hgs
parents:
diff changeset
    37
// IMPLEMENTATION
hgs
parents:
diff changeset
    38
hgs
parents:
diff changeset
    39
EXPORT_C RMemSpySession::RMemSpySession()
hgs
parents:
diff changeset
    40
    {
hgs
parents:
diff changeset
    41
    }
hgs
parents:
diff changeset
    42
hgs
parents:
diff changeset
    43
hgs
parents:
diff changeset
    44
EXPORT_C TInt RMemSpySession::Connect()
hgs
parents:
diff changeset
    45
    {
hgs
parents:
diff changeset
    46
	TInt error(KErrNone);
hgs
parents:
diff changeset
    47
	
hgs
parents:
diff changeset
    48
	for (TInt i=0; i<2; i++) // Two retries max
hgs
parents:
diff changeset
    49
		{
hgs
parents:
diff changeset
    50
		TInt error = CreateSession(KMemSpyServerName, TVersion(KMemSpyVersion, 0, 0));
hgs
parents:
diff changeset
    51
		
hgs
parents:
diff changeset
    52
		if (error != KErrNotFound && error != KErrServerTerminated)
hgs
parents:
diff changeset
    53
			return error;
hgs
parents:
diff changeset
    54
		
hgs
parents:
diff changeset
    55
		error = StartServer();
hgs
parents:
diff changeset
    56
		
hgs
parents:
diff changeset
    57
		if (error != KErrNone && error != KErrAlreadyExists)
hgs
parents:
diff changeset
    58
			return error;
hgs
parents:
diff changeset
    59
		}
hgs
parents:
diff changeset
    60
	
hgs
parents:
diff changeset
    61
	return error;	
hgs
parents:
diff changeset
    62
    }
hgs
parents:
diff changeset
    63
hgs
parents:
diff changeset
    64
TInt RMemSpySession::StartServer()
hgs
parents:
diff changeset
    65
	{
hgs
parents:
diff changeset
    66
	RProcess server;
hgs
parents:
diff changeset
    67
	_LIT(KCommand, "start");
hgs
parents:
diff changeset
    68
	const TUid KServerUid3 = {0xE5883BC2};
hgs
parents:
diff changeset
    69
	TInt error = server.Create(KMemSpyServerName, KCommand);//, KServerUid3);
hgs
parents:
diff changeset
    70
	
hgs
parents:
diff changeset
    71
	if (error != KErrNone)
hgs
parents:
diff changeset
    72
		return error;
hgs
parents:
diff changeset
    73
	
hgs
parents:
diff changeset
    74
	TRequestStatus startStatus, stopStatus;
hgs
parents:
diff changeset
    75
	server.Logon(stopStatus);
hgs
parents:
diff changeset
    76
	if (stopStatus != KRequestPending)
hgs
parents:
diff changeset
    77
		{
hgs
parents:
diff changeset
    78
		User::WaitForRequest(stopStatus);
hgs
parents:
diff changeset
    79
		server.Kill(0);
hgs
parents:
diff changeset
    80
		server.Close();
hgs
parents:
diff changeset
    81
		return stopStatus.Int();
hgs
parents:
diff changeset
    82
		}
hgs
parents:
diff changeset
    83
	
hgs
parents:
diff changeset
    84
	server.Rendezvous(startStatus);
hgs
parents:
diff changeset
    85
	server.Resume();
hgs
parents:
diff changeset
    86
	User::WaitForRequest(startStatus, stopStatus);
hgs
parents:
diff changeset
    87
	if (startStatus == KRequestPending)
hgs
parents:
diff changeset
    88
		{
hgs
parents:
diff changeset
    89
		// not started yet, i.e. stopStatus was signaled
hgs
parents:
diff changeset
    90
		server.Close();
hgs
parents:
diff changeset
    91
		return stopStatus.Int();
hgs
parents:
diff changeset
    92
		}
hgs
parents:
diff changeset
    93
	
hgs
parents:
diff changeset
    94
	// Rendezvous was called - the server is ready
hgs
parents:
diff changeset
    95
	
hgs
parents:
diff changeset
    96
	// We first need to cancel Logon
hgs
parents:
diff changeset
    97
	server.LogonCancel(stopStatus);
hgs
parents:
diff changeset
    98
	// We don't need this anymore
hgs
parents:
diff changeset
    99
	server.Close();
hgs
parents:
diff changeset
   100
	// Wait for LogonCancel to complete
hgs
parents:
diff changeset
   101
	User::WaitForRequest(stopStatus);
hgs
parents:
diff changeset
   102
hgs
parents:
diff changeset
   103
	// Everything went OK
hgs
parents:
diff changeset
   104
	return KErrNone;
hgs
parents:
diff changeset
   105
	}
hgs
parents:
diff changeset
   106
hgs
parents:
diff changeset
   107
EXPORT_C void RMemSpySession::GetProcessesL(RArray<CMemSpyApiProcess*> &aProcesses, TSortType aSortType)
hgs
parents:
diff changeset
   108
	{
hgs
parents:
diff changeset
   109
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   110
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcessCount, TIpcArgs(&count)));
hgs
parents:
diff changeset
   111
	
hgs
parents:
diff changeset
   112
	TInt requestedCount = count();
hgs
parents:
diff changeset
   113
	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyProcessData));
hgs
parents:
diff changeset
   114
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   115
	
hgs
parents:
diff changeset
   116
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetProcesses, TIpcArgs(&count, &bufferPtr)));
hgs
parents:
diff changeset
   117
	aProcesses.Reset();
hgs
parents:
diff changeset
   118
	
hgs
parents:
diff changeset
   119
	TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   120
	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyProcessData))
hgs
parents:
diff changeset
   121
		{
hgs
parents:
diff changeset
   122
		TPckgBuf<TMemSpyProcessData> data;
hgs
parents:
diff changeset
   123
		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyProcessData));
hgs
parents:
diff changeset
   124
		aProcesses.AppendL(CMemSpyApiProcess::NewLC(data()));
hgs
parents:
diff changeset
   125
		}
hgs
parents:
diff changeset
   126
	CleanupStack::Pop(aProcesses.Count());
hgs
parents:
diff changeset
   127
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   128
	}
hgs
parents:
diff changeset
   129
hgs
parents:
diff changeset
   130
EXPORT_C TProcessId RMemSpySession::GetProcessIdByNameL(const TDesC& aProcessName)
hgs
parents:
diff changeset
   131
	{
hgs
parents:
diff changeset
   132
	TPckgBuf<TProcessId> procId;
hgs
parents:
diff changeset
   133
	User::LeaveIfError(SendReceive(EMemSpyClienServerOpGetProcessIdByName, 
hgs
parents:
diff changeset
   134
			TIpcArgs(&aProcessName, &procId)));
hgs
parents:
diff changeset
   135
	
hgs
parents:
diff changeset
   136
	return procId();
hgs
parents:
diff changeset
   137
	}
hgs
parents:
diff changeset
   138
hgs
parents:
diff changeset
   139
EXPORT_C TInt RMemSpySession::ProcessSystemPermanentOrCritical( TProcessId aId, TBool aValue )
hgs
parents:
diff changeset
   140
	{
hgs
parents:
diff changeset
   141
	TPckgBuf<TProcessId> arg1( aId );
hgs
parents:
diff changeset
   142
	TPckgBuf<TBool> arg2( aValue );
hgs
parents:
diff changeset
   143
	TIpcArgs args( &arg1, &arg2 );
hgs
parents:
diff changeset
   144
		
hgs
parents:
diff changeset
   145
	TInt error = SendReceive( EMemSpyClientServerOpProcessSystemPermanentOrCritical, args );
hgs
parents:
diff changeset
   146
	
hgs
parents:
diff changeset
   147
	aValue = arg2();
hgs
parents:
diff changeset
   148
	
hgs
parents:
diff changeset
   149
	return error;
hgs
parents:
diff changeset
   150
	}
hgs
parents:
diff changeset
   151
hgs
parents:
diff changeset
   152
EXPORT_C TInt RMemSpySession::EndProcessL( TProcessId aId, TMemSpyEndType aType )
hgs
parents:
diff changeset
   153
	{
hgs
parents:
diff changeset
   154
	TPckgBuf<TProcessId> arg1( aId );
hgs
parents:
diff changeset
   155
	TPckgBuf<TMemSpyEndType> arg2( aType );
hgs
parents:
diff changeset
   156
	TIpcArgs args( &arg1, &arg2 );
hgs
parents:
diff changeset
   157
	
hgs
parents:
diff changeset
   158
	TInt error = SendReceive( EMemSpyClientServerOpEndProcess, args );
hgs
parents:
diff changeset
   159
	
hgs
parents:
diff changeset
   160
	return error;
hgs
parents:
diff changeset
   161
	}
hgs
parents:
diff changeset
   162
hgs
parents:
diff changeset
   163
EXPORT_C TInt RMemSpySession::SwitchToProcess( TProcessId aId, TBool aBrought )
hgs
parents:
diff changeset
   164
	{
hgs
parents:
diff changeset
   165
	TPckgBuf<TProcessId> arg1( aId );
hgs
parents:
diff changeset
   166
	TPckgBuf<TBool> arg2( aBrought );
hgs
parents:
diff changeset
   167
	TIpcArgs args( &arg1, &arg2 );
hgs
parents:
diff changeset
   168
	
hgs
parents:
diff changeset
   169
	TInt error = SendReceive( EMemSpyClientServerOpSwitchToProcess, args );
hgs
parents:
diff changeset
   170
	
hgs
parents:
diff changeset
   171
	return error;	
hgs
parents:
diff changeset
   172
	}
hgs
parents:
diff changeset
   173
hgs
parents:
diff changeset
   174
// Threads related methods
hgs
parents:
diff changeset
   175
EXPORT_C void RMemSpySession::GetThreadsL(TProcessId aProcessId, RArray<CMemSpyApiThread*> &aThreads, TSortType aSortType)
hgs
parents:
diff changeset
   176
	{
hgs
parents:
diff changeset
   177
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   178
	TPckgBuf<TProcessId> pid(aProcessId);
hgs
parents:
diff changeset
   179
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetThreadCount, TIpcArgs(&count, &pid)));
hgs
parents:
diff changeset
   180
	
hgs
parents:
diff changeset
   181
	TInt requestedCount = count();
hgs
parents:
diff changeset
   182
	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyThreadData));
hgs
parents:
diff changeset
   183
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   184
	
hgs
parents:
diff changeset
   185
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetThreads, TIpcArgs(&count, &bufferPtr, &pid)));
hgs
parents:
diff changeset
   186
	aThreads.Reset();
hgs
parents:
diff changeset
   187
	
hgs
parents:
diff changeset
   188
	TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   189
	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyThreadData))
hgs
parents:
diff changeset
   190
		{
hgs
parents:
diff changeset
   191
		TPckgBuf<TMemSpyThreadData> data;
hgs
parents:
diff changeset
   192
		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadData));
hgs
parents:
diff changeset
   193
		aThreads.AppendL(CMemSpyApiThread::NewLC(data()));
hgs
parents:
diff changeset
   194
		}
hgs
parents:
diff changeset
   195
	CleanupStack::Pop(aThreads.Count());
hgs
parents:
diff changeset
   196
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   197
	}
hgs
parents:
diff changeset
   198
hgs
parents:
diff changeset
   199
EXPORT_C void RMemSpySession::SetThreadPriorityL(TThreadId aId, TInt aPriority)
hgs
parents:
diff changeset
   200
	{
hgs
parents:
diff changeset
   201
	TPckgBuf<TThreadId> arg1( aId );
hgs
parents:
diff changeset
   202
	TPckgBuf<TInt> arg2( aPriority );
hgs
parents:
diff changeset
   203
	
hgs
parents:
diff changeset
   204
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpSetThreadPriority, TIpcArgs(&arg1, &arg2)));
hgs
parents:
diff changeset
   205
	}
hgs
parents:
diff changeset
   206
hgs
parents:
diff changeset
   207
EXPORT_C TInt RMemSpySession::ThreadSystemPermanentOrCritical( TThreadId aId, TBool aValue )
hgs
parents:
diff changeset
   208
	{
hgs
parents:
diff changeset
   209
	TPckgBuf<TThreadId> arg1( aId );
hgs
parents:
diff changeset
   210
	TPckgBuf<TBool> arg2( aValue );
hgs
parents:
diff changeset
   211
	TIpcArgs args( &arg1, &arg2 );
hgs
parents:
diff changeset
   212
	
hgs
parents:
diff changeset
   213
	TInt error = SendReceive( EMemSpyClientServerOpThreadSystemPermanentOrCritical, args );
hgs
parents:
diff changeset
   214
	
hgs
parents:
diff changeset
   215
	aValue = arg2();
hgs
parents:
diff changeset
   216
	
hgs
parents:
diff changeset
   217
	return error;
hgs
parents:
diff changeset
   218
	}
hgs
parents:
diff changeset
   219
hgs
parents:
diff changeset
   220
EXPORT_C TInt RMemSpySession::EndThreadL( TThreadId aId, TMemSpyEndType aType )
hgs
parents:
diff changeset
   221
	{
hgs
parents:
diff changeset
   222
	TPckgBuf<TThreadId> arg1( aId );
hgs
parents:
diff changeset
   223
	TPckgBuf<TMemSpyEndType> arg2( aType );
hgs
parents:
diff changeset
   224
	TIpcArgs args( &arg1, &arg2 );
hgs
parents:
diff changeset
   225
	
hgs
parents:
diff changeset
   226
	TInt error = SendReceive( EMemSpyClientServerOpEndThread, args );
hgs
parents:
diff changeset
   227
	
hgs
parents:
diff changeset
   228
	return error;
hgs
parents:
diff changeset
   229
	}
hgs
parents:
diff changeset
   230
hgs
parents:
diff changeset
   231
EXPORT_C TInt RMemSpySession::SwitchToThread( TThreadId aId, TBool aBrought )
hgs
parents:
diff changeset
   232
	{
hgs
parents:
diff changeset
   233
	TPckgBuf<TThreadId> arg1( aId );
hgs
parents:
diff changeset
   234
	TPckgBuf<TBool> arg2( aBrought );
hgs
parents:
diff changeset
   235
	TIpcArgs args( &arg1, &arg2 );
hgs
parents:
diff changeset
   236
	
hgs
parents:
diff changeset
   237
	TInt error = SendReceive( EMemSpyClientServerOpSwitchToThread, args );
hgs
parents:
diff changeset
   238
	
hgs
parents:
diff changeset
   239
	return error;	
hgs
parents:
diff changeset
   240
	}
hgs
parents:
diff changeset
   241
hgs
parents:
diff changeset
   242
EXPORT_C TInt RMemSpySession::GetInfoItemType( TInt aIndex, TThreadId aId, TMemSpyThreadInfoItemType &aType )
hgs
parents:
diff changeset
   243
	{
hgs
parents:
diff changeset
   244
	TPckgBuf<TInt> arg1( aIndex );
hgs
parents:
diff changeset
   245
	TPckgBuf<TThreadId> arg2( aId );
hgs
parents:
diff changeset
   246
	TPckgBuf<TMemSpyThreadInfoItemType> arg3;
hgs
parents:
diff changeset
   247
	TIpcArgs args( &arg1, &arg2, &arg3 );
hgs
parents:
diff changeset
   248
		
hgs
parents:
diff changeset
   249
	TInt error = SendReceive( EMemSpyClientServerOpGetInfoItemType, args );
hgs
parents:
diff changeset
   250
	
hgs
parents:
diff changeset
   251
	aType = arg3();
hgs
parents:
diff changeset
   252
	
hgs
parents:
diff changeset
   253
	return error;
hgs
parents:
diff changeset
   254
	}
hgs
parents:
diff changeset
   255
hgs
parents:
diff changeset
   256
EXPORT_C void RMemSpySession::GetThreadInfoItemsL( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
hgs
parents:
diff changeset
   257
	{
hgs
parents:
diff changeset
   258
	TPckgBuf<TThreadId> id( aId );	
hgs
parents:
diff changeset
   259
	TPckgBuf<TMemSpyThreadInfoItemType> type( aType );
hgs
parents:
diff changeset
   260
	TPckgBuf<TInt> count;	
hgs
parents:
diff changeset
   261
	
hgs
parents:
diff changeset
   262
	TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItemsCount, TIpcArgs( &id, &type, &count ) );
hgs
parents:
diff changeset
   263
	TInt itemCount = count();
hgs
parents:
diff changeset
   264
	
hgs
parents:
diff changeset
   265
	if( error == KErrNone )
hgs
parents:
diff changeset
   266
		{		
hgs
parents:
diff changeset
   267
		if( itemCount == 0 )
hgs
parents:
diff changeset
   268
			{
hgs
parents:
diff changeset
   269
			aInfoItems.Reset();
hgs
parents:
diff changeset
   270
			}
hgs
parents:
diff changeset
   271
		else
hgs
parents:
diff changeset
   272
			{
hgs
parents:
diff changeset
   273
			HBufC8* buffer = HBufC8::NewLC( itemCount * sizeof(TMemSpyThreadInfoItemData) );
hgs
parents:
diff changeset
   274
			TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   275
			
hgs
parents:
diff changeset
   276
			TPckgBuf<TInt> requestedCount( itemCount );
hgs
parents:
diff changeset
   277
			
hgs
parents:
diff changeset
   278
			TIpcArgs args( &requestedCount, &id, &type, &bufferPtr );
hgs
parents:
diff changeset
   279
			TInt error = SendReceive( EMemSpyClientServerOpGetThreadInfoItems, args ); // TODO check error
hgs
parents:
diff changeset
   280
			
hgs
parents:
diff changeset
   281
			aInfoItems.Reset();
hgs
parents:
diff changeset
   282
		
hgs
parents:
diff changeset
   283
			for(TInt i=0, offset = 0; i < itemCount; i++, offset+=sizeof(TMemSpyThreadInfoItemData))
hgs
parents:
diff changeset
   284
				{
hgs
parents:
diff changeset
   285
				TPckgBuf<TMemSpyThreadInfoItemData> data;
hgs
parents:
diff changeset
   286
				data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyThreadInfoItemData));
hgs
parents:
diff changeset
   287
				aInfoItems.AppendL(CMemSpyApiThreadInfoItem::NewLC(data()));
hgs
parents:
diff changeset
   288
				}
hgs
parents:
diff changeset
   289
			
hgs
parents:
diff changeset
   290
			CleanupStack::Pop(aInfoItems.Count());
hgs
parents:
diff changeset
   291
			CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   292
			}
hgs
parents:
diff changeset
   293
		}
hgs
parents:
diff changeset
   294
	
hgs
parents:
diff changeset
   295
	User::LeaveIfError(error);
hgs
parents:
diff changeset
   296
	}
hgs
parents:
diff changeset
   297
hgs
parents:
diff changeset
   298
EXPORT_C TInt RMemSpySession::GetThreadInfoItems( RArray<CMemSpyApiThreadInfoItem*> &aInfoItems, TThreadId aId, TMemSpyThreadInfoItemType aType )
hgs
parents:
diff changeset
   299
	{
hgs
parents:
diff changeset
   300
	TRAPD(error, GetThreadInfoItemsL(aInfoItems, aId, aType));
hgs
parents:
diff changeset
   301
	return error;
hgs
parents:
diff changeset
   302
	}
hgs
parents:
diff changeset
   303
hgs
parents:
diff changeset
   304
EXPORT_C void RMemSpySession::GetProcessIdByThreadId( TProcessId& aPID, TThreadId aTID )
hgs
parents:
diff changeset
   305
	{	
hgs
parents:
diff changeset
   306
	TPckgBuf<TProcessId> pid(aPID);
hgs
parents:
diff changeset
   307
	TPckgBuf<TThreadId> tid(aTID);
hgs
parents:
diff changeset
   308
	
hgs
parents:
diff changeset
   309
	TIpcArgs args( &pid, &tid );
hgs
parents:
diff changeset
   310
	User::LeaveIfError( SendReceive( EMemSpyClientServerOpGetProcessIdByThreadId, args ) );
hgs
parents:
diff changeset
   311
	aPID = pid();
hgs
parents:
diff changeset
   312
	}
hgs
parents:
diff changeset
   313
hgs
parents:
diff changeset
   314
//Kernel Objects specific operations
hgs
parents:
diff changeset
   315
EXPORT_C void RMemSpySession::GetKernelObjectsL( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
hgs
parents:
diff changeset
   316
	{		
hgs
parents:
diff changeset
   317
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   318
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectCount, TIpcArgs(&count) ));
hgs
parents:
diff changeset
   319
	
hgs
parents:
diff changeset
   320
	TInt requestedCount = count();
hgs
parents:
diff changeset
   321
	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyKernelObjectData));
hgs
parents:
diff changeset
   322
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   323
		
hgs
parents:
diff changeset
   324
	TIpcArgs args( &count, &bufferPtr );
hgs
parents:
diff changeset
   325
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjects, args ));
hgs
parents:
diff changeset
   326
	
hgs
parents:
diff changeset
   327
	aKernelObjects.Reset();
hgs
parents:
diff changeset
   328
	
hgs
parents:
diff changeset
   329
	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyKernelObjectData))
hgs
parents:
diff changeset
   330
		{
hgs
parents:
diff changeset
   331
		TPckgBuf<TMemSpyKernelObjectData> data;
hgs
parents:
diff changeset
   332
		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyKernelObjectData));
hgs
parents:
diff changeset
   333
		aKernelObjects.AppendL(CMemSpyApiKernelObject::NewLC(data()));
hgs
parents:
diff changeset
   334
		}
hgs
parents:
diff changeset
   335
	
hgs
parents:
diff changeset
   336
	CleanupStack::Pop(aKernelObjects.Count());
hgs
parents:
diff changeset
   337
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   338
	}
hgs
parents:
diff changeset
   339
hgs
parents:
diff changeset
   340
EXPORT_C TInt RMemSpySession::GetKernelObjects( RArray<CMemSpyApiKernelObject*> &aKernelObjects )
hgs
parents:
diff changeset
   341
	{
hgs
parents:
diff changeset
   342
	TRAPD(error, GetKernelObjectsL(aKernelObjects));
hgs
parents:
diff changeset
   343
	return error;
hgs
parents:
diff changeset
   344
	}
hgs
parents:
diff changeset
   345
hgs
parents:
diff changeset
   346
EXPORT_C void RMemSpySession::GetKernelObjectItemsL( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
hgs
parents:
diff changeset
   347
	{
hgs
parents:
diff changeset
   348
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   349
	TPckgBuf<TMemSpyDriverContainerType> type(aForContainer);
hgs
parents:
diff changeset
   350
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectItemCount, TIpcArgs(&count, &type) ));
hgs
parents:
diff changeset
   351
hgs
parents:
diff changeset
   352
	TInt requestedCount = count();
hgs
parents:
diff changeset
   353
	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyDriverHandleInfoGeneric));
hgs
parents:
diff changeset
   354
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   355
	
hgs
parents:
diff changeset
   356
	TIpcArgs args( &count, &type, &bufferPtr );
hgs
parents:
diff changeset
   357
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetKernelObjectItems, args ));
hgs
parents:
diff changeset
   358
	
hgs
parents:
diff changeset
   359
	aKernelObjectItems.Reset();
hgs
parents:
diff changeset
   360
	
hgs
parents:
diff changeset
   361
	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyDriverHandleInfoGeneric))
hgs
parents:
diff changeset
   362
		{
hgs
parents:
diff changeset
   363
		TPckgBuf<TMemSpyDriverHandleInfoGeneric> data;
hgs
parents:
diff changeset
   364
		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyDriverHandleInfoGeneric));
hgs
parents:
diff changeset
   365
		aKernelObjectItems.AppendL( CMemSpyApiKernelObjectItem::NewLC( data() ) );
hgs
parents:
diff changeset
   366
		}
hgs
parents:
diff changeset
   367
	CleanupStack::Pop(aKernelObjectItems.Count());
hgs
parents:
diff changeset
   368
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   369
	}
hgs
parents:
diff changeset
   370
hgs
parents:
diff changeset
   371
EXPORT_C TInt RMemSpySession::GetKernelObjectItems( RArray<CMemSpyApiKernelObjectItem*> &aKernelObjectItems, TMemSpyDriverContainerType aForContainer )
hgs
parents:
diff changeset
   372
	{
hgs
parents:
diff changeset
   373
	TRAPD(error, GetKernelObjectItemsL(aKernelObjectItems, aForContainer));
hgs
parents:
diff changeset
   374
	return error;
hgs
parents:
diff changeset
   375
	}
hgs
parents:
diff changeset
   376
hgs
parents:
diff changeset
   377
EXPORT_C void RMemSpySession::GetMemoryTrackingCyclesL(RArray<CMemSpyApiMemoryTrackingCycle*>& aCycles)
hgs
parents:
diff changeset
   378
	{
hgs
parents:
diff changeset
   379
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   380
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycleCount, TIpcArgs(&count) ));
hgs
parents:
diff changeset
   381
	
hgs
parents:
diff changeset
   382
	TInt requestedCount = count();
hgs
parents:
diff changeset
   383
	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyMemoryTrackingCycleData));
hgs
parents:
diff changeset
   384
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   385
		
hgs
parents:
diff changeset
   386
	TIpcArgs args( &count, &bufferPtr );
hgs
parents:
diff changeset
   387
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycles, args ));
hgs
parents:
diff changeset
   388
	
hgs
parents:
diff changeset
   389
	aCycles.Reset();
hgs
parents:
diff changeset
   390
	
hgs
parents:
diff changeset
   391
	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyMemoryTrackingCycleData))
hgs
parents:
diff changeset
   392
		{
hgs
parents:
diff changeset
   393
		TPckgBuf<TMemSpyMemoryTrackingCycleData> data;
hgs
parents:
diff changeset
   394
		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyMemoryTrackingCycleData));
hgs
parents:
diff changeset
   395
		aCycles.AppendL(CMemSpyApiMemoryTrackingCycle::NewLC(data()));
hgs
parents:
diff changeset
   396
		}
hgs
parents:
diff changeset
   397
	
hgs
parents:
diff changeset
   398
	CleanupStack::Pop(aCycles.Count());
hgs
parents:
diff changeset
   399
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   400
	}
hgs
parents:
diff changeset
   401
hgs
parents:
diff changeset
   402
EXPORT_C void RMemSpySession::OutputAllContainerContents()
hgs
parents:
diff changeset
   403
	{
hgs
parents:
diff changeset
   404
	SendReceive( EMemSpyClientServerOpOutputAllContainerContents );
hgs
parents:
diff changeset
   405
	}
hgs
parents:
diff changeset
   406
hgs
parents:
diff changeset
   407
hgs
parents:
diff changeset
   408
//Heap specific operations
hgs
parents:
diff changeset
   409
hgs
parents:
diff changeset
   410
EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeapL()
hgs
parents:
diff changeset
   411
	{
hgs
parents:
diff changeset
   412
	CMemSpyApiHeap* aHeap;
hgs
parents:
diff changeset
   413
	
hgs
parents:
diff changeset
   414
	HBufC8* buffer = HBufC8::NewLC( sizeof(TMemSpyHeapData) );
hgs
parents:
diff changeset
   415
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   416
	TIpcArgs args( &bufferPtr );
hgs
parents:
diff changeset
   417
	
hgs
parents:
diff changeset
   418
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetHeap, args ));
hgs
parents:
diff changeset
   419
	
hgs
parents:
diff changeset
   420
	TPckgBuf<TMemSpyHeapData> data;
hgs
parents:
diff changeset
   421
	data.Copy(bufferPtr.Ptr(), sizeof(TMemSpyHeapData));		
hgs
parents:
diff changeset
   422
	aHeap = CMemSpyApiHeap::NewL( data() );
hgs
parents:
diff changeset
   423
	
hgs
parents:
diff changeset
   424
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   425
		
hgs
parents:
diff changeset
   426
	return aHeap;
hgs
parents:
diff changeset
   427
	}
hgs
parents:
diff changeset
   428
hgs
parents:
diff changeset
   429
EXPORT_C CMemSpyApiHeap* RMemSpySession::GetHeap()
hgs
parents:
diff changeset
   430
	{
hgs
parents:
diff changeset
   431
	CMemSpyApiHeap *result = NULL;
hgs
parents:
diff changeset
   432
	TRAPD(error, result = GetHeapL());
hgs
parents:
diff changeset
   433
	return error == KErrNone ? result : NULL;
hgs
parents:
diff changeset
   434
	}
hgs
parents:
diff changeset
   435
hgs
parents:
diff changeset
   436
hgs
parents:
diff changeset
   437
hgs
parents:
diff changeset
   438
EXPORT_C void RMemSpySession::GetEComCategoriesL(RArray<CMemSpyApiEComCategory*> &aCategories)
hgs
parents:
diff changeset
   439
    {
hgs
parents:
diff changeset
   440
    TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   441
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComCategoryCount, TIpcArgs(&count)));
hgs
parents:
diff changeset
   442
    
hgs
parents:
diff changeset
   443
    TInt requestedCount = count();
hgs
parents:
diff changeset
   444
    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEComCategoryData));
hgs
parents:
diff changeset
   445
    TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   446
    
hgs
parents:
diff changeset
   447
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComCategories, TIpcArgs(&count, &bufferPtr)));
hgs
parents:
diff changeset
   448
    aCategories.Reset();
hgs
parents:
diff changeset
   449
    
hgs
parents:
diff changeset
   450
    TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   451
    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEComCategoryData))
hgs
parents:
diff changeset
   452
        {
hgs
parents:
diff changeset
   453
        TPckgBuf<TMemSpyEComCategoryData> data;
hgs
parents:
diff changeset
   454
        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEComCategoryData));
hgs
parents:
diff changeset
   455
        aCategories.AppendL(CMemSpyApiEComCategory::NewLC(data()));
hgs
parents:
diff changeset
   456
        }
hgs
parents:
diff changeset
   457
    CleanupStack::Pop(aCategories.Count());
hgs
parents:
diff changeset
   458
    CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   459
    }
hgs
parents:
diff changeset
   460
    
hgs
parents:
diff changeset
   461
EXPORT_C void RMemSpySession::GetEComInterfacesL(TUid aCategory, RArray<CMemSpyApiEComInterface*> &aInterfaces)
hgs
parents:
diff changeset
   462
    {
hgs
parents:
diff changeset
   463
    TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   464
    TPckgBuf<TUid> category(aCategory);
hgs
parents:
diff changeset
   465
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComInterfaceCount, TIpcArgs(&count, &category)));
hgs
parents:
diff changeset
   466
    
hgs
parents:
diff changeset
   467
    TInt requestedCount = count();
hgs
parents:
diff changeset
   468
    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEComInterfaceData));
hgs
parents:
diff changeset
   469
    TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   470
    
hgs
parents:
diff changeset
   471
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComInterfaces, TIpcArgs(&count, &category, &bufferPtr)));
hgs
parents:
diff changeset
   472
    aInterfaces.Reset();
hgs
parents:
diff changeset
   473
    
hgs
parents:
diff changeset
   474
    TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   475
    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEComInterfaceData))
hgs
parents:
diff changeset
   476
        {
hgs
parents:
diff changeset
   477
        TPckgBuf<TMemSpyEComInterfaceData> data;
hgs
parents:
diff changeset
   478
        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEComInterfaceData));
hgs
parents:
diff changeset
   479
        aInterfaces.AppendL(CMemSpyApiEComInterface::NewLC(data()));
hgs
parents:
diff changeset
   480
        }
hgs
parents:
diff changeset
   481
    CleanupStack::Pop(aInterfaces.Count());
hgs
parents:
diff changeset
   482
    CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   483
    }
hgs
parents:
diff changeset
   484
hgs
parents:
diff changeset
   485
EXPORT_C void RMemSpySession::GetEComImplementationsL(TUid aInterface, RArray<CMemSpyApiEComImplementation*> &aImplementations)
hgs
parents:
diff changeset
   486
    {
hgs
parents:
diff changeset
   487
    TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   488
    TPckgBuf<TUid> interface(aInterface);
hgs
parents:
diff changeset
   489
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComImplementationCount, TIpcArgs(&count, &interface)));
hgs
parents:
diff changeset
   490
    
hgs
parents:
diff changeset
   491
    TInt requestedCount = count();
hgs
parents:
diff changeset
   492
    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEComImplementationData));
hgs
parents:
diff changeset
   493
    TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   494
    
hgs
parents:
diff changeset
   495
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetEComImplementations, TIpcArgs(&count, &interface, &bufferPtr)));
hgs
parents:
diff changeset
   496
    aImplementations.Reset();
hgs
parents:
diff changeset
   497
    
hgs
parents:
diff changeset
   498
    TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   499
    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEComImplementationData))
hgs
parents:
diff changeset
   500
        {
hgs
parents:
diff changeset
   501
        TPckgBuf<TMemSpyEComImplementationData> data;
hgs
parents:
diff changeset
   502
        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEComImplementationData));
hgs
parents:
diff changeset
   503
        aImplementations.AppendL(CMemSpyApiEComImplementation::NewLC(data()));
hgs
parents:
diff changeset
   504
        }
hgs
parents:
diff changeset
   505
    CleanupStack::Pop(aImplementations.Count());
hgs
parents:
diff changeset
   506
    CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   507
    }
hgs
parents:
diff changeset
   508
52
hgs
parents: 51
diff changeset
   509
EXPORT_C void RMemSpySession::GetWindowGroupsL(RArray<CMemSpyApiWindowGroup*> &aGroups)
hgs
parents: 51
diff changeset
   510
    {
hgs
parents: 51
diff changeset
   511
    TPckgBuf<TInt> count;
hgs
parents: 51
diff changeset
   512
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetWindowGroupCount, TIpcArgs(&count)));
hgs
parents: 51
diff changeset
   513
    
hgs
parents: 51
diff changeset
   514
    TInt requestedCount = count();
hgs
parents: 51
diff changeset
   515
    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyEngineWindowGroupDetails));
hgs
parents: 51
diff changeset
   516
    TPtr8 bufferPtr(buffer->Des());
hgs
parents: 51
diff changeset
   517
    
hgs
parents: 51
diff changeset
   518
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetWindowGroups, TIpcArgs(&count, &bufferPtr)));
hgs
parents: 51
diff changeset
   519
    aGroups.Reset();
hgs
parents: 51
diff changeset
   520
    
hgs
parents: 51
diff changeset
   521
    TInt receivedCount = Min(count(), requestedCount);
hgs
parents: 51
diff changeset
   522
    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyEngineWindowGroupDetails))
hgs
parents: 51
diff changeset
   523
        {
hgs
parents: 51
diff changeset
   524
        TPckgBuf<TMemSpyEngineWindowGroupDetails> data;
hgs
parents: 51
diff changeset
   525
        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyEngineWindowGroupDetails));
hgs
parents: 51
diff changeset
   526
        aGroups.AppendL(CMemSpyApiWindowGroup::NewLC(data()));
hgs
parents: 51
diff changeset
   527
        }
hgs
parents: 51
diff changeset
   528
    CleanupStack::Pop(aGroups.Count());
hgs
parents: 51
diff changeset
   529
    CleanupStack::PopAndDestroy(buffer);
hgs
parents: 51
diff changeset
   530
    }
hgs
parents: 51
diff changeset
   531
51
hgs
parents:
diff changeset
   532
EXPORT_C void RMemSpySession::DumpKernelHeap()
hgs
parents:
diff changeset
   533
	{
hgs
parents:
diff changeset
   534
	SendReceive( EMemSpyClientServerOpDumpKernelHeap );
hgs
parents:
diff changeset
   535
	}
hgs
parents:
diff changeset
   536
hgs
parents:
diff changeset
   537
EXPORT_C void RMemSpySession::OutputKernelHeapDataL()
hgs
parents:
diff changeset
   538
	{		
hgs
parents:
diff changeset
   539
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
hgs
parents:
diff changeset
   540
			TIpcArgs(KMemSpyClientServerThreadIdKernel)));
hgs
parents:
diff changeset
   541
	
hgs
parents:
diff changeset
   542
	}
hgs
parents:
diff changeset
   543
hgs
parents:
diff changeset
   544
EXPORT_C void RMemSpySession::OutputKernelHeapData(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   545
	{
hgs
parents:
diff changeset
   546
	SendReceive(EMemSpyClientServerOpHeapData,
hgs
parents:
diff changeset
   547
		TIpcArgs(KMemSpyClientServerThreadIdKernel),
hgs
parents:
diff changeset
   548
		aStatus);
hgs
parents:
diff changeset
   549
	}
hgs
parents:
diff changeset
   550
hgs
parents:
diff changeset
   551
EXPORT_C void RMemSpySession::OutputThreadHeapDataL( TThreadId aThreadId)
hgs
parents:
diff changeset
   552
	{			
hgs
parents:
diff changeset
   553
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadId,
hgs
parents:
diff changeset
   554
			TIpcArgs(aThreadId)));
hgs
parents:
diff changeset
   555
	}
hgs
parents:
diff changeset
   556
hgs
parents:
diff changeset
   557
EXPORT_C void RMemSpySession::OutputThreadHeapDataL(const TDesC& aThreadName)
hgs
parents:
diff changeset
   558
	{	
hgs
parents:
diff changeset
   559
	const TIpcArgs args( &aThreadName );
hgs
parents:
diff changeset
   560
	        
hgs
parents:
diff changeset
   561
	User::LeaveIfError( SendReceive( EMemSpyClientServerOpHeapData | KMemSpyOpFlagsIncludesThreadName, args ));	
hgs
parents:
diff changeset
   562
	}
hgs
parents:
diff changeset
   563
hgs
parents:
diff changeset
   564
EXPORT_C void RMemSpySession::OutputThreadCellListL(TThreadId aThreadId)
hgs
parents:
diff changeset
   565
	{	
hgs
parents:
diff changeset
   566
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsIncludesThreadId,
hgs
parents:
diff changeset
   567
			TIpcArgs(aThreadId)));
hgs
parents:
diff changeset
   568
	}
hgs
parents:
diff changeset
   569
hgs
parents:
diff changeset
   570
EXPORT_C void RMemSpySession::OutputHeapInfoUserL(TThreadId aThreadId)
hgs
parents:
diff changeset
   571
	{
hgs
parents:
diff changeset
   572
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpHeapInfo | KMemSpyOpFlagsIncludesThreadId,
hgs
parents:
diff changeset
   573
			TIpcArgs(aThreadId)));
hgs
parents:
diff changeset
   574
	}
hgs
parents:
diff changeset
   575
hgs
parents:
diff changeset
   576
EXPORT_C void RMemSpySession::SwitchOutputSinkL( TMemSpySinkType aType )
hgs
parents:
diff changeset
   577
	{
hgs
parents:
diff changeset
   578
	TInt op;
hgs
parents:
diff changeset
   579
	if( aType == ESinkTypeFile )
hgs
parents:
diff changeset
   580
		op = EMemSpyClientServerOpSwitchOutputSinkFile;
hgs
parents:
diff changeset
   581
	else
hgs
parents:
diff changeset
   582
		op = EMemSpyClientServerOpSwitchOutputSinkTrace;
hgs
parents:
diff changeset
   583
			
hgs
parents:
diff changeset
   584
	User::LeaveIfError(SendReceive( op ));
hgs
parents:
diff changeset
   585
	}
hgs
parents:
diff changeset
   586
hgs
parents:
diff changeset
   587
EXPORT_C void RMemSpySession::SwitchOutputToTraceL()
hgs
parents:
diff changeset
   588
	{
hgs
parents:
diff changeset
   589
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSwitchOutputSinkTrace));
hgs
parents:
diff changeset
   590
	}
hgs
parents:
diff changeset
   591
    
hgs
parents:
diff changeset
   592
EXPORT_C void RMemSpySession::SwitchOutputToFileL(const TDesC& aRootFolder)
hgs
parents:
diff changeset
   593
	{
hgs
parents:
diff changeset
   594
	TIpcArgs args;
hgs
parents:
diff changeset
   595
	if (aRootFolder.Length())
hgs
parents:
diff changeset
   596
		{
hgs
parents:
diff changeset
   597
		args.Set(0, &aRootFolder);
hgs
parents:
diff changeset
   598
		}
hgs
parents:
diff changeset
   599
	
hgs
parents:
diff changeset
   600
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSwitchOutputSinkFile, args));
hgs
parents:
diff changeset
   601
	}
hgs
parents:
diff changeset
   602
hgs
parents:
diff changeset
   603
EXPORT_C void RMemSpySession::OutputStackInfoL(TThreadId aThreadId)
hgs
parents:
diff changeset
   604
	{
hgs
parents:
diff changeset
   605
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpStackInfo | KMemSpyOpFlagsIncludesThreadId,
hgs
parents:
diff changeset
   606
			TIpcArgs(aThreadId)));
hgs
parents:
diff changeset
   607
	}
hgs
parents:
diff changeset
   608
hgs
parents:
diff changeset
   609
EXPORT_C void RMemSpySession::OutputStackDataL(TThreadId aThreadId, TMemSpyDriverDomainType aType )
hgs
parents:
diff changeset
   610
	{
hgs
parents:
diff changeset
   611
	TInt op;
hgs
parents:
diff changeset
   612
	if( aType == EMemSpyDriverDomainUser )
hgs
parents:
diff changeset
   613
		op = EMemSpyClientServerOpStackDataUser;
hgs
parents:
diff changeset
   614
	else
hgs
parents:
diff changeset
   615
		op = EMemSpyClientServerOpStackDataKernel;
hgs
parents:
diff changeset
   616
	
hgs
parents:
diff changeset
   617
	User::LeaveIfError(SendReceive( op | KMemSpyOpFlagsIncludesThreadId,
hgs
parents:
diff changeset
   618
			TIpcArgs(aThreadId, aType)));
hgs
parents:
diff changeset
   619
		
hgs
parents:
diff changeset
   620
	}
hgs
parents:
diff changeset
   621
hgs
parents:
diff changeset
   622
EXPORT_C void RMemSpySession::OutputThreadInfoHandlesL(TThreadId aThreadId)
hgs
parents:
diff changeset
   623
	{
hgs
parents:
diff changeset
   624
	TPckgBuf<TThreadId> id(aThreadId);
hgs
parents:
diff changeset
   625
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpOutputInfoHandles, TIpcArgs( &id )));	
hgs
parents:
diff changeset
   626
	}
hgs
parents:
diff changeset
   627
hgs
parents:
diff changeset
   628
EXPORT_C void RMemSpySession::OutputAOListL(TThreadId aId, TMemSpyThreadInfoItemType aType)
hgs
parents:
diff changeset
   629
	{
hgs
parents:
diff changeset
   630
	TPckgBuf<TThreadId> id(aId);
hgs
parents:
diff changeset
   631
	TPckgBuf<TMemSpyThreadInfoItemType> type(aType);
hgs
parents:
diff changeset
   632
	
hgs
parents:
diff changeset
   633
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpOutputAOList, TIpcArgs( &id, &type )));
hgs
parents:
diff changeset
   634
	}
hgs
parents:
diff changeset
   635
hgs
parents:
diff changeset
   636
EXPORT_C void RMemSpySession::OutputKernelObjectsL()
hgs
parents:
diff changeset
   637
	{
hgs
parents:
diff changeset
   638
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpEnumerateKernelContainerAll));
hgs
parents:
diff changeset
   639
	}
hgs
parents:
diff changeset
   640
hgs
parents:
diff changeset
   641
EXPORT_C void RMemSpySession::OutputCompactStackInfoL()
hgs
parents:
diff changeset
   642
	{
hgs
parents:
diff changeset
   643
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpStackInfoCompact)); 
hgs
parents:
diff changeset
   644
	}
hgs
parents:
diff changeset
   645
hgs
parents:
diff changeset
   646
EXPORT_C void RMemSpySession::OutputCompactHeapInfoL()
hgs
parents:
diff changeset
   647
	{
hgs
parents:
diff changeset
   648
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpHeapInfoCompact)); 
hgs
parents:
diff changeset
   649
	}
hgs
parents:
diff changeset
   650
// Asynchronous operations
hgs
parents:
diff changeset
   651
EXPORT_C void RMemSpySession::OutputPhoneInfo(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   652
	{	
hgs
parents:
diff changeset
   653
	SendReceive(EMemSpyClientServerOpSummaryInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   654
	}
hgs
parents:
diff changeset
   655
hgs
parents:
diff changeset
   656
EXPORT_C void RMemSpySession::OutputDetailedPhoneInfo(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   657
	{	
hgs
parents:
diff changeset
   658
	SendReceive(EMemSpyClientServerOpSummaryInfoDetailed | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   659
	}
hgs
parents:
diff changeset
   660
hgs
parents:
diff changeset
   661
EXPORT_C void RMemSpySession::OutputHeapInfo(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   662
	{	
hgs
parents:
diff changeset
   663
	SendReceive(EMemSpyClientServerOpHeapInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   664
	}
hgs
parents:
diff changeset
   665
hgs
parents:
diff changeset
   666
EXPORT_C void RMemSpySession::OutputCompactHeapInfo(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   667
	{	
hgs
parents:
diff changeset
   668
	SendReceive(EMemSpyClientServerOpHeapInfoCompact | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   669
	}
hgs
parents:
diff changeset
   670
hgs
parents:
diff changeset
   671
EXPORT_C void RMemSpySession::OutputHeapCellListing(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   672
	{	
hgs
parents:
diff changeset
   673
	SendReceive(EMemSpyClientServerOpHeapCellListing | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   674
	}
hgs
parents:
diff changeset
   675
hgs
parents:
diff changeset
   676
EXPORT_C void RMemSpySession::OutputHeapData(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   677
	{	
hgs
parents:
diff changeset
   678
	SendReceive(EMemSpyClientServerOpHeapData | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   679
	}
hgs
parents:
diff changeset
   680
hgs
parents:
diff changeset
   681
// synchronous version of the operation - for CLI
hgs
parents:
diff changeset
   682
EXPORT_C void RMemSpySession::OutputHeapData()
hgs
parents:
diff changeset
   683
	{
hgs
parents:
diff changeset
   684
	SendReceive(EMemSpyClientServerOpHeapData);
hgs
parents:
diff changeset
   685
	}
hgs
parents:
diff changeset
   686
hgs
parents:
diff changeset
   687
EXPORT_C void RMemSpySession::OutputStackInfo(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   688
	{	
hgs
parents:
diff changeset
   689
	SendReceive(EMemSpyClientServerOpStackInfo | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   690
	}
hgs
parents:
diff changeset
   691
hgs
parents:
diff changeset
   692
EXPORT_C void RMemSpySession::OutputCompactStackInfo(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   693
	{	
hgs
parents:
diff changeset
   694
	SendReceive(EMemSpyClientServerOpStackInfoCompact | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   695
	}
hgs
parents:
diff changeset
   696
hgs
parents:
diff changeset
   697
EXPORT_C void RMemSpySession::OutputUserStackData(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   698
	{	
hgs
parents:
diff changeset
   699
	SendReceive(EMemSpyClientServerOpStackDataUser | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   700
	}
hgs
parents:
diff changeset
   701
hgs
parents:
diff changeset
   702
EXPORT_C void RMemSpySession::OutputKernelStackData(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   703
	{	
hgs
parents:
diff changeset
   704
	SendReceive(EMemSpyClientServerOpStackDataKernel | KMemSpyOpFlagsAsyncOperation, TIpcArgs(), aStatus);
hgs
parents:
diff changeset
   705
	}
hgs
parents:
diff changeset
   706
hgs
parents:
diff changeset
   707
// Synchronous operations
hgs
parents:
diff changeset
   708
EXPORT_C void RMemSpySession::OutputPhoneInfo()
hgs
parents:
diff changeset
   709
	{	
hgs
parents:
diff changeset
   710
	SendReceive( EMemSpyClientServerOpSummaryInfo , TIpcArgs() );
hgs
parents:
diff changeset
   711
	}
hgs
parents:
diff changeset
   712
hgs
parents:
diff changeset
   713
EXPORT_C TInt RMemSpySession::GetSwmtCyclesCount()
hgs
parents:
diff changeset
   714
	{
hgs
parents:
diff changeset
   715
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   716
	TIpcArgs args( &count );
hgs
parents:
diff changeset
   717
		
hgs
parents:
diff changeset
   718
	User::LeaveIfError(SendReceive( EMemSpyClientServerOpGetMemoryTrackingCycleCount, args ));
hgs
parents:
diff changeset
   719
	
hgs
parents:
diff changeset
   720
	return count();
hgs
parents:
diff changeset
   721
	}
hgs
parents:
diff changeset
   722
hgs
parents:
diff changeset
   723
EXPORT_C void RMemSpySession::SetSwmtAutoStartProcessList( CArrayFixFlat<TUid>* aList )
hgs
parents:
diff changeset
   724
	{
hgs
parents:
diff changeset
   725
	TInt count = aList->Count();
hgs
parents:
diff changeset
   726
	TIpcArgs args( &aList, &count );
hgs
parents:
diff changeset
   727
	
hgs
parents:
diff changeset
   728
	SendReceive( EMemSpyClientServerOpSetSwmtAutoStartProcessList, args );
hgs
parents:
diff changeset
   729
	}
hgs
parents:
diff changeset
   730
hgs
parents:
diff changeset
   731
EXPORT_C void RMemSpySession::SwmtResetTracking()
hgs
parents:
diff changeset
   732
	{
hgs
parents:
diff changeset
   733
	SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingReset );
hgs
parents:
diff changeset
   734
	}
hgs
parents:
diff changeset
   735
hgs
parents:
diff changeset
   736
EXPORT_C void RMemSpySession::GetOutputSink( TMemSpySinkType& aType )
hgs
parents:
diff changeset
   737
	{
hgs
parents:
diff changeset
   738
	TPckgBuf<TMemSpySinkType> type( aType );
hgs
parents:
diff changeset
   739
	TIpcArgs args( &type );
hgs
parents:
diff changeset
   740
	
hgs
parents:
diff changeset
   741
	SendReceive( EMemSpyClientServerOpGetOutputSink, args );
hgs
parents:
diff changeset
   742
	
hgs
parents:
diff changeset
   743
	aType = type();
hgs
parents:
diff changeset
   744
	}
hgs
parents:
diff changeset
   745
hgs
parents:
diff changeset
   746
EXPORT_C void RMemSpySession::NotifyDeviceWideOperationProgress(TMemSpyDeviceWideOperationProgress &aProgress, TRequestStatus &aStatus)
hgs
parents:
diff changeset
   747
	{
hgs
parents:
diff changeset
   748
	SendReceive(EMemSpyClientServerOpNotifyDeviceWideOperationProgress | KMemSpyOpFlagsAsyncOperation,
hgs
parents:
diff changeset
   749
			TIpcArgs(&aProgress.iProgress, &aProgress.iDescription), 
hgs
parents:
diff changeset
   750
			aStatus);
hgs
parents:
diff changeset
   751
	}
hgs
parents:
diff changeset
   752
hgs
parents:
diff changeset
   753
EXPORT_C void RMemSpySession::CancelDeviceWideOperationL()
hgs
parents:
diff changeset
   754
	{
hgs
parents:
diff changeset
   755
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpCancelDeviceWideOperation));
hgs
parents:
diff changeset
   756
	}
hgs
parents:
diff changeset
   757
hgs
parents:
diff changeset
   758
// SWMT operations
hgs
parents:
diff changeset
   759
EXPORT_C void RMemSpySession::SetSwmtCategoriesL(TInt aCategories)
hgs
parents:
diff changeset
   760
	{
hgs
parents:
diff changeset
   761
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesSet,
hgs
parents:
diff changeset
   762
			TIpcArgs(aCategories)));
hgs
parents:
diff changeset
   763
	}
hgs
parents:
diff changeset
   764
hgs
parents:
diff changeset
   765
EXPORT_C void RMemSpySession::SetSwmtHeapDumpsEnabledL(TBool aEnabled)
hgs
parents:
diff changeset
   766
	{
hgs
parents:
diff changeset
   767
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpSet,
hgs
parents:
diff changeset
   768
			TIpcArgs(aEnabled)));
hgs
parents:
diff changeset
   769
	}
hgs
parents:
diff changeset
   770
hgs
parents:
diff changeset
   771
EXPORT_C void RMemSpySession::SetSwmtMode(TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode aMode)
hgs
parents:
diff changeset
   772
	{
hgs
parents:
diff changeset
   773
	TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mode( aMode );
hgs
parents:
diff changeset
   774
	TIpcArgs args(&mode);
hgs
parents:
diff changeset
   775
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingModeSet, args));
hgs
parents:
diff changeset
   776
	}
hgs
parents:
diff changeset
   777
hgs
parents:
diff changeset
   778
EXPORT_C TBool RMemSpySession::IsSwmtRunningL()
hgs
parents:
diff changeset
   779
	{
hgs
parents:
diff changeset
   780
	TPckgBuf<TBool> ret;
hgs
parents:
diff changeset
   781
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpIsSwmtRunning, TIpcArgs(&ret)));
54
hgs
parents: 52
diff changeset
   782
		
51
hgs
parents:
diff changeset
   783
	return ret();
hgs
parents:
diff changeset
   784
	}
hgs
parents:
diff changeset
   785
hgs
parents:
diff changeset
   786
EXPORT_C void RMemSpySession::StartSwmtTimerL(TInt aPeriod)
hgs
parents:
diff changeset
   787
	{
hgs
parents:
diff changeset
   788
	SetSwmtTimerIntervalL(aPeriod);
hgs
parents:
diff changeset
   789
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart));
hgs
parents:
diff changeset
   790
	}
hgs
parents:
diff changeset
   791
54
hgs
parents: 52
diff changeset
   792
EXPORT_C void RMemSpySession::StartSwmtTimer( TRequestStatus& aStatus )
hgs
parents: 52
diff changeset
   793
	{
hgs
parents: 52
diff changeset
   794
	SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart, 
hgs
parents: 52
diff changeset
   795
			TIpcArgs(), aStatus );
hgs
parents: 52
diff changeset
   796
	}
hgs
parents: 52
diff changeset
   797
51
hgs
parents:
diff changeset
   798
EXPORT_C void RMemSpySession::StartSwmtTimerL()
hgs
parents:
diff changeset
   799
	{
hgs
parents:
diff changeset
   800
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStart));
hgs
parents:
diff changeset
   801
	}
hgs
parents:
diff changeset
   802
hgs
parents:
diff changeset
   803
EXPORT_C void RMemSpySession::SetSwmtTimerIntervalL(TInt aPeriod)
hgs
parents:
diff changeset
   804
	{
hgs
parents:
diff changeset
   805
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodSet,
hgs
parents:
diff changeset
   806
			TIpcArgs(aPeriod)));
hgs
parents:
diff changeset
   807
	}
hgs
parents:
diff changeset
   808
hgs
parents:
diff changeset
   809
EXPORT_C void RMemSpySession::StopSwmtTimerL()
hgs
parents:
diff changeset
   810
	{
hgs
parents:
diff changeset
   811
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerStop));
hgs
parents:
diff changeset
   812
	}
hgs
parents:
diff changeset
   813
hgs
parents:
diff changeset
   814
hgs
parents:
diff changeset
   815
EXPORT_C void RMemSpySession::ForceSwmtUpdateL()
hgs
parents:
diff changeset
   816
	{
hgs
parents:
diff changeset
   817
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate));
hgs
parents:
diff changeset
   818
	}
hgs
parents:
diff changeset
   819
hgs
parents:
diff changeset
   820
EXPORT_C void RMemSpySession::ForceSwmtUpdate(TRequestStatus& aStatus)
hgs
parents:
diff changeset
   821
	{
hgs
parents:
diff changeset
   822
	SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingForceUpdate, 
hgs
parents:
diff changeset
   823
			TIpcArgs(),
hgs
parents:
diff changeset
   824
			aStatus);
hgs
parents:
diff changeset
   825
	}
hgs
parents:
diff changeset
   826
hgs
parents:
diff changeset
   827
EXPORT_C void RMemSpySession::SetSwmtFilter( const TDesC& aFilter )
hgs
parents:
diff changeset
   828
	{	
hgs
parents:
diff changeset
   829
	TIpcArgs args( &aFilter );
hgs
parents:
diff changeset
   830
	User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterSet, args ) );
hgs
parents:
diff changeset
   831
	}
hgs
parents:
diff changeset
   832
hgs
parents:
diff changeset
   833
EXPORT_C void RMemSpySession::GetSwmtFilter( TName& aFilter )
hgs
parents:
diff changeset
   834
	{
hgs
parents:
diff changeset
   835
    TPckgBuf<TName> name;
hgs
parents:
diff changeset
   836
    TIpcArgs args( &name );
hgs
parents:
diff changeset
   837
		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingThreadNameFilterGet, args ) );
hgs
parents:
diff changeset
   838
	aFilter = name();
hgs
parents:
diff changeset
   839
	}
hgs
parents:
diff changeset
   840
        
hgs
parents:
diff changeset
   841
EXPORT_C void RMemSpySession::GetSwmtCategoriesL(TInt& aCategories)
hgs
parents:
diff changeset
   842
	{
hgs
parents:
diff changeset
   843
	TPckgBuf<TInt> cat;	
hgs
parents:
diff changeset
   844
	TIpcArgs args( &cat );
hgs
parents:
diff changeset
   845
		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingCategoriesGet, args ) );
hgs
parents:
diff changeset
   846
	aCategories = cat();
hgs
parents:
diff changeset
   847
	}
hgs
parents:
diff changeset
   848
hgs
parents:
diff changeset
   849
EXPORT_C void RMemSpySession::GetSwmtHeapDumpsEnabledL(TBool& aEnabled)
hgs
parents:
diff changeset
   850
	{
hgs
parents:
diff changeset
   851
	TPckgBuf<TBool> enabled;
hgs
parents:
diff changeset
   852
	TIpcArgs args( &enabled );
hgs
parents:
diff changeset
   853
		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingHeapDumpGet, args ) );
hgs
parents:
diff changeset
   854
		
hgs
parents:
diff changeset
   855
	aEnabled = enabled();
hgs
parents:
diff changeset
   856
	}
hgs
parents:
diff changeset
   857
        
hgs
parents:
diff changeset
   858
EXPORT_C void RMemSpySession::GetSwmtMode(TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode& aMode)
hgs
parents:
diff changeset
   859
	{
hgs
parents:
diff changeset
   860
	TPckgBuf<TMemSpyEngineHelperSysMemTrackerConfig::TMemSpyEngineSysMemTrackerMode> mode;
hgs
parents:
diff changeset
   861
	TIpcArgs args( &mode );
hgs
parents:
diff changeset
   862
		User::LeaveIfError( SendReceive( EMemSpyClientServerOpSystemWideMemoryTrackingModeGet, args ) );
hgs
parents:
diff changeset
   863
	aMode = mode();
hgs
parents:
diff changeset
   864
	}
hgs
parents:
diff changeset
   865
    
hgs
parents:
diff changeset
   866
EXPORT_C void RMemSpySession::GetSwmtTimerIntervalL(TInt& aPeriod)
hgs
parents:
diff changeset
   867
	{
hgs
parents:
diff changeset
   868
	TPckgBuf<TInt> time;
hgs
parents:
diff changeset
   869
	TIpcArgs args( &time );
hgs
parents:
diff changeset
   870
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpSystemWideMemoryTrackingTimerPeriodGet,
hgs
parents:
diff changeset
   871
			args));
hgs
parents:
diff changeset
   872
	aPeriod = time();
hgs
parents:
diff changeset
   873
	}
hgs
parents:
diff changeset
   874
hgs
parents:
diff changeset
   875
EXPORT_C TInt TMemSpyDeviceWideOperationProgress::Progress() const 
hgs
parents:
diff changeset
   876
	{
hgs
parents:
diff changeset
   877
	return iProgress();
hgs
parents:
diff changeset
   878
	}
hgs
parents:
diff changeset
   879
hgs
parents:
diff changeset
   880
EXPORT_C const TDesC& TMemSpyDeviceWideOperationProgress::Description() const
hgs
parents:
diff changeset
   881
	{
hgs
parents:
diff changeset
   882
	return iDescription;
hgs
parents:
diff changeset
   883
	}
hgs
parents:
diff changeset
   884
hgs
parents:
diff changeset
   885
// Servers
hgs
parents:
diff changeset
   886
EXPORT_C void RMemSpySession::GetServersL(RArray<CMemSpyApiServer*> &aServers)
hgs
parents:
diff changeset
   887
    {
hgs
parents:
diff changeset
   888
    TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   889
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetServerCount, TIpcArgs(&count)));
hgs
parents:
diff changeset
   890
    
hgs
parents:
diff changeset
   891
    TInt requestedCount = count();
hgs
parents:
diff changeset
   892
    HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyServerData));
hgs
parents:
diff changeset
   893
    TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   894
    
hgs
parents:
diff changeset
   895
    User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetServers, TIpcArgs(&count, &bufferPtr)));
hgs
parents:
diff changeset
   896
    aServers.Reset();
hgs
parents:
diff changeset
   897
    
hgs
parents:
diff changeset
   898
    TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   899
    for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyServerData))
hgs
parents:
diff changeset
   900
        {
hgs
parents:
diff changeset
   901
        TPckgBuf<TMemSpyServerData> data;
hgs
parents:
diff changeset
   902
        data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyServerData));
hgs
parents:
diff changeset
   903
        aServers.AppendL(CMemSpyApiServer::NewLC(data()));
hgs
parents:
diff changeset
   904
        }
hgs
parents:
diff changeset
   905
    CleanupStack::Pop(aServers.Count());
hgs
parents:
diff changeset
   906
    CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   907
    }
hgs
parents:
diff changeset
   908
hgs
parents:
diff changeset
   909
EXPORT_C void RMemSpySession::GetServersL(RArray<CMemSpyApiServer*> &aServers, TSortType aSortType)
hgs
parents:
diff changeset
   910
	{
hgs
parents:
diff changeset
   911
	TPckgBuf<TInt> count;
hgs
parents:
diff changeset
   912
	TPckgBuf<TSortType> sort( aSortType );
hgs
parents:
diff changeset
   913
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetServerCount, TIpcArgs(&count)));
hgs
parents:
diff changeset
   914
	    	
hgs
parents:
diff changeset
   915
	TInt requestedCount = count();
hgs
parents:
diff changeset
   916
	HBufC8* buffer = HBufC8::NewLC(requestedCount * sizeof(TMemSpyServerData));
hgs
parents:
diff changeset
   917
	TPtr8 bufferPtr(buffer->Des());
hgs
parents:
diff changeset
   918
	    
hgs
parents:
diff changeset
   919
	User::LeaveIfError(SendReceive(EMemSpyClientServerOpGetSortedServers, TIpcArgs(&count, &bufferPtr, &sort)));
hgs
parents:
diff changeset
   920
	aServers.Reset();
hgs
parents:
diff changeset
   921
	    
hgs
parents:
diff changeset
   922
	TInt receivedCount = Min(count(), requestedCount);
hgs
parents:
diff changeset
   923
	for(TInt i=0, offset = 0; i<requestedCount; i++, offset+=sizeof(TMemSpyServerData))
hgs
parents:
diff changeset
   924
		{
hgs
parents:
diff changeset
   925
		TPckgBuf<TMemSpyServerData> data;
hgs
parents:
diff changeset
   926
		data.Copy(bufferPtr.Ptr()+offset, sizeof(TMemSpyServerData));
hgs
parents:
diff changeset
   927
		aServers.AppendL(CMemSpyApiServer::NewLC(data()));
hgs
parents:
diff changeset
   928
		}
hgs
parents:
diff changeset
   929
	CleanupStack::Pop(aServers.Count());
hgs
parents:
diff changeset
   930
	CleanupStack::PopAndDestroy(buffer);
hgs
parents:
diff changeset
   931
	}
hgs
parents:
diff changeset
   932
hgs
parents:
diff changeset
   933
EXPORT_C void RMemSpySession::ServerListOutputGenericL( TBool aDetailed )
hgs
parents:
diff changeset
   934
	{
hgs
parents:
diff changeset
   935
	TPckgBuf<TBool> detailed( aDetailed );
hgs
parents:
diff changeset
   936
	TIpcArgs args( &detailed );
hgs
parents:
diff changeset
   937
	User::LeaveIfError( SendReceive( EMemSpyClientServerOpServerListOutputGeneric, args ) );
hgs
parents:
diff changeset
   938
	}
hgs
parents:
diff changeset
   939