Rev 1492 | Go to most recent revision | Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
1491 | 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> |
||
10 | * |
||
11 | * ReTiS Lab (Scuola Superiore S.Anna - Pisa - Italy) |
||
12 | * |
||
13 | * http://www.sssup.it |
||
14 | * http://retis.sssup.it |
||
15 | * http://shark.sssup.it |
||
16 | */ |
||
17 | |||
18 | #include <stdio.h> |
||
19 | #include <unistd.h> |
||
20 | #include <stdlib.h> |
||
21 | #include <string.h> |
||
22 | |||
23 | #include <FTrace.h> |
||
24 | |||
25 | #define READ_BUFFER 2000 |
||
26 | #define DELTA_BUFFER 100 |
||
27 | |||
28 | int main(int argc, char *argv[]) |
||
29 | { |
||
30 | |||
31 | char buffer[READ_BUFFER+DELTA_BUFFER]; |
||
32 | void *p, *last; |
||
33 | int n,delta,size; |
||
34 | |||
35 | unsigned long long ev = 0, tsc_value; |
||
36 | |||
37 | FILE *input_file; |
||
38 | |||
39 | if (argc < 2) { |
||
40 | printf("%s: Enter the input file name [%s filename]\n",argv[0],argv[0]); |
||
41 | exit(1); |
||
42 | } |
||
43 | |||
44 | input_file = fopen(argv[1],"rb"); |
||
45 | |||
46 | last = buffer + READ_BUFFER; |
||
47 | |||
48 | while(!feof(input_file)) { |
||
49 | |||
50 | //move remaining byte |
||
51 | delta = (unsigned int)(buffer) + READ_BUFFER - (unsigned int)(last); |
||
52 | if (delta > 0) memcpy(buffer,last,delta); |
||
53 | |||
54 | n = fread(buffer+delta,1,READ_BUFFER+10,input_file); |
||
55 | fseek(input_file,-(delta+10),SEEK_CUR); |
||
56 | |||
57 | p = buffer; |
||
58 | |||
59 | while ((unsigned int)(p) + 16 <= (unsigned int)(buffer + READ_BUFFER) && |
||
60 | (unsigned int)(p) + 16 <= (unsigned int)(buffer + n + delta)) { |
||
61 | |||
62 | switch (*(unsigned short int *)(p)) { |
||
63 | |||
64 | case FTrace_EVT_ipoint: |
||
65 | printf("%d ",*(unsigned short int *)(p+2)); |
||
66 | break; |
||
67 | |||
68 | case FTrace_EVT_trace_start: |
||
69 | printf("0 "); |
||
70 | break; |
||
71 | |||
72 | case FTrace_EVT_trace_stop: |
||
73 | printf("1 "); |
||
74 | break; |
||
75 | |||
76 | case FTrace_EVT_timer_wakeup_start: |
||
77 | case FTrace_EVT_interrupt_start: |
||
78 | printf("2 "); |
||
79 | break; |
||
80 | |||
81 | |||
82 | case FTrace_EVT_timer_wakeup_end: |
||
83 | case FTrace_EVT_interrupt_end: |
||
84 | printf("3 "); |
||
85 | break; |
||
86 | |||
87 | case FTrace_EVT_context_switch: |
||
88 | printf("4 "); |
||
89 | break; |
||
90 | |||
91 | } |
||
92 | |||
93 | tsc_value = (unsigned long long)(*(unsigned int *)(p+4)) << 32; |
||
94 | tsc_value += (unsigned long long)(*(unsigned int *)(p+8)); |
||
95 | |||
96 | printf("%llu ",tsc_value); |
||
97 | |||
98 | size = 16; |
||
99 | |||
100 | ev++; |
||
101 | |||
102 | p += 16; |
||
103 | |||
104 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
105 | |||
106 | last = p; |
||
107 | |||
108 | } |
||
109 | |||
110 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
111 | |||
112 | } |
||
113 | |||
114 | fclose(input_file); |
||
115 | |||
116 | return 0; |
||
117 | |||
118 | } |
||
119 |