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