Subversion Repositories shark

Rev

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

Rev Author Line No. Line
1293 giacomo 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
 *   Giacomo Guidi       <giacomo@gandalf.sssup.it>
1568 tullio 10
 *   Tullio Facchinetti  <tullio.facchinetti@unipv.it>
1293 giacomo 11
 *
12
 * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy)
13
 *
14
 * http://www.sssup.it
15
 * http://retis.sssup.it
16
 * http://shark.sssup.it
1568 tullio 17
 * http://robot.unipv.it
1293 giacomo 18
 */
19
 
1606 tullio 20
/*
21
 * This program is free software; you can redistribute it and/or modify
22
 * it under the terms of the GNU General Public License as published by
23
 * the Free Software Foundation; either version 2 of the License, or
24
 * (at your option) any later version.
25
 *
26
 * This program is distributed in the hope that it will be useful,
27
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
28
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
29
 * GNU General Public License for more details.
30
 *
31
 * You should have received a copy of the GNU General Public License
32
 * along with this program; if not, write to the Free Software
33
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
34
 *
35
 */
36
 
1293 giacomo 37
#include <kernel/kern.h>
1364 giacomo 38
#include <FTrace_chunk.h>
39
#include <FTrace_udp.h>
1293 giacomo 40
#include <tracer.h>
41
 
1515 giacomo 42
extern unsigned int clk_per_msec;
43
 
1293 giacomo 44
int main(int argc, char **argv)
45
{
46
 
47
  long long i;
48
 
1353 giacomo 49
  int a,b,c;
1293 giacomo 50
  struct timespec start,end,diff;
1371 giacomo 51
  SYS_FLAGS f;
1293 giacomo 52
 
1615 tullio 53
  /**
54
    *  Create 3 chunks for storing the tracer events.
55
    *  Explanation of flags:
56
    *  FTRACE_CHUNK_FLAG_FREE : the chunk is free to use
57
    *  FTRACE_CHUNK_FLAG_CYC  : the chunk stores events in a cyclical way.
58
    *                           When the chunk is full,
59
    *                           it will continue from the head.
60
    *  FTRACE_CHUNK_FLAG_JTN  : when the chunk is full,
61
    *                           it jumps to the next chunk.
62
    */
1353 giacomo 63
  a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
64
  b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
65
  c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
1293 giacomo 66
 
1615 tullio 67
  /**
68
   *  Link the 3 chunks together.
69
   *  It is important to link before you can jump from one to another.
70
   */
1353 giacomo 71
  FTrace_chunk_link(a,b);
72
  FTrace_chunk_link(b,c);
73
 
1568 tullio 74
  /** Select the first chunk for saving the events. */
1353 giacomo 75
  FTrace_actual_chunk_select(a);
76
 
1293 giacomo 77
  kern_gettime(&start);
1568 tullio 78
 
79
  /** Start the tracer. */
1353 giacomo 80
  FTrace_enable();
1568 tullio 81
 
1573 tullio 82
  /** Enable filtering for timer related events. */
1568 tullio 83
  FTrace_set_filter(FTrace_filter_timer, 1);
1293 giacomo 84
 
1518 giacomo 85
  TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec);
1510 giacomo 86
 
1508 giacomo 87
  for (i=0;i<10;i++)
88
    if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id,
89
					(unsigned short int)proc_table[i].context,i);
90
 
1293 giacomo 91
  for (i=0;i<1000000000;i++);
1568 tullio 92
 
1574 tullio 93
  /** Enable filtering for timer related events. */
1568 tullio 94
  FTrace_set_filter(FTrace_filter_timer, 0);
1353 giacomo 95
 
1568 tullio 96
  /** Change the chunk where the events are stored. */
1353 giacomo 97
  TRACER_LOGEVENT(FTrace_EVT_next_chunk,0,0);
1371 giacomo 98
 
99
  f = kern_fsave();
100
  __asm__("cpuid":::"eax","ebx","ecx","edx");
1510 giacomo 101
  FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1000,0);
102
  FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2000,0);
103
  FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3000,0);
104
  FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,4000,0);
105
  FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,5000,0);
1371 giacomo 106
  __asm__("cpuid":::"eax","ebx","ecx","edx");
107
  kern_frestore(f);
108
 
1510 giacomo 109
  TRACER_LOGEVENT(FTrace_EVT_ipoint,6000,0);
1371 giacomo 110
 
1353 giacomo 111
  for (i=0;i<1000000000;i++);
112
 
1568 tullio 113
  /** Store a TFrace stop event. */
1510 giacomo 114
  TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0);
115
 
1568 tullio 116
  /** Stop the tracer. */
1353 giacomo 117
  FTrace_disable();
1293 giacomo 118
  kern_gettime(&end);
119
 
120
  SUBTIMESPEC(&end,&start,&diff);
121
 
122
  cprintf("Logged Time %d s %d us\n",(int)diff.tv_sec,(int)diff.tv_nsec/1000);
123
 
1568 tullio 124
  /** Initialize the network for remotely saving the trace.  */
1411 giacomo 125
  FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1");
1568 tullio 126
 
127
  /**
128
   * You may want to save the events to disk. In that case, simply change
129
   * the network initialization instruction with the following line:
130
   *
131
   * FTrace_init_disk_writer("trace.dat", 0, NULL, NULL);
132
   *
133
   */
1293 giacomo 134
 
1568 tullio 135
  /** Save the chunk. */
1372 giacomo 136
  FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC);
137
  FTrace_send_chunk(b, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN);
1364 giacomo 138
 
1293 giacomo 139
  return 0;
140
 
141
}