Line 73... |
Line 73... |
static int cumulative = 0;
|
static int cumulative = 0;
|
|
|
/* Whether we should not report warnings */
|
/* Whether we should not report warnings */
|
static int quiet = 0;
|
static int quiet = 0;
|
|
|
|
void prof_help ()
|
|
{
|
|
printf ("profiler [-c] [-q] -g [profile_file_name]\n");
|
|
printf ("\t-c\t--cumulative\t\tcumulative sum of cycles in functions\n");
|
|
printf ("\t-q\t--quiet\t\t\tsuppress messages\n");
|
|
printf ("\t-g\t--generate [profile_file_name]\n");
|
|
printf ("\t\t\t\t\toutput profiling results to\n");
|
|
printf ("\t\t\t\t\tstdout/profile_file_name\n");
|
|
}
|
|
|
/* File to read from */
|
/* File to read from */
|
static FILE *fprof = 0;
|
static FILE *fprof = 0;
|
|
|
int main_profile (int mode, char *fname) {
|
int main_profiler (int argc, char *argv[]) {
|
char fprofname[50] = "sim.profile";
|
char fprofname[50] = "sim.profile";
|
int line = 0;
|
int line = 0;
|
|
|
/*
|
if (argc > 4 || argc < 2) {
|
if (argc > 4 || argc < 2) {
|
prof_help ();
|
fprintf (stderr, "USAGE: profiler [--cumulative|-c] [--quiet|-q] --generate|-g [profile_file_name]\n");
|
return 1;
|
exit(1);
|
}
|
}
|
|
*/
|
argv++; argc--;
|
|
while (argc > 0) {
|
if (mode && PROF_CUMULATIVE) cumulative = 1;
|
if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) {
|
if (mode && PROF_QUIET) quiet = 1;
|
quiet = 1;
|
if (!fname) fname = fprofname;
|
argv++; argc--;
|
|
} else if (!strcmp(argv[0], "-c") || !strcmp(argv[0], "--cumulative")) {
|
/*
|
cumulative = 1;
|
argv++; argc--;
|
argv++; argc--;
|
while (argc > 0) {
|
} else if (strcmp(argv[0], "-g") && strcmp(argv[0], "--generate")) {
|
if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) {
|
prof_help ();
|
quiet = 1;
|
return -1;
|
argv++; argc--;
|
} else {
|
} else if (!strcmp(argv[0], "-c") || !strcmp(argv[0], "--cumulative")) {
|
argv++; argc--;
|
cumulative = 1;
|
if (argv[0] && argv[0][0] != '-') {
|
argv++; argc--;
|
strcpy (&fprofname[0], argv[0]);
|
} else if (strcmp(argv[0], "-g") && strcmp(argv[0], "--generate")) {
|
argv++; argc--;
|
fprintf (stderr, "USAGE: profiler [--cumulative|-c] [--generate|-g] [profile_file_name]\n");
|
}
|
exit(1);
|
}
|
} else {
|
}
|
argv++; argc--;
|
|
if (argv[0] && argv[0][0] != '-') {
|
|
strcpy (&fprofname[0], argv[0]);
|
|
argv++; argc--;
|
|
}
|
|
}
|
|
}
|
|
*/
|
|
|
|
fprof = fopen (fname, "rt");
|
fprof = fopen (fprofname, "rt");
|
|
|
if (!fprof) {
|
if (!fprof) {
|
fprintf (stderr, "Cannot open profile file: %s\n", fname);
|
fprintf (stderr, "Cannot open profile file: %s\n", fprofname);
|
exit(1);
|
return 1;
|
}
|
}
|
|
|
while (1) {
|
while (1) {
|
char dir = fgetc (fprof);
|
char dir = fgetc (fprof);
|
line++;
|
line++;
|