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;
    }
// --------------------------------------------------------------------------
//  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" );
    }
Esempio n. 3
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"));
    }
// ------------------------------------------------------------------------
//  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" );
    }
Esempio n. 5
0
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"));
    }
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;
	    }
    }
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;
    }
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;
    }