OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [branches/] [stable_0_2_x/] [or1ksim/] [profiler.c] - Diff between revs 547 and 632

Go to most recent revision | Show entire file | Details | Blame | View Log

Rev 547 Rev 632
Line 19... Line 19...
 
 
/* Command line utility, that displays profiling information, generated
/* Command line utility, that displays profiling information, generated
   by or1ksim. (use --profile option at command line, when running or1ksim.  */
   by or1ksim. (use --profile option at command line, when running or1ksim.  */
 
 
#include <stdio.h>
#include <stdio.h>
 
#include "profiler.h"
#define MAX_STACK 1024
 
#define MAX_FUNCS 1024
 
 
 
struct stack_struct {
struct stack_struct {
  /* Function address */
  /* Function address */
  unsigned int addr;
  unsigned int addr;
 
 
Line 78... Line 76...
static int quiet = 0;
static int quiet = 0;
 
 
/* File to read from */
/* File to read from */
static FILE *fprof = 0;
static FILE *fprof = 0;
 
 
int main (int argc, char *argv[]) {
int main_profile (int mode, char *fname) {
  char fprofname[50] = "sim.profile";
  char fprofname[50] = "sim.profile";
  int line = 0;
  int line = 0;
  if (argc > 4 || argc < 2) {
 
    fprintf (stderr, "USAGE: profiler [--cumulative|-c] [--quiet|-q] --generate|-g [profile_file_name]\n");
 
    exit(1);
 
  }
 
  argv++; argc--;
 
  while (argc > 0) {
 
    if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) {
 
      quiet = 1;
 
      argv++; argc--;
 
    } else if (!strcmp(argv[0], "-c") || !strcmp(argv[0], "--cumulative")) {
 
      cumulative = 1;
 
      argv++; argc--;
 
    } else if (strcmp(argv[0], "-g") && strcmp(argv[0], "--generate")) {
 
      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 (&fprofname[0], "rt");
  /*
 
  if (argc > 4 || argc < 2) {
 
    fprintf (stderr, "USAGE: profiler [--cumulative|-c] [--quiet|-q] --generate|-g [profile_file_name]\n");
 
    exit(1);
 
  }
 
  */
 
 
 
  if (mode && PROF_CUMULATIVE) cumulative = 1;
 
  if (mode && PROF_QUIET)      quiet = 1;
 
  if (!fname)                  fname = fprofname;
 
 
 
  /*
 
  argv++; argc--;
 
  while (argc > 0) {
 
    if (!strcmp(argv[0], "-q") || !strcmp(argv[0], "--quiet")) {
 
      quiet = 1;
 
      argv++; argc--;
 
    } else if (!strcmp(argv[0], "-c") || !strcmp(argv[0], "--cumulative")) {
 
      cumulative = 1;
 
      argv++; argc--;
 
    } else if (strcmp(argv[0], "-g") && strcmp(argv[0], "--generate")) {
 
      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");
 
 
  if (!fprof) {
  if (!fprof) {
    fprintf (stderr, "Cannot open profile file: %s\n", &fprofname[0]);
    fprintf (stderr, "Cannot open profile file: %s\n", fname);
    exit(1);
    exit(1);
  }
  }
 
 
  while (1) {
  while (1) {
    char dir = fgetc (fprof);
    char dir = fgetc (fprof);

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.