📄 r2analyz.c
字号:
/*====================================================================*/
/* PROGRAM: @(#)r2analyz.c 2.3 - 08/04/99 */
/*====================================================================*/
/* PURPOSE: This program performs the Analysis functions for the */
/* Recon II system by reading test data (created by */
/* executing instrumented code) and producing an */
/* annotated source listing(s) on disk. */
/* */
/* SYSTEM : RECON II */
/* */
/* USAGE : r2analyz [?|-h|-q|-v|-s] -r {filename} -p {directory} */
/* (CASE IN-SENSITIVE SWITCHES) */
/* -h|-H */
/* -q|-Q */
/* -v|-V */
/* -s|-S */
/* -r|-R */
/* -p|-P */
/* See the Usage() function for details */
/* */
/* HISTORY: */
/* VER DATE AUTHOR DESCRIPTION */
/* 1.00 23 Feb 93 L. Richard Created program. */
/* 1.01 3 Mar 93 L. Richard Moved CreateTestList() and */
/* CreateCompList() calls from */
/* sub-units to main(). */
/* 1.02 10 Mar 93 L. Richard Added calls to SetTalk() and */
/* SetDirectory(). */
/* 1.03 16 Mar 93 L. Richard Added version number to banner. */
/* 1.04 31 Mar 93 L. Richard Corrected runtime error in function*/
/* AnnotateSource() in Unit R2Annote. */
/* 1.05 4 Apr 93 L. Richard Modified function BuildCompList() */
/* in Unit R2Build. */
/* 1.06 5 Apr 93 L. Richard Modified function AnnotateSource() */
/* in Unit R2Annote. */
/* 1.07 10 May 93 L. Richard Added call to Usage(). */
/* 1.08 22 Jun 93 L. Richard Added defines for Ops Systems. */
/* 1.09 5 Nov 93 N. Wilde Added the OutputSets option */
/* 1.10 21 Nov 96 W. Flood Added ability to read multible */
/* command line arguments, by placing */
/* them into an ADT called CLInput */
/* 1.11 30 Mar 96 L. Landry Added new trace file format read */
/* W. Flood and binary tree for source name */
/* storage, filename retrival and */
/* index generation */
/* 2.2 31 Jan 98 T. Hall Changed retrieval of command line */
/* arguments so that switches may be */
/* case-insensitive and true file */
/* paths will be stored in CLInput. */
/* Did away with -Os and -Oa switch. */
/* Added -s switch. */
/* Added the function isArgument(). */
/* The call to SetDirectory() in */
/* r2util.c was deleted because */
/* SetDirectory() was done away with. */
/* Modified call to ReadTestData() */
/* and AnnotateSource(). */
/* Deleted variable anl_dir. */
/*--------------------------------------------------------------------*/
/*==[ INTERFACE ]=====================================================*/
#include "r2.h"
#include "r2analyz.h"
#include <stdio.h>
/*==[ PRIVATE IMPLEMENTATION ]========================================*/
#include "r2read.h"
#include "r2build.h"
#include "r2select.h"
#include "r2annote.h"
#include "r2clist.h"
#include "r2tlist.h"
#include "r2util.h"
#include "r2outset.h"
/*==[ PUBLIC IMPLEMENTATION ]=========================================*/
/*--------------------------------------------------------------------*/
/* FUNCTION main */
/*--------------------------------------------------------------------*/
int main(
int argc, /* Cmd line argument count */
char *argv[] /* List of arguments */
)
{
BOOL error; /* Error flag */
char type; /* Method flag */
int thresh; /* Probabilistic threshold */
STRING symb[ 5 + 1 ]; /* Annotation symbol */
TESTLIST *tl = NULL; /* Test case list */
COMPLIST *cl = NULL; /* Component list */
OUTPUT_MODE outputMode; /* sets or annotated list? */
int casesWith; /* Count of test cases that */
/* exhibit the feature */
int casesTot; /* Count total number of cases*/
clinput CLInput; /* Structure to recieve the */
/* command line arguments. */
int i; /* Counter for reading command*/
/* line arguments */
char *temp; /* Recieves command line argument*/
/* then is used as the switch comparison*/
Tree ptree; /* Btree created from trace file*/
/* Initialization */
NullStruct( &CLInput);
for ( i=1; i<argc; i++)
{
temp=argv[i];
switch( temp[0] )
{
case '?' : CLInput.usage = "-h";
break;
case '-' : switch( temp[1])
{
case 'r':
case 'R' :
if (!isArgument(argc,argv,i+1))
{
printf("\nInvalid analysis input file \n\n");
Usage(); /*print usage and exit*/
}
/*get following argument as the analysis input file*/
CLInput.analfile = argv[i+1];
i++;
break;
case 'p':
case 'P':
if (!isArgument(argc,argv,i+1))
{
printf("\nInvalid output directory \n\n");
Usage(); /*print usage and exit*/
}
/*get following argument as the analysis input file*/
CLInput.annotout = argv[i+1];
if (strlen(CLInput.annotout) > MAXLENGTH)
{
printf("Analysis output destination and file names cannot exceed %d characters.\n", MAXLENGTH);
printf ("Program Terminating.\n");
exit(1);
}
i++;
break;
case 's':
case 'S':
CLInput.outmode = "-s";
break;
case 'v':
case 'V':
CLInput.talk = "-v";
break;
case 'q':
case 'Q':
CLInput.talk = "-q";
break;
case 'h':
case 'H':
CLInput.usage = "-h";
break;
default :
printf("\nInvalid parameter %s \n\n",argv[i]);
CLInput.usage = "-h";
break;
} break;
default :
printf("\nInvalid parameter %s \n\n",argv[i]);
CLInput.usage = "-h";
break;
}
}
if (( argc == 1 ) || (0 == strcmp( CLInput.usage, "-h")))
Usage();
SetTalk( &CLInput );
outputMode = GetOutputMode( &CLInput );
/* Create primary linked lists */
CreateTestList( &tl );
CreateCompList( &cl );
InitTree(&ptree);
/* Perform Analysis Process */
error = ReadTestData( &type, &thresh, symb, tl,
&casesWith, &casesTot, &CLInput);
error = BuildCompList( tl, cl, &ptree, &CLInput );
switch (outputMode)
{
case (SETS):
{
OutputSets( cl, casesWith, casesTot, &ptree);
DeleteCompList ( &cl); /* free memory */
FreeTree(&ptree); /* free btree */
break;
}
default /* (ANNOTATED_LISTING) */:
{
if (!error)
error = SelectComp( cl, &thresh );
if (!error)
error = AnnotateSource(&type,symb,CLInput.annotout,cl, &ptree);
FreeTree(&ptree); /* free btree */
break;
}
}
/* Cleanup */
if (0 < gTALK)
if (error)
printf( "R2Analyz: ABORTED - Results are unusable!\n" );
/* NOTE: Need to delete R2Analyz created files ??? */
else
printf( "R2Analyz: Executed Successfully.\n" );
return( 0 );
} /* main() */
/*--------------------------------------------------------------------*/
/* FUNCTION isArgument */
/*--------------------------------------------------------------------*/
/* PURPOSE checks to make sure there is another argument available */
/* on the command line. If there is, it checks to make sure */
/* its first character is not equal to '-' (denoting another */
/* switch). */
/* */
/* USED BY main() */
/* */
/* HISTORY */
/* VER DATE AUTHOR DESCRIPTION */
/* 2.2 31 Jan 98 W. Hall Created */
/*--------------------------------------------------------------------*/
BOOL isArgument(
int argc,
char *argv[],
int i
)
/*return true if argv[i] is a string not beginning with "-" */
{
if (i>=argc) /*check that argument exists*/
return FALSE;
if (*argv[i] == '-') /*check first character*/
return FALSE;
return TRUE;
} /*isArgument*/
/*====================================================================*/
/* EOF : r2analyz.c */
/*====================================================================*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -