os/kernelhwsrv/kerneltest/e32test/debug/d_btrace.cpp
author sl@SLION-WIN7.fritz.box
Fri, 15 Jun 2012 03:10:57 +0200
changeset 0 bde4ae8d615e
permissions -rw-r--r--
First public contribution.
sl@0
     1
// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
sl@0
     2
// All rights reserved.
sl@0
     3
// This component and the accompanying materials are made available
sl@0
     4
// under the terms of the License "Eclipse Public License v1.0"
sl@0
     5
// which accompanies this distribution, and is available
sl@0
     6
// at the URL "http://www.eclipse.org/legal/epl-v10.html".
sl@0
     7
//
sl@0
     8
// Initial Contributors:
sl@0
     9
// Nokia Corporation - initial contribution.
sl@0
    10
//
sl@0
    11
// Contributors:
sl@0
    12
//
sl@0
    13
// Description:
sl@0
    14
// e32\drivers\trace\btrace.cpp
sl@0
    15
// 
sl@0
    16
//
sl@0
    17
sl@0
    18
#include <kernel/kern_priv.h>
sl@0
    19
#include "platform.h"
sl@0
    20
#include "d_btrace.h"
sl@0
    21
sl@0
    22
sl@0
    23
class DBTraceTestFactory : public DLogicalDevice
sl@0
    24
	{
sl@0
    25
public:
sl@0
    26
	virtual TInt Install();
sl@0
    27
	virtual void GetCaps(TDes8& aDes) const;
sl@0
    28
	virtual TInt Create(DLogicalChannelBase*& aChannel);
sl@0
    29
	};
sl@0
    30
sl@0
    31
sl@0
    32
class DBTraceTestChannel : public DLogicalChannelBase
sl@0
    33
	{
sl@0
    34
public:
sl@0
    35
	DBTraceTestChannel();
sl@0
    36
	virtual ~DBTraceTestChannel();
sl@0
    37
	//	Inherited from DObject
sl@0
    38
	virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
sl@0
    39
	// Inherited from DLogicalChannelBase
sl@0
    40
	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
sl@0
    41
	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
sl@0
    42
private:
sl@0
    43
	DThread* iClient;
sl@0
    44
public:
sl@0
    45
	static void TestTrace(DBTraceTestChannel* aSelf);
sl@0
    46
	static void TestUTrace(DBTraceTestChannel* aSelf);
sl@0
    47
private:
sl@0
    48
	TUint32 iTestType;
sl@0
    49
	TInt iTestDataSize;
sl@0
    50
	TUint32 iTestData[KMaxBTraceRecordSize*2/4];
sl@0
    51
	volatile TBool iTimerExpired;
sl@0
    52
	NTimer iTraceTimer;
sl@0
    53
	TDfc iTraceIDFC;
sl@0
    54
	};
sl@0
    55
sl@0
    56
sl@0
    57
//
sl@0
    58
// DBTraceTestFactory
sl@0
    59
//
sl@0
    60
sl@0
    61
TInt DBTraceTestFactory::Install()
sl@0
    62
	{
sl@0
    63
	return SetName(&RBTraceTest::Name());
sl@0
    64
	}
sl@0
    65
sl@0
    66
void DBTraceTestFactory::GetCaps(TDes8& aDes) const
sl@0
    67
	{
sl@0
    68
	Kern::InfoCopy(aDes,0,0);
sl@0
    69
	}
sl@0
    70
sl@0
    71
TInt DBTraceTestFactory::Create(DLogicalChannelBase*& aChannel)
sl@0
    72
	{
sl@0
    73
	aChannel=new DBTraceTestChannel();
sl@0
    74
	if(!aChannel)
sl@0
    75
		return KErrNoMemory;
sl@0
    76
	return KErrNone;
sl@0
    77
	}
sl@0
    78
sl@0
    79
sl@0
    80
//
sl@0
    81
// DBTraceTestChannel
sl@0
    82
//
sl@0
    83
