Subversion Repositories shark

Rev

Rev 1093 | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1096 pj 1
/*
2
 * Project: S.Ha.R.K.
3
 *
4
 * Coordinators:
5
 *   Giorgio Buttazzo    <giorgio@sssup.it>
6
 *   Paolo Gai           <pj@gandalf.sssup.it>
7
 *
8
 * Authors     :
9
 *   Paolo Gai           <pj@gandalf.sssup.it>
10
 *   Massimiliano Giorgi <massy@gandalf.sssup.it>
11
 *   Luca Abeni          <luca@gandalf.sssup.it>
12
 *   (see the web pages for full authors list)
13
 *
14
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
15
 *
16
 * http://www.sssup.it
17
 * http://retis.sssup.it
18
 * http://shark.sssup.it
19
 */
1093 pj 20
 
1096 pj 21
/*
22
 * Copyright (C) 2000 Massimiliano Giorgi
23
 * Copyright (C) 2002 Paolo Gai
24
 *
25
 * This program is free software; you can redistribute it and/or modify
26
 * it under the terms of the GNU General Public License as published by
27
 * the Free Software Foundation; either version 2 of the License, or
28
 * (at your option) any later version.
29
 *
30
 * This program is distributed in the hope that it will be useful,
31
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
32
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
33
 * GNU General Public License for more details.
34
 *
35
 * You should have received a copy of the GNU General Public License
36
 * along with this program; if not, write to the Free Software
37
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
38
 *
39
 * CVS :        $Id: tdump.c,v 1.2 2002-10-28 08:07:32 pj Exp $
40
 */
41
 
1093 pj 42
/* this example simply prints a Shark trace file */
43
 
44
#include <netinet/in.h>
45
 
46
#include <stdio.h>
47
#include "types.h"
48
#include <trace.h>
49
#include "util.h"
50
 
51
int dumpsys(trc_system_event_t *sys)
52
{
53
  /*
54
  if (sys->event==TRC_SCHEDULE) {
55
    //if (sys->prev!=65535)
56
    //  printf("%02i->%02i\n",sys->prev,sys->task);
57
    //else
58
      printf("??->%02i\n",sys->task);
59
    return 0;
60
  }
61
  */
62
  printf("%02i\n",sys->task);
63
  return 0;
64
}
65
 
66
int dumpusr(trc_user_event_t *usr)
67
{
68
  printf("%8li ",usr->n);
69
  printf("\n");
70
  return 0;
71
}
72
 
73
int dumpsem(trc_sem_event_t *sem)
74
{
75
  printf("on [%i]\n",sem->id);
76
  return 0;
77
}
78
 
79
int dumpfunc(trc_event_t *ev)
80
{
81
  static int counter=0;
82
 
83
  printf("%4i ",counter);
84
  counter++;
85
  printf("%12s ",format_time(ev->time));
86
  printf("%-10s ",event_name(ev->event));
87
 
88
  //printf("%08x\n",(unsigned)ev->sys.event);
89
  //return 0;
90
 
91
  switch(event_class(ev->event)) {
92
    case TRC_CLASS_SYSTEM: return dumpsys(&ev->x.sys);
93
    case TRC_CLASS_USER:   return dumpusr(&ev->x.usr);
94
    case TRC_CLASS_SEM:    return dumpsem(&ev->x.sem);
95
  }
96
  printf("\nEVENT %i... CLASS %i UNKNOWN!\n",ev->event,event_class(ev->event));
97
  return -1;
98
}
99
 
100
int main(int argc, char *argv[])
101
{
102
  int res;
103
 
104
  if (argc!=2) {
105
    fprintf(stderr,"missing filename!\n");
106
    return -1;
107
  }
108
 
109
  res=read_trace(argv[1],dumpfunc);
110
 
111
  //fprintf(stderr,"result=%i\n",res);
112
  //fprintf(stderr,"size=%li\n",sizeof(trc_event_t));
113
 
114
  return 0;
115
}