Rev 1573 | Rev 1606 | 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 | |||
20 | #include <kernel/kern.h> |
||
1364 | giacomo | 21 | #include <FTrace_chunk.h> |
22 | #include <FTrace_udp.h> |
||
1293 | giacomo | 23 | #include <tracer.h> |
24 | |||
1515 | giacomo | 25 | extern unsigned int clk_per_msec; |
26 | |||
1293 | giacomo | 27 | int main(int argc, char **argv) |
28 | { |
||
29 | |||
30 | long long i; |
||
31 | |||
1353 | giacomo | 32 | int a,b,c; |
1293 | giacomo | 33 | struct timespec start,end,diff; |
1371 | giacomo | 34 | SYS_FLAGS f; |
1293 | giacomo | 35 | |
1568 | tullio | 36 | /** Create 3 chunks for storing the tracer events. */ |
1353 | giacomo | 37 | a = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
38 | b = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
||
39 | c = FTrace_chunk_create(1000000, 1000000, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
||
1293 | giacomo | 40 | |
1353 | giacomo | 41 | FTrace_chunk_link(a,b); |
42 | FTrace_chunk_link(b,c); |
||
43 | |||
1568 | tullio | 44 | /** Select the first chunk for saving the events. */ |
1353 | giacomo | 45 | FTrace_actual_chunk_select(a); |
46 | |||
1293 | giacomo | 47 | kern_gettime(&start); |
1568 | tullio | 48 | |
49 | /** Start the tracer. */ |
||
1353 | giacomo | 50 | FTrace_enable(); |
1568 | tullio | 51 | |
1573 | tullio | 52 | /** Enable filtering for timer related events. */ |
1568 | tullio | 53 | FTrace_set_filter(FTrace_filter_timer, 1); |
1293 | giacomo | 54 | |
1518 | giacomo | 55 | TRACER_LOGEVENT(FTrace_EVT_trace_start,proc_table[exec_shadow].context,clk_per_msec); |
1510 | giacomo | 56 | |
1508 | giacomo | 57 | for (i=0;i<10;i++) |
58 | if (proc_table[i].context != 0) TRACER_LOGEVENT(FTrace_EVT_id, |
||
59 | (unsigned short int)proc_table[i].context,i); |
||
60 | |||
1293 | giacomo | 61 | for (i=0;i<1000000000;i++); |
1568 | tullio | 62 | |
1574 | tullio | 63 | /** Enable filtering for timer related events. */ |
1568 | tullio | 64 | FTrace_set_filter(FTrace_filter_timer, 0); |
1353 | giacomo | 65 | |
1568 | tullio | 66 | /** Change the chunk where the events are stored. */ |
1353 | giacomo | 67 | TRACER_LOGEVENT(FTrace_EVT_next_chunk,0,0); |
1371 | giacomo | 68 | |
69 | f = kern_fsave(); |
||
70 | __asm__("cpuid":::"eax","ebx","ecx","edx"); |
||
1510 | giacomo | 71 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,1000,0); |
72 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,2000,0); |
||
73 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,3000,0); |
||
74 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,4000,0); |
||
75 | FAST_TRACER_LOGEVENT(FTrace_EVT_ipoint,5000,0); |
||
1371 | giacomo | 76 | __asm__("cpuid":::"eax","ebx","ecx","edx"); |
77 | kern_frestore(f); |
||
78 | |||
1510 | giacomo | 79 | TRACER_LOGEVENT(FTrace_EVT_ipoint,6000,0); |
1371 | giacomo | 80 | |
1353 | giacomo | 81 | for (i=0;i<1000000000;i++); |
82 | |||
1568 | tullio | 83 | /** Store a TFrace stop event. */ |
1510 | giacomo | 84 | TRACER_LOGEVENT(FTrace_EVT_trace_stop,0,0); |
85 | |||
1568 | tullio | 86 | /** Stop the tracer. */ |
1353 | giacomo | 87 | FTrace_disable(); |
1293 | giacomo | 88 | kern_gettime(&end); |
89 | |||
90 | SUBTIMESPEC(&end,&start,&diff); |
||
91 | |||
92 | cprintf("Logged Time %d s %d us\n",(int)diff.tv_sec,(int)diff.tv_nsec/1000); |
||
93 | |||
1568 | tullio | 94 | /** Initialize the network for remotely saving the trace. */ |
1411 | giacomo | 95 | FTrace_OSD_init_udp(1, "192.168.1.10", "192.168.1.1"); |
1568 | tullio | 96 | |
97 | /** |
||
98 | * You may want to save the events to disk. In that case, simply change |
||
99 | * the network initialization instruction with the following line: |
||
100 | * |
||
101 | * FTrace_init_disk_writer("trace.dat", 0, NULL, NULL); |
||
102 | * |
||
103 | */ |
||
1293 | giacomo | 104 | |
1568 | tullio | 105 | /** Save the chunk. */ |
1372 | giacomo | 106 | FTrace_send_chunk(a, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_CYC); |
107 | FTrace_send_chunk(b, 0, FTRACE_CHUNK_FLAG_FREE | FTRACE_CHUNK_FLAG_JTN); |
||
1364 | giacomo | 108 | |
1293 | giacomo | 109 | return 0; |
110 | |||
111 | } |