/**
 * Returns the size of the trace data available
 * @return Trace Size
 * @leave One of the system wide codes
 */
TUint CServerCrashDataSource::GetAvailableTraceSizeL()
	{
	LOG_MSG("->CServerCrashDataSource::GetAvailableTraceSizeL()");
    
    RBTrace trace;
    User::LeaveIfError(trace.Open());
    
    TUint8 *data = NULL;
    TInt size = trace.GetData(data);

    trace.Close();  
    
    return size;
	}
Exemplo n.º 2
0
void CBtraceReader::ConstructL(TUint aMode)
{
    if (aMode & EDebug)
    {
        iDebugConsole = Console::NewL(_L("debug"), TSize(KConsFullScreen,KConsFullScreen));
    }
    User::LeaveIfError(iBtrace.Open());
    if (aMode & EConfigBtrace)
    {
        User::LeaveIfError(iBtrace.ResizeBuffer(KBtraceBufferSize));
        // Turn everything off.
        for (TInt i = 0; i < KMaxCategories; ++i)
        {
            iBtrace.SetFilter(i, 0);
        }
        if (aMode & EDebug)
        {
            iBtrace.SetFilter(BTrace::EKernPrintf, 1);
        }
        iBtrace.SetFilter(RMemSampler::EBtraceCategory, 1);
        User::LeaveIfError(iBtrace.SetFilter2((const TUint32*)NULL, 0));
        iBtrace.SetMode(RBTrace::EEnable | RBTrace::EFreeRunning);
    }
    if (iFileName.Length())
    {
        User::LeaveIfError(iFile.Replace(iCommand.FsL(), iFileName, EFileWrite));
    }
    QueueRead();
}
Exemplo n.º 3
0
//---------------------------------------------------------------------------------
void MainL(void)
	{
    test.Start(_L("Kern Perf Logger tests"));
    Initialise();
	
	
    RBTrace trace;
	TInt error = trace.Open();
    test(error == KErrNone);
	
	trace.Empty();
	trace.SetFilter(BTrace::EThreadIdentification,0);
	
    
    
    //-- actually, for hardware platforms, the testing category and trace enabling 
    //-- may be set up in appropriate "header.iby" file
    trace.SetMode(RBTrace::EEnable);
    trace.SetFilter(BTrace::EKernPerfLog, ETrue);
    
    //-- unit-test for PERF_LOG macros
    TestMacros(trace);
	
    //-- functionality test
    TestPerfLogger(trace); 
	
    trace.Close();
	
    Finalise();
	test.End();
	}
Exemplo n.º 4
0
void CBtraceReader::QueueRead()
{
    iBtrace.RequestData(iStatus, 0);
    SetActive();
}
Exemplo n.º 5
0
void CBtraceReader::DoCancel()
{
    iBtrace.CancelRequestData();
}
Exemplo n.º 6
0
void CBtraceReader::RunL()
{
    QueueRead();
    TUint8* data;
    TInt size;
    while ((size = iBtrace.GetData(data)) != 0)
    {
        if (iMemoryView || iDebugConsole)
        {
            // Only decode btrace frames if we're attached to a CMemoryView object or have a debug console.
            TUint8* c = data;
            TUint8* end = c + size;
            do
            {
                TBtraceHeader* header = (TBtraceHeader*)c;
                TUint8* d = c + sizeof(TBtraceHeader);
                TUint32 tickCount = 0;
                if (header->iFlags & BTrace::EMissingRecord)
                {
                    User::Leave(KErrOverflow);
                }
                if (header->iFlags & BTrace::EHeader2Present)
                {
                    d += 4;
                }
                if (header->iFlags & BTrace::ETimestampPresent)
                {
                    tickCount = *((TUint32*)d);
                    d += 4;
                }
                if (header->iFlags & BTrace::ETimestamp2Present)
                {
                    d += 4;
                }
                if (header->iFlags & BTrace::EContextIdPresent)
                {
                    d += 4;
                }
                if (header->iFlags & BTrace::EPcPresent)
                {
                    d += 4;
                }
                if (header->iFlags & BTrace::EExtraPresent)
                {
                    d += 4;
                }
                TPtrC8 ptr(d, (c + header->iSize) - d);
                DecodeFrame(*header, ptr, tickCount);
                c += (header->iSize + 3) & ~3;
            }
            while (c < end);
        }
        if (iFileName.Length())
        {
            User::LeaveIfError(iFile.Write(TPtrC8(data, size)));
        }
        iBtrace.DataUsed();
    }
    if (iMemoryView)
    {
        iMemoryView->UpdateL();
    }
}
Exemplo n.º 7
0
/**
	Get logging trace from the kernel trace engine and optionally check if it corresponds to the 
	TTestLogCtrl structure fields. Actually, the logging trace in our case shall be the result of the 
	test helper LDD worr, that in turn, is controlled by the data in TTestLogCtrl structure.

  @param  aTrace          ref. to the kernel trace engine LDD.
  @param  apControlStruct if not NULL obtained trace fields checked against fields of this structure.
  
*/
void GetParseRecordData(RBTrace& aTrace, const TTestLogCtrl* apControlStruct = NULL)
	{
    TUint8*         record;
    TTraceLayout    traceLayout;
	TInt    		nRecords = 0;
	
	for(TInt i=0; ;++i)
		{
        //-- get raw trace record
        TInt dataSize = aTrace.GetData(record);
		
        if(i != 0 && !dataSize)
            break; //-- no more data
        
        //-- check if we get log data at all at the very beginning
        if(i == 0 && !dataSize)
			{
			if(!apControlStruct)
				{//-- it's ok, no check
                break;
				}
            else
				{//-- panic if there is no log data, but we are required to get some.
                if(apControlStruct->iLogsNum > 0)
					{
                    test.Printf(_L("GetParseRecordData() No trace data found!\n"));
                    test(0);
					}
				}
			}
        
		
        TUint8* end = record+dataSize;
        TUint8* currPos = record;
		TUint nBytes = 0;
		
        //-- parser the record, print out fields and optionally check the correspondence to the fields of the control structure.
        for(; currPos<end; currPos+=nBytes)
			{
            
            nBytes = ParseTraceRecord(currPos ,traceLayout);
            test(nBytes >0 );
            
            //-- skip possible loggings that we didn't make
            if(traceLayout.iCategory != BTrace::EKernPerfLog)
                continue;
            
            ++nRecords;
			
            //-- print the record out
            PrintTraceRecord(traceLayout);

			//-- check the obtained record structure
			if(apControlStruct)
				{
				test(traceLayout.iCategory    == apControlStruct->iCategory);
				test(traceLayout.iSubCategory == apControlStruct->iSubCategory);
				
				if(traceLayout.iDataWords > 1)  //-- we have at least 1 word of user data (1 is for TickCount)
					test(traceLayout.ipData[0] == apControlStruct->iUserData);
				
				if(traceLayout.iDataWords > 2)  //-- we have 2 words of user data (1 is for TickCount)
					test(traceLayout.ipData[1] == apControlStruct->iUserData2);
				
				}
            
			}
				
		//-- release data buffer.
		aTrace.DataUsed();
		}
		
	//-- check number of trace records obtained
	if(apControlStruct)
		{
		test(nRecords == apControlStruct->iLogsNum);
		}

	}