Monster fix: TMF model update + corresponding LTTng adaptations + JUnits
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng / src / org / eclipse / linuxtools / lttng / jni / JniTrace.java
1 package org.eclipse.linuxtools.lttng.jni;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
4 *
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
9 *
10 * Contributors:
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
13
14
15 import java.util.HashMap;
16 import java.util.Iterator;
17 import java.util.PriorityQueue;
18
19 /**
20 * <b><u>JniTrace</u></b>
21 * <p>
22 * This is the top level class in the JNI. It provides access to the
23 * LttTrace C structure in java.
24 * <p>
25 * Most important fields in the JniTrace are :
26 * <ul>
27 * <li>a JniTrace path (a trace <b>directory</b>)
28 * <li>a HashMap of tracefiles that exists in this trace
29 * </ul>
30 */
31 public class JniTrace extends Jni_C_Common {
32
33 private final static boolean DEFAULT_LTT_DEBUG = false;
34
35 // Internal C pointer of the JniTrace used in LTT
36 private Jni_C_Pointer thisTracePtr = new Jni_C_Pointer();
37
38 // Data we should populate from LTT
39 // Note that all type have been scaled up as there is no "unsigned" in java
40 // This might be a problem about "unsigned long" as there is no equivalent
41 // in java
42
43 private String tracepath = ""; // Path of the trace. Should be a directory (like : /tmp/traceX)
44 private int cpuNumber = 0;
45 private long archType = 0;
46 private long archVariant = 0;
47 private short archSize = 0;
48 private short lttMajorVersion = 0;
49 private short lttMinorVersion = 0;
50 private short flightRecorder = 0;
51 private long freqScale = 0;
52 private long startFreq = 0;
53 private long startTimestampCurrentCounter = 0;
54 private long startMonotonic = 0;
55 private JniTime startTime = null;
56 private JniTime startTimeFromTimestampCurrentCounter = null;
57
58 // This Map holds a reference to the tracefiles owned by this trace
59 private HashMap<String, JniTracefile> tracefilesMap = null;
60 // The priority queue (similar to heap) hold events
61 private PriorityQueue<JniEvent> eventsHeap = null;
62
63 // This variable will hold the content of the "last" event we read
64 private JniEvent currentEvent = null;
65
66 // Should we print debug in the C library or not?
67 private boolean printLttDebug = DEFAULT_LTT_DEBUG;
68
69 // Open/close native functions
70 private native long ltt_openTrace(String pathname, boolean printDebug);
71 private native void ltt_closeTrace(long tracePtr);
72
73 // Native access functions
74 private native String ltt_getTracepath(long tracePtr);
75 private native int ltt_getCpuNumber(long tracePtr);
76 private native long ltt_getArchType(long tracePtr);
77 private native long ltt_getArchVariant(long tracePtr);
78 private native short ltt_getArchSize(long tracePtr);
79 private native short ltt_getLttMajorVersion(long tracePtr);
80 private native short ltt_getLttMinorVersion(long tracePtr);
81 private native short ltt_getFlightRecorder(long tracePtr);
82 private native long ltt_getFreqScale(long tracePtr);
83 private native long ltt_getStartFreq(long tracePtr);
84 private native long ltt_getStartTimestampCurrentCounter(long tracePtr);
85 private native long ltt_getStartMonotonic(long tracePtr);
86
87 // Native function to fill out startTime
88 private native void ltt_feedStartTime(long tracePtr, JniTime startTime);
89
90 // Native function to fill out startTimeFromTimestampCurrentCounter
91 private native void ltt_feedStartTimeFromTimestampCurrentCounter(long tracePtr, JniTime startTime);
92
93 // Native function to fill out tracefilesMap
94 private native void ltt_getAllTracefiles(long tracePtr);
95
96 // Debug native function, ask LTT to print trace structure
97 private native void ltt_printTrace(long tracePtr);
98
99 static {
100 System.loadLibrary("lttvtraceread");
101 }
102
103 /*
104 * Default constructor is forbidden
105 */
106 @SuppressWarnings("unused")
107 private JniTrace() {
108 }
109
110 /**
111 * Constructor that takes a tracepath parameter.<p>
112 *
113 * This constructor also opens the trace.
114 *
115 * @param newpath The <b>directory</b> of the trace to be opened
116 * @param newPrintDebug Should the debug information be printed in the LTT C library
117 *
118 * @exception JniException
119 */
120 public JniTrace(String newpath, boolean newPrintDebug) throws JniException {
121 tracepath = newpath;
122 thisTracePtr = new Jni_C_Pointer();
123 printLttDebug = newPrintDebug;
124
125 openTrace(newpath);
126 }
127
128 /**
129 * Copy constructor.
130 *
131 * @param oldTrace A reference to the JniTrace to copy.
132 */
133 public JniTrace(JniTrace oldTrace) {
134 thisTracePtr = oldTrace.thisTracePtr;
135
136 tracepath = oldTrace.tracepath;
137 cpuNumber = oldTrace.cpuNumber;
138 archType = oldTrace.archType;
139 archVariant = oldTrace.archVariant;
140 archSize = oldTrace.archSize;
141 lttMajorVersion = oldTrace.lttMajorVersion;
142 lttMinorVersion = oldTrace.lttMinorVersion;
143 flightRecorder = oldTrace.flightRecorder;
144 freqScale = oldTrace.freqScale;
145 startFreq = oldTrace.startFreq;
146 startTimestampCurrentCounter = oldTrace.startTimestampCurrentCounter;
147 startMonotonic = oldTrace.startMonotonic;
148 startTime = oldTrace.startTime;
149 startTimeFromTimestampCurrentCounter = oldTrace.startTimeFromTimestampCurrentCounter;
150
151 tracefilesMap = new HashMap<String, JniTracefile>(oldTrace.tracefilesMap.size());
152 tracefilesMap = oldTrace.tracefilesMap;
153
154 eventsHeap = new PriorityQueue<JniEvent>( oldTrace.eventsHeap.size());
155 eventsHeap = oldTrace.eventsHeap;
156
157 printLttDebug = oldTrace.printLttDebug;
158 }
159
160 /**
161 * Constructor, using C pointer.<p>
162 *
163 * @param newPtr The pointer to an already opened LttTrace C structure.
164 * @param newPrintDebug Should the debug information be printed in the LTT C library
165 *
166 * @exception JniException
167 *
168 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
169 */
170 public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException {
171 thisTracePtr = newPtr;
172 printLttDebug = newPrintDebug;
173
174 // Populate our trace
175 populateTraceInformation();
176 }
177
178 /**
179 * Open an existing trace.<p>
180 *
181 * The tracepath is a directory and needs to exist, otherwise
182 * a JafOpenTraceFailedException is throwed.
183 *
184 * @param newPath The <b>directory</b> of the trace to be opened
185 *
186 * @exception JniOpenTraceFailedException Thrown if the open failed
187 */
188 public void openTrace(String newPath) throws JniException {
189 // If open is called while a trace is already opened, we will try to close it first
190 if (thisTracePtr.getPointer() != NULL) {
191 closeTrace();
192 }
193
194 // Set the tracepath and open it
195 tracepath = newPath;
196 openTrace();
197 }
198
199 /**
200 * Open an existing trace.<p>
201 *
202 * The tracepath should have been set already,
203 *
204 * @exception JniOpenTraceFailedException Thrown if the open failed
205 */
206 public void openTrace() throws JniException {
207
208 // Raise an exception if the tracepath is empty, otherwise open the trace
209 if (tracepath == "") {
210 throw new JniTraceException("Tracepath is not set. (openTrace)");
211 }
212
213 // If the file is already opened, close it first
214 if (thisTracePtr.getPointer() != NULL) {
215 closeTrace();
216 }
217
218 // Call the LTT to open the trace
219 long newPtr = ltt_openTrace(tracepath, printLttDebug);
220 if (newPtr == NULL) {
221 throw new JniOpenTraceFailedException("Error while opening trace. Is the tracepath correct? (openTrace)");
222 }
223
224 // This is OUR pointer
225 thisTracePtr = new Jni_C_Pointer(newPtr);
226
227 // Populate the trace with LTT information
228 populateTraceInformation();
229 }
230
231 /**
232 * Close a trace.<p>
233 *
234 * If the trace is already closed, will silently do nothing.
235 */
236 public void closeTrace() {
237 if (thisTracePtr.getPointer() != NULL) {
238 ltt_closeTrace(thisTracePtr.getPointer());
239 thisTracePtr = new Jni_C_Pointer(NULL);
240
241 // Clear the tracefile map
242 tracefilesMap.clear();
243 tracefilesMap = null;
244
245 // Clear the eventsHeap and make it points to null
246 eventsHeap.clear();
247 eventsHeap = null;
248
249 // Ask the garbage collector to make a little pass here, as we could
250 // be left with 100's of unreferenced objects
251 System.gc();
252 }
253 }
254
255 /*
256 * This function populates the trace data with data from LTT
257 *
258 * @throws JniException
259 */
260 private void populateTraceInformation() throws JniException {
261 if (thisTracePtr.getPointer() == NULL) {
262 throw new JniTraceException("Pointer is NULL, trace not opened/already closed? (populateTraceInformation)");
263 }
264
265 // Populate from the LTT library
266 tracepath = ltt_getTracepath( thisTracePtr.getPointer() );
267 cpuNumber = ltt_getCpuNumber( thisTracePtr.getPointer() );
268 archType = ltt_getArchType( thisTracePtr.getPointer() );
269 archVariant = ltt_getArchVariant( thisTracePtr.getPointer() );
270 archSize = ltt_getArchSize( thisTracePtr.getPointer() );
271 lttMajorVersion = ltt_getLttMajorVersion( thisTracePtr.getPointer() );
272 lttMinorVersion = ltt_getLttMinorVersion( thisTracePtr.getPointer() );
273 flightRecorder = ltt_getFlightRecorder( thisTracePtr.getPointer() );
274 freqScale = ltt_getFreqScale( thisTracePtr.getPointer() );
275 startFreq = ltt_getStartFreq( thisTracePtr.getPointer() );
276 startTimestampCurrentCounter = ltt_getStartTimestampCurrentCounter( thisTracePtr.getPointer() );
277 startMonotonic = ltt_getStartMonotonic( thisTracePtr.getPointer() );
278
279 // Creation of time is a bit different, we need to pass the object reference to C
280 startTime = new JniTime();
281 ltt_feedStartTime( thisTracePtr.getPointer(), startTime );
282
283 startTimeFromTimestampCurrentCounter = new JniTime();
284 ltt_feedStartTimeFromTimestampCurrentCounter( thisTracePtr.getPointer(), startTimeFromTimestampCurrentCounter );
285
286 // Call the fill up function for the tracefiles map
287 if ( tracefilesMap== null ) {
288 tracefilesMap = new HashMap<String, JniTracefile>();
289 }
290
291 ltt_getAllTracefiles( thisTracePtr.getPointer() );
292
293 if (eventsHeap == null) {
294 eventsHeap = new PriorityQueue<JniEvent>(tracefilesMap.size());
295 }
296
297 // Populate the heap with events
298 populateEventHeap();
299 }
300
301 /*
302 * This function populates the event heap with one event from each tracefile
303 * It should be called after each seek or when the object is constructed
304 */
305 private void populateEventHeap() {
306 currentEvent = null;
307 eventsHeap.clear();
308
309 Object new_key = null;
310 JniTracefile tmpTracefile = null;
311
312 Iterator<String> iterator = tracefilesMap.keySet().iterator();
313 while( iterator.hasNext() ) {
314 new_key = iterator.next();
315
316 tmpTracefile = tracefilesMap.get(new_key);
317 if ( tmpTracefile.getCurrentEvent().getEventState() == EOK ) {
318 eventsHeap.add( tmpTracefile.getCurrentEvent() );
319 }
320 }
321 }
322
323 /*
324 * Fills a map of all the trace files.
325 *
326 * Note: This function is called from C and there is no way to propagate
327 * exception back to the caller without crashing JNI. Therefore, it MUST
328 * catch all exceptions.
329 *
330 * @param tracefileName
331 * @param tracefilePtr
332 */
333 @SuppressWarnings("unused")
334 private void addTracefileFromC(String tracefileName, long tracefilePtr) {
335
336 JniTracefile newTracefile = null;
337
338 // Create a new tracefile object and insert it in the map
339 // the tracefile fill itself with LTT data while being constructed
340 try {
341 newTracefile = new JniTracefile( new Jni_C_Pointer(tracefilePtr), this );
342 tracefilesMap.put( (tracefileName + newTracefile.getCpuNumber()), newTracefile);
343 }
344 catch(JniTracefileWithoutEventException e) {
345 printlnC("JniTracefile " + tracefileName + " has no event (addTracefileFromC). Ignoring.");
346 }
347 catch(Exception e) {
348 printlnC("Failed to add tracefile " + tracefileName + " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e.toString() );
349 }
350 }
351
352 /**
353 * Return the top event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
354 *
355 * Note : If the events were read before, the top event and the event currently loaded (currentEvent) are most likely the same.
356 *
357 * @return The top event in the stack or null if no event is available.
358 *
359 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
360 */
361 public JniEvent findNextEvent() {
362 return eventsHeap.peek();
363 }
364
365 /**
366 * Return the next event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
367 *
368 * @return The next event in the trace or null if no event is available.
369 *
370 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
371 */
372 public JniEvent readNextEvent() {
373 // Get the "next" event on the top of the heap but DO NOT remove it
374 JniEvent tmpEvent = eventsHeap.peek();
375
376 // If the event is null, it was the last one in the trace we can leave the function
377 if (tmpEvent == null) {
378 return null;
379 }
380
381 // Otherwise, we need to make sure the timestamp of the event we got is not the same as the last "NextEvent" we requested
382 // NOTE : JniEvent.compareTo() compare by timestamp AND type, as 2 events of different type could have the same timestamp.
383 if ( tmpEvent.compareTo(currentEvent) == 0 ) {
384 // Remove the event on top as it is the same currentEventTimestamp
385 eventsHeap.poll();
386
387 // Read the next event for this particular event type
388 tmpEvent.readNextEvent();
389
390 // If the event state is sane (not Out of Range), put it back in the heap
391 if ( tmpEvent.getEventState() == EOK ) {
392 eventsHeap.add(tmpEvent);
393 }
394
395 // Pick the top event again
396 tmpEvent = eventsHeap.peek();
397
398 // Save the event we just read as the "current event"
399 currentEvent = tmpEvent;
400 }
401 // If the event on top has different timestamp than the currentTimestamp, just save this timestamp as current
402 else {
403 currentEvent = tmpEvent;
404 }
405
406 return tmpEvent;
407 }
408
409 /**
410 * Read the next event on a certain tracefile.<p>
411 *
412 * By calling this function make sure the "global" readNextEvent() stay synchronised.
413 * Calling readNextEvent() after this function will consider this tracefile moved and is then consistent.
414 *
415 * @param targetTracefile The tracefile object to read from
416 *
417 * @return The next event in the tracefile or null if no event is available.
418 *
419 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
420 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
421 */
422 public JniEvent readNextEvent(JniTracefile targetTracefile) {
423 JniEvent returnedEvent = null;
424
425 // There is 2 special cases where we should read the CURRENT event, not the next one
426 // 1- The currentEvent is null --> We never read or we just seeked
427 // 2- The currentEvent is of another type --> We last read on a DIFFERENT tracefile
428 if ( (currentEvent == null) ||
429 (currentEvent.getParentTracefile().equals(targetTracefile) == false)
430 ) {
431 returnedEvent = targetTracefile.getCurrentEvent();
432 // Save the event we read
433 currentEvent = returnedEvent;
434 }
435 else {
436 // Remove from the event related to this tracefile from the event heap, if it exists.
437 // WARNING : This only safe as long getCurrentEvent() never return "null" in any case.
438 eventsHeap.remove(targetTracefile.getCurrentEvent() );
439
440 // If status EOK, we can return the event, otherwise something wrong happen (out of range, read error, etc...)
441 if ( targetTracefile.readNextEvent() == EOK) {
442 returnedEvent = targetTracefile.getCurrentEvent();
443 // Add back to the heap the read event
444 eventsHeap.add(returnedEvent);
445 }
446 // Save the event we read...
447 // Note : might be null if the read failed and it's ok
448 currentEvent = targetTracefile.getCurrentEvent();
449 }
450
451 return returnedEvent;
452 }
453
454 /**
455 * Seek to a certain time but <b>do not</b> read the next event.<p>
456 *
457 * This only position the trace, it will not return anything.<p>
458 *
459 * @param seekTime The time where we want to seek to
460 *
461 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
462 */
463 public void seekToTime(JniTime seekTime) {
464
465 // Invalidate the last read event
466 currentEvent = null;
467
468 Object tracefile_name = null;
469 Iterator<String> iterator = tracefilesMap.keySet().iterator();
470
471 while (iterator.hasNext() ) {
472 // We seek to the given event for ALL tracefiles
473 tracefile_name = iterator.next();
474 seekToTime(seekTime, tracefilesMap.get(tracefile_name));
475 }
476
477 populateEventHeap();
478 }
479
480 /**
481 * Seek to a certain time on a certain tracefile but <b>do not</b> read the next event.<p>
482 *
483 * This only position the trace, it will not return anything.<p>
484 *
485 * @param targetTracefile The tracefile object to read from
486 * @param seekTime The time where we want to seek to
487 *
488 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
489 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
490 */
491 public void seekToTime(JniTime seekTime, JniTracefile targetTracefile) {
492 // Invalidate the current read event
493 currentEvent = null;
494
495 // Remove from the event related to this tracefile from the event heap, if it exists.
496 // WARNING : This is only safe as long getCurrentEvent() never return "null" in any case.
497 eventsHeap.remove(targetTracefile.getCurrentEvent() );
498
499 // Perform the actual seek on the tracefile
500 // Add the event to the heap if it succeed
501 if ( targetTracefile.seekToTime(seekTime) == EOK) {
502 // Add back to the heap the read event
503 eventsHeap.add(targetTracefile.getCurrentEvent());
504 }
505 }
506
507 /**
508 * Seek to a certain timestamp and read the next event.
509 * <p>
510 * If no more events are available or an error happen, null will be returned.
511 *
512 * @param seekTime The time where we want to seek to.
513 *
514 * @return The event just after the seeked time or null if none available.
515 *
516 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
517 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
518 */
519 public JniEvent seekAndRead(JniTime seekTime) {
520 JniEvent returnedEvent = null;
521 seekToTime(seekTime);
522
523 // The trace should be correctly positionned, let's get the event
524 returnedEvent = readNextEvent();
525
526 return returnedEvent;
527 }
528
529 /**
530 * Seek to a certain timestamp on a certain tracefile and read the next event.<p>
531 *
532 * If no more events are available or an error happen, null will be returned.
533 *
534 * Calling readNextEvent() after this function will consider this tracefile moved and is then consistent.<br>
535 *
536 * @param tracefileName The tracefile object to read from
537 * @param seekTime The time where we want to seek to
538 *
539 * @return The event just after the seeked time or null if none available.
540 *
541 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
542 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
543 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
544 */
545 public JniEvent seekAndRead(JniTime seekTime, JniTracefile targetTracefile) {
546 seekToTime(seekTime, targetTracefile);
547 return readNextEvent(targetTracefile);
548 }
549
550 /**
551 * Get a certain tracefile from its given name.<p>
552 *
553 * @param tracefileName The name of the tracefile.
554 *
555 * @return The tracefile found or null if none.
556 *
557 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
558 */
559 public JniTracefile requestTracefileByName(String tracefileName) {
560 return tracefilesMap.get(tracefileName);
561 }
562
563 /**
564 * Get a certain event associated to a tracefile from the tracefile name.<p>
565 *
566 * @param tracefileName The name of the trace file.
567 *
568 * @return Event of the tracefile or null if none found.
569 *
570 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent
571 */
572 public JniEvent requestEventByName(String tracefileName) {
573 JniEvent returnValue = null;
574
575 JniTracefile tmpTracefile = tracefilesMap.get(tracefileName);
576
577 // If the tracefile is found, return the current event
578 // There should always be an event linked to a tracefile
579 if (tmpTracefile != null) {
580 returnValue = tmpTracefile.getCurrentEvent();
581 }
582
583 return returnValue;
584 }
585
586 // Access to class variable. Most of them doesn't have setter
587 public String getTracepath() {
588 return tracepath;
589 }
590
591 public int getCpuNumber() {
592 return cpuNumber;
593 }
594
595 public long getArchType() {
596 return archType;
597 }
598
599 public long getArchVariant() {
600 return archVariant;
601 }
602
603 public short getArchSize() {
604 return archSize;
605 }
606
607 public short getLttMajorVersion() {
608 return lttMajorVersion;
609 }
610
611 public short getLttMinorVersion() {
612 return lttMinorVersion;
613 }
614
615 public short getFlightRecorder() {
616 return flightRecorder;
617 }
618
619 public long getFreqScale() {
620 return freqScale;
621 }
622
623 public long getStartFreq() {
624 return startFreq;
625 }
626
627 public long getStartTimestampCurrentCounter() {
628 return startTimestampCurrentCounter;
629 }
630
631 public long getStartMonotonic() {
632 return startMonotonic;
633 }
634
635 public JniTime getStartTime() {
636 return startTime;
637 }
638
639 public JniTime getStartTimeFromTimestampCurrentCounter() {
640 return startTimeFromTimestampCurrentCounter;
641 }
642
643 public HashMap<String, JniTracefile> getTracefilesMap() {
644 return tracefilesMap;
645 }
646
647 /**
648 * The timestamp of the last read event.<p>
649 *
650 * Note : If no event is available, Long.MAX_VALUE is returned.
651 *
652 * @return Time of the last event read
653 *
654 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTime
655 */
656 public JniTime getCurrentEventTimestamp() {
657 JniTime returnedTime = null;
658
659 // If no event were read or we reach the last event in the trace,
660 // currentEvent will be null
661 if ( currentEvent != null ) {
662 returnedTime = currentEvent.getEventTime();
663 }
664 else {
665 returnedTime = new JniTime(Long.MAX_VALUE);
666 }
667 return returnedTime;
668 }
669
670 /**
671 * Pointer to the LttTrace C structure.<p>
672 *
673 * The pointer should only be used <u>INTERNALY</u>, do not use unless you
674 * know what you are doing.
675 *
676 * @return The actual (long converted) pointer or NULL.
677 *
678 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.Jni_C_Pointer
679 */
680 public Jni_C_Pointer getTracePtr() {
681 return thisTracePtr;
682 }
683
684 /**
685 * Return boolean value saying if the debug is enabled in LTT or not.<p>
686 *
687 * Note : this need to be set at construction.
688 *
689 * @return If the debug is set or not
690 */
691 public boolean isPrintingLttDebug() {
692 return printLttDebug;
693 }
694
695 /**
696 * Print information for all the tracefiles associated with this trace.
697 * <u>Intended to debug</u><p>
698 *
699 * This function will call Ltt to print, so information printed will be the
700 * one from the C structure, not the one populated in java.
701 *
702 * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile
703 */
704 public void printAllTracefilesInformation() {
705 JniTracefile tracefile = null;
706
707 Iterator<String> iterator = tracefilesMap.keySet().iterator();
708 while (iterator.hasNext()) {
709 tracefile = tracefilesMap.get(iterator.next());
710 tracefile.printTracefileInformation();
711 }
712 }
713
714 /**
715 * Print information for this trace.
716 * <u>Intended to debug</u><p>
717 *
718 * This function will call Ltt to print, so information printed will be the
719 * one from the C structure, not the one populated in java.<p>
720 * <br>
721 * This function will not throw but will complain loudly if pointer is NULL
722 */
723 public void printTraceInformation() {
724
725 // If null pointer, print a warning!
726 if (thisTracePtr.getPointer() == NULL) {
727 printlnC("Pointer is NULL, cannot print. (printTraceInformation)");
728 }
729 else {
730 ltt_printTrace( thisTracePtr.getPointer() );
731 }
732 }
733
734 /**
735 * toString() method.
736 * <u>Intended to debug</u><br>
737 *
738 * @return Attributes of the object concatenated in String
739 */
740 @Override
741 public String toString() {
742 String returnData = "";
743 returnData += "tracepath : " + tracepath + "\n";
744 returnData += "cpuNumber : " + cpuNumber + "\n";
745 returnData += "archType : " + archType + "\n";
746 returnData += "archVariant : " + archVariant + "\n";
747 returnData += "archSize : " + archSize + "\n";
748 returnData += "lttMajorVersion : " + lttMajorVersion + "\n";
749 returnData += "lttMinorVersion : " + lttMinorVersion + "\n";
750 returnData += "flightRecorder : " + flightRecorder + "\n";
751 returnData += "freqScale : " + freqScale + "\n";
752 returnData += "startFreq : " + startFreq + "\n";
753 returnData += "startTimestampCurrentCounter : " + startTimestampCurrentCounter + "\n";
754 returnData += "startMonotonic : " + startMonotonic + "\n";
755 returnData += "startTime : " + startTime.getReferenceToString() + "\n";
756 returnData += " seconds : " + startTime.getSeconds() + "\n";
757 returnData += " nanoSeconds : " + startTime.getNanoSeconds() + "\n";
758 returnData += "startTimeFromTimestampCurrentCounter : " + startTimeFromTimestampCurrentCounter.getReferenceToString() + "\n";
759 returnData += " seconds : " + startTimeFromTimestampCurrentCounter.getSeconds() + "\n";
760 returnData += " nanoSeconds : " + startTimeFromTimestampCurrentCounter.getNanoSeconds() + "\n";
761 returnData += "tracefilesMap : " + tracefilesMap.keySet() + "\n"; // Hack to avoid ending up with tracefilesMap.toString()
762
763 return returnData;
764 }
765 }
This page took 0.049631 seconds and 5 git commands to generate.