sl@0
    84
DBTraceTestChannel::DBTraceTestChannel()
sl@0
    85
	: iTraceTimer((NTimerFn)TestTrace,this),
sl@0
    86
	iTraceIDFC((NTimerFn)TestTrace,this)
sl@0
    87
	{
sl@0
    88
	}
sl@0
    89
sl@0
    90
DBTraceTestChannel::~DBTraceTestChannel()
sl@0
    91
	{
sl@0
    92
	iTraceTimer.Cancel();
sl@0
    93
	}
sl@0
    94
sl@0
    95
TInt DBTraceTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
sl@0
    96
	{
sl@0
    97
	iClient = &Kern::CurrentThread();
sl@0
    98
	return KErrNone;
sl@0
    99
	}
sl@0
   100
sl@0
   101
sl@0
   102
TInt DBTraceTestChannel::RequestUserHandle(DThread* aThread, TOwnerType aType)
sl@0
   103
	{
sl@0
   104
	if (aType!=EOwnerThread || aThread!=iClient)
sl@0
   105
		return KErrAccessDenied;
sl@0
   106
	return KErrNone;
sl@0
   107
	}
sl@0
   108
sl@0
   109
TInt DBTraceTestChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
sl@0
   110
	{
sl@0
   111
	switch(aReqNo)
sl@0
   112
		{
sl@0
   113
	// test functions
sl@0
   114
	case RBTraceTest::ETestSpecialTrace:
sl@0
   115
	case RBTraceTest::ETestTrace:
sl@0
   116
		{
sl@0
   117
		TPtr8 data((TUint8*)&iTestData,sizeof(iTestData));
sl@0
   118
		Kern::KUDesGet(data,*(TDesC8*)a2);
sl@0
   119
		iTestDataSize = data.Size()-4;
sl@0
   120
		if(aReqNo==RBTraceTest::ETestSpecialTrace)
sl@0
   121
			{
sl@0
   122
			iTestType = (TUint)a1;
sl@0
   123
			iTimerExpired = EFalse;
sl@0
   124
			if(iTestType&RBTraceTest::EContextIsr)
sl@0
   125
				iTraceTimer.OneShot(1);
sl@0
   126
			else if(iTestType&RBTraceTest::EContextIDFC)
sl@0
   127
				{
sl@0
   128
				NKern::Lock();
sl@0
   129
				iTraceIDFC.Add();
sl@0
   130
				NKern::Unlock();
sl@0
   131
				}
sl@0
   132
			else if(iTestType&RBTraceTest::EContextIntsOff)
sl@0
   133
				{
sl@0
   134
				TInt irq = NKern::DisableAllInterrupts();
sl@0
   135
				TestTrace(this);
sl@0
   136
				NKern::RestoreInterrupts(irq);
sl@0
   137
				}
sl@0
   138
			else
sl@0
   139
				TestTrace(this);
sl@0
   140
			while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
sl@0
   141
			return (TInt)NKern::CurrentThread();
sl@0
   142
			}
sl@0
   143
		else
sl@0
   144
			{
sl@0
   145
			TInt delay = (TInt)a1/NKern::TickPeriod();
sl@0
   146
			iTestType = 0;
sl@0
   147
			if(!delay)
sl@0
   148
				TestTrace(this);
sl@0
   149
			else
sl@0
   150
				{
sl@0
   151
				iTraceTimer.Cancel();
sl@0
   152
				iTraceTimer.OneShot(delay+1);
sl@0
   153
				}
sl@0
   154
			}
sl@0
   155
		}
sl@0
   156
		return KErrNone;
sl@0
   157
sl@0
   158
	case RBTraceTest::ETestBenchmark:
sl@0
   159
		{
sl@0
   160
		TInt delay = (TInt)a2/NKern::TickPeriod();
sl@0
   161
		TInt size = (TInt)a1;
sl@0
   162
		iTestDataSize = -1;
sl@0
   163
sl@0
   164
		// wait for next tick...
sl@0
   165
		iTraceTimer.Cancel();
sl@0
   166
		iTimerExpired = EFalse;
sl@0
   167
		iTraceTimer.OneShot(1);
sl@0
   168
		while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
sl@0
   169
sl@0
   170
		// do benchmark...
sl@0
   171
		iTimerExpired = EFalse;
sl@0
   172
		iTraceTimer.OneShot(delay+1);
sl@0
   173
		TInt count = 0;
sl@0
   174
		if(size)
sl@0
   175
			for(;;)
sl@0
   176
				{
sl@0
   177
				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
sl@0
   178
				BTraceContextN(BTrace::ETest1,0,0,0,&iTestData,size);
sl@0
   179
				++count;
sl@0
   180
				if(!finished)
sl@0
   181
					continue;
sl@0
   182
				break;
sl@0
   183
				}
sl@0
   184
		else
sl@0
   185
			for(;;)
sl@0
   186
				{
sl@0
   187
				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
sl@0
   188
				BTrace0(BTrace::ETest1,0);
sl@0
   189
				++count;
sl@0
   190
				if(!finished)
sl@0
   191
					continue;
sl@0
   192
				break;
sl@0
   193
				}
sl@0
   194
		return count;
sl@0
   195
		}
sl@0
   196
sl@0
   197
	case RBTraceTest::ETestBenchmark2:
sl@0
   198
		{
sl@0
   199
		TInt delay = (TInt)a2/NKern::TickPeriod();
sl@0
   200
		TInt size = (TInt)a1;
sl@0
   201
		iTestDataSize = -1;
sl@0
   202
sl@0
   203
		// wait for next tick...
sl@0
   204
		iTraceTimer.Cancel();
sl@0
   205
		iTimerExpired = EFalse;
sl@0
   206
		iTraceTimer.OneShot(1);
sl@0
   207
		while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
sl@0
   208
sl@0
   209
		// do benchmark...
sl@0
   210
		iTimerExpired = EFalse;
sl@0
   211
		iTraceTimer.OneShot(delay+1);
sl@0
   212
		TInt count = 0;
sl@0
   213
		if(size)
sl@0
   214
			for(;;)
sl@0
   215
				{
sl@0
   216
				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
sl@0
   217
				BTraceFilteredContextN(BTrace::ETest1,0,KBTraceFilterTestUid1,0,&iTestData,size);
sl@0
   218
				++count;
sl@0
   219
				if(!finished)
sl@0
   220
					continue;
sl@0
   221
				break;
sl@0
   222
				}
sl@0
   223
		else
sl@0
   224
			for(;;)
sl@0
   225
				{
sl@0
   226
				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
sl@0
   227
				BTraceFiltered4(BTrace::ETest1,0,KBTraceFilterTestUid1);
sl@0
   228
				++count;
sl@0
   229
				if(!finished)
sl@0
   230
					continue;
sl@0
   231
				break;
sl@0
   232
				}
sl@0
   233
		return count;
sl@0
   234
		}
sl@0
   235
sl@0
   236
	case RBTraceTest::ETestBenchmarkCheckFilter:
sl@0
   237
		{
sl@0
   238
		TInt delay = (TInt)a2/NKern::TickPeriod();
sl@0
   239
sl@0
   240
		// wait for next tick...
sl@0
   241
		iTraceTimer.Cancel();
sl@0
   242
		iTimerExpired = EFalse;
sl@0
   243
		iTraceTimer.OneShot(1);
sl@0
   244
		while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
sl@0
   245
sl@0
   246
		// do benchmark...
sl@0
   247
		iTimerExpired = EFalse;
sl@0
   248
		iTraceTimer.OneShot(delay+1);
sl@0
   249
		TInt count = 0;
sl@0
   250
		if(a1)
sl@0
   251
			for(;;)
sl@0
   252
				{
sl@0
   253
				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
sl@0
   254
				BTrace::CheckFilter2(BTrace::ETest1,KBTraceFilterTestUid1);
sl@0
   255
				++count;
sl@0
   256
				if(!finished)
sl@0
   257
					continue;
sl@0
   258
				break;
sl@0
   259
				}
sl@0
   260
		else
sl@0
   261
			for(;;)
sl@0
   262
				{
sl@0
   263
				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
sl@0
   264
				BTrace::CheckFilter(BTrace::ETest1);
sl@0
   265
				++count;
sl@0
   266
				if(!finished)
sl@0
   267
					continue;
sl@0
   268
				break;
sl@0
   269
				}
sl@0
   270
		return count;
sl@0
   271
		}
sl@0
   272
	case RBTraceTest::ETestUTrace:
sl@0
   273
		{
sl@0
   274
		TPtr8 data((TUint8*)&iTestData,sizeof(iTestData));
sl@0
   275
		Kern::KUDesGet(data,*(TDesC8*)a2);
sl@0
   276
		iTestDataSize = data.Size()-4;
sl@0
   277
		TInt delay = (TInt)a1/NKern::TickPeriod();
sl@0
   278
		iTestType = 0;
sl@0
   279
		if(!delay)
sl@0
   280
			TestUTrace(this);
sl@0
   281
		else
sl@0
   282
			{
sl@0
   283
			iTraceTimer.Cancel();
sl@0
   284
			iTraceTimer.OneShot(delay+1);
sl@0
   285
			}
sl@0
   286
		return KErrNone;
sl@0
   287
		}
sl@0
   288
sl@0
   289
	default:
sl@0
   290
		break;
sl@0
   291
		}
sl@0
   292
	return KErrNotSupported;
sl@0
   293
	}
