1 package org
.eclipse
.linuxtools
.lttng
.jni
;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
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
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
14 import java
.util
.HashMap
;
15 import java
.util
.Iterator
;
16 import java
.util
.PriorityQueue
;
18 import org
.eclipse
.linuxtools
.lttng
.jni
.common
.JniTime
;
19 import org
.eclipse
.linuxtools
.lttng
.jni
.common
.Jni_C_Pointer_And_Library_Id
;
20 import org
.eclipse
.linuxtools
.lttng
.jni
.exception
.JniException
;
21 import org
.eclipse
.linuxtools
.lttng
.jni
.exception
.JniOpenTraceFailedException
;
22 import org
.eclipse
.linuxtools
.lttng
.jni
.exception
.JniTraceException
;
23 import org
.eclipse
.linuxtools
.lttng
.jni
.exception
.JniTracefileWithoutEventException
;
26 * <b><u>JniTrace</u></b>
28 * This is the top level class in the JNI. It provides access to the
29 * LttTrace C structure in java.
31 * Most important fields in the JniTrace are :
33 * <li>a JniTrace path (a trace <b>directory</b>)
34 * <li>a HashMap of tracefiles that exists in this trace
38 * This class is ABSTRACT, you need to extends it to support your specific LTTng version.<br>
39 * Please look at the abstract functions to override at the bottom of this file.<p>
41 public abstract class JniTrace
extends Jni_C_Common
{
43 private final static boolean DEFAULT_LTT_DEBUG
= false;
45 // Internal C pointer of the JniTrace used in LTT
46 private Jni_C_Pointer_And_Library_Id thisTracePtr
= new Jni_C_Pointer_And_Library_Id();
48 // Data we should populate from LTT
49 // Note that all type have been scaled up as there is no "unsigned" in java
50 // This might be a problem about "unsigned long" as there is no equivalent
53 private String tracepath
= ""; // Path of the trace. Should be a directory (like : /tmp/traceX)
54 private int cpuNumber
= 0;
55 private long archType
= 0;
56 private long archVariant
= 0;
57 private short archSize
= 0;
58 private short lttMajorVersion
= 0;
59 private short lttMinorVersion
= 0;
60 private short flightRecorder
= 0;
61 private long freqScale
= 0;
62 private long startFreq
= 0;
63 private long startTimestampCurrentCounter
= 0;
64 private long startMonotonic
= 0;
65 private JniTime startTimeNoAdjustement
= null;
66 private JniTime startTime
= null;
67 private JniTime endTime
= null;
69 // This Map holds a reference to the tracefiles owned by this trace
70 private HashMap
<String
, JniTracefile
> tracefilesMap
= null;
71 // The priority queue (similar to heap) hold events
72 private PriorityQueue
<JniEvent
> eventsHeap
= null;
74 // This variable will hold the content of the "last" event we read
75 private JniEvent currentEvent
= null;
77 // Should we print debug in the C library or not?
78 private boolean printLttDebug
= DEFAULT_LTT_DEBUG
;
81 // This need to be called prior to any operation
82 protected native int ltt_initializeHandle(String libname
);
84 // This need to be called at the very end (destructor)
85 protected native boolean ltt_freeHandle(int libId
);
87 // Open/close native functions
88 protected native long ltt_openTrace(int libId
, String pathname
, boolean printDebug
);
89 protected native void ltt_closeTrace(int libId
, long tracePtr
);
91 // Native access functions
92 protected native String
ltt_getTracepath(int libId
, long tracePtr
);
93 protected native int ltt_getCpuNumber(int libId
, long tracePtr
);
94 protected native long ltt_getArchType(int libId
, long tracePtr
);
95 protected native long ltt_getArchVariant(int libId
, long tracePtr
);
96 protected native short ltt_getArchSize(int libId
, long tracePtr
);
97 protected native short ltt_getLttMajorVersion(int libId
, long tracePtr
);
98 protected native short ltt_getLttMinorVersion(int libId
, long tracePtr
);
99 protected native short ltt_getFlightRecorder(int libId
, long tracePtr
);
100 protected native long ltt_getFreqScale(int libId
, long tracePtr
);
101 protected native long ltt_getStartFreq(int libId
, long tracePtr
);
102 protected native long ltt_getStartTimestampCurrentCounter(int libId
, long tracePtr
);
103 protected native long ltt_getStartMonotonic(int libId
, long tracePtr
);
105 // Native function to fill out startTime
106 protected native void ltt_feedStartTime(int libId
, long tracePtr
, JniTime startTime
);
108 // Native function to fill out startTimeFromTimestampCurrentCounter
109 protected native void ltt_feedStartTimeFromTimestampCurrentCounter(int libId
, long tracePtr
, JniTime startTime
);
111 // Native function to fill out tracefilesMap
112 protected native void ltt_feedAllTracefiles(int libId
, long tracePtr
);
114 // Native function to fill out the start and end time of the trace
115 protected native void ltt_feedTracefileTimeRange(int libId
, long tracePtr
, JniTime startTime
, JniTime endTime
);
117 // Debug native function, ask LTT to print trace structure
118 protected native void ltt_printTrace(int libId
, long tracePtr
);
121 * Default constructor is forbidden
123 protected JniTrace() {
127 * Constructor that takes a tracepath parameter.<p>
129 * This constructor also opens the trace.
131 * @param newpath The <b>directory</b> of the trace to be opened
133 * @exception JniException
135 public JniTrace(String newpath
) throws JniException
{
136 this(newpath
, DEFAULT_LTT_DEBUG
);
140 * Constructor that takes a tracepath parameter and a debug value.<p>
142 * This constructor also opens the trace.
144 * @param newpath The <b>directory</b> of the trace to be opened
145 * @param newPrintDebug Should the debug information be printed in the LTT C library
147 * @exception JniException
149 public JniTrace(String newpath
, boolean newPrintDebug
) throws JniException
{
151 thisTracePtr
= new Jni_C_Pointer_And_Library_Id();
152 printLttDebug
= newPrintDebug
;
160 * @param oldTrace A reference to the JniTrace to copy.
162 public JniTrace(JniTrace oldTrace
) {
163 thisTracePtr
= oldTrace
.thisTracePtr
;
165 tracepath
= oldTrace
.tracepath
;
166 cpuNumber
= oldTrace
.cpuNumber
;
167 archType
= oldTrace
.archType
;
168 archVariant
= oldTrace
.archVariant
;
169 archSize
= oldTrace
.archSize
;
170 lttMajorVersion
= oldTrace
.lttMajorVersion
;
171 lttMinorVersion
= oldTrace
.lttMinorVersion
;
172 flightRecorder
= oldTrace
.flightRecorder
;
173 freqScale
= oldTrace
.freqScale
;
174 startFreq
= oldTrace
.startFreq
;
175 startTimestampCurrentCounter
= oldTrace
.startTimestampCurrentCounter
;
176 startMonotonic
= oldTrace
.startMonotonic
;
177 startTimeNoAdjustement
= oldTrace
.startTimeNoAdjustement
;
178 startTime
= oldTrace
.startTime
;
179 endTime
= oldTrace
.endTime
;
181 tracefilesMap
= new HashMap
<String
, JniTracefile
>(oldTrace
.tracefilesMap
.size());
182 ltt_feedAllTracefiles(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
184 eventsHeap
= new PriorityQueue
<JniEvent
>( oldTrace
.eventsHeap
.size());
187 printLttDebug
= oldTrace
.printLttDebug
;
191 * Constructor, using C pointer.<p>
193 * @param newPtr The pointer to an already opened LttTrace C structure.
194 * @param newPrintDebug Should the debug information be printed in the LTT C library
196 * @exception JniException
198 * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id
200 public JniTrace(Jni_C_Pointer_And_Library_Id newPtr
, boolean newPrintDebug
) throws JniException
{
201 thisTracePtr
= newPtr
;
202 printLttDebug
= newPrintDebug
;
204 // Populate our trace
205 populateTraceInformation();
210 public void finalize() {
211 // If the trace is open, close it
212 if (thisTracePtr
.getPointer() != NULL
) {
216 // Tell the C to free the allocated memory
221 * Open an existing trace.<p>
223 * The tracepath is a directory and needs to exist, otherwise
224 * a JniOpenTraceFailedException is throwed.
226 * @param newPath The <b>directory</b> of the trace to be opened
228 * @exception JniOpenTraceFailedException Thrown if the open failed
230 public void openTrace(String newPath
) throws JniException
{
231 // If open is called while a trace is already opened, we will try to close it first
232 if (thisTracePtr
.getPointer() != NULL
) {
236 // Set the tracepath and open it
242 * Open an existing trace.<p>
244 * The tracepath should have been set already,
246 * @exception JniOpenTraceFailedException Thrown if the open failed
248 public void openTrace() throws JniException
{
250 // Raise an exception if the tracepath is empty, otherwise open the trace
251 if (tracepath
== "") {
252 throw new JniTraceException("Tracepath is not set. (openTrace)");
255 // If the file is already opened, close it first
256 if (thisTracePtr
.getPointer() != NULL
) {
260 // Initialization of the library is made here
261 // It is very important that the id is kept!
262 int newLibraryId
= initializeLibrary();
263 if ( newLibraryId
!= -1 ) {
264 // Call the LTT to open the trace
265 // Note that the libraryId is not yet and the pointer
266 long newPtr
= ltt_openTrace(newLibraryId
, tracepath
, printLttDebug
);
268 if (newPtr
== NULL
) {
269 thisTracePtr
= new Jni_C_Pointer_And_Library_Id();
270 throw new JniOpenTraceFailedException("Error while opening trace. Is the tracepath correct? (openTrace)");
273 // This is OUR pointer
274 thisTracePtr
= new Jni_C_Pointer_And_Library_Id(newLibraryId
, newPtr
);
276 // Populate the trace with LTT information
277 populateTraceInformation();
280 thisTracePtr
= new Jni_C_Pointer_And_Library_Id();
281 throw new JniTraceException("Failed to initialize library! Is the trace version supported?\n" +
282 "Make sure you have the correct LTTv library compiled. (openTrace)");
289 * If the trace is already closed, will silently do nothing.
291 public void closeTrace() {
293 if (thisTracePtr
.getPointer() != NULL
) {
294 ltt_closeTrace(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
296 // Clear the tracefile map
297 tracefilesMap
.clear();
298 tracefilesMap
= null;
300 // Clear the eventsHeap and make it points to null
304 // Nullify the pointer
305 thisTracePtr
= new Jni_C_Pointer_And_Library_Id();
310 * This function force the library to free its memory.<p>
312 * Note : No call to the library will work after this until ltt_initializeHandle is called again
314 public void freeLibrary() {
315 ltt_freeHandle(thisTracePtr
.getLibraryId());
319 * This function populates the trace data with data from LTT
321 * @throws JniException
323 private void populateTraceInformation() throws JniException
{
324 if (thisTracePtr
.getPointer() == NULL
) {
325 throw new JniTraceException("Pointer is NULL, trace not opened/already closed? (populateTraceInformation)");
328 // Populate from the LTT library
329 tracepath
= ltt_getTracepath(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
330 cpuNumber
= ltt_getCpuNumber(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
331 archType
= ltt_getArchType(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
332 archVariant
= ltt_getArchVariant(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
333 archSize
= ltt_getArchSize(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
334 lttMajorVersion
= ltt_getLttMajorVersion(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
335 lttMinorVersion
= ltt_getLttMinorVersion(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
336 flightRecorder
= ltt_getFlightRecorder(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
337 freqScale
= ltt_getFreqScale(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
338 startFreq
= ltt_getStartFreq(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
339 startTimestampCurrentCounter
= ltt_getStartTimestampCurrentCounter(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
340 startMonotonic
= ltt_getStartMonotonic(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
342 // Creation of time is a bit different, we need to pass the object reference to C
344 // *** NOTE : LTTv consider "raw startTime" (time without any frequency adjustement) to be default startTime
345 // So "startTimeNoAdjustement" is obtain throught "ltt_feedStartTime()" and
346 // "startTime" is obtained from ltt_feedStartTimeFromTimestampCurrentCounter()
347 startTimeNoAdjustement
= new JniTime();
348 ltt_feedStartTime(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer(), startTimeNoAdjustement
);
350 startTime
= new JniTime();
351 ltt_feedStartTimeFromTimestampCurrentCounter(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer(), startTime
);
353 // Call the fill up function for the tracefiles map
354 if ( tracefilesMap
== null ) {
355 tracefilesMap
= new HashMap
<String
, JniTracefile
>();
357 ltt_feedAllTracefiles(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
359 // Now, obtain the trace "endTime"
360 // Note that we discard "startTime" right away, as we already have it
361 endTime
= new JniTime();
362 ltt_feedTracefileTimeRange(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer(), new JniTime(), endTime
);
364 if (eventsHeap
== null) {
365 eventsHeap
= new PriorityQueue
<JniEvent
>(tracefilesMap
.size());
368 // Populate the heap with events
373 * This function populates the event heap with one event from each tracefile
374 * It should be called after each seek or when the object is constructed
376 private void populateEventHeap() {
380 Object new_key
= null;
381 JniTracefile tmpTracefile
= null;
383 Iterator
<String
> iterator
= tracefilesMap
.keySet().iterator();
384 while( iterator
.hasNext() ) {
385 new_key
= iterator
.next();
387 tmpTracefile
= tracefilesMap
.get(new_key
);
388 if ( tmpTracefile
.getCurrentEvent().getEventState() == EOK
) {
389 eventsHeap
.add( tmpTracefile
.getCurrentEvent() );
395 * Fills a map of all the trace files.
397 * Note: This function is called from C and there is no way to propagate
398 * exception back to the caller without crashing JNI. Therefore, it MUST
399 * catch all exceptions.
401 * @param tracefileName
402 * @param tracefilePtr
404 protected void addTracefileFromC(String tracefileName
, long tracefilePtr
) {
406 JniTracefile newTracefile
= null;
408 // Create a new tracefile object and insert it in the map
409 // the tracefile fill itself with LTT data while being constructed
411 newTracefile
= allocateNewJniTracefile(new Jni_C_Pointer_And_Library_Id(thisTracePtr
.getLibraryId(), tracefilePtr
), this);
412 getTracefilesMap().put( (tracefileName
+ newTracefile
.getCpuNumber()), newTracefile
);
414 catch(JniTracefileWithoutEventException e
) {
415 if ( printLttDebug
== true ) {
416 printlnC(thisTracePtr
.getLibraryId(), "JniTracefile " + tracefileName
+ " has no event (addTracefileFromC). Ignoring.");
420 if ( printLttDebug
== true ) {
421 printlnC(thisTracePtr
.getLibraryId(), "Failed to add tracefile " + tracefileName
+ " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e
.toString() );
427 * Return the top event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
429 * Note : If the events were read before, the top event and the event currently loaded (currentEvent) are most likely the same.
431 * @return The top event in the stack or null if no event is available.
433 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
435 public JniEvent
findNextEvent() {
436 return eventsHeap
.peek();
440 * Return the next event in the events stack, determined by timestamp, in the trace (all the tracefiles).<p>
442 * @return The next event in the trace or null if no event is available.
444 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
446 public JniEvent
readNextEvent() {
447 // Get the "next" event on the top of the heap but DO NOT remove it
448 JniEvent tmpEvent
= eventsHeap
.peek();
450 // If the event is null, it was the last one in the trace we can leave the function
451 if (tmpEvent
== null) {
455 // Otherwise, we need to make sure the timestamp of the event we got is not the same as the last "NextEvent" we requested
456 // NOTE : JniEvent.compareTo() compare by timestamp AND type, as 2 events of different type could have the same timestamp.
457 // if( currentEvent != null ){
458 if (tmpEvent
.equals(currentEvent
)) {
459 // Remove the event on top as it is the same currentEventTimestamp
462 // Read the next event for this particular event type
463 tmpEvent
.readNextEvent();
465 // If the event state is sane (not Out of Range), put it back in the heap
466 if ( tmpEvent
.getEventState() == EOK
) {
467 eventsHeap
.add(tmpEvent
);
470 // Pick the top event again
471 tmpEvent
= eventsHeap
.peek();
473 // Save the event we just read as the "current event"
474 currentEvent
= tmpEvent
;
476 // If the event on top has different timestamp than the currentTimestamp, just save this timestamp as current
478 currentEvent
= tmpEvent
;
485 * Read the next event on a certain tracefile.<p>
487 * By calling this function make sure the "global" readNextEvent() stay synchronised.
488 * Calling readNextEvent() after this function will consider this tracefile moved and is then consistent.
490 * @param targetTracefile The tracefile object to read from
492 * @return The next event in the tracefile or null if no event is available.
494 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
495 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
497 public JniEvent
readNextEvent(JniTracefile targetTracefile
) {
498 JniEvent returnedEvent
= null;
500 // There is 2 special cases where we should read the CURRENT event, not the next one
501 // 1- The currentEvent is null --> We never read or we just seeked
502 // 2- The currentEvent is of another type --> We last read on a DIFFERENT tracefile
503 if ( (currentEvent
== null) ||
504 (currentEvent
.getParentTracefile().equals(targetTracefile
) == false)
506 returnedEvent
= targetTracefile
.getCurrentEvent();
507 // Save the event we read
508 currentEvent
= returnedEvent
;
511 // Remove from the event related to this tracefile from the event heap, if it exists.
512 // WARNING : This only safe as long getCurrentEvent() never return "null" in any case.
513 eventsHeap
.remove(targetTracefile
.getCurrentEvent() );
515 // If status EOK, we can return the event, otherwise something wrong happen (out of range, read error, etc...)
516 if ( targetTracefile
.readNextEvent() == EOK
) {
517 returnedEvent
= targetTracefile
.getCurrentEvent();
518 // Add back to the heap the read event
519 eventsHeap
.add(returnedEvent
);
521 // Save the event we read...
522 // Note : might be null if the read failed and it's ok
523 currentEvent
= targetTracefile
.getCurrentEvent();
526 return returnedEvent
;
530 * Seek to a certain time but <b>do not</b> read the next event.<p>
532 * This only position the trace, it will not return anything.<p>
534 * @param seekTime The time where we want to seek to
536 * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
538 public void seekToTime(JniTime seekTime
) {
540 // Invalidate the last read event
543 Object tracefile_name
= null;
544 Iterator
<String
> iterator
= tracefilesMap
.keySet().iterator();
546 while (iterator
.hasNext() ) {
547 // We seek to the given event for ALL tracefiles
548 tracefile_name
= iterator
.next();
549 seekToTime(seekTime
, tracefilesMap
.get(tracefile_name
));
556 * Seek to a certain time on a certain tracefile but <b>do not</b> read the next event.<p>
558 * This only position the trace, it will not return anything.<p>
560 * @param targetTracefile The tracefile object to read from
561 * @param seekTime The time where we want to seek to
563 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
564 * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
566 public void seekToTime(JniTime seekTime
, JniTracefile targetTracefile
) {
567 // Invalidate the current read event
570 // Remove from the event related to this tracefile from the event heap, if it exists.
571 // WARNING : This is only safe as long getCurrentEvent() never return "null" in any case.
572 eventsHeap
.remove(targetTracefile
.getCurrentEvent() );
574 // Perform the actual seek on the tracefile
575 // Add the event to the heap if it succeed
576 if ( targetTracefile
.seekToTime(seekTime
) == EOK
) {
577 // Add back to the heap the read event
578 eventsHeap
.add(targetTracefile
.getCurrentEvent());
583 * Seek to a certain timestamp and read the next event.
585 * If no more events are available or an error happen, null will be returned.
587 * @param seekTime The time where we want to seek to.
589 * @return The event just after the seeked time or null if none available.
591 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
592 * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
594 public JniEvent
seekAndRead(JniTime seekTime
) {
595 JniEvent returnedEvent
= null;
596 seekToTime(seekTime
);
598 // The trace should be correctly positionned, let's get the event
599 returnedEvent
= readNextEvent();
601 return returnedEvent
;
605 * Seek to a certain timestamp on a certain tracefile and read the next event.<p>
607 * If no more events are available or an error happen, null will be returned.
609 * Calling readNextEvent() after this function will consider this tracefile moved and is then consistent.<br>
611 * @param targetTracefile The tracefile object to read from
612 * @param seekTime The time where we want to seek to
614 * @return The event just after the seeked time or null if none available.
616 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
617 * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
618 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
620 public JniEvent
seekAndRead(JniTime seekTime
, JniTracefile targetTracefile
) {
621 seekToTime(seekTime
, targetTracefile
);
622 return readNextEvent(targetTracefile
);
626 * Get a certain tracefile from its given name.<p>
628 * @param tracefileName The name of the tracefile.
630 * @return The tracefile found or null if none.
632 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
634 public JniTracefile
requestTracefileByName(String tracefileName
) {
635 return tracefilesMap
.get(tracefileName
);
639 * Get a certain event associated to a tracefile from the tracefile name.<p>
641 * @param tracefileName The name of the trace file.
643 * @return Event of the tracefile or null if none found.
645 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
647 public JniEvent
requestEventByName(String tracefileName
) {
648 JniEvent returnValue
= null;
650 JniTracefile tmpTracefile
= tracefilesMap
.get(tracefileName
);
652 // If the tracefile is found, return the current event
653 // There should always be an event linked to a tracefile
654 if (tmpTracefile
!= null) {
655 returnValue
= tmpTracefile
.getCurrentEvent();
661 // Access to class variable. Most of them doesn't have setter
662 public String
getTracepath() {
666 public int getCpuNumber() {
670 public long getArchType() {
674 public long getArchVariant() {
678 public short getArchSize() {
682 public short getLttMajorVersion() {
683 return lttMajorVersion
;
686 public short getLttMinorVersion() {
687 return lttMinorVersion
;
690 public short getFlightRecorder() {
691 return flightRecorder
;
694 public long getFreqScale() {
698 public long getStartFreq() {
702 public long getStartTimestampCurrentCounter() {
703 return startTimestampCurrentCounter
;
706 public long getStartMonotonic() {
707 return startMonotonic
;
710 public JniTime
getStartTime() {
714 public JniTime
getEndTime() {
718 public JniTime
getStartTimeNoAdjustement() {
719 return startTimeNoAdjustement
;
722 public HashMap
<String
, JniTracefile
> getTracefilesMap() {
723 return tracefilesMap
;
727 * The timestamp of the last read event.<p>
729 * Note : If no event is available, Long.MAX_VALUE is returned.
731 * @return Time of the last event read
733 * @see org.eclipse.linuxtools.lttng.jni.common.JniTime
735 public JniTime
getCurrentEventTimestamp() {
736 JniTime returnedTime
= null;
738 // If no event were read or we reach the last event in the trace,
739 // currentEvent will be null
740 if ( currentEvent
!= null ) {
741 returnedTime
= currentEvent
.getEventTime();
744 returnedTime
= new JniTime(Long
.MAX_VALUE
);
750 * Pointer to the LttTrace C structure.<p>
752 * The pointer should only be used <u>INTERNALY</u>, do not use unless you
753 * know what you are doing.
755 * @return The actual (long converted) pointer or NULL.
757 * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id
759 public Jni_C_Pointer_And_Library_Id
getTracePtr() {
764 * Return boolean value saying if the debug is enabled in LTT or not.<p>
766 * Note : this need to be set at construction.
768 * @return If the debug is set or not
770 public boolean isPrintingLttDebug() {
771 return printLttDebug
;
775 * Print information for all the tracefiles associated with this trace.
776 * <u>Intended to debug</u><p>
778 * This function will call Ltt to print, so information printed will be the
779 * one from the C structure, not the one populated in java.
781 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
783 public void printAllTracefilesInformation() {
784 JniTracefile tracefile
= null;
786 Iterator
<String
> iterator
= tracefilesMap
.keySet().iterator();
787 while (iterator
.hasNext()) {
788 tracefile
= tracefilesMap
.get(iterator
.next());
789 tracefile
.printTracefileInformation();
794 * Print information for this trace.
795 * <u>Intended to debug</u><p>
797 * This function will call Ltt to print, so information printed will be the
798 * one from the C structure, not the one populated in java.<p>
800 public void printTraceInformation() {
801 ltt_printTrace(thisTracePtr
.getLibraryId(), thisTracePtr
.getPointer());
806 * <u>Intended to debug</u><br>
808 * @return Attributes of the object concatenated in String
811 @SuppressWarnings("nls")
812 public String
toString() {
813 String returnData
= "";
814 returnData
+= "tracepath : " + tracepath
+ "\n";
815 returnData
+= "cpuNumber : " + cpuNumber
+ "\n";
816 returnData
+= "archType : " + archType
+ "\n";
817 returnData
+= "archVariant : " + archVariant
+ "\n";
818 returnData
+= "archSize : " + archSize
+ "\n";
819 returnData
+= "lttMajorVersion : " + lttMajorVersion
+ "\n";
820 returnData
+= "lttMinorVersion : " + lttMinorVersion
+ "\n";
821 returnData
+= "flightRecorder : " + flightRecorder
+ "\n";
822 returnData
+= "freqScale : " + freqScale
+ "\n";
823 returnData
+= "startFreq : " + startFreq
+ "\n";
824 returnData
+= "startTimestampCurrentCounter : " + startTimestampCurrentCounter
+ "\n";
825 returnData
+= "startMonotonic : " + startMonotonic
+ "\n";
826 returnData
+= "startTimeNoAdjustement : " + startTimeNoAdjustement
.getReferenceToString() + "\n";
827 returnData
+= " seconds : " + startTimeNoAdjustement
.getSeconds() + "\n";
828 returnData
+= " nanoSeconds : " + startTimeNoAdjustement
.getNanoSeconds() + "\n";
829 returnData
+= "startTime : " + startTime
.getReferenceToString() + "\n";
830 returnData
+= " seconds : " + startTime
.getSeconds() + "\n";
831 returnData
+= " nanoSeconds : " + startTime
.getNanoSeconds() + "\n";
832 returnData
+= "endTime : " + endTime
.getReferenceToString() + "\n";
833 returnData
+= " seconds : " + endTime
.getSeconds() + "\n";
834 returnData
+= " nanoSeconds : " + endTime
.getNanoSeconds() + "\n";
835 returnData
+= "tracefilesMap : " + tracefilesMap
.keySet() + "\n"; // Hack to avoid ending up with tracefilesMap.toString()
841 // ****************************
842 // **** ABSTRACT FUNCTIONS ****
843 // You MUST override those in your version specific implementation
846 * Function place holder to load the correct C library.<p>
848 * Can be as simple as calling ltt_initializeHandle(LIBRARY_NAME) with the correct .so instead of LIBRARY_NAME.<br>
849 * You may also want to perform some check or some additionnal validations.<br>
851 * <b>!! Override this with you version specific implementation.</b><br>
853 * @return integer that is the library id, or -1 if the load was unsuccessful
855 public abstract int initializeLibrary();
859 * Function place holder to allocate a new JniTracefile.<p>
861 * JniTracefile constructor is non overridable so we need another overridable function to return the correct version of JniTracefile.<br>
862 * Effect of this function should be the same (allocate a fresh new JniTracefile)<br>
864 * <b>!! Override this with you version specific implementation.</b><br>
866 * @param newPtr The pointer of an already opened LttTracefile C Structure
867 * @param newParentTrace The JniTrace parent of this tracefile.
869 * @return The newly allocated JniTracefile of the correct version
871 * @throws JniException The construction (allocation) failed.
873 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
874 * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id
875 * @see org.eclipse.linuxtools.lttng.jni.JniTrace
877 public abstract JniTracefile
allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr
, JniTrace newParentTrace
) throws JniException
;