Rev 1491 | Rev 1494 | Go to most recent revision | Details | Compare with Previous | 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; |
||
1492 | giacomo | 33 | int n,delta,size,tsc; |
1491 | giacomo | 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 | |||
1492 | giacomo | 62 | tsc = 0; |
63 | |||
1491 | giacomo | 64 | switch (*(unsigned short int *)(p)) { |
65 | |||
66 | case FTrace_EVT_ipoint: |
||
67 | printf("%d ",*(unsigned short int *)(p+2)); |
||
1492 | giacomo | 68 | tsc = 1; |
1491 | giacomo | 69 | break; |
70 | |||
71 | case FTrace_EVT_trace_start: |
||
72 | printf("0 "); |
||
1492 | giacomo | 73 | tsc = 1; |
1491 | giacomo | 74 | break; |
75 | |||
76 | case FTrace_EVT_trace_stop: |
||
77 | printf("1 "); |
||
1492 | giacomo | 78 | tsc = 1; |
1491 | giacomo | 79 | break; |
80 | |||
81 | case FTrace_EVT_timer_wakeup_start: |
||
82 | case FTrace_EVT_interrupt_start: |
||
83 | printf("2 "); |
||
1492 | giacomo | 84 | tsc = 1; |
1491 | giacomo | 85 | break; |
86 | |||
87 | |||
88 | case FTrace_EVT_timer_wakeup_end: |
||
89 | case FTrace_EVT_interrupt_end: |
||
90 | printf("3 "); |
||
1492 | giacomo | 91 | tsc = 1; |
1491 | giacomo | 92 | break; |
93 | |||
94 | case FTrace_EVT_context_switch: |
||
95 | printf("4 "); |
||
1492 | giacomo | 96 | tsc = 1; |
1491 | giacomo | 97 | break; |
98 | |||
99 | } |
||
100 | |||
101 | tsc_value = (unsigned long long)(*(unsigned int *)(p+4)) << 32; |
||
102 | tsc_value += (unsigned long long)(*(unsigned int *)(p+8)); |
||
103 | |||
1492 | giacomo | 104 | if (tsc == 1) { |
1491 | giacomo | 105 | |
1492 | giacomo | 106 | printf("%llu ",tsc_value); |
107 | |||
108 | switch (*(unsigned short int *)(p)) { |
||
109 | |||
110 | case FTrace_EVT_interrupt_start: |
||
111 | printf("%d ",*(unsigned short int *)(p+2)); |
||
112 | break; |
||
113 | |||
114 | case FTrace_EVT_timer_wakeup_start: |
||
115 | printf("%d ",0); |
||
116 | break; |
||
117 | |||
118 | case FTrace_EVT_timer_wakeup_end: |
||
119 | case FTrace_EVT_interrupt_end: |
||
120 | printf("%d ",*(unsigned short int *)(p+2)); |
||
121 | break; |
||
122 | |||
123 | case FTrace_EVT_context_switch: |
||
124 | printf("%d ",*(unsigned short int *)(p+2)); |
||
125 | break; |
||
126 | |||
127 | } |
||
128 | |||
129 | printf("\n"); |
||
130 | |||
131 | } |
||
132 | |||
1491 | giacomo | 133 | size = 16; |
134 | |||
135 | ev++; |
||
136 | |||
137 | p += 16; |
||
138 | |||
139 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
140 | |||
141 | last = p; |
||
142 | |||
143 | } |
||
144 | |||
145 | if ((unsigned int)(p) + 10 > (unsigned int)(buffer + n + delta)) break; |
||
146 | |||
147 | } |
||
148 | |||
149 | fclose(input_file); |
||
150 | |||
151 | return 0; |
||
152 | |||
153 | } |
||
154 |