sl@0
   294
sl@0
   295
sl@0
   296
void DBTraceTestChannel::TestTrace(DBTraceTestChannel* aSelf)
sl@0
   297
	{
sl@0
   298
	TInt size = aSelf->iTestDataSize;
sl@0
   299
	if(size<0)
sl@0
   300
		{
sl@0
   301
		__e32_atomic_store_rel32(&aSelf->iTimerExpired, 1);
sl@0
   302
		return;
sl@0
   303
		}
sl@0
   304
	TUint32* data = aSelf->iTestData;
sl@0
   305
	BTrace::TCategory category = (BTrace::TCategory)((TUint8*)data)[0];
sl@0
   306
	TUint subCategory = (BTrace::TCategory)((TUint8*)data)[1];
sl@0
   307
	TUint type = aSelf->iTestType&0xff;
sl@0
   308
	TBool bigTrace = aSelf->iTestType&RBTraceTest::EBigTrace;
sl@0
   309
	TBool filter2Trace = aSelf->iTestType&RBTraceTest::EFilter2Trace;
sl@0
   310
sl@0
   311
	if(!filter2Trace)
sl@0
   312
		{
sl@0
   313
		if(type==BTrace::EPcPresent)
sl@0
   314
			{
sl@0
   315
			if(bigTrace)
sl@0
   316
				{
sl@0
   317
				BTracePcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   318
				BTracePcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   319
				}
sl@0
   320
			else if(size==0)
sl@0
   321
				{
sl@0
   322
				BTracePc0(category,subCategory);
sl@0
   323
				BTracePc0(category,subCategory);
sl@0
   324
				}
sl@0
   325
			else if(size<=4)
sl@0
   326
				{
sl@0
   327
				BTracePc4(category,subCategory,data[1]);
sl@0
   328
				BTracePc4(category,subCategory,data[1]);
sl@0
   329
				}
sl@0
   330
			else if(size<=8)
sl@0
   331
				{
sl@0
   332
				BTracePc8(category,subCategory,data[1],data[2]);
sl@0
   333
				BTracePc8(category,subCategory,data[1],data[2]);
sl@0
   334
				}
sl@0
   335
			else
sl@0
   336
				{
sl@0
   337
				BTracePcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   338
				BTracePcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   339
				}
sl@0
   340
			}
sl@0
   341
		else if(type==BTrace::EContextIdPresent)
sl@0
   342
			{
sl@0
   343
			if(bigTrace)
sl@0
   344
				{
sl@0
   345
				BTraceContextBig(category,subCategory,data[1],data+2,size-4);
sl@0
   346
				BTraceContextBig(category,subCategory,data[1],data+2,size-4);
sl@0
   347
				}
sl@0
   348
			else if(size==0)
sl@0
   349
				{
sl@0
   350
				BTraceContext0(category,subCategory);
sl@0
   351
				BTraceContext0(category,subCategory);
sl@0
   352
				}
sl@0
   353
			else if(size<=4)
sl@0
   354
				{
sl@0
   355
				BTraceContext4(category,subCategory,data[1]);
sl@0
   356
				BTraceContext4(category,subCategory,data[1]);
sl@0
   357
				}
sl@0
   358
			else if(size<=8)
sl@0
   359
				{
sl@0
   360
				BTraceContext8(category,subCategory,data[1],data[2]);
sl@0
   361
				BTraceContext8(category,subCategory,data[1],data[2]);
sl@0
   362
				}
sl@0
   363
			else
sl@0
   364
				{
sl@0
   365
				BTraceContextN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   366
				BTraceContextN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   367
				}
sl@0
   368
			}
sl@0
   369
		else if(type==BTrace::EContextIdPresent+BTrace::EPcPresent)
sl@0
   370
			{
sl@0
   371
			if(bigTrace)
sl@0
   372
				{
sl@0
   373
				BTraceContextPcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   374
				BTraceContextPcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   375
				}
sl@0
   376
			else if(size==0)
sl@0
   377
				{
sl@0
   378
				BTraceContextPc0(category,subCategory);
sl@0
   379
				BTraceContextPc0(category,subCategory);
sl@0
   380
				}
sl@0
   381
			else if(size<=4)
sl@0
   382
				{
sl@0
   383
				BTraceContextPc4(category,subCategory,data[1]);
sl@0
   384
				BTraceContextPc4(category,subCategory,data[1]);
sl@0
   385
				}
sl@0
   386
			else if(size<=8)
sl@0
   387
				{
sl@0
   388
				BTraceContextPc8(category,subCategory,data[1],data[2]);
sl@0
   389
				BTraceContextPc8(category,subCategory,data[1],data[2]);
sl@0
   390
				}
sl@0
   391
			else
sl@0
   392
				{
sl@0
   393
				BTraceContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   394
				BTraceContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   395
				}
sl@0
   396
			}
sl@0
   397
		else
sl@0
   398
			{
sl@0
   399
			if(bigTrace)
sl@0
   400
				BTraceBig(category,subCategory,data[1],data+2,size-4);
sl@0
   401
			else if(size==0)
sl@0
   402
				BTrace0(category,subCategory);
sl@0
   403
			else if(size<=4)
sl@0
   404
				BTrace4(category,subCategory,data[1]);
sl@0
   405
			else if(size<8)
sl@0
   406
				BTrace8(category,subCategory,data[1],data[2]);
sl@0
   407
			else
sl@0
   408
				BTraceN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   409
			}
sl@0
   410
		}
sl@0
   411
	else
sl@0
   412
		{
sl@0
   413
		if(type==BTrace::EPcPresent)
sl@0
   414
			{
sl@0
   415
			if(bigTrace)
sl@0
   416
				{
sl@0
   417
				BTraceFilteredPcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   418
				BTraceFilteredPcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   419
				}
sl@0
   420
			else if(size<4)
sl@0
   421
				{
sl@0
   422
				// invalid
sl@0
   423
				}
sl@0
   424
			else if(size==4)
sl@0
   425
				{
sl@0
   426
				BTraceFilteredPc4(category,subCategory,data[1]);
sl@0
   427
				BTraceFilteredPc4(category,subCategory,data[1]);
sl@0
   428
				}
sl@0
   429
			else if(size<=8)
sl@0
   430
				{
sl@0
   431
				BTraceFilteredPc8(category,subCategory,data[1],data[2]);
sl@0
   432
				BTraceFilteredPc8(category,subCategory,data[1],data[2]);
sl@0
   433
				}
sl@0
   434
			else
sl@0
   435
				{
sl@0
   436
				BTraceFilteredPcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   437
				BTraceFilteredPcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   438
				}
sl@0
   439
			}
sl@0
   440
		else if(type==BTrace::EContextIdPresent)
sl@0
   441
			{
sl@0
   442
			if(bigTrace)
sl@0
   443
				{
sl@0
   444
				BTraceFilteredContextBig(category,subCategory,data[1],data+2,size-4);
sl@0
   445
				BTraceFilteredContextBig(category,subCategory,data[1],data+2,size-4);
sl@0
   446
				}
sl@0
   447
			else if(size<4)
sl@0
   448
				{
sl@0
   449
				// invalid
sl@0
   450
				}
sl@0
   451
			else if(size==4)
sl@0
   452
				{
sl@0
   453
				BTraceFilteredContext4(category,subCategory,data[1]);
sl@0
   454
				BTraceFilteredContext4(category,subCategory,data[1]);
sl@0
   455
				}
sl@0
   456
			else if(size<=8)
sl@0
   457
				{
sl@0
   458
				BTraceFilteredContext8(category,subCategory,data[1],data[2]);
sl@0
   459
				BTraceFilteredContext8(category,subCategory,data[1],data[2]);
sl@0
   460
				}
sl@0
   461
			else
sl@0
   462
				{
sl@0
   463
				BTraceFilteredContextN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   464
				BTraceFilteredContextN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   465
				}
sl@0
   466
			}
sl@0
   467
		else if(type==BTrace::EContextIdPresent+BTrace::EPcPresent)
sl@0
   468
			{
sl@0
   469
			if(bigTrace)
sl@0
   470
				{
sl@0
   471
				BTraceFilteredContextPcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   472
				BTraceFilteredContextPcBig(category,subCategory,data[1],data+2,size-4);
sl@0
   473
				}
sl@0
   474
			else if(size<4)
sl@0
   475
				{
sl@0
   476
				// invalid
sl@0
   477
				}
sl@0
   478
			else if(size==4)
sl@0
   479
				{
sl@0
   480
				BTraceFilteredContextPc4(category,subCategory,data[1]);
sl@0
   481
				BTraceFilteredContextPc4(category,subCategory,data[1]);
sl@0
   482
				}
sl@0
   483
			else if(size<=8)
sl@0
   484
				{
sl@0
   485
				BTraceFilteredContextPc8(category,subCategory,data[1],data[2]);
sl@0
   486
				BTraceFilteredContextPc8(category,subCategory,data[1],data[2]);
sl@0
   487
				}
sl@0
   488
			else
sl@0
   489
				{
sl@0
   490
				BTraceFilteredContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   491
				BTraceFilteredContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   492
				}
sl@0
   493
			}
sl@0
   494
		else
sl@0
   495
			{
sl@0
   496
			if(bigTrace)
sl@0
   497
				BTraceFilteredBig(category,subCategory,data[1],data+2,size-4);
sl@0
   498
			else if(size<4)
sl@0
   499
				{
sl@0
   500
				// invalid
sl@0
   501
				}
sl@0
   502
			else if(size==4)
sl@0
   503
				BTraceFiltered4(category,subCategory,data[1]);
sl@0
   504
			else if(size<8)
sl@0
   505
				BTraceFiltered8(category,subCategory,data[1],data[2]);
sl@0
   506
			else
sl@0
   507
				BTraceFilteredN(category,subCategory,data[1],data[2],data+3,size-8);
sl@0
   508
			}
sl@0
   509
		}
sl@0
   510
	__e32_atomic_store_rel32(&aSelf->iTimerExpired, 1);
sl@0
   511
	}
