kerneltest/e32utils/trace/btrace_host.cpp
changeset 0 a41df078684a
equal deleted inserted replaced
-1:000000000000 0:a41df078684a
       
     1 // Copyright (c) 2007-2009 Nokia Corporation and/or its subsidiary(-ies).
       
     2 // All rights reserved.
       
     3 // This component and the accompanying materials are made available
       
     4 // under the terms of the License "Eclipse Public License v1.0"
       
     5 // which accompanies this distribution, and is available
       
     6 // at the URL "http://www.eclipse.org/legal/epl-v10.html".
       
     7 //
       
     8 // Initial Contributors:
       
     9 // Nokia Corporation - initial contribution.
       
    10 //
       
    11 // Contributors:
       
    12 //
       
    13 // Description:
       
    14 //
       
    15 
       
    16 #include <stdio.h>
       
    17 #include <stdlib.h>
       
    18 
       
    19 extern void ProcessAllTrace(unsigned (*aInput)(void* aBuffer, unsigned aMaxSize),int aReportLevel);
       
    20 
       
    21 FILE* InFile = 0;
       
    22 
       
    23 unsigned GetTraceData(void* aBuffer, unsigned aMaxSize)
       
    24 	{
       
    25 	return fread(aBuffer, 1, aMaxSize, InFile);
       
    26 	}
       
    27 
       
    28 char* ThisProgram = "BTRACE";
       
    29 
       
    30 int Help()
       
    31 	{
       
    32 	printf("Usage: %s [options] file\n",ThisProgram);
       
    33 	printf("Options:\n");
       
    34 	printf("  -a<level>     Set analysis level, 0 = brief summary, 1 = full summary,\n");
       
    35 	printf("                2 = condensed trace dump, 3 = full trace dump (DEFAULT)\n");
       
    36 	printf("\nTHIS TOOL IS UNOFFICIAL, UNSUPPORTED AND SUBJECT TO CHANGE WITHOUT NOTICE!\n");
       
    37 	return 1;
       
    38 	}
       
    39 
       
    40 int main(int argc, char** argv)
       
    41 	{
       
    42 	int reportLevel = 99;
       
    43 	InFile = 0;
       
    44 
       
    45 	ThisProgram = argv[0];
       
    46 	int nextArg=0;
       
    47 	for(;;)
       
    48 		{
       
    49 		++nextArg;
       
    50 		if(nextArg>=argc)
       
    51 			{
       
    52 			fprintf(stderr,"Missing input file\n");
       
    53 			return Help();
       
    54 			}
       
    55 		if(argv[nextArg][0]!='-')
       
    56 			break; // not option
       
    57 		if(argv[nextArg][1]=='a')
       
    58 			{
       
    59 			reportLevel = strtoul(argv[nextArg]+2,0,10);
       
    60 			continue;
       
    61 			}
       
    62 		fprintf(stderr,"Unknown option: %s\n",argv[nextArg]);
       
    63 		return Help();
       
    64 		}
       
    65 
       
    66 	InFile = fopen(argv[nextArg],"rb");
       
    67 	if(!InFile)
       
    68 		{
       
    69 		fprintf(stderr,"Can't open input file '%s'\n",argv[nextArg]);
       
    70 		return Help();
       
    71 		}
       
    72 
       
    73 	ProcessAllTrace(GetTraceData,reportLevel);
       
    74 
       
    75 	fclose(InFile);
       
    76 	return 0;
       
    77 	}
       
    78