libraries/extrabtrace/src/extrabtracek.cpp
changeset 22 30834c0f3179
parent 0 7f656887cf89
equal deleted inserted replaced
21:7b569e2061c7 22:30834c0f3179
    12 
    12 
    13 #include <fshell/extrabtracek.h>
    13 #include <fshell/extrabtracek.h>
    14 #include <kern_priv.h>
    14 #include <kern_priv.h>
    15 
    15 
    16 #include "common.h"
    16 #include "common.h"
       
    17 #ifndef __SMP__
    17 #include "sampler.h"
    18 #include "sampler.h"
       
    19 #endif
    18 #include "eventhandler.h"
    20 #include "eventhandler.h"
    19 
    21 
    20 class DExtraBTraceChannel : public DLogicalChannelBase
    22 class DExtraBTraceChannel : public DLogicalChannelBase
    21 	{
    23 	{
    22 public:
    24 public:
    36 	TInt err = SetName(&KLogicalDeviceName);
    38 	TInt err = SetName(&KLogicalDeviceName);
    37 	if (err) return err;
    39 	if (err) return err;
    38 	err = Open();
    40 	err = Open();
    39 	if (err) return err;
    41 	if (err) return err;
    40 
    42 
       
    43 #ifndef __SMP__
    41 	iSampler = new DCpuSampler();
    44 	iSampler = new DCpuSampler();
    42 	if (!iSampler) err = KErrNoMemory;
    45 	if (!iSampler) err = KErrNoMemory;
       
    46 #endif
    43 
    47 
    44 	if (!err) iEventHandler = new DExtraBtraceEventHandler(this);
    48 	if (!err) iEventHandler = new DExtraBtraceEventHandler(this);
    45 	if (!iEventHandler) err = KErrNoMemory;
    49 	if (!iEventHandler) err = KErrNoMemory;
    46 
    50 
    47 	if (err)
    51 	if (err)
    70 	return KErrNone;
    74 	return KErrNone;
    71 	}
    75 	}
    72 
    76 
    73 DExtraBTraceFactory::~DExtraBTraceFactory()
    77 DExtraBTraceFactory::~DExtraBTraceFactory()
    74 	{
    78 	{
       
    79 #ifndef __SMP__
    75 	delete iSampler;
    80 	delete iSampler;
       
    81 #endif
    76 	delete iEventHandler;
    82 	delete iEventHandler;
    77 	}
    83 	}
    78 
    84 
    79 void DExtraBTraceFactory::SetCpuUsageSampling(MExtraBtrace::TCpuUsageCallback aCallbackFn)
    85 void DExtraBTraceFactory::SetCpuUsageSampling(MExtraBtrace::TCpuUsageCallback aCallbackFn)
    80 	{
    86 	{
       
    87 #ifndef __SMP__
    81 	iSampler->SetCpuUsageSampling(aCallbackFn);
    88 	iSampler->SetCpuUsageSampling(aCallbackFn);
       
    89 #endif
    82 	}
    90 	}
    83 
    91 
    84 void DExtraBTraceFactory::SetProfilingSampling(TBool aEnabled)
    92 void DExtraBTraceFactory::SetProfilingSampling(TBool aEnabled)
    85 	{
    93 	{
       
    94 #ifndef __SMP__
    86 	iSampler->SetProfilingSampling(aEnabled);
    95 	iSampler->SetProfilingSampling(aEnabled);
       
    96 #endif
    87 	}
    97 	}
    88 
    98 
    89 TAny* DExtraBTraceFactory::GetVersion(TInt /*aVersion*/)
    99 TAny* DExtraBTraceFactory::GetVersion(TInt /*aVersion*/)
    90 	{
   100 	{
    91 	return NULL; // We don't have any versions yet - this is like CBase::_Extension, just in case
   101 	return NULL; // We don't have any versions yet - this is like CBase::_Extension, just in case
   109 TInt DExtraBTraceChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
   119 TInt DExtraBTraceChannel::DoCreate(TInt /*aUnit*/, const TDesC8* /*aInfo*/, const TVersion& /*aVer*/)
   110 	{
   120 	{
   111 	return KErrNone;
   121 	return KErrNone;
   112 	}
   122 	}
   113 
   123 
       
   124 #ifndef __SMP__
   114 DCpuSampler* DExtraBTraceChannel::Sampler()
   125 DCpuSampler* DExtraBTraceChannel::Sampler()
   115 	{
   126 	{
   116 	return static_cast<DExtraBTraceFactory*>(iDevice)->iSampler;
   127 	return static_cast<DExtraBTraceFactory*>(iDevice)->iSampler;
   117 	}
   128 	}
       
   129 #endif
   118 
   130 
   119 TInt DExtraBTraceChannel::RequestUserHandle(DThread* /*aThread*/, TOwnerType /*aType*/)
   131 TInt DExtraBTraceChannel::RequestUserHandle(DThread* /*aThread*/, TOwnerType /*aType*/)
   120 	{
   132 	{
   121 	//if (aType!=EOwnerThread || aThread!=iClient)
   133 	//if (aType!=EOwnerThread || aThread!=iClient)
   122 	//	return KErrAccessDenied;
   134 	//	return KErrAccessDenied;
   127 	{
   139 	{
   128 	switch (aReqNo)
   140 	switch (aReqNo)
   129 		{
   141 		{
   130 	case EControlEnableProfiling:
   142 	case EControlEnableProfiling:
   131 		{
   143 		{
       
   144 #ifdef __SMP__
       
   145 		return KErrNotSupported;
       
   146 #else
   132 		TInt enable = (a1 == 0) ? 0 : 1; // We still ignore the rate, currently
   147 		TInt enable = (a1 == 0) ? 0 : 1; // We still ignore the rate, currently
   133 		TInt err = BTrace::SetFilter(BTrace::EProfiling, enable);
   148 		TInt err = BTrace::SetFilter(BTrace::EProfiling, enable);
   134 		if (err >= 0)
   149 		if (err >= 0)
   135 			{
   150 			{
   136 			Sampler()->SetProfilingSampling(enable);
   151 			Sampler()->SetProfilingSampling(enable);
   137 			}
   152 			}
   138 		return err;
   153 		return err;
       
   154 #endif
   139 		}
   155 		}
   140 	default:
   156 	default:
   141 		return KErrNotSupported;
   157 		return KErrNotSupported;
   142 		}
   158 		}
   143 	}
   159 	}