sl@0
   512
sl@0
   513
void DBTraceTestChannel::TestUTrace(DBTraceTestChannel* aSelf)
sl@0
   514
	{
sl@0
   515
	aSelf->iTimerExpired = ETrue;
sl@0
   516
	TInt size = aSelf->iTestDataSize;
sl@0
   517
	if(size<0)
sl@0
   518
		return;
sl@0
   519
	TUint32* data = aSelf->iTestData;
sl@0
   520
	BTrace::TCategory category = (BTrace::TCategory)((TUint8*)data)[0];
sl@0
   521
	TUint subCategory = (BTrace::TCategory)((TUint8*)data)[1];
sl@0
   522
sl@0
   523
	#define T_UTRACE_HEADER(aSize,aClassification,aContext,aPc)																\
sl@0
   524
		((((aSize) + (aContext?4:0) + (aPc?4:0)) << BTrace::ESizeIndex*8)										\
sl@0
   525
		+(((aContext?BTrace::EContextIdPresent:0) | (aPc?BTrace::EPcPresent:0)) << BTrace::EFlagsIndex*8)			\
sl@0
   526
		+((aClassification) << BTrace::ECategoryIndex*8)																				\
sl@0
   527
		+((subCategory) << BTrace::ESubCategoryIndex*8))
sl@0
   528
sl@0
   529
	#define UTRACE_SECONDARY(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId)	\
sl@0
   530
		BTrace::OutFilteredPcFormatBig(T_UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,0,0)
sl@0
   531
sl@0
   532
	#define UTRACE_SECONDARY_4(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId, aData1) \
sl@0
   533
		BTrace::OutFilteredPcFormatBig(T_UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,&aData1,4)
sl@0
   534
sl@0
   535
	#define UTRACE_SECONDARY_ANY(aClassification, aModuleUid, aThreadIdPresent, aPcPresent, aPc, aFormatId, aData, aDataSize) \
sl@0
   536
		BTrace::OutFilteredPcFormatBig(T_UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,aData,(TInt)(aDataSize))
sl@0
   537
sl@0
   538
sl@0
   539
	TUint32 KUtracePcValues[3]={0, 0x123456, 0x987654};
sl@0
   540
	TUint16 formatId = (TUint16)data[2];
sl@0
   541
	TUint type = aSelf->iTestType&0xff;
sl@0
   542
	if(type == BTrace::EPcPresent)
sl@0
   543
		{
sl@0
   544
		if(size <= 0)
sl@0
   545
			{
sl@0
   546
			UTRACE_SECONDARY(category, data[1], EFalse, ETrue, KUtracePcValues[1], formatId);
sl@0
   547
			UTRACE_SECONDARY(category, data[1], EFalse, ETrue, KUtracePcValues[2], formatId);
sl@0
   548
			}
sl@0
   549
		else if(size <= 4)
sl@0
   550
			{
sl@0
   551
			UTRACE_SECONDARY_4(category, data[1], EFalse, ETrue, KUtracePcValues[1], formatId, data[3]);
sl@0
   552
			UTRACE_SECONDARY_4(category, data[1], EFalse, ETrue, KUtracePcValues[2], formatId, data[3]);
sl@0
   553
			}
sl@0
   554
		else //size > 8
sl@0
   555
			{
sl@0
   556
			UTRACE_SECONDARY_ANY(category, data[1], EFalse, ETrue, KUtracePcValues[1], formatId, data+3, size);
sl@0
   557
			UTRACE_SECONDARY_ANY(category, data[1], EFalse, ETrue, KUtracePcValues[2], formatId, data+3, size);
sl@0
   558
			}
sl@0
   559
		}
sl@0
   560
	else if(type==BTrace::EContextIdPresent)
sl@0
   561
		{
sl@0
   562
		if(size <= 0)
sl@0
   563
			{
sl@0
   564
			UTRACE_SECONDARY(category, data[1], ETrue, EFalse, KUtracePcValues[1], formatId);
sl@0
   565
			UTRACE_SECONDARY(category, data[1], ETrue, EFalse, KUtracePcValues[2], formatId);
sl@0
   566
			}
sl@0
   567
		else if(size <= 4)
sl@0
   568
			{
sl@0
   569
			UTRACE_SECONDARY_4(category, data[1], ETrue, EFalse, KUtracePcValues[1], formatId, data[3]);
sl@0
   570
			UTRACE_SECONDARY_4(category, data[1], ETrue, EFalse, KUtracePcValues[2], formatId, data[3]);
sl@0
   571
			}
sl@0
   572
		else //size > 8
sl@0
   573
			{
sl@0
   574
			UTRACE_SECONDARY_ANY(category, data[1], ETrue, EFalse, KUtracePcValues[1], formatId, data+3, size);
sl@0
   575
			UTRACE_SECONDARY_ANY(category, data[1], ETrue, EFalse, KUtracePcValues[2], formatId, data+3, size);
sl@0
   576
			}
sl@0
   577
		}
sl@0
   578
	else if(type==BTrace::EContextIdPresent+BTrace::EPcPresent)
sl@0
   579
		{
sl@0
   580
		if(size <= 0)
sl@0
   581
			{
sl@0
   582
			UTRACE_SECONDARY(category, data[1], ETrue, ETrue, KUtracePcValues[1], formatId);
sl@0
   583
			UTRACE_SECONDARY(category, data[1], ETrue, ETrue, KUtracePcValues[2], formatId);
sl@0
   584
			}
sl@0
   585
		else if(size <= 4)
sl@0
   586
			{
sl@0
   587
			UTRACE_SECONDARY_4(category, data[1], ETrue, ETrue, KUtracePcValues[1], formatId, data[3]);
sl@0
   588
			UTRACE_SECONDARY_4(category, data[1], ETrue, ETrue, KUtracePcValues[2], formatId, data[3]);
sl@0
   589
			}
sl@0
   590
		else //size > 8
sl@0
   591
			{
sl@0
   592
			UTRACE_SECONDARY_ANY(category, data[1], ETrue, ETrue, KUtracePcValues[1], formatId, data+3, size);
sl@0
   593
			UTRACE_SECONDARY_ANY(category, data[1], ETrue, ETrue, KUtracePcValues[2], formatId, data+3, size);
sl@0
   594
			}
sl@0
   595
		}
sl@0
   596
	else
sl@0
   597
		{
sl@0
   598
		if(size <= 0)
sl@0
   599
			{
sl@0
   600
			UTRACE_SECONDARY(category, data[1], EFalse, EFalse, KUtracePcValues[1], formatId);
sl@0
   601
			UTRACE_SECONDARY(category, data[1], EFalse, EFalse, KUtracePcValues[2], formatId);
sl@0
   602
			}
sl@0
   603
		else if(size <= 4)
sl@0
   604
			{
sl@0
   605
			UTRACE_SECONDARY_4(category, data[1], EFalse, EFalse, KUtracePcValues[1], formatId, data[3]);
sl@0
   606
			UTRACE_SECONDARY_4(category, data[1], EFalse, EFalse, KUtracePcValues[2], formatId, data[3]);
sl@0
   607
			}
sl@0
   608
		else //size > 8
sl@0
   609
			{
sl@0
   610
			UTRACE_SECONDARY_ANY(category, data[1], EFalse, EFalse, KUtracePcValues[1], formatId, data+3, size);
sl@0
   611
			UTRACE_SECONDARY_ANY(category, data[1], EFalse, EFalse, KUtracePcValues[2], formatId, data+3, size);
sl@0
   612
			}
sl@0
   613
		}
sl@0
   614
sl@0
   615
	}
sl@0
   616
sl@0
   617
DECLARE_STANDARD_LDD()
sl@0
   618
	{
sl@0
   619
	return new DBTraceTestFactory;
sl@0
   620
	}
sl@0
   621
sl@0
   622