23 import java.util.Enumeration; |
23 import java.util.Enumeration; |
24 import java.util.Vector; |
24 import java.util.Vector; |
25 |
25 |
26 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; |
26 import com.nokia.carbide.cpp.internal.pi.analyser.NpiInstanceRepository; |
27 import com.nokia.carbide.cpp.internal.pi.model.FunctionResolver; |
27 import com.nokia.carbide.cpp.internal.pi.model.FunctionResolver; |
|
28 import com.nokia.carbide.cpp.internal.pi.model.GenericEvent; |
28 import com.nokia.carbide.cpp.internal.pi.model.GenericTrace; |
29 import com.nokia.carbide.cpp.internal.pi.model.GenericTrace; |
29 import com.nokia.carbide.cpp.internal.pi.model.ParsedTraceData; |
30 import com.nokia.carbide.cpp.internal.pi.model.ParsedTraceData; |
30 import com.nokia.carbide.cpp.internal.pi.model.Parser; |
31 import com.nokia.carbide.cpp.internal.pi.model.Parser; |
31 import com.nokia.carbide.cpp.internal.pi.model.TraceDataRepository; |
32 import com.nokia.carbide.cpp.internal.pi.model.TraceDataRepository; |
32 import com.nokia.carbide.cpp.internal.pi.utils.QuickSortImpl; |
33 import com.nokia.carbide.cpp.internal.pi.utils.QuickSortImpl; |
213 catch (Exception e) |
214 catch (Exception e) |
214 { |
215 { |
215 // end of trace |
216 // end of trace |
216 } |
217 } |
217 } |
218 } |
218 else if (traceVersion.indexOf("ITT_V1.22") != -1 || traceVersion.indexOf("ITT_V2.01") != -1) //$NON-NLS-1$ //$NON-NLS-2$ |
219 else if (traceVersion.indexOf("ITT_V1.22") != -1 ) //$NON-NLS-1$ |
219 { |
220 { |
220 boolean isVersion201 = traceVersion.indexOf("ITT_V2.01") != -1; //$NON-NLS-1$ |
221 this.trace122 = parse122IttTrace(traceArray, false); |
221 this.trace122 = parse122IttTrace(traceArray, isVersion201); |
222 } |
|
223 else if (traceVersion.indexOf("ITT_V2.00") != -1 || traceVersion.indexOf("ITT_V2.01") != -1) //$NON-NLS-1$ //$NON-NLS-2$ |
|
224 { |
|
225 this.trace122 = parse122IttTrace(traceArray, true); |
222 } |
226 } |
223 else |
227 else |
224 { |
228 { |
225 GeneralMessages.showErrorMessage(Messages.getString("IttTraceParser.unsupportedTrace")+traceVersion); //$NON-NLS-1$ |
229 GeneralMessages.showErrorMessage(Messages.getString("IttTraceParser.unsupportedTrace")+traceVersion); //$NON-NLS-1$ |
226 } |
230 } |
227 } |
231 } |
228 |
232 |
229 private IttTrace122 parse122IttTrace(byte[] traceArray, boolean isVersion201) |
233 private IttTrace122 parse122IttTrace(byte[] traceArray, boolean isVersion2x) |
230 { |
234 { |
231 IttTrace122 trace = new IttTrace122(); |
235 IttTrace122 trace = new IttTrace122(); |
232 |
236 |
233 int ptr = 0; |
237 int ptr = 0; |
234 |
238 |
235 // read the first header |
239 // read the first header |
236 byte length = traceArray[ptr++]; |
240 byte length = traceArray[ptr++]; |
237 String txt = new String(traceArray,ptr,length);ptr+=length; |
241 String txt = new String(traceArray,ptr,length);ptr+=length; |
238 |
242 |
239 Vector sortables = new Vector(); |
|
240 |
|
241 class SortableString implements Sortable |
243 class SortableString implements Sortable |
242 { |
244 { |
243 String string; |
245 String string; |
244 long value; |
246 long value; |
245 long startAddress; |
247 long startAddress; |
246 long endAddress; |
248 long endAddress; |
247 double samplingTime; |
249 double sampleStartTime; |
|
250 double sampleRemoveTime; |
248 |
251 |
249 public long valueOf() |
252 public long valueOf() |
250 { |
253 { |
251 return this.value; |
254 return this.value; |
252 } |
255 } |
253 } |
256 } |
254 |
257 Vector<SortableString> sortables = new Vector<SortableString>(); |
255 int adjust = isVersion201 ? 12 : 8; |
258 |
|
259 |
|
260 |
|
261 int adjust = isVersion2x ? 12 : 8; |
256 |
262 |
257 while(ptr < traceArray.length) |
263 while(ptr < traceArray.length) |
258 { |
264 { |
259 IttEvent122 event = new IttEvent122(); |
265 IttEvent122 event = new IttEvent122(); |
260 try |
266 try |
282 len |= (getUnsignedByte(traceArray[ptr++])<<16); |
288 len |= (getUnsignedByte(traceArray[ptr++])<<16); |
283 len |= (getUnsignedByte(traceArray[ptr++])<<24); |
289 len |= (getUnsignedByte(traceArray[ptr++])<<24); |
284 len = (len<<32)>>>32; |
290 len = (len<<32)>>>32; |
285 event.binaryLength = len; |
291 event.binaryLength = len; |
286 |
292 |
287 if (isVersion201) { |
293 if (isVersion2x) { |
288 long time = getUnsignedByte(traceArray[ptr++]); |
294 long time = getUnsignedByte(traceArray[ptr++]); |
289 time |= (getUnsignedByte(traceArray[ptr++])<<8); |
295 time |= (getUnsignedByte(traceArray[ptr++])<<8); |
290 time |= (getUnsignedByte(traceArray[ptr++])<<16); |
296 time |= (getUnsignedByte(traceArray[ptr++])<<16); |
291 time |= (getUnsignedByte(traceArray[ptr++])<<24); |
297 time |= (getUnsignedByte(traceArray[ptr++])<<24); |
292 time = (time<<32)>>>32; |
298 time = (time<<32)>>>32; |
295 event.eventTime = 0.0; |
301 event.eventTime = 0.0; |
296 } |
302 } |
297 |
303 |
298 event.createBinary(); |
304 event.createBinary(); |
299 |
305 |
300 trace.addEvent(event); |
306 trace.addEvent(event, isVersion2x); |
301 if (debug) |
|
302 { |
|
303 SortableString s = new SortableString(); |
|
304 s.string = Long.toHexString(adr)+" - "+Long.toHexString(adr+len)+" \t "+event.binary.binaryName+" length:"+len; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
305 s.value = adr; |
|
306 s.startAddress = adr; |
|
307 s.endAddress = adr+len; |
|
308 s.samplingTime = event.eventTime; |
|
309 sortables.add(s); |
|
310 } |
|
311 } |
307 } |
312 |
308 |
313 if (debug) |
309 if (debug) |
314 { |
310 { |
|
311 for(GenericEvent ge : trace.getEvents()) |
|
312 { |
|
313 IttEvent122 ie = (IttEvent122)ge; |
|
314 SortableString s = new SortableString(); |
|
315 if(isVersion2x){ |
|
316 s.string = Long.toHexString(ie.binaryLocation)+" - "+Long.toHexString(ie.binaryLocation+ie.binaryLength)+" \t "+ie.getBinary().getBinaryName()+" length:"+ie.binaryLength+"\tEvent Start Time: "+ie.eventTime+"\tEvent End Time: "+ie.eventEndTime; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$ //$NON-NLS-5$ |
|
317 }else{ |
|
318 s.string = Long.toHexString(ie.binaryLocation)+" - "+Long.toHexString(ie.binaryLocation+ie.binaryLength)+" \t "+ie.getBinary().getBinaryName()+" length:"+ie.binaryLength; //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ |
|
319 } |
|
320 |
|
321 s.value = ie.binaryLocation; |
|
322 s.startAddress = ie.binaryLocation; |
|
323 s.endAddress = ie.binaryLocation+ie.binaryLength; |
|
324 s.sampleStartTime = ie.eventTime; |
|
325 s.sampleRemoveTime = ie.eventEndTime; |
|
326 sortables.add(s); |
|
327 } |
315 QuickSortImpl.sort(sortables); |
328 QuickSortImpl.sort(sortables); |
316 Enumeration e = sortables.elements(); |
329 Enumeration<SortableString> e = sortables.elements(); |
317 SortableString prev = null; |
330 SortableString prev = null; |
318 while (e.hasMoreElements()) |
331 while (e.hasMoreElements()) |
319 { |
332 { |
320 SortableString s = (SortableString)e.nextElement(); |
333 SortableString s = (SortableString)e.nextElement(); |
321 if (prev != null) |
334 if (prev != null) |
322 { |
335 { |
323 // System.out.println("Empty:"+(s.startAddress - prev.endAddress)+" bytes"); |
336 if(isVersion2x){ |
324 if (s.startAddress < prev.endAddress) { |
337 if(prev.sampleRemoveTime <= 0){ |
325 System.out.println(Messages.getString("IttTraceParser.debugOverlapping")); //$NON-NLS-1$ |
338 prev.sampleRemoveTime = Double.MAX_VALUE; |
326 System.out.println(Messages.getString("IttTraceParser.previous") + prev.string); //$NON-NLS-1$ |
339 } |
327 System.out.println(Messages.getString("IttTraceParser.this") + s.string); //$NON-NLS-1$ |
340 if(s.sampleRemoveTime <= 0){ |
|
341 s.sampleRemoveTime = Double.MAX_VALUE; |
|
342 } |
|
343 if (s.startAddress < prev.endAddress && s.sampleStartTime < prev.sampleRemoveTime && s.sampleRemoveTime > prev.startAddress) { |
|
344 System.out.println(Messages.getString("IttTraceParser.debugOverlapping")); //$NON-NLS-1$ |
|
345 System.out.println(Messages.getString("IttTraceParser.previous") + prev.string); //$NON-NLS-1$ |
|
346 System.out.println(Messages.getString("IttTraceParser.this") + s.string); //$NON-NLS-1$ |
|
347 } |
|
348 }else{ |
|
349 if (s.startAddress < prev.endAddress) { |
|
350 System.out.println(Messages.getString("IttTraceParser.debugOverlapping")); //$NON-NLS-1$ |
|
351 System.out.println(Messages.getString("IttTraceParser.previous") + prev.string); //$NON-NLS-1$ |
|
352 System.out.println(Messages.getString("IttTraceParser.this") + s.string); //$NON-NLS-1$ |
|
353 } |
328 } |
354 } |
|
355 |
329 } |
356 } |
330 System.out.println(s.string); |
357 System.out.println(s.string); |
331 prev = s; |
358 prev = s; |
332 } |
359 } |
333 } |
360 } |
429 public Enumeration getSamples() |
456 public Enumeration getSamples() |
430 { |
457 { |
431 return this.samples.elements(); |
458 return this.samples.elements(); |
432 } |
459 } |
433 |
460 |
434 private GenericTrace getTrace() |
461 public GenericTrace getTrace() |
435 { |
462 { |
436 if (this.trace122 == null) |
463 if (this.trace122 == null) |
437 { |
464 { |
438 IttTrace trace = new IttTrace(); |
465 IttTrace trace = new IttTrace(); |
439 Enumeration sEnum = this.samples.elements(); |
466 Enumeration sEnum = this.samples.elements(); |