// ---------------------------------------------------------------------------- // CSamplerPluginLoader::LoadRlibraryL // ---------------------------------------------------------------------------- // void CSamplerPluginLoader::LoadRlibraryL(CArrayPtrFlat<CSamplerPluginInterface>* aPluginArray) { LOGSTRING("CSamplerPluginLoader rlibrary loading"); // Load dll iPluginArray = aPluginArray; RLibrary aLib; TInt ret = aLib.Load(_L("PIProfilerGenerals.dll"),_L("c:\\sys\\bin")); LOGSTRING2("RLibrary load returns %d", ret); User::LeaveIfError(ret); const TInt KNewLOrdinal = 2; TLibraryFunction NewL =aLib.Lookup(KNewLOrdinal); if(!NewL) { RDebug::Printf("library.lookup returns null"); } else { LOGSTRING2("library.lookup returns 0x%x", NewL); //CGeneralsPlugin* mydll=(CGeneralsPlugin*)NewL(); CSamplerPluginInterface* mydll=(CSamplerPluginInterface*)NewL(); //Generals plugin loaded, samplers enabled. CleanupStack::PushL( mydll ); //InsertPluginInOrderL( mydll, aPluginArray); CleanupStack::Pop(mydll); // call engine to finalize the startup //TRAPD(result, iObserver->HandleSamplerControllerReadyL();); NotifyProgress(); //Begin CActive asynchronous loop. CompleteOwnRequest(); } LOGSTRING("RLibrary and plugins loaded"); }
// -------------------------------------------------------------------------- // CNSmlDmAOAdapter::FetchLeafObjectSizeL // Fetches leaf object size. // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::FetchLeafObjectSizeL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& /* aType */, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: Start" ); LOGSTRING3( "\tFetchLeafObjectSizeL \tURI: %S, \tLUID: %S,", &aURI, &aLUID ); CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( ETrue, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetSizeCmd, LastURISeg( aURI ), KNullDesC8); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); // if executed get status if ( cmd->Executed() ) { Callback().SetStatusL( aStatusRef, cmd->Status() ); // if successful get results if ( cmd->Status() == CSmlDmAdapter::EOk ) { LOGSTRING2( "\tCmd executed with result: %S ", cmd->Data() ); CBufBase* result = CBufFlat::NewL( cmd->Data()->Size() ); CleanupStack::PushL( result ); result->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *result, KNullDesC8 ); CleanupStack::PopAndDestroy( result ); } } else { // failed to execute command Callback().SetStatusL( aStatusRef, CSmlDmAdapter::EError ); } CleanupStack::PopAndDestroy( cmd ); LOGSTRING( "CNSmlDmAOAdapter::FetchLeafObjectSizeL: End" ); }
void CProfilerPowerListener::LightStatusChanged(TInt aTarget, CHWRMLight::TLightStatus aStatus) { LOGTEXT(_L("CProfilerPowerListener::LightStatusChanged - entry")); LOGSTRING3("CProfilerPowerListener::LightStatusChanged - Target: %d Status: %d", aTarget, aStatus); if (aTarget == CHWRMLight::EPrimaryDisplay) { LOGSTRING2("CProfilerPowerListener::LightStatusChanged - Previous light status: %d", iBackLightStatus); iBackLightStatus = aStatus; LOGSTRING2("CProfilerPowerListener::LightStatusChanged - New light status: %d", iBackLightStatus); this->Sample(); } LOGTEXT(_L("CProfilerPowerListener::LightStatusChanged - exit")); }
inline TInt DMemSamplerImpl::EncodeChunkData(DLibrary& l) { LOGTEXT("MemSamplerImpl::EncodeChunkData (Library) - entry"); // the size of the following name is in the first byte TUint8* size = &sample[0]; *size = 0; this->sampleDescriptor.Zero(); TUint32 address((TUint32)&l); this->sampleDescriptor.Append((TUint8*)&address,sizeof(TUint32)); *size += sizeof(TUint); this->sampleDescriptor.Append((TUint8*)&(l.iCodeSeg->iSize),sizeof(TUint32)); *size += sizeof(TInt); this->sampleDescriptor.Append((TUint8*)&(l.iMapCount),sizeof(TInt)); *size += sizeof(TInt); TInt zero(0); this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); *size += sizeof(TInt); this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); *size += sizeof(TInt); LOGSTRING2("LData - %d",*size); return ((TInt)(*size))+1; }
// ---------------------------------------------------------------------------- // CWriterPluginLoader::LoadSyncL // // // ---------------------------------------------------------------------------- // CWriterPluginInterface& CWriterPluginLoader::LoadSyncL( TUid aImplementationUid ) { Cancel(); CWriterPluginInterface* plugin = NULL; // Get a list of all implementations, even though we only want one specific // one. There appears to be no way to otherwise extract a specific implementation // info object :( // Search for the implementation that matches aImplementationUid const TInt impCount = iImplInfoArray.Count(); for( TInt i=0; i<impCount; i++ ) { const CImplementationInformation* info = iImplInfoArray[ i ]; if ( info->ImplementationUid() == aImplementationUid ) { TRAPD(ret, plugin = &CreatePluginInstanceL( *info ); ); if( ret == KErrNone ) { // Plugin ownership is transfered to iPluginArray InsertPluginInOrderL( plugin, iPluginArray ); } else { // Error note is displayed even if plugin is not loaded LOGSTRING2("CWriterPluginLoader::LoadSyncL() - plugin load failed, error %d", ret); } break; }
inline TInt DMemSamplerImpl::EncodeChunkData(DChunk& c) { // the size of the following name is in the first byte TUint8* size = &sample[0]; *size = 0; this->sampleDescriptor.Zero(); TInt zero(0); TUint32 address((TUint32)&c); this->sampleDescriptor.Append((TUint8*)&address,sizeof(TUint32)); *size += sizeof(TUint); // copy the total amount of memory allocated this->sampleDescriptor.Append((TUint8*)&(c.iSize),sizeof(TInt)); *size += sizeof(TInt); // append the cell amount allocated this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); *size += sizeof(TInt); // append the chunk size this->sampleDescriptor.Append((TUint8*)&(c.iSize),sizeof(TUint)); *size += sizeof(TUint); // append the thread user stack size this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TInt)); *size += sizeof(TInt); LOGSTRING2("Data - %d",*size); return ((TInt)(*size))+1; }
inline TInt DMemSamplerImpl::EncodeChunkData(DThread& t) { LOGTEXT("MemSamplerImpl::EncodeChunkData - entry"); //LOGSTRING2("MemSamplerImpl::EncodeChunkData - processing thread 0x%x ",&t); // the size of the following name is in the first byte TUint8* size = &sample[0]; *size = 0; this->sampleDescriptor.Zero(); LOGTEXT("MemSamplerImpl::EncodeChunkData - cleared"); this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); *size += sizeof(TUint); // copy the total amount of memory allocated for user side stack this->sampleDescriptor.Append((TUint8*)&(t.iUserStackSize),sizeof(TInt)); *size += sizeof(TInt); TInt zero(0); // append the cell amount allocated (zero, not in use here) this->sampleDescriptor.Append((TUint8*)&zero,sizeof(TInt)); *size += sizeof(TInt); // append the chunk size (this is not a chunk) this->sampleDescriptor.Append((TUint8*)&(zero),sizeof(TUint)); *size += sizeof(TUint); // append user stack (max) size this->sampleDescriptor.Append((TUint8*)&(t.iUserStackSize),sizeof(TInt)); *size += sizeof(TInt); LOGSTRING2("Data -> %d",*size); return ((TInt)(*size))+1; }
TInt DIttEventHandler::Stop() { LOGSTRING("DIttEventHandler::Stop()"); iTracking = EFalse; LOGSTRING2("ITT - gpp sample counter %d", this->gppSamplerData->sampleNumber); return KErrNone; }
TInt CProfilerPowerListener::Stop() { LOGTEXT(_L("CProfilerPowerListener::Stop() - entry")); if (iPowerAPI) { TRAPD(err, iPowerAPI->StopAveragePowerReportingL()); if(err != KErrNone) { LOGSTRING2("CProfilerPowerListener::Stop() - Failed to stop power reporting: %d", err); } else { LOGTEXT(_L("CProfilerPowerListener::Stop() - Stopped power monitoring")); } delete iPowerAPI; iPowerAPI = 0; // Restore original value to max sampling period CRepository* centRep = 0; TRAP(err, centRep = CRepository::NewL(KCRUidPowerSettings)); if (err != KErrNone) { LOGSTRING2("CProfilerPowerListener::Stop() - Failed to open Central Repository: %d", err); } else { err = centRep->Set(KPowerMaxReportingPeriod, iOriginalReportingPeriod); if(err != KErrNone) { LOGSTRING2("CProfilerPowerListener::Stop() - Failed to restore max sampling period: %d", err); } } } #ifdef PWR_SAMPLER_BACKLIGHT if (iLightAPI) { delete iLightAPI; iLightAPI = 0; } #endif LOGTEXT(_L("CProfilerPowerListener::Stop() - exit")); return KErrNone; }
inline TInt DMemSamplerImpl::GatherThreads() { // The thread memory consumption NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex DObjectCon& threads = *Kern::Containers()[EThread]; threads.Wait(); // Obtain the container mutex so the list does get changed under us this->iThreadCount = 0; this->iNewThreadCount = 0; this->iTotalMemoryOk = false; TInt totalThreadCount = threads.Count(); for(TInt i(0);i<totalThreadCount;i++) { DThread* t = (DThread*)(threads)[i]; LOGSTRING3("Processing thread %d, tag: 0x%x",i,TAG(t)); if( (TAG(t) & PROFILER_MEM_THREAD_MARK) == 0) { LOGSTRING4("Marking thread %d/%d, old tag 0x%x",i,(totalThreadCount-1), TAG(t)); // this thread's chunk has not been reported yet this->threadNamesToReport[iNewThreadCount] = t; iNewThreadCount++; // tag the thread TAG(t) |= PROFILER_MEM_THREAD_MARK; } // the chunk has been tagged, add heap chunks to the list this->threadsToSample[this->iThreadCount] = t; this->iThreadCount++; LOGSTRING2("Added thread %d to threads to sample",i); } if(this->iThreadCount > 0 || this->iNewThreadCount > 0) { this->iThreadsProcessing = EStartingToProcess; // process the first sample TInt length = this->ProcessThreads(); if(length == 0) { this->iThreadsProcessing = ENothingToProcess; } threads.Signal(); // Release the container mutex NKern::ThreadLeaveCS(); // End of critical section return length; } LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); threads.Signal(); // Release the container mutex NKern::ThreadLeaveCS(); // End of critical section return 0; }
TInt CPwrPlugin::ResetAndActivateL(CProfilerSampleStream& aStream) { LOGTEXT(_L("CPwrPlugin::ResetAndActivate() - entry")); // check if sampler enabled if(iSamplerAttributes->At(0).iEnabled) { // create a new listener instance for every trace, destroy it on stop iPowerListener = CProfilerPowerListener::NewL(this); iStream = &aStream; TInt length = this->CreateFirstSample(); iVersion[0] = (TUint8)length; LOGSTRING2("CPwrPlugin::ResetAndActivate() - AddSample, length %d", length); TInt ret = this->AddSample(iVersion, length+1, 0); LOGSTRING2("CPwrPlugin::ConstructL() - sampling period %d", this->iPeriod); HBufC8* iBufRes = HBufC8::NewMaxLC(10); TPtr8 iPtrRes = iBufRes->Des(); // check if sampling rate set to something reasonable, relevant only in SYNC case if(iSamplerAttributes->At(0).iSampleRate != -1) { iPtrRes.Num(iSamplerAttributes->At(0).iSampleRate); } else { iPtrRes.Append(KNullDesC8); } // set disabled SetEnabled(ETrue); // activate power listener ret = iPowerListener->StartL(iPtrRes); LOGTEXT(_L("CPwrPlugin::ResetAndActivate() - exit")); CleanupStack::PopAndDestroy(); if(ret != KErrNone) return ret; } return KErrNone; }
EXPORT_C void CEventLogger::LogCallStart(const TDesC& aRemote,TInt aLogDir,const TDesC& aTelNum,TUid aDataEventType, TRequestStatus& aStatus) /** DEPRECATED, use LogDataAddEvent instead */ { LOGSTRING2("GenConn:\tCEventLogger LogCallStart aRemote:%S", &aRemote); LogDataAddEvent(R_LOG_CON_CONNECTED, aRemote, aLogDir, aTelNum, aDataEventType); // we could complete the TRequestStatus right now. We go safer way and let istatus complete when logg evnt has been added LogDataNotifyLastEventUpdate(&aStatus); }
inline TInt DMemSamplerImpl::ProcessLibraries() { LOGTEXT("ProcessLibraries - entry"); if(iNewLibraryCount > 0) { if(this->iLibrariesProcessing == EStartingToProcess) { // this is the first sample, encode a code for names this->iLibrariesProcessing = EProcessingNames; return EncodeNameCode(); } if(iTotalMemoryNameOk == false) { return EncodeTotalMemoryName(); } // there are new library names to report iNewLibraryCount--; DLibrary* l = this->libraryNamesToReport[iNewLibraryCount]; return EncodeChunkName(*l); } else if(iLibraryCount > 0) { if(this->iLibrariesProcessing == EProcessingNames || this->iLibrariesProcessing == EStartingToProcess) { // this is the first data sample, encode a code for data this->iLibrariesProcessing = EProcessingData; return EncodeDataCode(); } if(this->iTotalMemoryOk == false) { return EncodeTotalMemory(); } // there are no new libraries to report // thus generate the real report iLibraryCount--; DLibrary* l = this->librariesToSample[iLibraryCount]; return EncodeChunkData(*l); } else { // everything is processed LOGSTRING2(" Libraries processed! Library count = %d", iLibraryCount); this->iLibrariesGathered = true; Kern::Printf("MemSamplerImpl::ProcessLibraries() - libraries gathered! Time: %d",iCount); return 0; } }
inline TInt DMemSamplerImpl::ProcessChunks() { if(iNewChunkCount > 0) { if(this->iChunksProcessing == EStartingToProcess) { // this is the first sample, encode a code for names this->iChunksProcessing = EProcessingNames; return EncodeNameCode(); } if(iTotalMemoryNameOk == false) { return EncodeTotalMemoryName(); } // there are new chunk names to report iNewChunkCount--; DChunk* c = this->heapChunkNamesToReport[iNewChunkCount]; return EncodeChunkName(*c); } else if(iChunkCount > 0) { if(this->iChunksProcessing == EProcessingNames || this->iChunksProcessing == EStartingToProcess) { // this is the first data sample, encode a code for data this->iChunksProcessing = EProcessingData; return EncodeDataCode(); } if(this->iTotalMemoryOk == false) { return EncodeTotalMemory(); } // there are no new chunks to report // thus generate the real report iChunkCount--; DChunk* c = this->heapChunksToSample[iChunkCount]; return EncodeChunkData(*c); } else { // everything is processed LOGSTRING2(" Chunks processed! Chunk count = %d", iChunkCount); #ifdef MEM_EVENT_HANDLER this->iChunksGathered = true; Kern::Printf("MemSamplerImpl::ProcessChunks() - chunks gathered! Time: %d",iCount); #endif return 0; } }
// ------------------------------------------------------------------------ // CNSmlDmAOAdapter::ChildURIListL // Fetches child nodes of a node. these may be either all VENDORCONFIG // nodes or leaf nodes under a VENDORCONFIG node. // ------------------------------------------------------------------------ void CNSmlDmAOAdapter::ChildURIListL( const TDesC8& aURI, const TDesC8& aLUID, const CArrayFix<TSmlDmMappingInfo>& /*aPreviousURISegmentList*/, TInt aResultsRef, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: Start" ); LOGSTRING3( "\tChildURIListL URI: %S, LUID: %S ", &aURI, &aLUID ); CBufBase* resultList = CBufFlat::NewL( KSmlMaxURISegLen ); CleanupStack::PushL( resultList ); // get all leaf nodes below VENDORCONFIG node if ( !aURI.Compare( KNSmlDmAOAdapterAO ) ) { CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( EFalse, aStatusRef, aResultsRef, CNSmlDmAOAdapter::EGetCmd, KNullDesC8, KNullDesC8 ); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d ", cmd->Status() ); Callback().SetStatusL( aStatusRef, cmd->Status() ); if( cmd->Status() == CSmlDmAdapter::EOk ) { resultList->InsertL( 0, *cmd->Data() ); Callback().SetResultsL( aResultsRef, *resultList, KNullDesC8 ); } CleanupStack::PopAndDestroy( cmd ); } CleanupStack::PopAndDestroy( resultList ); LOGSTRING( "CNSmlDmAOAdapter::ChildURIListL: End" ); }
void CProfilerPowerListener::Sample() { LOGTEXT(_L("CProfilerPowerListener::Sample() - entry")); TRequestStatus status; CHWRMPower::TBatteryConsumptionData consumptionData; iPowerAPI->GetBatteryInfo(status, consumptionData); User::WaitForRequest(status); // Data is valid only if status == KErrNone if (status.Int() != KErrNone) { LOGSTRING2("CProfilerPowerListener::Sample() - Getting battery info failed with code: ", status.Int()); iNominalCapa = 0; } else { iNominalCapa = consumptionData.iNominalCapacity; } // Space for GPP sample time //TUint32 sampleTime = iSampler->iStream->iSampler->GetSampleTime(); TUint32 sampleTime = User::NTickCount() - iSampleStartTime; LOGSTRING2("CProfilerPowerListener::Sample() - Sample time: %d", sampleTime); LOGSTRING2("CProfilerPowerListener::Sample() - Nominal capacitance: %d", iNominalCapa); LOGSTRING2("CProfilerPowerListener::Sample() - Voltage: %d", iVoltage); LOGSTRING2("CProfilerPowerListener::Sample() - Current: %d", iCurrent); #ifdef PWR_SAMPLER_BACKLIGHT LOGSTRING2("CProfilerPowerListener::Sample() - Backlight status: %d", (TUint8)iBackLightStatus); #endif iSample[0] = iNominalCapa; iSample[1] = iNominalCapa >> 8; iSample[2] = iVoltage; iSample[3] = iVoltage >> 8; iSample[4] = iCurrent; iSample[5] = iCurrent >> 8; iSample[6] = iCurrent >> 16; iSample[7] = iCurrent >> 24; #ifdef PWR_SAMPLER_BACKLIGHT iSample[8] = (TUint8)iBackLightStatus; iSample[9] = sampleTime; iSample[10] = sampleTime >> 8; iSample[11] = sampleTime >> 16; iSample[12] = sampleTime >> 24; iSampler->AddSample(iSample, 13, 0); #else iSample[8] = sampleTime; iSample[9] = sampleTime >> 8; iSample[10] = sampleTime >> 16; iSample[11] = sampleTime >> 24; iSampler->AddSample(iSample, 12, 0); #endif LOGTEXT(_L("CProfilerPowerListener::Sample() - exit")); }
inline TInt DPriSamplerImpl::EncodeChunkData(DThread& t) { LOGTEXT("PriSamplerImpl::EncodeChunkData - entry"); LOGSTRING2("PriSamplerImpl::EncodeChunkData - processing thread 0x%x ",&t); // the size of the following name is in the first byte TUint8* size = &sample[0]; *size = 0; this->sampleDescriptor.Zero(); LOGTEXT("PriSamplerImpl::EncodeChunkData - cleared"); // append the thread id this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); *size += sizeof(TUint); // NKern::LockSystem(); // TInt priority(-1); // if(&t && t.Open()== KErrNone) // { // priority = t.iDefaultPriority; // } // NKern::UnlockSystem(); // append the priority of the nanokernel fast semaphore // this->sampleDescriptor.Append((TUint8*)&priority,sizeof(TUint8)); // append the priority of the nanokernel fast semaphore this->sampleDescriptor.Append((TUint8*)&(t.iNThread.iPriority),sizeof(TUint8)); // add space because EKA-1 implementation needs it this->sampleDescriptor.Append((TUint8)0x0); *size += 2*sizeof(TUint8); LOGTEXT("PriSamplerImpl::EncodeChunkData - appended priority"); LOGSTRING2("Data size - %d",*size); return ((TInt)(*size))+1; }
// ---------------------------------------------------------------------------- // CWriterPluginLoader::LoadAsync // // // ---------------------------------------------------------------------------- // void CWriterPluginLoader::LoadAsyncL( CArrayPtrFlat<CWriterPluginInterface>* aPluginArray ) { iPluginArray = aPluginArray; // Reset iterator: iImplInfoArrayIterator = 0; LOGSTRING2( "CWriterPluginLoader()::Implementation info count: %d", iImplInfoArray.Count() ); NotifyProgress(); //Begin CActive asynchronous loop. CompleteOwnRequest(); }
inline TInt DPriSamplerImpl::EncodeChunkName(DThread& t) { // the size of the following name is in the first byte TUint8* size = &sample[0]; *size = 0; this->sampleDescriptor.Zero(); t.TraceAppendFullName(this->sampleDescriptor,false); *size += this->sampleDescriptor.Size(); // copy the 4 bytes from the thread id field this->sampleDescriptor.Append((TUint8*)&(t.iId),sizeof(TUint)); *size += sizeof(TUint); // the size is the descriptor length + the size field LOGSTRING2("Name size - %d",*size); return ((TInt)(*size))+1; }
inline TInt DPriSamplerImpl::ProcessChunks() { /* * * EKA-2 implementation of PRI trace * */ if(iNewThreadCount > 0) { if(this->iProcessing == EStartingToProcess) { // this is the first sample, encode a code for names this->iProcessing = EProcessingNames; return EncodeNameCode(); } // there are new thread names to report iNewThreadCount--; DThread* t = this->threadNamesToReport[iNewThreadCount]; return EncodeChunkName(*t); } else if(iThreadCount > 0) { if(this->iProcessing == EProcessingNames || this->iProcessing == EStartingToProcess) { // this is the first data sample, encode a code for data this->iProcessing = EProcessingData; return EncodeDataCode(); } // there are no new chunks to report // thus generate the real report iThreadCount--; DThread* t = this->threadsToSample[iThreadCount]; LOGSTRING2("PriSamplerImpl::ProcessChunks - starting to process thread 0x%x",t); return EncodeChunkData(*t); } else { // everything is processed return 0; } }
void CProfilerPowerListener::PowerMeasurement(TInt aErr, CHWRMPower::TBatteryPowerMeasurementData& aMeasurement) { LOGTEXT(_L("CProfilerPowerListener::PowerMeasurement - entry")); if (aErr == KErrNone) { LOGSTRING3("CProfilerPowerListener::PowerMeasurement - Previous values - Voltage: %d Current: %d", iVoltage, iCurrent); iVoltage = aMeasurement.iAverageVoltage; iCurrent = aMeasurement.iAverageCurrent; LOGSTRING3("CProfilerPowerListener::PowerMeasurement - New values - Voltage: %d Current: %d", iVoltage, iCurrent); this->Sample(); } else { LOGSTRING2("CProfilerPowerListener::PowerMeasurement - Failed with error code: %d", aErr); DisplayNotifierL(KPowerTextLine1, KPowerTextErrorSampling, KButtonOk, KNullDesC); } LOGTEXT(_L("CProfilerPowerListener::PowerMeasurement - exit")); }
inline TInt DMemSamplerImpl::EncodeChunkName(DLibrary& l) { // the size of the following name is in the first byte TUint8* size = &sample[0]; *size = 0; // encode library name this->sampleDescriptor.Zero(); this->sampleDescriptor.Append(_L("L_")); l.TraceAppendFullName(this->sampleDescriptor,false); *size += this->sampleDescriptor.Size(); // add chunk object address here TUint32 libAddr((TUint32)&l); this->sampleDescriptor.Append((TUint8*)&(libAddr),sizeof(TUint32)); *size += sizeof(TUint32); // the size is the descriptor length + the size field LOGSTRING2("Name - %d",*size); return ((TInt)(*size))+1; }
TBool DMemSamplerImpl::SampleNeeded() { iCount++; #ifdef MEM_EVENT_HANDLER // make the collection of chunks/threads only once, rest will be collected with mem event handler #ifdef MEM_EVENT_HANDLER_LIBRARY_EVENTS if (iCount <= iMemSamplingPeriod && ((iCount % iMemSamplingPeriod) == 0 || (iCount % iMemSamplingPeriodDiv3) == 0)) #else if (iCount <= iMemSamplingPeriod && ((iCount % iMemSamplingPeriod) == 0 || (iCount % iMemSamplingPeriodDiv2) == 0)) #endif #else if ((iCount % iMemSamplingPeriod) == 0 || (iCount % iMemSamplingPeriodDiv2) == 0) #endif { LOGSTRING2("MemSamplerImpl::SampleNeeded - time: %d", iCount); iTimeToSample = true; return true; } else { return false; } }
// ------------------------------------------------------------------------- // CNSmlDmAOAdapter::UpdateLeafObjectL // Adds or updates leaf node value. // ------------------------------------------------------------------------- void CNSmlDmAOAdapter::UpdateLeafObjectL( const TDesC8& aURI, const TDesC8& aLUID, const TDesC8& aObject, const TDesC8& /*aType*/, TInt aStatusRef ) { LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: Start" ); LOGSTRING4( "\tUpdateLeafObjectL \tURI: %S, \n\tLUID: %S,\ \tobject: %S ", &aURI, &aLUID, &aObject ); // execute command and return status CSmlDmAOCommandElement* cmd = CSmlDmAOCommandElement::NewLC( ETrue, aStatusRef, KNSmlDmAOInvalidRef, CNSmlDmAOAdapter::EAddCmd, LastURISeg( aURI ), aObject); TInt luid( KDefaultLuid ); if ( aLUID.Length() > 0 ) { luid = DesToIntL( aLUID ); } iSettingStore->ExecuteCmdL( *cmd, luid ); LOGSTRING2( "\tCmd executed with status: %d", cmd->Status() ); Callback().SetStatusL( aStatusRef, cmd->Status() ); CleanupStack::PopAndDestroy( cmd ); LOGSTRING( "CNSmlDmAOAdapter::UpdateLeafObjectL: End" ); }
TInt CProfilerPowerListener::StartL(const TDesC8& aBuf) { LOGTEXT(_L("CProfilerPowerListener::StartL() - entry")); // get the property value TInt r = RProperty::Get(KGppPropertyCat, EGppPropertySyncSampleNumber, iSampleStartTime); if(r != KErrNone) { LOGSTRING2("CProfilerPowerListener::StartL() - getting iSyncOffset failed, error %d", r); } // check if given sampling period is valid if(aBuf.CompareF(KNullDesC8)!= 0) { TLex8* lex = new TLex8(aBuf); lex->Val(iPwrSamplingPeriod); delete lex; } else { // set default period iPwrSamplingPeriod = 250; } // Check that sampling period is in allowed range if (KMinSampleInterval > 0 && iPwrSamplingPeriod < KMinSampleInterval) { iPwrSamplingPeriod = KMinSampleInterval; } LOGSTRING2("CProfilerPowerListener::StartL() - Sampling period %d", iPwrSamplingPeriod); // Start monitoring voltage and current iPowerAPI = CHWRMPower::NewL(); iPowerAPI->SetPowerReportObserver(this); // Read HWRM reporting settings from central repository CRepository* centRep = CRepository::NewL(KCRUidPowerSettings); TInt baseInterval(0); User::LeaveIfError(centRep->Get(KPowerBaseTimeInterval, baseInterval)); User::LeaveIfError(centRep->Get(KPowerMaxReportingPeriod, iOriginalReportingPeriod)); LOGSTRING2("CProfilerPowerListener::StartL() - HWRM base power report interval: %d", baseInterval); LOGSTRING2("CProfilerPowerListener::StartL() - Original HWRM max power reporting period: %d", iOriginalReportingPeriod); User::LeaveIfError(centRep->Set(KPowerMaxReportingPeriod, KReportingPeriodInfinite)); // Power reporting interval reading may return too low value sometimes. Minimum value expected to be 250ms. if ( baseInterval < KMinSampleInterval ) { baseInterval = KMinSampleInterval; LOGSTRING2("CProfilerPowerListener::StartL() - Power report interval too low. Changed to: %d", baseInterval); } // Power reporting period is multiplier of HWRM base period TInt intervalMultiplier = iPwrSamplingPeriod / baseInterval; if (intervalMultiplier < 1) { intervalMultiplier = 1; } LOGSTRING2("CProfilerPowerListener::StartL() - Reporting period multiplier: %d", intervalMultiplier); TRequestStatus status(KRequestPending); iPowerAPI->StartAveragePowerReporting(status, intervalMultiplier); User::WaitForRequest(status); if (status.Int() != KErrNone) { LOGTEXT(_L("CProfilerPowerListener::StartL() - Failed to initialize power reporting")); DisplayNotifierL(KPowerTextLine1, KPowerTextLine2, KButtonOk, KNullDesC); return status.Int(); } #ifdef PWR_SAMPLER_BACKLIGHT // Start monitoring backlight status iLightAPI = CHWRMLight::NewL(this); #endif LOGTEXT(_L("CProfilerPowerListener::StartL() - exit")); return KErrNone; }
EXPORT_C void CEventLogger::LogDataAddEvent(TInt aRConnectionStatusId, const TDesC& aRemote, TInt aLogDir, const TDesC& aTelNum, TUid aDataEventType) { LOGSTRING2("GenConn:\tCEventLogger LogDataAddEvent aRConnectionStatusId:%d", aRConnectionStatusId); //It is possible to add a new logevent with a new log id for the same connection (reconnect case) // assuming that all the next updates will be for the new event and not the old one. // [NeilMa 140403]: This method cannot leave and has no return value, but // performs memory allocations if the event cannot be logged immediately. // Therefore, if the memory alloc fails for any reason, the event is // currently discarded with no record. This method should be replaced by // one which can Leave or returns an error code. See Typhoon DEF022946. TTime time; time.UniversalTime(); if (!IsActive() && (iLogEventQueue->Count() ==0)) { iCurrentLogEvent->SetId(KGenconnLogWaitingForLogId); iCurrentLogEvent->SetTime(time); TBuf<KLogMaxStatusLength > logStatusBuf; iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok iCurrentLogEvent->SetStatus(logStatusBuf); iCurrentLogEvent->SetRemoteParty(aRemote); TBuf<KLogMaxDirectionLength> logDirBuf; iLogWrap->Log().GetString(logDirBuf, aLogDir); // Ignore error - string blank on error which is ok iCurrentLogEvent->SetDirection(logDirBuf); iCurrentLogEvent->SetNumber(aTelNum); iCurrentLogEvent->SetEventType(aDataEventType); iCurrentLogEvent->SetDurationType(KLogDurationValid); iStatus=KRequestPending; iLogWrap->Log().AddEvent(*iCurrentLogEvent, iStatus); SetActive(); } else { // add the request to the queue, it will be processed asap CLogEvent* eventUpdate = 0; TRAPD(error, eventUpdate = CLogEvent::NewL()); if (KErrNone != error) { return; // event is discarded! } eventUpdate->SetId(KGenconnLogWaitingForLogId); eventUpdate->SetTime(time); TBuf<KLogMaxStatusLength > logStatusBuf; iLogWrap->Log().GetString(logStatusBuf, aRConnectionStatusId); // Ignore error - string blank on error which is ok eventUpdate->SetStatus(logStatusBuf); eventUpdate->SetRemoteParty(aRemote); TBuf<KLogMaxDirectionLength> logDirBuf; iLogWrap->Log().GetString(logDirBuf, aLogDir); // Ignore error - string blank on error which is ok eventUpdate->SetDirection(logDirBuf); eventUpdate->SetNumber(aTelNum); eventUpdate->SetEventType(aDataEventType); eventUpdate->SetDurationType(KLogDurationValid); // add to the queue TRAP(error, iLogEventQueue->AppendL(eventUpdate)); if (KErrNone != error) { delete eventUpdate; // event is discarded! return; } } }
inline TInt DMemSamplerImpl::GatherChunks() { // encode a process binary name.Zero(); NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex DObjectCon& chunks = *Kern::Containers()[EChunk]; chunks.Wait(); // Obtain the container mutex so the list does get changed under us this->iChunkCount = 0; this->iNewChunkCount = 0; this->iTotalMemoryOk = false; TInt totalChunkCount(chunks.Count()); DChunk* c; for(TInt i(0);i<totalChunkCount;i++) { c = (DChunk*)(chunks)[i]; LOGSTRING3("Processing chunk %d, tag: 0x%x",i,TAG(c)); if( (TAG(c) & 0x0000ffff) != PROFILER_CHUNK_MARK) { LOGSTRING4("Marking chunk %d/%d, old tag 0x%x",i,(totalChunkCount-1), TAG(c)); // this chunk has not been tagged yet name.Zero(); c->TraceAppendName(name,false); TAG(c) = (PROFILER_CHUNK_MARK); this->heapChunkNamesToReport[iNewChunkCount] = c; iNewChunkCount++; } // the chunk has been tagged, add heap chunks to the list this->heapChunksToSample[this->iChunkCount] = c; this->iChunkCount++; LOGSTRING2("Added chunk %d to Chunks",i); } if(this->iChunkCount > 0 || this->iNewChunkCount > 0) { this->iChunksProcessing = EStartingToProcess; // process the first sample TInt length = this->ProcessChunks(); if(length == 0) { this->iChunksProcessing = ENothingToProcess; } chunks.Signal(); // Release the container mutex NKern::ThreadLeaveCS(); // End of critical section return length; } LOGTEXT("MemSamplerImpl::SampleImpl - Error, no threads"); chunks.Signal(); // Release the container mutex NKern::ThreadLeaveCS(); // End of critical section return 0; }
inline TInt DMemSamplerImpl::GatherLibraries() { LOGTEXT("MemSamplerImpl::GatherLibraries() - entry"); // encode a process binary name.Zero(); NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex DObjectCon& libs = *Kern::Containers()[ELibrary]; libs.Wait(); // Obtain the container mutex so the list does get changed under us this->iLibraryCount = 0; this->iNewLibraryCount = 0; this->iTotalMemoryOk = false; TInt totalLibCount(libs.Count()); DLibrary* l; for(TInt i(0);i<totalLibCount;i++) { l = (DLibrary*)(libs)[i]; LOGSTRING3("Processing library %d, tag: 0x%x",i,TAG(l)); if( (TAG(l) & 0xffffffff) != PROFILER_LIBRARY_MARK) { LOGSTRING4("Marking library %d/%d, old tag 0x%x",i,(totalLibCount-1), TAG(l)); // this library has not been tagged yet name.Zero(); l->TraceAppendName(name,false); TAG(l) = (PROFILER_LIBRARY_MARK); this->libraryNamesToReport[iNewLibraryCount] = l; iNewLibraryCount++; } // the library has been tagged, add library to the list this->librariesToSample[this->iLibraryCount] = l; this->iLibraryCount++; LOGSTRING2("Added library %d to Libraries",i); } if(this->iLibraryCount > 0 || this->iNewLibraryCount > 0) { this->iLibrariesProcessing = EStartingToProcess; // process the first sample TInt length = this->ProcessLibraries(); if(length == 0) { this->iLibrariesProcessing = ENothingToProcess; } libs.Signal(); // Release the container mutex NKern::ThreadLeaveCS(); // End of critical section return length; } LOGTEXT("MemSamplerImpl::SampleImpl - Error, no libraries"); libs.Signal(); // Release the container mutex NKern::ThreadLeaveCS(); // End of critical section return 0; }
TInt DPriSamplerImpl::SampleImpl() { /* * * EKA-2 implementation of PRI trace * */ if(this->iProcessing == ENothingToProcess) { if((iCountti % iPriSamplingPeriod) != 0 ) return 0; LOGTEXT("Processing threads..."); DObjectCon* threads = Kern::Containers()[EThread]; NKern::ThreadEnterCS(); // Prevent us from dying or suspending whilst holding a DMutex threads->Wait(); // PRI trace variables this->iThreadCount = 0; this->iNewThreadCount = 0; TInt totalThreadCount = threads->Count(); for(TInt i=0;i<totalThreadCount;i++) { //DThread* t = (DThread*)(threads)[i]; DObject* pO=(*threads)[i]; DThread* t = (DThread*)pO; LOGSTRING3("Processing thread %d, tag: 0x%x",i,TAG(t)); if( (TAG(t) & PROFILER_THREAD_MARK) == 0) { LOGSTRING2("Marking thread %d",i); // this thread's chunk has not been reported yet this->threadNamesToReport[iNewThreadCount] = t; iNewThreadCount++; // tag the thread TAG(t) |= PROFILER_THREAD_MARK; LOGSTRING2("New Thread %d",i); } else { LOGSTRING3("Thread %d marked already - 0x%x",i,TAG(t)); } // the thread has been tagged, add heap chunks to the list this->threadsToSample[this->iThreadCount] = t; this->iThreadCount++; LOGSTRING2("Added thread %d to threads to sample",i); } threads->Signal(); NKern::ThreadLeaveCS(); // End of critical section if(this->iThreadCount > 0 || this->iNewThreadCount > 0) { this->iProcessing = EStartingToProcess; // process the first sample TInt length = this->ProcessChunks(); if(length == 0) { this->iProcessing = ENothingToProcess; } return length; } else { // there were no threads, should not take place LOGTEXT("PriSamplerImpl::SampleImpl - Error, no threads"); return 0; } } else { TInt length = this->ProcessChunks(); if(length == 0) { this->iProcessing = ENothingToProcess; } return length; } }
TUid CPwrPlugin::Id(TInt /*aSubId*/) const { LOGSTRING2( "CPwrPlugin::Id():0x%X", KSamplerPwrPluginUid.iUid ); return KSamplerPwrPluginUid; }