Subversion Repositories shark

Rev

Blame | Last modification | View Log | RSS feed


#include <netinet/in.h>

#include <stdio.h>
#include "types.h"
#include <trace.h>
#include "util.h"

int dumpsys(trc_system_event_t *sys)
{
  /*
  if (sys->event==TRC_SCHEDULE) {
    //if (sys->prev!=65535)
    //  printf("%02i->%02i\n",sys->prev,sys->task);
    //else
      printf("??->%02i\n",sys->task);
    return 0;
  }
  */

  printf("%02i\n",sys->task);
  return 0;
}

int dumpusr(trc_user_event_t *usr)
{
  printf("%8li ",usr->n);
  printf("\n");
  return 0;
}

int dumpsem(trc_sem_event_t *sem)
{
  printf("on [%i]\n",sem->id);
  return 0;
}

int dumpfunc(trc_event_t *ev)
{
  static int counter=0;
 
  printf("%4i ",counter);
  counter++;
  printf("%12s ",format_time(ev->time));
  printf("%-10s ",event_name(ev->event));

  //printf("%08x\n",(unsigned)ev->sys.event);
  //return 0;
 
  switch(event_class(ev->event)) {
    case TRC_CLASS_SYSTEM: return dumpsys(&ev->x.sys);
    case TRC_CLASS_USER:   return dumpusr(&ev->x.usr);
    case TRC_CLASS_SEM:    return dumpsem(&ev->x.sem);
  }
  printf("\nEVENT %i... CLASS %i UNKNOWN!\n",ev->event,event_class(ev->event));
  return -1;
}

int main(int argc, char *argv[])
{
  int res;
 
  if (argc!=2) {
    fprintf(stderr,"missing filename!\n");
    return -1;
  }

  res=read_trace(argv[1],dumpfunc);

  //fprintf(stderr,"result=%i\n",res);
  //fprintf(stderr,"size=%li\n",sizeof(trc_event_t));
 
  return 0;
}