os/kernelhwsrv/kerneltest/e32test/debug/d_btrace.cpp
changeset 0 bde4ae8d615e
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/os/kernelhwsrv/kerneltest/e32test/debug/d_btrace.cpp	Fri Jun 15 03:10:57 2012 +0200
     1.3 @@ -0,0 +1,622 @@
     1.4 +// Copyright (c) 2005-2009 Nokia Corporation and/or its subsidiary(-ies).
     1.5 +// All rights reserved.
     1.6 +// This component and the accompanying materials are made available
     1.7 +// under the terms of the License "Eclipse Public License v1.0"
     1.8 +// which accompanies this distribution, and is available
     1.9 +// at the URL "http://www.eclipse.org/legal/epl-v10.html".
    1.10 +//
    1.11 +// Initial Contributors:
    1.12 +// Nokia Corporation - initial contribution.
    1.13 +//
    1.14 +// Contributors:
    1.15 +//
    1.16 +// Description:
    1.17 +// e32\drivers\trace\btrace.cpp
    1.18 +// 
    1.19 +//
    1.20 +
    1.21 +#include <kernel/kern_priv.h>
    1.22 +#include "platform.h"
    1.23 +#include "d_btrace.h"
    1.24 +
    1.25 +
    1.26 +class DBTraceTestFactory : public DLogicalDevice
    1.27 +	{
    1.28 +public:
    1.29 +	virtual TInt Install();
    1.30 +	virtual void GetCaps(TDes8& aDes) const;
    1.31 +	virtual TInt Create(DLogicalChannelBase*& aChannel);
    1.32 +	};
    1.33 +
    1.34 +
    1.35 +class DBTraceTestChannel : public DLogicalChannelBase
    1.36 +	{
    1.37 +public:
    1.38 +	DBTraceTestChannel();
    1.39 +	virtual ~DBTraceTestChannel();
    1.40 +	//	Inherited from DObject
    1.41 +	virtual TInt RequestUserHandle(DThread* aThread, TOwnerType aType);
    1.42 +	// Inherited from DLogicalChannelBase
    1.43 +	virtual TInt DoCreate(TInt aUnit, const TDesC8* anInfo, const TVersion& aVer);
    1.44 +	virtual TInt Request(TInt aReqNo, TAny* a1, TAny* a2);
    1.45 +private:
    1.46 +	DThread* iClient;
    1.47 +public:
    1.48 +	static void TestTrace(DBTraceTestChannel* aSelf);
    1.49 +	static void TestUTrace(DBTraceTestChannel* aSelf);
    1.50 +private:
    1.51 +	TUint32 iTestType;
    1.52 +	TInt iTestDataSize;
    1.53 +	TUint32 iTestData[KMaxBTraceRecordSize*2/4];
    1.54 +	volatile TBool iTimerExpired;
    1.55 +	NTimer iTraceTimer;
    1.56 +	TDfc iTraceIDFC;
    1.57 +	};
    1.58 +
    1.59 +
    1.60 +//
    1.61 +// DBTraceTestFactory
    1.62 +//
    1.63 +
    1.64 +TInt DBTraceTestFactory::Install()
    1.65 +	{
    1.66 +	return SetName(&RBTraceTest::Name());
    1.67 +	}
    1.68 +
    1.69 +void DBTraceTestFactory::GetCaps(TDes8& aDes) const
    1.70 +	{
    1.71 +	Kern::InfoCopy(aDes,0,0);
    1.72 +	}
    1.73 +
    1.74 +TInt DBTraceTestFactory::Create(DLogicalChannelBase*& aChannel)
    1.75 +	{
    1.76 +	aChannel=new DBTraceTestChannel();
    1.77 +	if(!aChannel)
    1.78 +		return KErrNoMemory;
    1.79 +	return KErrNone;
    1.80 +	}
    1.81 +
    1.82 +
    1.83 +//
    1.84 +// DBTraceTestChannel
    1.85 +//
    1.86 +
    1.87 +DBTraceTestChannel::DBTraceTestChannel()
    1.88 +	: iTraceTimer((NTimerFn)TestTrace,this),
    1.89 +	iTraceIDFC((NTimerFn)TestTrace,this)
    1.90 +	{
    1.91 +	}
    1.92 +
    1.93 +DBTraceTestChannel::~DBTraceTestChannel()
    1.94 +	{
    1.95 +	iTraceTimer.Cancel();
    1.96 +	}
    1.97 +
    1.98 +TInt DBTraceTestChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
    1.99 +	{
   1.100 +	iClient = &Kern::CurrentThread();
   1.101 +	return KErrNone;
   1.102 +	}
   1.103 +
   1.104 +
   1.105 +TInt DBTraceTestChannel::RequestUserHandle(DThread* aThread, TOwnerType aType)
   1.106 +	{
   1.107 +	if (aType!=EOwnerThread || aThread!=iClient)
   1.108 +		return KErrAccessDenied;
   1.109 +	return KErrNone;
   1.110 +	}
   1.111 +
   1.112 +TInt DBTraceTestChannel::Request(TInt aReqNo, TAny* a1, TAny* a2)
   1.113 +	{
   1.114 +	switch(aReqNo)
   1.115 +		{
   1.116 +	// test functions
   1.117 +	case RBTraceTest::ETestSpecialTrace:
   1.118 +	case RBTraceTest::ETestTrace:
   1.119 +		{
   1.120 +		TPtr8 data((TUint8*)&iTestData,sizeof(iTestData));
   1.121 +		Kern::KUDesGet(data,*(TDesC8*)a2);
   1.122 +		iTestDataSize = data.Size()-4;
   1.123 +		if(aReqNo==RBTraceTest::ETestSpecialTrace)
   1.124 +			{
   1.125 +			iTestType = (TUint)a1;
   1.126 +			iTimerExpired = EFalse;
   1.127 +			if(iTestType&RBTraceTest::EContextIsr)
   1.128 +				iTraceTimer.OneShot(1);
   1.129 +			else if(iTestType&RBTraceTest::EContextIDFC)
   1.130 +				{
   1.131 +				NKern::Lock();
   1.132 +				iTraceIDFC.Add();
   1.133 +				NKern::Unlock();
   1.134 +				}
   1.135 +			else if(iTestType&RBTraceTest::EContextIntsOff)
   1.136 +				{
   1.137 +				TInt irq = NKern::DisableAllInterrupts();
   1.138 +				TestTrace(this);
   1.139 +				NKern::RestoreInterrupts(irq);
   1.140 +				}
   1.141 +			else
   1.142 +				TestTrace(this);
   1.143 +			while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
   1.144 +			return (TInt)NKern::CurrentThread();
   1.145 +			}
   1.146 +		else
   1.147 +			{
   1.148 +			TInt delay = (TInt)a1/NKern::TickPeriod();
   1.149 +			iTestType = 0;
   1.150 +			if(!delay)
   1.151 +				TestTrace(this);
   1.152 +			else
   1.153 +				{
   1.154 +				iTraceTimer.Cancel();
   1.155 +				iTraceTimer.OneShot(delay+1);
   1.156 +				}
   1.157 +			}
   1.158 +		}
   1.159 +		return KErrNone;
   1.160 +
   1.161 +	case RBTraceTest::ETestBenchmark:
   1.162 +		{
   1.163 +		TInt delay = (TInt)a2/NKern::TickPeriod();
   1.164 +		TInt size = (TInt)a1;
   1.165 +		iTestDataSize = -1;
   1.166 +
   1.167 +		// wait for next tick...
   1.168 +		iTraceTimer.Cancel();
   1.169 +		iTimerExpired = EFalse;
   1.170 +		iTraceTimer.OneShot(1);
   1.171 +		while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
   1.172 +
   1.173 +		// do benchmark...
   1.174 +		iTimerExpired = EFalse;
   1.175 +		iTraceTimer.OneShot(delay+1);
   1.176 +		TInt count = 0;
   1.177 +		if(size)
   1.178 +			for(;;)
   1.179 +				{
   1.180 +				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
   1.181 +				BTraceContextN(BTrace::ETest1,0,0,0,&iTestData,size);
   1.182 +				++count;
   1.183 +				if(!finished)
   1.184 +					continue;
   1.185 +				break;
   1.186 +				}
   1.187 +		else
   1.188 +			for(;;)
   1.189 +				{
   1.190 +				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
   1.191 +				BTrace0(BTrace::ETest1,0);
   1.192 +				++count;
   1.193 +				if(!finished)
   1.194 +					continue;
   1.195 +				break;
   1.196 +				}
   1.197 +		return count;
   1.198 +		}
   1.199 +
   1.200 +	case RBTraceTest::ETestBenchmark2:
   1.201 +		{
   1.202 +		TInt delay = (TInt)a2/NKern::TickPeriod();
   1.203 +		TInt size = (TInt)a1;
   1.204 +		iTestDataSize = -1;
   1.205 +
   1.206 +		// wait for next tick...
   1.207 +		iTraceTimer.Cancel();
   1.208 +		iTimerExpired = EFalse;
   1.209 +		iTraceTimer.OneShot(1);
   1.210 +		while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
   1.211 +
   1.212 +		// do benchmark...
   1.213 +		iTimerExpired = EFalse;
   1.214 +		iTraceTimer.OneShot(delay+1);
   1.215 +		TInt count = 0;
   1.216 +		if(size)
   1.217 +			for(;;)
   1.218 +				{
   1.219 +				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
   1.220 +				BTraceFilteredContextN(BTrace::ETest1,0,KBTraceFilterTestUid1,0,&iTestData,size);
   1.221 +				++count;
   1.222 +				if(!finished)
   1.223 +					continue;
   1.224 +				break;
   1.225 +				}
   1.226 +		else
   1.227 +			for(;;)
   1.228 +				{
   1.229 +				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
   1.230 +				BTraceFiltered4(BTrace::ETest1,0,KBTraceFilterTestUid1);
   1.231 +				++count;
   1.232 +				if(!finished)
   1.233 +					continue;
   1.234 +				break;
   1.235 +				}
   1.236 +		return count;
   1.237 +		}
   1.238 +
   1.239 +	case RBTraceTest::ETestBenchmarkCheckFilter:
   1.240 +		{
   1.241 +		TInt delay = (TInt)a2/NKern::TickPeriod();
   1.242 +
   1.243 +		// wait for next tick...
   1.244 +		iTraceTimer.Cancel();
   1.245 +		iTimerExpired = EFalse;
   1.246 +		iTraceTimer.OneShot(1);
   1.247 +		while(!__e32_atomic_load_acq32(&iTimerExpired)) {};
   1.248 +
   1.249 +		// do benchmark...
   1.250 +		iTimerExpired = EFalse;
   1.251 +		iTraceTimer.OneShot(delay+1);
   1.252 +		TInt count = 0;
   1.253 +		if(a1)
   1.254 +			for(;;)
   1.255 +				{
   1.256 +				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
   1.257 +				BTrace::CheckFilter2(BTrace::ETest1,KBTraceFilterTestUid1);
   1.258 +				++count;
   1.259 +				if(!finished)
   1.260 +					continue;
   1.261 +				break;
   1.262 +				}
   1.263 +		else
   1.264 +			for(;;)
   1.265 +				{
   1.266 +				TBool finished = __e32_atomic_load_acq32(&iTimerExpired);
   1.267 +				BTrace::CheckFilter(BTrace::ETest1);
   1.268 +				++count;
   1.269 +				if(!finished)
   1.270 +					continue;
   1.271 +				break;
   1.272 +				}
   1.273 +		return count;
   1.274 +		}
   1.275 +	case RBTraceTest::ETestUTrace:
   1.276 +		{
   1.277 +		TPtr8 data((TUint8*)&iTestData,sizeof(iTestData));
   1.278 +		Kern::KUDesGet(data,*(TDesC8*)a2);
   1.279 +		iTestDataSize = data.Size()-4;
   1.280 +		TInt delay = (TInt)a1/NKern::TickPeriod();
   1.281 +		iTestType = 0;
   1.282 +		if(!delay)
   1.283 +			TestUTrace(this);
   1.284 +		else
   1.285 +			{
   1.286 +			iTraceTimer.Cancel();
   1.287 +			iTraceTimer.OneShot(delay+1);
   1.288 +			}
   1.289 +		return KErrNone;
   1.290 +		}
   1.291 +
   1.292 +	default:
   1.293 +		break;
   1.294 +		}
   1.295 +	return KErrNotSupported;
   1.296 +	}
   1.297 +
   1.298 +
   1.299 +void DBTraceTestChannel::TestTrace(DBTraceTestChannel* aSelf)
   1.300 +	{
   1.301 +	TInt size = aSelf->iTestDataSize;
   1.302 +	if(size<0)
   1.303 +		{
   1.304 +		__e32_atomic_store_rel32(&aSelf->iTimerExpired, 1);
   1.305 +		return;
   1.306 +		}
   1.307 +	TUint32* data = aSelf->iTestData;
   1.308 +	BTrace::TCategory category = (BTrace::TCategory)((TUint8*)data)[0];
   1.309 +	TUint subCategory = (BTrace::TCategory)((TUint8*)data)[1];
   1.310 +	TUint type = aSelf->iTestType&0xff;
   1.311 +	TBool bigTrace = aSelf->iTestType&RBTraceTest::EBigTrace;
   1.312 +	TBool filter2Trace = aSelf->iTestType&RBTraceTest::EFilter2Trace;
   1.313 +
   1.314 +	if(!filter2Trace)
   1.315 +		{
   1.316 +		if(type==BTrace::EPcPresent)
   1.317 +			{
   1.318 +			if(bigTrace)
   1.319 +				{
   1.320 +				BTracePcBig(category,subCategory,data[1],data+2,size-4);
   1.321 +				BTracePcBig(category,subCategory,data[1],data+2,size-4);
   1.322 +				}
   1.323 +			else if(size==0)
   1.324 +				{
   1.325 +				BTracePc0(category,subCategory);
   1.326 +				BTracePc0(category,subCategory);
   1.327 +				}
   1.328 +			else if(size<=4)
   1.329 +				{
   1.330 +				BTracePc4(category,subCategory,data[1]);
   1.331 +				BTracePc4(category,subCategory,data[1]);
   1.332 +				}
   1.333 +			else if(size<=8)
   1.334 +				{
   1.335 +				BTracePc8(category,subCategory,data[1],data[2]);
   1.336 +				BTracePc8(category,subCategory,data[1],data[2]);
   1.337 +				}
   1.338 +			else
   1.339 +				{
   1.340 +				BTracePcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.341 +				BTracePcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.342 +				}
   1.343 +			}
   1.344 +		else if(type==BTrace::EContextIdPresent)
   1.345 +			{
   1.346 +			if(bigTrace)
   1.347 +				{
   1.348 +				BTraceContextBig(category,subCategory,data[1],data+2,size-4);
   1.349 +				BTraceContextBig(category,subCategory,data[1],data+2,size-4);
   1.350 +				}
   1.351 +			else if(size==0)
   1.352 +				{
   1.353 +				BTraceContext0(category,subCategory);
   1.354 +				BTraceContext0(category,subCategory);
   1.355 +				}
   1.356 +			else if(size<=4)
   1.357 +				{
   1.358 +				BTraceContext4(category,subCategory,data[1]);
   1.359 +				BTraceContext4(category,subCategory,data[1]);
   1.360 +				}
   1.361 +			else if(size<=8)
   1.362 +				{
   1.363 +				BTraceContext8(category,subCategory,data[1],data[2]);
   1.364 +				BTraceContext8(category,subCategory,data[1],data[2]);
   1.365 +				}
   1.366 +			else
   1.367 +				{
   1.368 +				BTraceContextN(category,subCategory,data[1],data[2],data+3,size-8);
   1.369 +				BTraceContextN(category,subCategory,data[1],data[2],data+3,size-8);
   1.370 +				}
   1.371 +			}
   1.372 +		else if(type==BTrace::EContextIdPresent+BTrace::EPcPresent)
   1.373 +			{
   1.374 +			if(bigTrace)
   1.375 +				{
   1.376 +				BTraceContextPcBig(category,subCategory,data[1],data+2,size-4);
   1.377 +				BTraceContextPcBig(category,subCategory,data[1],data+2,size-4);
   1.378 +				}
   1.379 +			else if(size==0)
   1.380 +				{
   1.381 +				BTraceContextPc0(category,subCategory);
   1.382 +				BTraceContextPc0(category,subCategory);
   1.383 +				}
   1.384 +			else if(size<=4)
   1.385 +				{
   1.386 +				BTraceContextPc4(category,subCategory,data[1]);
   1.387 +				BTraceContextPc4(category,subCategory,data[1]);
   1.388 +				}
   1.389 +			else if(size<=8)
   1.390 +				{
   1.391 +				BTraceContextPc8(category,subCategory,data[1],data[2]);
   1.392 +				BTraceContextPc8(category,subCategory,data[1],data[2]);
   1.393 +				}
   1.394 +			else
   1.395 +				{
   1.396 +				BTraceContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.397 +				BTraceContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.398 +				}
   1.399 +			}
   1.400 +		else
   1.401 +			{
   1.402 +			if(bigTrace)
   1.403 +				BTraceBig(category,subCategory,data[1],data+2,size-4);
   1.404 +			else if(size==0)
   1.405 +				BTrace0(category,subCategory);
   1.406 +			else if(size<=4)
   1.407 +				BTrace4(category,subCategory,data[1]);
   1.408 +			else if(size<8)
   1.409 +				BTrace8(category,subCategory,data[1],data[2]);
   1.410 +			else
   1.411 +				BTraceN(category,subCategory,data[1],data[2],data+3,size-8);
   1.412 +			}
   1.413 +		}
   1.414 +	else
   1.415 +		{
   1.416 +		if(type==BTrace::EPcPresent)
   1.417 +			{
   1.418 +			if(bigTrace)
   1.419 +				{
   1.420 +				BTraceFilteredPcBig(category,subCategory,data[1],data+2,size-4);
   1.421 +				BTraceFilteredPcBig(category,subCategory,data[1],data+2,size-4);
   1.422 +				}
   1.423 +			else if(size<4)
   1.424 +				{
   1.425 +				// invalid
   1.426 +				}
   1.427 +			else if(size==4)
   1.428 +				{
   1.429 +				BTraceFilteredPc4(category,subCategory,data[1]);
   1.430 +				BTraceFilteredPc4(category,subCategory,data[1]);
   1.431 +				}
   1.432 +			else if(size<=8)
   1.433 +				{
   1.434 +				BTraceFilteredPc8(category,subCategory,data[1],data[2]);
   1.435 +				BTraceFilteredPc8(category,subCategory,data[1],data[2]);
   1.436 +				}
   1.437 +			else
   1.438 +				{
   1.439 +				BTraceFilteredPcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.440 +				BTraceFilteredPcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.441 +				}
   1.442 +			}
   1.443 +		else if(type==BTrace::EContextIdPresent)
   1.444 +			{
   1.445 +			if(bigTrace)
   1.446 +				{
   1.447 +				BTraceFilteredContextBig(category,subCategory,data[1],data+2,size-4);
   1.448 +				BTraceFilteredContextBig(category,subCategory,data[1],data+2,size-4);
   1.449 +				}
   1.450 +			else if(size<4)
   1.451 +				{
   1.452 +				// invalid
   1.453 +				}
   1.454 +			else if(size==4)
   1.455 +				{
   1.456 +				BTraceFilteredContext4(category,subCategory,data[1]);
   1.457 +				BTraceFilteredContext4(category,subCategory,data[1]);
   1.458 +				}
   1.459 +			else if(size<=8)
   1.460 +				{
   1.461 +				BTraceFilteredContext8(category,subCategory,data[1],data[2]);
   1.462 +				BTraceFilteredContext8(category,subCategory,data[1],data[2]);
   1.463 +				}
   1.464 +			else
   1.465 +				{
   1.466 +				BTraceFilteredContextN(category,subCategory,data[1],data[2],data+3,size-8);
   1.467 +				BTraceFilteredContextN(category,subCategory,data[1],data[2],data+3,size-8);
   1.468 +				}
   1.469 +			}
   1.470 +		else if(type==BTrace::EContextIdPresent+BTrace::EPcPresent)
   1.471 +			{
   1.472 +			if(bigTrace)
   1.473 +				{
   1.474 +				BTraceFilteredContextPcBig(category,subCategory,data[1],data+2,size-4);
   1.475 +				BTraceFilteredContextPcBig(category,subCategory,data[1],data+2,size-4);
   1.476 +				}
   1.477 +			else if(size<4)
   1.478 +				{
   1.479 +				// invalid
   1.480 +				}
   1.481 +			else if(size==4)
   1.482 +				{
   1.483 +				BTraceFilteredContextPc4(category,subCategory,data[1]);
   1.484 +				BTraceFilteredContextPc4(category,subCategory,data[1]);
   1.485 +				}
   1.486 +			else if(size<=8)
   1.487 +				{
   1.488 +				BTraceFilteredContextPc8(category,subCategory,data[1],data[2]);
   1.489 +				BTraceFilteredContextPc8(category,subCategory,data[1],data[2]);
   1.490 +				}
   1.491 +			else
   1.492 +				{
   1.493 +				BTraceFilteredContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.494 +				BTraceFilteredContextPcN(category,subCategory,data[1],data[2],data+3,size-8);
   1.495 +				}
   1.496 +			}
   1.497 +		else
   1.498 +			{
   1.499 +			if(bigTrace)
   1.500 +				BTraceFilteredBig(category,subCategory,data[1],data+2,size-4);
   1.501 +			else if(size<4)
   1.502 +				{
   1.503 +				// invalid
   1.504 +				}
   1.505 +			else if(size==4)
   1.506 +				BTraceFiltered4(category,subCategory,data[1]);
   1.507 +			else if(size<8)
   1.508 +				BTraceFiltered8(category,subCategory,data[1],data[2]);
   1.509 +			else
   1.510 +				BTraceFilteredN(category,subCategory,data[1],data[2],data+3,size-8);
   1.511 +			}
   1.512 +		}
   1.513 +	__e32_atomic_store_rel32(&aSelf->iTimerExpired, 1);
   1.514 +	}
   1.515 +
   1.516 +void DBTraceTestChannel::TestUTrace(DBTraceTestChannel* aSelf)
   1.517 +	{
   1.518 +	aSelf->iTimerExpired = ETrue;
   1.519 +	TInt size = aSelf->iTestDataSize;
   1.520 +	if(size<0)
   1.521 +		return;
   1.522 +	TUint32* data = aSelf->iTestData;
   1.523 +	BTrace::TCategory category = (BTrace::TCategory)((TUint8*)data)[0];
   1.524 +	TUint subCategory = (BTrace::TCategory)((TUint8*)data)[1];
   1.525 +
   1.526 +	#define T_UTRACE_HEADER(aSize,aClassification,aContext,aPc)																\
   1.527 +		((((aSize) + (aContext?4:0) + (aPc?4:0)) << BTrace::ESizeIndex*8)										\
   1.528 +		+(((aContext?BTrace::EContextIdPresent:0) | (aPc?BTrace::EPcPresent:0)) << BTrace::EFlagsIndex*8)			\
   1.529 +		+((aClassification) << BTrace::ECategoryIndex*8)																				\
   1.530 +		+((subCategory) << BTrace::ESubCategoryIndex*8))
   1.531 +
   1.532 +	#define UTRACE_SECONDARY(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId)	\
   1.533 +		BTrace::OutFilteredPcFormatBig(T_UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,0,0)
   1.534 +
   1.535 +	#define UTRACE_SECONDARY_4(aClassification,aModuleUid,aThreadIdPresent,aPcPresent,aPc,aFormatId, aData1) \
   1.536 +		BTrace::OutFilteredPcFormatBig(T_UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,&aData1,4)
   1.537 +
   1.538 +	#define UTRACE_SECONDARY_ANY(aClassification, aModuleUid, aThreadIdPresent, aPcPresent, aPc, aFormatId, aData, aDataSize) \
   1.539 +		BTrace::OutFilteredPcFormatBig(T_UTRACE_HEADER(8,aClassification,aThreadIdPresent,aPcPresent),(TUint32)(aModuleUid),aPc,aFormatId,aData,(TInt)(aDataSize))
   1.540 +
   1.541 +
   1.542 +	TUint32 KUtracePcValues[3]={0, 0x123456, 0x987654};
   1.543 +	TUint16 formatId = (TUint16)data[2];
   1.544 +	TUint type = aSelf->iTestType&0xff;
   1.545 +	if(type == BTrace::EPcPresent)
   1.546 +		{
   1.547 +		if(size <= 0)
   1.548 +			{
   1.549 +			UTRACE_SECONDARY(category, data[1], EFalse, ETrue, KUtracePcValues[1], formatId);
   1.550 +			UTRACE_SECONDARY(category, data[1], EFalse, ETrue, KUtracePcValues[2], formatId);
   1.551 +			}
   1.552 +		else if(size <= 4)
   1.553 +			{
   1.554 +			UTRACE_SECONDARY_4(category, data[1], EFalse, ETrue, KUtracePcValues[1], formatId, data[3]);
   1.555 +			UTRACE_SECONDARY_4(category, data[1], EFalse, ETrue, KUtracePcValues[2], formatId, data[3]);
   1.556 +			}
   1.557 +		else //size > 8
   1.558 +			{
   1.559 +			UTRACE_SECONDARY_ANY(category, data[1], EFalse, ETrue, KUtracePcValues[1], formatId, data+3, size);
   1.560 +			UTRACE_SECONDARY_ANY(category, data[1], EFalse, ETrue, KUtracePcValues[2], formatId, data+3, size);
   1.561 +			}
   1.562 +		}
   1.563 +	else if(type==BTrace::EContextIdPresent)
   1.564 +		{
   1.565 +		if(size <= 0)
   1.566 +			{
   1.567 +			UTRACE_SECONDARY(category, data[1], ETrue, EFalse, KUtracePcValues[1], formatId);
   1.568 +			UTRACE_SECONDARY(category, data[1], ETrue, EFalse, KUtracePcValues[2], formatId);
   1.569 +			}
   1.570 +		else if(size <= 4)
   1.571 +			{
   1.572 +			UTRACE_SECONDARY_4(category, data[1], ETrue, EFalse, KUtracePcValues[1], formatId, data[3]);
   1.573 +			UTRACE_SECONDARY_4(category, data[1], ETrue, EFalse, KUtracePcValues[2], formatId, data[3]);
   1.574 +			}
   1.575 +		else //size > 8
   1.576 +			{
   1.577 +			UTRACE_SECONDARY_ANY(category, data[1], ETrue, EFalse, KUtracePcValues[1], formatId, data+3, size);
   1.578 +			UTRACE_SECONDARY_ANY(category, data[1], ETrue, EFalse, KUtracePcValues[2], formatId, data+3, size);
   1.579 +			}
   1.580 +		}
   1.581 +	else if(type==BTrace::EContextIdPresent+BTrace::EPcPresent)
   1.582 +		{
   1.583 +		if(size <= 0)
   1.584 +			{
   1.585 +			UTRACE_SECONDARY(category, data[1], ETrue, ETrue, KUtracePcValues[1], formatId);
   1.586 +			UTRACE_SECONDARY(category, data[1], ETrue, ETrue, KUtracePcValues[2], formatId);
   1.587 +			}
   1.588 +		else if(size <= 4)
   1.589 +			{
   1.590 +			UTRACE_SECONDARY_4(category, data[1], ETrue, ETrue, KUtracePcValues[1], formatId, data[3]);
   1.591 +			UTRACE_SECONDARY_4(category, data[1], ETrue, ETrue, KUtracePcValues[2], formatId, data[3]);
   1.592 +			}
   1.593 +		else //size > 8
   1.594 +			{
   1.595 +			UTRACE_SECONDARY_ANY(category, data[1], ETrue, ETrue, KUtracePcValues[1], formatId, data+3, size);
   1.596 +			UTRACE_SECONDARY_ANY(category, data[1], ETrue, ETrue, KUtracePcValues[2], formatId, data+3, size);
   1.597 +			}
   1.598 +		}
   1.599 +	else
   1.600 +		{
   1.601 +		if(size <= 0)
   1.602 +			{
   1.603 +			UTRACE_SECONDARY(category, data[1], EFalse, EFalse, KUtracePcValues[1], formatId);
   1.604 +			UTRACE_SECONDARY(category, data[1], EFalse, EFalse, KUtracePcValues[2], formatId);
   1.605 +			}
   1.606 +		else if(size <= 4)
   1.607 +			{
   1.608 +			UTRACE_SECONDARY_4(category, data[1], EFalse, EFalse, KUtracePcValues[1], formatId, data[3]);
   1.609 +			UTRACE_SECONDARY_4(category, data[1], EFalse, EFalse, KUtracePcValues[2], formatId, data[3]);
   1.610 +			}
   1.611 +		else //size > 8
   1.612 +			{
   1.613 +			UTRACE_SECONDARY_ANY(category, data[1], EFalse, EFalse, KUtracePcValues[1], formatId, data+3, size);
   1.614 +			UTRACE_SECONDARY_ANY(category, data[1], EFalse, EFalse, KUtracePcValues[2], formatId, data+3, size);
   1.615 +			}
   1.616 +		}
   1.617 +
   1.618 +	}
   1.619 +
   1.620 +DECLARE_STANDARD_LDD()
   1.621 +	{
   1.622 +	return new DBTraceTestFactory;
   1.623 +	}
   1.624 +
   1.625 +