63 public PecTraceParser(boolean allowUserInteraction) { |
65 public PecTraceParser(boolean allowUserInteraction) { |
64 super(); |
66 super(); |
65 this.allowUserInteraction = allowUserInteraction; |
67 this.allowUserInteraction = allowUserInteraction; |
66 } |
68 } |
67 |
69 |
68 private static final Map<Integer, String> eventTypeTable = new HashMap<Integer, String>(); |
70 private static final Map<Integer, String> EVENT_TYPE_TABLE = new HashMap<Integer, String>(); |
69 static { |
71 static { |
70 eventTypeTable.put(0x0,Messages.PecTraceParser_0); |
72 EVENT_TYPE_TABLE.put(0x0,Messages.PecTraceParser_0); |
71 eventTypeTable.put(0x1,Messages.PecTraceParser_1); |
73 EVENT_TYPE_TABLE.put(0x1,Messages.PecTraceParser_1); |
72 eventTypeTable.put(0x2,Messages.PecTraceParser_2); |
74 EVENT_TYPE_TABLE.put(0x2,Messages.PecTraceParser_2); |
73 eventTypeTable.put(0x3,Messages.PecTraceParser_3); |
75 EVENT_TYPE_TABLE.put(0x3,Messages.PecTraceParser_3); |
74 eventTypeTable.put(0x4, Messages.PecTraceParser_4); |
76 EVENT_TYPE_TABLE.put(0x4, Messages.PecTraceParser_4); |
75 eventTypeTable.put(0x5, Messages.PecTraceParser_5); |
77 EVENT_TYPE_TABLE.put(0x5, Messages.PecTraceParser_5); |
76 eventTypeTable.put(0x6, Messages.PecTraceParser_6); |
78 EVENT_TYPE_TABLE.put(0x6, Messages.PecTraceParser_6); |
77 eventTypeTable.put(INSTRUCTIONS_EXECUTED, Messages.PecTraceParser_7); |
79 EVENT_TYPE_TABLE.put(INSTRUCTIONS_EXECUTED, Messages.PecTraceParser_7); |
78 eventTypeTable.put(0x9, Messages.PecTraceParser_8); |
80 EVENT_TYPE_TABLE.put(0x9, Messages.PecTraceParser_8); |
79 eventTypeTable.put(0xA, Messages.PecTraceParser_9); |
81 EVENT_TYPE_TABLE.put(0xA, Messages.PecTraceParser_9); |
80 eventTypeTable.put(0xB, Messages.PecTraceParser_10); |
82 EVENT_TYPE_TABLE.put(0xB, Messages.PecTraceParser_10); |
81 eventTypeTable.put(0xC, Messages.PecTraceParser_11); |
83 EVENT_TYPE_TABLE.put(0xC, Messages.PecTraceParser_11); |
82 eventTypeTable.put(0xD, Messages.PecTraceParser_12); |
84 EVENT_TYPE_TABLE.put(0xD, Messages.PecTraceParser_12); |
83 eventTypeTable.put(0xF, Messages.PecTraceParser_13); |
85 EVENT_TYPE_TABLE.put(0xF, Messages.PecTraceParser_13); |
84 eventTypeTable.put(0x10, Messages.PecTraceParser_14); |
86 EVENT_TYPE_TABLE.put(0x10, Messages.PecTraceParser_14); |
85 eventTypeTable.put(0x11, Messages.PecTraceParser_15); |
87 EVENT_TYPE_TABLE.put(0x11, Messages.PecTraceParser_15); |
86 eventTypeTable.put(0x12, Messages.PecTraceParser_16); |
88 EVENT_TYPE_TABLE.put(0x12, Messages.PecTraceParser_16); |
87 eventTypeTable.put(0x20, Messages.PecTraceParser_17); |
89 EVENT_TYPE_TABLE.put(0x20, Messages.PecTraceParser_17); |
88 eventTypeTable.put(0x21, Messages.PecTraceParser_18); |
90 EVENT_TYPE_TABLE.put(0x21, Messages.PecTraceParser_18); |
89 eventTypeTable.put(0x22, Messages.PecTraceParser_19); |
91 EVENT_TYPE_TABLE.put(0x22, Messages.PecTraceParser_19); |
90 eventTypeTable.put(0xFF, Messages.PecTraceParser_20); |
92 EVENT_TYPE_TABLE.put(0xFF, Messages.PecTraceParser_20); |
91 eventTypeTable.put(CPU_CLOCK_TICK_DIV64, Messages.PecTraceParser_21); |
93 EVENT_TYPE_TABLE.put(CPU_CLOCK_TICK_DIV64, Messages.PecTraceParser_21); |
92 eventTypeTable.put(DUMMY_MIPS_ID, PecTrace.MIPS_NAME); |
94 EVENT_TYPE_TABLE.put(DUMMY_MIPS_ID, PecTrace.MIPS_NAME); |
|
95 EVENT_TYPE_TABLE.put(DUMMY_CPU_CLOCK_ID, Messages.PecTraceParser_23); |
93 } |
96 } |
94 |
97 |
95 /* (non-Javadoc) |
98 /* (non-Javadoc) |
96 * @see com.nokia.carbide.cpp.internal.pi.model.Parser#parse(java.io.File) |
99 * @see com.nokia.carbide.cpp.internal.pi.model.Parser#parse(java.io.File) |
97 */ |
100 */ |
121 if(debug)System.out.println("PEC trace version:"+this.traceVersion); //$NON-NLS-1$ |
124 if(debug)System.out.println("PEC trace version:"+this.traceVersion); //$NON-NLS-1$ |
122 |
125 |
123 int firstData = dis.readUnsignedByte(); |
126 int firstData = dis.readUnsignedByte(); |
124 int secondData = dis.readUnsignedByte(); |
127 int secondData = dis.readUnsignedByte(); |
125 int thirdData = CPU_CLOCK_TICK_DIV64; |
128 int thirdData = CPU_CLOCK_TICK_DIV64; |
126 |
129 |
127 if (allowUserInteraction && (firstData == INSTRUCTIONS_EXECUTED || secondData == INSTRUCTIONS_EXECUTED)){ |
130 if (this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
128 Display.getDefault().syncExec( new Runnable() { |
131 if (allowUserInteraction && (firstData == INSTRUCTIONS_EXECUTED || secondData == INSTRUCTIONS_EXECUTED)){ |
129 |
132 Display.getDefault().syncExec( new Runnable() { |
130 public void run () { |
133 |
131 // in future, if we don't want to have a dialog in the core parser class |
134 public void run () { |
132 // we could call into an interface which ProcessorSpeedInputDialog would have to implement |
135 // in future, if we don't want to have a dialog in the core parser class |
133 ProcessorSpeedInputDialog dialog = new ProcessorSpeedInputDialog( |
136 // we could call into an interface which ProcessorSpeedInputDialog would have to implement |
134 PlatformUI.getWorkbench() |
137 ProcessorSpeedInputDialog dialog = new ProcessorSpeedInputDialog( |
135 .getActiveWorkbenchWindow().getShell()); |
138 PlatformUI.getWorkbench() |
136 if (dialog.open() == Window.OK){ |
139 .getActiveWorkbenchWindow().getShell()); |
137 processorSpeed = dialog.getIntValue(); |
140 if (dialog.open() == Window.OK){ |
138 mipsEnabled = true; |
141 processorSpeed = dialog.getIntValue(); |
|
142 mipsEnabled = true; |
|
143 } |
139 } |
144 } |
140 } |
145 }); |
141 }); |
146 } |
142 |
147 } |
143 |
148 |
144 } |
149 // >=Bappea_V1.25_PEC |
145 |
150 else { |
146 Integer[] valueTypeVector = new Integer[mipsEnabled ? 4 : 3]; |
151 if (firstData == INSTRUCTIONS_EXECUTED || secondData == INSTRUCTIONS_EXECUTED) { |
|
152 mipsEnabled = true; |
|
153 } |
|
154 |
|
155 long cpuClockRate = readCpuClockRate(dis); |
|
156 if(cpuClockRate > 0){ |
|
157 // Hz => MHz |
|
158 trace.setCpuClockRate((int) cpuClockRate / 1000000); |
|
159 } |
|
160 |
|
161 } |
|
162 |
|
163 int graphCount = 0; |
|
164 |
|
165 if (this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
166 graphCount = 4; |
|
167 } |
|
168 // >=Bappea_V1.25_PEC |
|
169 else { |
|
170 graphCount = 5; |
|
171 } |
|
172 |
|
173 Integer[] valueTypeVector = new Integer[mipsEnabled ? graphCount : 3]; |
|
174 |
147 valueTypeVector[0] = Integer.valueOf(firstData); |
175 valueTypeVector[0] = Integer.valueOf(firstData); |
148 valueTypeVector[1] = Integer.valueOf(secondData); |
176 valueTypeVector[1] = Integer.valueOf(secondData); |
149 // this type is always the cpu clock tick div 64 |
177 // this type is always the cpu clock tick div 64 |
150 valueTypeVector[2] = Integer.valueOf(thirdData); |
178 valueTypeVector[2] = Integer.valueOf(thirdData); |
151 |
179 |
152 if (mipsEnabled){ |
180 if (mipsEnabled){ |
153 valueTypeVector[3] = DUMMY_MIPS_ID; |
181 valueTypeVector[3] = DUMMY_MIPS_ID; |
|
182 // >=Bappea_V1.25_PEC |
|
183 if (!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) |
|
184 { |
|
185 valueTypeVector[4] = DUMMY_CPU_CLOCK_ID; |
|
186 } |
154 } |
187 } |
155 |
188 |
156 trace.setValueTypes(this.parseValueTypes(valueTypeVector)); |
189 trace.setValueTypes(this.parseValueTypes(valueTypeVector)); |
157 |
190 |
158 PecSample s = null; |
191 PecSample s = null; |
169 } |
202 } |
170 } |
203 } |
171 |
204 |
172 private PecSample readSample(DataInputStream dis,PecSample prevSample) throws IOException |
205 private PecSample readSample(DataInputStream dis,PecSample prevSample) throws IOException |
173 { |
206 { |
174 int headerByte = (dis.readByte() << 24) >>> 24; |
207 int headerByte = 0; |
|
208 int negBitOffset = 0; |
|
209 int sampleBitOffset = 0; |
|
210 |
|
211 if (this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
212 headerByte = (dis.readByte() << 24) >>> 24; |
|
213 } |
|
214 // >=Bappea_V1.25_PEC |
|
215 else { |
|
216 int headerByte1 = (dis.readByte() << 24) >>> 24; |
|
217 int headerByte2 = (dis.readByte() << 24) >>> 24; |
|
218 headerByte = ((headerByte1) | (headerByte2) << 8); |
|
219 negBitOffset = 1; |
|
220 sampleBitOffset = 2; |
|
221 } |
|
222 |
175 int neg0 = 0; |
223 int neg0 = 0; |
176 int neg1 = 0; |
224 int neg1 = 0; |
177 int neg2 = 0; |
225 int neg2 = 0; |
|
226 int neg3 = 0; |
178 |
227 |
179 int prev0 = 0; |
228 int prev0 = 0; |
180 int prev1 = 0; |
229 int prev1 = 0; |
181 int prev2 = 0; |
230 int prev2 = 0; |
|
231 int prev3 = 0; |
182 |
232 |
183 if(prevSample != null) |
233 if(prevSample != null) |
184 { |
234 { |
185 prev0 = prevSample.values[0]; |
235 prev0 = prevSample.values[0]; |
186 prev1 = prevSample.values[1]; |
236 prev1 = prevSample.values[1]; |
187 prev2 = prevSample.values[2]/64; |
237 prev2 = prevSample.values[2]/64; |
|
238 prev3 = processorSpeed; |
188 } |
239 } |
189 if(debug) if(this.time > 7820 && this.time < 7830) System.out.println("header: "+Long.toHexString(headerByte)+" = "+Integer.toBinaryString(headerByte)); //$NON-NLS-1$//$NON-NLS-2$ |
240 if(debug) if(this.time > 7820 && this.time < 7830) System.out.println("header: "+Long.toHexString(headerByte)+" = "+Integer.toBinaryString(headerByte)); //$NON-NLS-1$//$NON-NLS-2$ |
190 |
241 |
191 if( ((headerByte >>> 7)&1) != 0) |
242 if( ((headerByte >>> 7 + negBitOffset + sampleBitOffset)&1) != 0) |
192 { |
243 { |
193 neg0 = 1; |
244 neg0 = 1; |
194 } |
245 } |
195 |
246 |
196 if( ((headerByte >>> 6)&1) != 0) |
247 if( ((headerByte >>> 6 + negBitOffset + sampleBitOffset)&1) != 0) |
197 { |
248 { |
198 neg1 = 1; |
249 neg1 = 1; |
199 } |
250 } |
200 |
251 |
201 if( ((headerByte >>> 5)&1) != 0) |
252 if( ((headerByte >>> 5 + negBitOffset + sampleBitOffset)&1) != 0) |
202 { |
253 { |
203 neg2 = 1; |
254 neg2 = 1; |
204 } |
255 } |
205 |
256 |
206 int len0 = (((headerByte >> 3) << 30) >>> 30)+1; |
257 // >=Bappea_V1.25_PEC |
207 int len1 = (((headerByte >> 1) << 30) >>> 30)+1; |
258 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD) && ((headerByte >>> 7)&1) != 0) { |
208 int len2 = ((((headerByte) << 31) >>> 31)+1)*2; |
259 neg3 = 1; |
209 |
260 } |
210 if(debug) if(this.time > 7820 && this.time < 7830) System.out.println("T:"+this.time+" len0:"+len0+" len1:"+len1+" len2:"+len2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
261 |
211 if(debug) if(this.time > 7900 && this.time < 7900) System.out.println("H: "+Integer.toBinaryString(headerByte)+" N0:"+neg0+" N1:"+neg1+" N2:"+neg2); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ |
262 int len0 = (((headerByte >> 3 + sampleBitOffset) << 30) >>> 30)+1; |
|
263 int len1 = (((headerByte >> 1 + sampleBitOffset) << 30) >>> 30)+1; |
|
264 int len2 = ((((headerByte >> sampleBitOffset) << 31) >>> 31)+1)*2; |
|
265 int len3 = -1; |
|
266 // >=Bappea_V1.25_PEC |
|
267 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
268 len3 = ((((headerByte) << 30) >>> 30)+1); |
|
269 } |
|
270 |
|
271 if(debug) { |
|
272 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
273 if(debug) if(this.time > 7820 && this.time < 7830) System.out.println("T:"+this.time+" len0:"+len0+" len1:"+len1+" len2:"+len2+" len3:"+len3); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
|
274 if(debug) if(this.time > 7900 && this.time < 7900) System.out.println("H: "+Integer.toBinaryString(headerByte)+" N0:"+neg0+" N1:"+neg1+" N2:"+neg2+" N3:"+neg3); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
|
275 |
|
276 } else { |
|
277 if(debug) if(this.time > 7820 && this.time < 7830) System.out.println("T:"+this.time+" len0:"+len0+" len1:"+len1+" len2:"+len2); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
278 if(debug) if(this.time > 7900 && this.time < 7900) System.out.println("H: "+Integer.toBinaryString(headerByte)+" N0:"+neg0+" N1:"+neg1+" N2:"+neg2); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ |
|
279 } |
|
280 } |
212 |
281 |
213 long val0 = readVal(neg0,len0,dis); |
282 long val0 = readVal(neg0,len0,dis); |
214 long val1 = readVal(neg1,len1,dis); |
283 long val1 = readVal(neg1,len1,dis); |
215 long val2 = readVal(neg2,len2,dis); |
284 long val2 = readVal(neg2,len2,dis); |
216 |
285 long val3 = -1; |
217 if(debug) if(this.time > 7820 && this.time < 7900) System.out.println("READ T:"+this.time+" V0:"+Long.toHexString(val0)+" V1:"+Long.toHexString(val1)+" V2:"+Long.toHexString(val2)); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ |
286 |
|
287 // >=Bappea_V1.25_PEC |
|
288 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
289 if (mipsEnabled) { |
|
290 val3 = readVal(neg3,len3,dis); |
|
291 } |
|
292 } |
|
293 |
|
294 if(debug) { |
|
295 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
296 if(this.time > 7820 && this.time < 7900) System.out.println("READ T:"+this.time+" V0:"+Long.toHexString(val0)+" V1:"+Long.toHexString(val1)+" V2:"+Long.toHexString(val2)+" V3:"+Long.toHexString(val3)); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
|
297 } else { |
|
298 if(this.time > 7820 && this.time < 7900) System.out.println("READ T:"+this.time+" V0:"+Long.toHexString(val0)+" V1:"+Long.toHexString(val1)+" V2:"+Long.toHexString(val2)); //$NON-NLS-1$//$NON-NLS-2$//$NON-NLS-3$ //$NON-NLS-4$ |
|
299 } |
|
300 } |
|
301 |
218 val0 = prev0-val0; |
302 val0 = prev0-val0; |
219 val1 = prev1-val1; |
303 val1 = prev1-val1; |
220 val2 = prev2-val2; |
304 val2 = prev2-val2; |
221 |
305 |
|
306 // >=Bappea_V1.25_PEC |
|
307 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
308 val3 = prev3-val3; |
|
309 processorSpeed = (int)val3; |
|
310 } |
|
311 |
222 int[] values; |
312 int[] values; |
223 if (mipsEnabled){ |
313 if (!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD) && mipsEnabled) { |
|
314 values = new int[]{(int)val0,(int)val1,((int)val2)*64, (int)((val3 / 1000000) * val1 / (val2*64)), ((int)(val3 / 1000000))}; |
|
315 } else if (mipsEnabled) { |
224 values = new int[]{(int)val0,(int)val1,((int)val2)*64, (int)(processorSpeed * val1 / (val2*64))}; |
316 values = new int[]{(int)val0,(int)val1,((int)val2)*64, (int)(processorSpeed * val1 / (val2*64))}; |
225 } else { |
317 } else { |
226 values = new int[]{(int)val0,(int)val1,((int)val2)*64}; |
318 values = new int[]{(int)val0,(int)val1,((int)val2)*64}; |
227 } |
319 } |
228 |
320 |
229 PecSample ps = new PecSample(values, this.time); |
321 PecSample ps = new PecSample(values, this.time); |
230 |
322 |
231 if(debug) if(this.time > 7820 && this.time < 7900) System.out.println("T:"+this.time+" V0:"+Long.toHexString(val0)+" V1:"+Long.toHexString(val1)+" V2:"+Long.toHexString(val2)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
323 if (debug) { |
232 if(debug) if(this.time > 7820 && this.time < 7900) System.out.println("T:"+this.time+" "+val0+" "+val1+" "+val2); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ |
324 if(!this.traceVersion.equals(DATA_FORMAT_VERSION_OLD)) { |
|
325 if(this.time > 7820 && this.time < 7900) System.out.println("T:"+this.time+" V0:"+Long.toHexString(val0)+" V1:"+Long.toHexString(val1)+" V2:"+Long.toHexString(val2)+" V3:"+Long.toHexString(val3)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
|
326 if(this.time > 7820 && this.time < 7900) System.out.println("T:"+this.time+" "+val0+" "+val1+" "+val2+" "+val3); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4//$NON-NLS-5$$ |
|
327 } else { |
|
328 if(this.time > 7820 && this.time < 7900) System.out.println("T:"+this.time+" V0:"+Long.toHexString(val0)+" V1:"+Long.toHexString(val1)+" V2:"+Long.toHexString(val2)); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ |
|
329 if(this.time > 7820 && this.time < 7900) System.out.println("T:"+this.time+" "+val0+" "+val1+" "+val2); //$NON-NLS-1$//$NON-NLS-2$ //$NON-NLS-3$//$NON-NLS-4$ |
|
330 } |
|
331 } |
233 this.time++; |
332 this.time++; |
234 |
333 |
235 return ps; |
334 return ps; |
236 } |
335 } |
237 |
336 |