Rev 1574 | Go to most recent revision | 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 | |
1568 | tullio | 53 | /** Create 3 chunks for storing the tracer events. */ |
1353 | giacomo | 54 | a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
55 | b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
||
56 | c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
||
1293 | giacomo | 57 | |
1353 | giacomo | 58 | FTrace_chunk_link(a,b); |
59 | FTrace_chunk_link(b,c); |
||
60 | |||
1568 | tullio | 61 | /** Select the first chunk for saving the events. */ |
1353 | giacomo | 62 | FTrace_actual_chunk_select(a); |
63 | |||
1293 | giacomo | 64 | kern_gettime(&start); |
1568 | tullio | 65 | |
66 | /** Start the tracer. */ |
||
1353 | giacomo | 67 | FTrace_enable(); |
1568 | tullio | 68 | |
1573 | tullio | 69 | /** Enable filtering for timer related events. */ |
1568 | tullio | 70 | FTrace_set_filter(FTrace_filter_timer, 1); |
1293 | giacomo | 71 | |
1518 | giacomo | 72 | TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec); |
1510 | giacomo | 73 | |
1508 | giacomo | 74 | for (i=0;i<10;i++) |
75 | if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id, |
||
76 | (unsigned short int)proc_table[i].context,i); |
||
77 | |||
1293 | giacomo | 78 | for (i=0;i<1000000000;i++); |
1568 | tullio | 79 | |
1574 | tullio | 80 | /** Enable filtering for timer related events. */ |
1568 | tullio | 81 | FTrace_set_filter(FTrace_filter_timer, 0); |
1353 | giacomo | 82 | |
1568 | tullio | 83 | /** Change the chunk where the events are stored. */ |
1353 | giacomo | 84 | TRACER_LOGEVENT(FTrace_EVT_next_chunk,0,0); |
1371 | giacomo | 85 | |
86 | f = kern_fsave(); |
||
87 | __asm__("cpuid":::"eax","ebx","ecx","edx"); |
||
1510 | giacomo | 88 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1000,0); |
89 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2000,0); |
||
90 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3000,0); |
||
91 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,4000,0); |
||
92 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,5000,0); |
||
1371 | giacomo | 93 | __asm__("cpuid":::"eax","ebx","ecx","edx"); |
94 | kern_frestore(f); |
||
95 | |||
1510 | giacomo | 96 | TRACER_LOGEVENT(FTrace_EVT_ipoint,6000,0); |
1371 | giacomo | 97 | |
1353 | giacomo | 98 | for (i=0;i<1000000000;i++); |
99 | |||
1568 | tullio | 100 | /** Store a TFrace stop event. */ |
1510 | giacomo | 101 | TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0); |
102 | |||
1568 | tullio | 103 | /** Stop the tracer. */ |
1353 | giacomo | 104 | FTrace_disable(); |
1293 | giacomo | 105 | kern_gettime(&end); |
106 | |||
107 | SUBTIMESPEC(&end,&start,&diff); |
||
108 | |||
109 | cprintf("Logged Time %d s %d us\n",(int)diff.tv_sec,(int)diff.tv_nsec/1000); |
||
110 | |||
1568 | tullio | 111 | /** Initialize the network for remotely saving the trace. */ |
1411 | giacomo | 112 | FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1"); |
1568 | tullio | 113 | |
114 | /** |
||
115 | * You may want to save the events to disk. In that case, simply change |
||
116 | * the network initialization instruction with the following line: |
||
117 | * |
||
118 | * FTrace_init_disk_writer("trace.dat", 0, NULL, NULL); |
||
119 | * |
||
120 | */ |
||
1293 | giacomo | 121 | |
1568 | tullio | 122 | /** Save the chunk. */ |
1372 | giacomo | 123 | FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
124 | FTrace_send_chunk(b, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
||
1364 | giacomo | 125 | |
1293 | giacomo | 126 | return 0; |
127 | |||
128 | } |