From: William Bourque Date: Tue, 16 Feb 2010 20:35:44 +0000 (+0000) Subject: First draft for the JNI change to support multiple trace version. X-Git-Url: http://drtracing.org/?a=commitdiff_plain;h=a9fcdd8d9dea3e87b6db34f380ee19822376f86e;p=deliverable%2Ftracecompass.git First draft for the JNI change to support multiple trace version. --- diff --git a/org.eclipse.linuxtools.lttng.jni/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.lttng.jni/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..b6b7fb0846 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Feb 01 15:09:25 EST 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.eclipse.linuxtools.lttng.jni/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng.jni/META-INF/MANIFEST.MF index 34c5ae0c0f..52f1943fb0 100644 --- a/org.eclipse.linuxtools.lttng.jni/META-INF/MANIFEST.MF +++ b/org.eclipse.linuxtools.lttng.jni/META-INF/MANIFEST.MF @@ -1,8 +1,8 @@ Manifest-Version: 1.0 Bundle-ManifestVersion: 2 -Bundle-Name: %Bundle-Name +Bundle-Name: Jni Bundle-SymbolicName: org.eclipse.linuxtools.lttng.jni -Bundle-Version: 0.2.0.qualifier +Bundle-Version: 0.2.0 Bundle-RequiredExecutionEnvironment: J2SE-1.5 Export-Package: org.eclipse.linuxtools.lttng.jni, org.eclipse.linuxtools.lttng.jni.common, @@ -10,5 +10,3 @@ Export-Package: org.eclipse.linuxtools.lttng.jni, org.eclipse.linuxtools.lttng.jni.factory, org.eclipse.linuxtools.lttng.jni_v2_3, org.eclipse.linuxtools.lttng.jni_v2_5 -Bundle-Localization: plugin -Bundle-Vendor: %Bundle-Vendor diff --git a/org.eclipse.linuxtools.lttng.jni/build.properties b/org.eclipse.linuxtools.lttng.jni/build.properties index aa1a008269..34d2e4d2da 100644 --- a/org.eclipse.linuxtools.lttng.jni/build.properties +++ b/org.eclipse.linuxtools.lttng.jni/build.properties @@ -1,5 +1,4 @@ source.. = src/ output.. = bin/ bin.includes = META-INF/,\ - .,\ - plugin.properties + . diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java index 48dee4a666..8ac2df3431 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniEvent.java @@ -15,7 +15,7 @@ package org.eclipse.linuxtools.lttng.jni; import java.util.HashMap; import org.eclipse.linuxtools.lttng.jni.common.JniTime; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniEventException; import org.eclipse.linuxtools.lttng.jni.exception.JniException; import org.eclipse.linuxtools.lttng.jni.exception.JniNoSuchEventException; @@ -32,20 +32,15 @@ import org.eclipse.linuxtools.lttng.jni.exception.JniNoSuchEventException; * * Note that the JniEvent content is not directly accessibe and should be obtained * using the parseAllFields() or parseFieldBy...() methods. - * - * NOTE

- * This class is ABSTRACT, you need to extends it to support your specific LTTng version.

- * */ -public abstract class JniEvent extends Jni_C_Common implements Comparable -{ +public abstract class JniEvent extends Jni_C_Common implements Comparable { // Variables to detect if the event have been filled at least once // this make possible the detection of "uninitialized" struct in Ltt - // Can be "EOK", "ERANGE" or "EPERM" (defined in Jni_C_Common) + // Can be "EOK", "ERANGE" or "EPERM" (defined in Jaf_C_Common) private int eventState = EPERM; // Start with EPERM to ensure sanity // Internal C pointer of the JniEvent used in LTT - private Jni_C_Pointer_And_Library_Id thisEventPtr = new Jni_C_Pointer_And_Library_Id(); + private Jni_C_Pointer thisEventPtr = new Jni_C_Pointer(); // Reference to the parent tracefile private JniTracefile parentTracefile = null; @@ -58,40 +53,53 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable @@ -120,12 +128,12 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable newMarkersMap, JniTracefile newParentTracefile) throws JniException { - + public JniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + // Basic test to make sure we didn't get null/empty value if ((newEventPtr.getPointer() == NULL) || (newMarkersMap == null) @@ -159,13 +167,13 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable * - * @return LTT read status, as defined in Jni_C_Constant + * @return LTT read status, as defined in Jni_C_Common * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common */ public int seekToTime(JniTime seekTime) { // Ask Ltt to read the next event for this particular tracefile - eventState = ltt_seekEvent(tracefilePtr.getLibraryId(), tracefilePtr.getPointer(), seekTime); - + eventState = ltt_seekEvent(tracefilePtr.getPointer(), seekTime); + // If the event state is sane populate it if (eventState == EOK) { populateEventInformation(); @@ -207,9 +215,9 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable * - * @return LTT read status, as defined in Jni_C_Constant + * @return LTT read status, as defined in Jni_C_Common * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common */ public int seekOrFallBack(JniTime seekTime) { // Save the old time @@ -237,12 +245,12 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable which is the parsedContent objects and their name as key. * - * @see org.eclipse.linuxtools.lttng.jni.JniParser + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniParser */ public HashMap parseAllFields() { return JniParser.parseAllFields(this); @@ -341,7 +349,7 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable getMarkersMap() { @@ -370,10 +378,10 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable + * + * This function will not throw but will complain loudly if pointer is NULL. */ public void printEventInformation() { - ltt_printEvent(thisEventPtr.getLibraryId(), thisEventPtr.getPointer()); + + // If null pointer, print a warning! + if (thisEventPtr.getPointer() == NULL) { + printlnC("Pointer is NULL, cannot print. (printEventInformation)"); + } + else { + ltt_printEvent(thisEventPtr.getPointer()); + } } /** @@ -464,5 +481,4 @@ public abstract class JniEvent extends Jni_C_Common implements Comparable an overview of the marker format (in C style printf format) *

  • a reference to an ArrayList that contains MarkerFields object of this JniMarker * - * - * NOTE

    - * This class is ABSTRACT, you need to extends it to support your specific LTTng version.
    - * Please look at the abstract functions to override at the bottom of this file.

    - * */ public abstract class JniMarker extends Jni_C_Common { // Internal C pointer of the JniEvent used in LTT - private Jni_C_Pointer_And_Library_Id thisMarkerPtr = new Jni_C_Pointer_And_Library_Id(); + private Jni_C_Pointer thisMarkerPtr = new Jni_C_Pointer(); private String name = ""; private String formatOverview = ""; @@ -53,24 +49,37 @@ public abstract class JniMarker extends Jni_C_Common private ArrayList markerFieldsArrayList = null; // Native access method - protected native String ltt_getName(int libId, long markerPtr); - protected native String ltt_getFormatOverview(int libId, long markerPtr); - protected native long ltt_getSize(int libId, long markerPtr); - protected native short ltt_getLargestAlign(int libId, long markerPtr); - protected native short ltt_getIntSize(int libId, long markerPtr); - protected native short ltt_getLongSize(int libId, long markerPtr); - protected native short ltt_getPointerSize(int libId, long markerPtr); - protected native short ltt_getSize_tSize(int libId, long markerPtr); - protected native void ltt_getAllMarkerFields(int libId, long tracePtr); - protected native short ltt_getAlignement(int libId, long markerPtr); - protected native long ltt_getNextMarkerPtr(int libId, long markerPtr); + protected native String ltt_getName(long markerPtr); + protected native String ltt_getFormatOverview(long markerPtr); + @SuppressWarnings("unused") + protected native long ltt_getSize(long markerPtr); + @SuppressWarnings("unused") + protected native short ltt_getLargestAlign(long markerPtr); + @SuppressWarnings("unused") + protected native short ltt_getIntSize(long markerPtr); + @SuppressWarnings("unused") + protected native short ltt_getLongSize(long markerPtr); + @SuppressWarnings("unused") + protected native short ltt_getPointerSize(long markerPtr); + @SuppressWarnings("unused") + protected native short ltt_getSize_tSize(long markerPtr); + protected native void ltt_getAllMarkerFields(long tracePtr); + @SuppressWarnings("unused") + protected native short ltt_getAlignement(long markerPtr); + @SuppressWarnings("unused") + protected native long ltt_getNextMarkerPtr(long markerPtr); // Debug native function, ask LTT to print marker structure - protected native void ltt_printMarker(int libId, long markerPtr); + protected native void ltt_printMarker(long markerPtr); + + static { + System.loadLibrary("lttvtraceread_loader"); + } /* * Default constructor is forbidden */ + @SuppressWarnings("unused") protected JniMarker() { } @@ -95,7 +104,7 @@ public abstract class JniMarker extends Jni_C_Common * * @exception JniException */ - public JniMarker(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + public JniMarker(Jni_C_Pointer newMarkerPtr) throws JniException { thisMarkerPtr = newMarkerPtr; markerFieldsArrayList = new ArrayList(); markerFieldsHashMap = new HashMap(); @@ -113,10 +122,10 @@ public abstract class JniMarker extends Jni_C_Common if (thisMarkerPtr.getPointer() == NULL) { throw new JniMarkerException("Pointer is NULL, trace closed? (populateMarkerInformatOverviewion)"); } else { - name = ltt_getName(thisMarkerPtr.getLibraryId(), thisMarkerPtr.getPointer()); - formatOverview = ltt_getFormatOverview(thisMarkerPtr.getLibraryId(), thisMarkerPtr.getPointer()); + name = ltt_getName( thisMarkerPtr.getPointer() ); + formatOverview = ltt_getFormatOverview( thisMarkerPtr.getPointer() ); // To fill the markerFieldArray is a bit different - ltt_getAllMarkerFields(thisMarkerPtr.getLibraryId(), thisMarkerPtr.getPointer()); + ltt_getAllMarkerFields( thisMarkerPtr.getPointer() ); } } @@ -130,16 +139,17 @@ public abstract class JniMarker extends Jni_C_Common * @param markerName Name of the parent marker * @param markerFieldPtr C Pointer (converted in long) to marker_field C Structure */ - private void addMarkerFieldFromC(String markerFieldName, long markerFieldPtr) { - // Create a new Jni_markerField object and insert it in the map + @SuppressWarnings("unused") + private void addMarkerFieldFromC(String markerFieldName, long markerFieldPtr) { + // Create a new Jaf_markerField object and insert it in the map // the maker field fill itself with LTT data while being constructed try { - JniMarkerField newMarkerField = allocateNewJniMarkerField( new Jni_C_Pointer_And_Library_Id(thisMarkerPtr.getLibraryId(), markerFieldPtr)); + JniMarkerField newMarkerField = allocateNewJniMarkerField( new Jni_C_Pointer(markerFieldPtr) ); markerFieldsArrayList.add(newMarkerField); markerFieldsHashMap.put(markerFieldName, newMarkerField); } catch (JniException e) { - printlnC(thisMarkerPtr.getLibraryId(), "Failed to add marker field " + markerFieldName + " to marker fields list!(addMarkerFieldFromC)\n\tException raised : " + e.toString() ); + printlnC("Failed to add marker field " + markerFieldName + " to marker fields list!(addMarkerFieldFromC)\n\tException raised : " + e.toString() ); } } @@ -168,9 +178,9 @@ public abstract class JniMarker extends Jni_C_Common * * @return The actual (long converted) pointer or NULL * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer */ - public Jni_C_Pointer_And_Library_Id getMarkerPtr() { + public Jni_C_Pointer getMarkerPtr() { return thisMarkerPtr; } @@ -185,7 +195,13 @@ public abstract class JniMarker extends Jni_C_Common * This function will not throw but will complain loudly if pointer is NULL */ public void printMarkerInformation() { - ltt_printMarker(thisMarkerPtr.getLibraryId(), thisMarkerPtr.getPointer()); + + // If null pointer, print a warning! + if (thisMarkerPtr.getPointer() == NULL) { + printlnC("Pointer is NULL, cannot print. (printMarkerInformation)"); + } else { + ltt_printMarker(thisMarkerPtr.getPointer()); + } } /** @@ -199,7 +215,7 @@ public abstract class JniMarker extends Jni_C_Common Object[] allMarkersField = markerFieldsArrayList.toArray(); for (int pos = 0; pos < allMarkersField.length; pos++) { - printlnC(thisMarkerPtr.getLibraryId(), allMarkersField[pos].toString()); + printlnC(allMarkersField[pos].toString()); } } @@ -215,34 +231,12 @@ public abstract class JniMarker extends Jni_C_Common returnData += "name : " + name + "\n"; returnData += "formatOverview : " + formatOverview + "\n"; - returnData += "markerFieldArrayList : " + markerFieldsArrayList.hashCode() + " (size : " + markerFieldsArrayList.size() + " )" + "\n"; - + returnData += "markerFieldArrayList : " + markerFieldsArrayList.toArray() + "\n"; + return returnData; } - // **************************** - // **** ABSTRACT FUNCTIONS **** - // You MUST override those in your version specific implementation - - - /** - * Function place holder to allocate a new JniMarkerField.

    - *
    - * JniMarkerField constructor is non overridable so we need another overridable function to return the correct version of JniMarkerField.
    - * Effect of this function should be the same (allocate a fresh new JniMarkerField).
    - *
    - * !! Override this with you version specific implementation.
    - * - * @param newMarkerFieldPtr The pointer and library id of an already opened marker_field C Structure - * - * @return The newly allocated JniMarkerField of the correct version - * - * @throws JniException The construction (allocation) failed. - * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id - * @see org.eclipse.linuxtools.lttng.jni.JniMarkerField - */ - public abstract JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException; + public abstract JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException; } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java index e2b13bb88c..23187acca5 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniMarkerField.java @@ -1,6 +1,6 @@ package org.eclipse.linuxtools.lttng.jni; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; import org.eclipse.linuxtools.lttng.jni.exception.JniMarkerFieldException; @@ -16,35 +16,42 @@ import org.eclipse.linuxtools.lttng.jni.exception.JniMarkerFieldException; *

  • the name (field) of in String *
  • the marker field format (in C style printf format) * - * - * NOTE

    - * This class is ABSTRACT, you need to extends it to support your specific LTTng version.

    - * */ public abstract class JniMarkerField extends Jni_C_Common { // Internal C pointer of the JniEvent used in LTT - private Jni_C_Pointer_And_Library_Id thisMarkerFieldPtr = new Jni_C_Pointer_And_Library_Id(); + private Jni_C_Pointer thisMarkerFieldPtr = new Jni_C_Pointer(); private String field = ""; private String format = ""; // Native access method - protected native String ltt_getField(int libId, long markerFieldPtr); - protected native int ltt_getType(int libId, long markerFieldPtr); - protected native long ltt_getOffset(int libId, long markerFieldPtr); - protected native long ltt_getSize(int libId, long markerFieldPtr); - protected native long ltt_getAlignment(int libId, long markerFieldPtr); - protected native long ltt_getAttributes(int libId, long markerFieldPtr); - protected native int ltt_getStatic_offset(int libId, long markerFieldPtr); - protected native String ltt_getFormat(int libId, long markerFieldPtr); + protected native String ltt_getField(long markerFieldPtr); + @SuppressWarnings("unused") + protected native int ltt_getType(long markerFieldPtr); + @SuppressWarnings("unused") + protected native long ltt_getOffset(long markerFieldPtr); + @SuppressWarnings("unused") + protected native long ltt_getSize(long markerFieldPtr); + @SuppressWarnings("unused") + protected native long ltt_getAlignment(long markerFieldPtr); + @SuppressWarnings("unused") + protected native long ltt_getAttributes(long markerFieldPtr); + @SuppressWarnings("unused") + protected native int ltt_getStatic_offset(long markerFieldPtr); + protected native String ltt_getFormat(long markerFieldPtr); // Debug native function, ask LTT to print marker structure - protected native void ltt_printMarkerField(int libId, long markerFieldPtr); + protected native void ltt_printMarkerField(long markerFieldPtr); + + static { + System.loadLibrary("lttvtraceread_loader"); + } /* * Default constructor is forbidden */ + @SuppressWarnings("unused") protected JniMarkerField() { } @@ -65,10 +72,8 @@ public abstract class JniMarkerField extends Jni_C_Common * @param newMarkerFieldPtr Pointer to a C marker_field structure * * @exception JniException - * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id */ - public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + public JniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException { thisMarkerFieldPtr = newMarkerFieldPtr; // Populate the marker field @@ -84,8 +89,8 @@ public abstract class JniMarkerField extends Jni_C_Common throw new JniMarkerFieldException( "Pointer is NULL, trace closed? (populateMarkerInformation)"); } else { - field = ltt_getField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer()); - format = ltt_getFormat(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer()); + field = ltt_getField(thisMarkerFieldPtr.getPointer()); + format = ltt_getFormat(thisMarkerFieldPtr.getPointer()); } } @@ -105,9 +110,9 @@ public abstract class JniMarkerField extends Jni_C_Common * * @return The actual (long converted) pointer or NULL * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer */ - public Jni_C_Pointer_And_Library_Id getMarkerFieldPtr() { + public Jni_C_Pointer getMarkerFieldPtr() { return thisMarkerFieldPtr; } @@ -116,9 +121,17 @@ public abstract class JniMarkerField extends Jni_C_Common * * This function will call Ltt to print, so information printed will be the one from * the C structure, not the one populated in java.

    + * + * This function will not throw but will complain loudly if pointer is NULL */ public void printMarkerFieldInformation() { - ltt_printMarkerField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer()); + + // If null pointer, print a warning! + if (thisMarkerFieldPtr.getPointer() == NULL) { + printlnC("Pointer is NULL, cannot print. (printMarkerFieldInformation)"); + } else { + ltt_printMarkerField(thisMarkerFieldPtr.getPointer()); + } } /** @@ -135,5 +148,4 @@ public abstract class JniMarkerField extends Jni_C_Common return returnData; } - } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniParser.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniParser.java index adeafd9ff5..22e7ab9dab 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniParser.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniParser.java @@ -23,14 +23,14 @@ import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; * JniParser is used to parse an event payload into something usable.

    * * All methods are static, the parser shouldn't be instantiated. - * - * NOTE

    - * This class is ABSTRACT, you need to extends it to support your specific LTTng version.

    - * */ public abstract class JniParser extends Jni_C_Common { - protected static native void ltt_getParsedData(int libId, ParsedObjectContent parseddata, long eventPtr, long markerFieldPtr); + protected static native void ltt_getParsedData(ParsedObjectContent parseddata, long eventPtr, long markerFieldPtr); + + static { + System.loadLibrary("lttvtraceread_loader"); + } // *** HACK *** // We cannot use "Object" directly as java does not support swapping primitive value @@ -56,7 +56,7 @@ public abstract class JniParser extends Jni_C_Common * * @return An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position) * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ static public Object parseField(JniEvent eventToParse, int fieldPosition) { @@ -68,7 +68,7 @@ public abstract class JniParser extends Jni_C_Common JniMarkerField tmpField = eventToParse.requestEventMarker().getMarkerFieldsArrayList().get(fieldPosition); // Call the parsing function in C. The result will be put in parsedData object - ltt_getParsedData(eventToParse.getEventPtr().getLibraryId(), parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer()); + ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() ); return parsedData.getData(); } @@ -84,7 +84,7 @@ public abstract class JniParser extends Jni_C_Common * * @return An Object that contain the JniEvent payload parsed by the C, or null, if if was impossible to parse (i.e., wrong position) * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ static public Object parseField(JniEvent eventToParse, String fieldName) { @@ -95,7 +95,7 @@ public abstract class JniParser extends Jni_C_Common return null; } - ltt_getParsedData(eventToParse.getEventPtr().getLibraryId(), parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer()); + ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), tmpField.getMarkerFieldPtr().getPointer() ); return parsedData.getData(); } @@ -110,7 +110,7 @@ public abstract class JniParser extends Jni_C_Common * @param eventToParse The jni event we want to parse. * @return An HashMap of Object that contain the is the JniEvent's payload parsed by the C * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ static public HashMap parseAllFields(JniEvent eventToParse) { HashMap markerFieldData = eventToParse.requestEventMarker().getMarkerFieldsHashMap(); @@ -130,14 +130,16 @@ public abstract class JniParser extends Jni_C_Common // HashMap parsedDataMap = (HashMap)markerFieldData.clone(); // Or even safer, use HashMap constructor to do so : HashMap parsedDataMap = new HashMap(markerFieldData); - + + String newKey = null; JniMarkerField newMarkerField = null; Iterator iterator = markerFieldData.keySet().iterator(); while ( iterator.hasNext() ) { - newMarkerField = markerFieldData.get(iterator.next()); + newKey = iterator.next(); + newMarkerField = markerFieldData.get(newKey); // Call the C to parse the data - ltt_getParsedData(eventToParse.getEventPtr().getLibraryId(), parsedData, eventToParse.getEventPtr().getPointer(), newMarkerField.getMarkerFieldPtr().getPointer()); + ltt_getParsedData(parsedData, eventToParse.getEventPtr().getPointer(), newMarkerField.getMarkerFieldPtr().getPointer() ); // Save the result into the HashMap parsedDataMap.put(newMarkerField.getField(), parsedData.getData() ); } @@ -158,7 +160,8 @@ public abstract class JniParser extends Jni_C_Common * @param stringToAdd The parsed data to add * @param formatToAdd The format of the raw data */ - static private void addStringToParsingFromC(Object contentHolder, String stringToAdd) { + @SuppressWarnings("unused") + static private void addStringToParsingFromC(Object contentHolder, String stringToAdd) { ((ParsedObjectContent)contentHolder).setData( stringToAdd); } @@ -174,7 +177,8 @@ public abstract class JniParser extends Jni_C_Common * @param pointerToAdd The parsed data to add (in 64 bits long!) * @param formatToAdd The format of the raw data */ - static private void addLongPointerToParsingFromC(Object contentHolder, long pointerToAdd) { + @SuppressWarnings("unused") + static private void addLongPointerToParsingFromC(Object contentHolder, long pointerToAdd) { ((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((long) pointerToAdd)); } @@ -190,7 +194,8 @@ public abstract class JniParser extends Jni_C_Common * @param pointerToAdd The parsed data to add (converted in 64 bits long!) * @param formatToAdd The format of the raw data */ - static private void addIntPointerToParsingFromC(Object contentHolder, long pointerToAdd) { + @SuppressWarnings("unused") + static private void addIntPointerToParsingFromC(Object contentHolder, long pointerToAdd) { ((ParsedObjectContent)contentHolder).setData( new Jni_C_Pointer((int) pointerToAdd)); } @@ -206,8 +211,9 @@ public abstract class JniParser extends Jni_C_Common * @param shortToAdd The parsed data to add * @param formatToAdd The format of the raw data */ - static private void addShortToParsingFromC(Object contentHolder, short shortToAdd) { - ((ParsedObjectContent)contentHolder).setData( Short.valueOf(shortToAdd)); + @SuppressWarnings("unused") + static private void addShortToParsingFromC(Object contentHolder, short shortToAdd) { + ((ParsedObjectContent)contentHolder).setData( new Short(shortToAdd)); } /* @@ -222,8 +228,9 @@ public abstract class JniParser extends Jni_C_Common * @param intToAdd The parsed data to add * @param formatToAdd The format of the raw data */ - static private void addIntegerToParsingFromC(Object contentHolder, int intToAdd) { - ((ParsedObjectContent)contentHolder).setData( Integer.valueOf(intToAdd)); + @SuppressWarnings("unused") + static private void addIntegerToParsingFromC(Object contentHolder, int intToAdd) { + ((ParsedObjectContent)contentHolder).setData( new Integer(intToAdd)); } /* @@ -238,8 +245,9 @@ public abstract class JniParser extends Jni_C_Common * @param longToAdd The parsed data to add * @param formatToAdd The format of the raw data */ - static private void addLongToParsingFromC(Object contentHolder, long longToAdd) { - ((ParsedObjectContent)contentHolder).setData( Long.valueOf(longToAdd)); + @SuppressWarnings("unused") + static private void addLongToParsingFromC(Object contentHolder, long longToAdd) { + ((ParsedObjectContent)contentHolder).setData( new Long(longToAdd)); } /* @@ -254,7 +262,8 @@ public abstract class JniParser extends Jni_C_Common * @param floatToAdd The parsed data to add * @param formatToAdd The format of the raw data */ - static private void addFloatToParsingFromC(Object contentHolder, float floatToAdd) { + @SuppressWarnings("unused") + static private void addFloatToParsingFromC(Object contentHolder, float floatToAdd) { ((ParsedObjectContent)contentHolder).setData( new Float(floatToAdd)); } @@ -271,13 +280,13 @@ public abstract class JniParser extends Jni_C_Common * @param doubleToAdd The parsed data to add * @param formatToAdd The format of the raw data */ - static private void addDoubleToParsingFromC(Object contentHolder, double doubleToAdd) { + @SuppressWarnings("unused") + static private void addDoubleToParsingFromC(Object contentHolder, double doubleToAdd) { ((ParsedObjectContent)contentHolder).setData( new Double(doubleToAdd)); } } - /** * ParsedObjectContent

    * @@ -294,4 +303,4 @@ class ParsedObjectContent { public void setData(Object newData) { parsedData = newData; } -} +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTime.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTime.java new file mode 100644 index 0000000000..b6bcdfe50a --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTime.java @@ -0,0 +1,178 @@ +package org.eclipse.linuxtools.lttng.jni; +/******************************************************************************* + * Copyright (c) 2009 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * William Bourque (wbourque@gmail.com) - Initial API and implementation + *******************************************************************************/ + + +/** + * JniTime + *

    + * Used to store (event, trace, tracefile, ...) timestamp. + * + * Mimic the behavior of the LttTime C structure. + */ +public class JniTime extends Jni_C_Common implements Comparable +{ + private long time = 0; + + /** + * Default constructor.

    + * + * Note : Time will be set to 0. + * + */ + public JniTime() { + time = 0; + } + + /** + * Copy constructor. + * + * @param oldTime Reference to the JniTime you want to copy. + */ + public JniTime(JniTime oldTime) { + time = oldTime.getTime(); + } + + /** + * Constructor with parameters.

    + * + * "LTT style" constructor with Seconds et Nanoseconds + * + * @param newSec Seconds of the JniTime + * @param newNanoSec Nanoseconds of the JniTime + */ + public JniTime(long newSec, long newNanoSec) { + time = (newSec * NANO) + newNanoSec; + } + + /** + * Constructor with parameters.

    + * + * Usual "nanosecond only" constructor. + * + * @param newNanoSecTime Time in nanoseconds + */ + public JniTime(long newNanoSecTime) { + time = newNanoSecTime; + } + + /** + * Second of the time.

    + * + * Returns seconds, i.e. multiple of 1 000 000, of the stored nanoseconds time. + * + * @return Second of this time. + */ + public long getSeconds() { + return (time / NANO); + } + + /** + * Getter for the nanosecond of the time.

    + * + * Returns nanoseconds part, i.e. modulo of 1 000 000, of the stored nanoseconds time. + * + * @return Nanoseconds of this time + */ + public long getNanoSeconds() { + return time % NANO; + } + + /** + * Full time, in nanoseconds.

    + * + * @return Complete time in nanoseconds + */ + public long getTime() { + return time; + } + + /** + * Changes the current time for this object

    + * + * @param newTime New time to set, in nanoseconds. + */ + public void setTime(long newTime) { + time = newTime; + } + + /* + * Populate this time object + * + * Note: This function is called from C side. + * + * @param newTime The time we want to populate + */ + @SuppressWarnings("unused") + private void setTimeFromC(long newTime) { + time = newTime; + } + + /** + * Comparaison operator smaller or equal than "<=" .

    + * + * @param comparedTime The time we want to compare with this one + * + * @return true if compared time is smaller or equal, false otherwise + */ + public boolean isSmallerOrEqual(JniTime comparedTime) { + + // NOTE : We check <= instead of just < + // This mean the LEFT OPERAND (comparedTime) always prevails + if (this.getTime() <= comparedTime.getTime() ) { + return true; + } + else { + return false; + } + } + + /** + * compareTo operator.

    + * + * @param right The time we want to compare with this one + * + * @return int of value -1, 0 or 1, as the pased argument is bigger, equal or smaller than this time + */ + public int compareTo(JniTime right) { + long leftTime = this.getTime(); + long rightTime = right.getTime(); + + if ( leftTime < rightTime ) { + return -1; + } + else if ( leftTime > rightTime ) { + return 1; + } + else { + return 0; + } + } + + /** + * toString() method. + * Intended to debug

    + * + * NOTE : We output the time in the same format as LTT (seconds and nanosecond separatly) + * + * @return String Attributes of the object concatenated in String + */ + @Override + public String toString() { + String returnData = ""; + + returnData += "seconds : " + this.getSeconds() + "\n"; + returnData += "nanoSeconds : " + this.getNanoSeconds() + "\n"; + + return returnData; + } +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java index 9387662a37..094f50f497 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTrace.java @@ -11,12 +11,13 @@ package org.eclipse.linuxtools.lttng.jni; * William Bourque (wbourque@gmail.com) - Initial API and implementation *******************************************************************************/ + import java.util.HashMap; import java.util.Iterator; import java.util.PriorityQueue; import org.eclipse.linuxtools.lttng.jni.common.JniTime; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; import org.eclipse.linuxtools.lttng.jni.exception.JniOpenTraceFailedException; import org.eclipse.linuxtools.lttng.jni.exception.JniTraceException; @@ -33,23 +34,19 @@ import org.eclipse.linuxtools.lttng.jni.exception.JniTracefileWithoutEventExcept *

  • a JniTrace path (a trace directory) *
  • a HashMap of tracefiles that exists in this trace * - *

    - * NOTE

    - * This class is ABSTRACT, you need to extends it to support your specific LTTng version.
    - * Please look at the abstract functions to override at the bottom of this file.

    */ public abstract class JniTrace extends Jni_C_Common { private final static boolean DEFAULT_LTT_DEBUG = false; // Internal C pointer of the JniTrace used in LTT - private Jni_C_Pointer_And_Library_Id thisTracePtr = new Jni_C_Pointer_And_Library_Id(); + private Jni_C_Pointer thisTracePtr = new Jni_C_Pointer(); // Data we should populate from LTT // Note that all type have been scaled up as there is no "unsigned" in java // This might be a problem about "unsigned long" as there is no equivalent // in java - + private String tracepath = ""; // Path of the trace. Should be a directory (like : /tmp/traceX) private int cpuNumber = 0; private long archType = 0; @@ -77,45 +74,47 @@ public abstract class JniTrace extends Jni_C_Common { // Should we print debug in the C library or not? private boolean printLttDebug = DEFAULT_LTT_DEBUG; - // This need to be called prior to any operation - protected native int ltt_initializeHandle(String libname); - + protected native boolean ltt_initializeHandle(String libname); // This need to be called at the very end (destructor) - protected native boolean ltt_freeHandle(int libId); + protected native boolean ltt_freeHandle(); // Open/close native functions - protected native long ltt_openTrace(int libId, String pathname, boolean printDebug); - protected native void ltt_closeTrace(int libId, long tracePtr); + protected native long ltt_openTrace(String pathname, boolean printDebug); + protected native void ltt_closeTrace(long tracePtr); // Native access functions - protected native String ltt_getTracepath(int libId, long tracePtr); - protected native int ltt_getCpuNumber(int libId, long tracePtr); - protected native long ltt_getArchType(int libId, long tracePtr); - protected native long ltt_getArchVariant(int libId, long tracePtr); - protected native short ltt_getArchSize(int libId, long tracePtr); - protected native short ltt_getLttMajorVersion(int libId, long tracePtr); - protected native short ltt_getLttMinorVersion(int libId, long tracePtr); - protected native short ltt_getFlightRecorder(int libId, long tracePtr); - protected native long ltt_getFreqScale(int libId, long tracePtr); - protected native long ltt_getStartFreq(int libId, long tracePtr); - protected native long ltt_getStartTimestampCurrentCounter(int libId, long tracePtr); - protected native long ltt_getStartMonotonic(int libId, long tracePtr); + protected native String ltt_getTracepath(long tracePtr); + protected native int ltt_getCpuNumber(long tracePtr); + protected native long ltt_getArchType(long tracePtr); + protected native long ltt_getArchVariant(long tracePtr); + protected native short ltt_getArchSize(long tracePtr); + protected native short ltt_getLttMajorVersion(long tracePtr); + protected native short ltt_getLttMinorVersion(long tracePtr); + protected native short ltt_getFlightRecorder(long tracePtr); + protected native long ltt_getFreqScale(long tracePtr); + protected native long ltt_getStartFreq(long tracePtr); + protected native long ltt_getStartTimestampCurrentCounter(long tracePtr); + protected native long ltt_getStartMonotonic(long tracePtr); // Native function to fill out startTime - protected native void ltt_feedStartTime(int libId, long tracePtr, JniTime startTime); + protected native void ltt_feedStartTime(long tracePtr, JniTime startTime); // Native function to fill out startTimeFromTimestampCurrentCounter - protected native void ltt_feedStartTimeFromTimestampCurrentCounter(int libId, long tracePtr, JniTime startTime); + protected native void ltt_feedStartTimeFromTimestampCurrentCounter(long tracePtr, JniTime startTime); // Native function to fill out tracefilesMap - protected native void ltt_feedAllTracefiles(int libId, long tracePtr); + protected native void ltt_feedAllTracefiles(long tracePtr); // Native function to fill out the start and end time of the trace - protected native void ltt_feedTracefileTimeRange(int libId, long tracePtr, JniTime startTime, JniTime endTime); + protected native void ltt_feedTracefileTimeRange(long tracePtr, JniTime startTime, JniTime endTime); // Debug native function, ask LTT to print trace structure - protected native void ltt_printTrace(int libId, long tracePtr); + protected native void ltt_printTrace(long tracePtr); + + static { + System.loadLibrary("lttvtraceread_loader"); + } /* * Default constructor is forbidden @@ -148,7 +147,7 @@ public abstract class JniTrace extends Jni_C_Common { */ public JniTrace(String newpath, boolean newPrintDebug) throws JniException { tracepath = newpath; - thisTracePtr = new Jni_C_Pointer_And_Library_Id(); + thisTracePtr = new Jni_C_Pointer(); printLttDebug = newPrintDebug; openTrace(newpath); @@ -179,10 +178,10 @@ public abstract class JniTrace extends Jni_C_Common { endTime = oldTrace.endTime; tracefilesMap = new HashMap(oldTrace.tracefilesMap.size()); - ltt_feedAllTracefiles(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); + tracefilesMap = oldTrace.tracefilesMap; eventsHeap = new PriorityQueue( oldTrace.eventsHeap.size()); - populateEventHeap(); + eventsHeap = oldTrace.eventsHeap; printLttDebug = oldTrace.printLttDebug; } @@ -195,9 +194,9 @@ public abstract class JniTrace extends Jni_C_Common { * * @exception JniException * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer */ - public JniTrace(Jni_C_Pointer_And_Library_Id newPtr, boolean newPrintDebug) throws JniException { + public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException { thisTracePtr = newPtr; printLttDebug = newPrintDebug; @@ -206,14 +205,12 @@ public abstract class JniTrace extends Jni_C_Common { } - @Override - public void finalize() { + public void finalize() { // If the trace is open, close it if (thisTracePtr.getPointer() != NULL) { closeTrace(); } - // Tell the C to free the allocated memory freeLibrary(); } @@ -221,7 +218,7 @@ public abstract class JniTrace extends Jni_C_Common { * Open an existing trace.

    * * The tracepath is a directory and needs to exist, otherwise - * a JniOpenTraceFailedException is throwed. + * a JafOpenTraceFailedException is throwed. * * @param newPath The directory of the trace to be opened * @@ -257,29 +254,24 @@ public abstract class JniTrace extends Jni_C_Common { closeTrace(); } - // Initialization of the library is made here - // It is very important that the id is kept! - int newLibraryId = initializeLibrary(); - if ( newLibraryId != -1 ) { + if ( initializeLibrary() == true ) { // Call the LTT to open the trace - // Note that the libraryId is not yet and the pointer - long newPtr = ltt_openTrace(newLibraryId, tracepath, printLttDebug); + long newPtr = ltt_openTrace(tracepath, printLttDebug); if (newPtr == NULL) { - thisTracePtr = new Jni_C_Pointer_And_Library_Id(); + thisTracePtr = new Jni_C_Pointer(NULL); throw new JniOpenTraceFailedException("Error while opening trace. Is the tracepath correct? (openTrace)"); } // This is OUR pointer - thisTracePtr = new Jni_C_Pointer_And_Library_Id(newLibraryId, newPtr); + thisTracePtr = new Jni_C_Pointer(newPtr); // Populate the trace with LTT information populateTraceInformation(); } else { - thisTracePtr = new Jni_C_Pointer_And_Library_Id(); - throw new JniTraceException("Failed to initialize library! Is the trace version supported?\n" + - "Make sure you have the correct LTTv library compiled. (openTrace)"); + thisTracePtr = new Jni_C_Pointer(NULL); + throw new JniTraceException("Failed to initialize library! Trace version not supported? (openTrace)"); } } @@ -291,7 +283,7 @@ public abstract class JniTrace extends Jni_C_Common { public void closeTrace() { if (thisTracePtr.getPointer() != NULL) { - ltt_closeTrace(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); + ltt_closeTrace(thisTracePtr.getPointer()); // Clear the tracefile map tracefilesMap.clear(); @@ -302,7 +294,11 @@ public abstract class JniTrace extends Jni_C_Common { eventsHeap = null; // Nullify the pointer - thisTracePtr = new Jni_C_Pointer_And_Library_Id(); + thisTracePtr = new Jni_C_Pointer(NULL); + + // Ask the garbage collector to make a little pass here, as we could + // be left with 100's of unreferenced objects + System.gc(); } } @@ -312,7 +308,7 @@ public abstract class JniTrace extends Jni_C_Common { * Note : No call to the library will work after this until ltt_initializeHandle is called again */ public void freeLibrary() { - ltt_freeHandle(thisTracePtr.getLibraryId()); + ltt_freeHandle(); } /* @@ -326,18 +322,18 @@ public abstract class JniTrace extends Jni_C_Common { } // Populate from the LTT library - tracepath = ltt_getTracepath(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - cpuNumber = ltt_getCpuNumber(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - archType = ltt_getArchType(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - archVariant = ltt_getArchVariant(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - archSize = ltt_getArchSize(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - lttMajorVersion = ltt_getLttMajorVersion(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - lttMinorVersion = ltt_getLttMinorVersion(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - flightRecorder = ltt_getFlightRecorder(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - freqScale = ltt_getFreqScale(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - startFreq = ltt_getStartFreq(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - startTimestampCurrentCounter = ltt_getStartTimestampCurrentCounter(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); - startMonotonic = ltt_getStartMonotonic(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); + tracepath = ltt_getTracepath( thisTracePtr.getPointer() ); + cpuNumber = ltt_getCpuNumber( thisTracePtr.getPointer() ); + archType = ltt_getArchType( thisTracePtr.getPointer() ); + archVariant = ltt_getArchVariant( thisTracePtr.getPointer() ); + archSize = ltt_getArchSize( thisTracePtr.getPointer() ); + lttMajorVersion = ltt_getLttMajorVersion( thisTracePtr.getPointer() ); + lttMinorVersion = ltt_getLttMinorVersion( thisTracePtr.getPointer() ); + flightRecorder = ltt_getFlightRecorder( thisTracePtr.getPointer() ); + freqScale = ltt_getFreqScale( thisTracePtr.getPointer() ); + startFreq = ltt_getStartFreq( thisTracePtr.getPointer() ); + startTimestampCurrentCounter = ltt_getStartTimestampCurrentCounter( thisTracePtr.getPointer() ); + startMonotonic = ltt_getStartMonotonic( thisTracePtr.getPointer() ); // Creation of time is a bit different, we need to pass the object reference to C // @@ -345,21 +341,21 @@ public abstract class JniTrace extends Jni_C_Common { // So "startTimeNoAdjustement" is obtain throught "ltt_feedStartTime()" and // "startTime" is obtained from ltt_feedStartTimeFromTimestampCurrentCounter() startTimeNoAdjustement = new JniTime(); - ltt_feedStartTime(thisTracePtr.getLibraryId(), thisTracePtr.getPointer(), startTimeNoAdjustement); + ltt_feedStartTime( thisTracePtr.getPointer(), startTimeNoAdjustement ); startTime = new JniTime(); - ltt_feedStartTimeFromTimestampCurrentCounter(thisTracePtr.getLibraryId(), thisTracePtr.getPointer(), startTime); + ltt_feedStartTimeFromTimestampCurrentCounter( thisTracePtr.getPointer(), startTime ); // Call the fill up function for the tracefiles map if ( tracefilesMap== null ) { tracefilesMap = new HashMap(); } - ltt_feedAllTracefiles(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); + ltt_feedAllTracefiles( thisTracePtr.getPointer() ); // Now, obtain the trace "endTime" // Note that we discard "startTime" right away, as we already have it endTime = new JniTime(); - ltt_feedTracefileTimeRange(thisTracePtr.getLibraryId(), thisTracePtr.getPointer(), new JniTime(), endTime); + ltt_feedTracefileTimeRange(thisTracePtr.getPointer(), new JniTime(), endTime); if (eventsHeap == null) { eventsHeap = new PriorityQueue(tracefilesMap.size()); @@ -408,17 +404,17 @@ public abstract class JniTrace extends Jni_C_Common { // Create a new tracefile object and insert it in the map // the tracefile fill itself with LTT data while being constructed try { - newTracefile = allocateNewJniTracefile(new Jni_C_Pointer_And_Library_Id(thisTracePtr.getLibraryId(), tracefilePtr), this); + newTracefile = allocateNewJniTracefile( new Jni_C_Pointer(tracefilePtr), this ); getTracefilesMap().put( (tracefileName + newTracefile.getCpuNumber()), newTracefile); } catch(JniTracefileWithoutEventException e) { if ( printLttDebug == true ) { - printlnC(thisTracePtr.getLibraryId(), "JniTracefile " + tracefileName + " has no event (addTracefileFromC). Ignoring."); + printlnC("JniTracefile " + tracefileName + " has no event (addTracefileFromC). Ignoring."); } } catch(Exception e) { if ( printLttDebug == true ) { - printlnC(thisTracePtr.getLibraryId(), "Failed to add tracefile " + tracefileName + " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e.toString() ); + printlnC("Failed to add tracefile " + tracefileName + " to tracefilesMap!(addTracefileFromC)\n\tException raised : " + e.toString() ); } } } @@ -430,7 +426,7 @@ public abstract class JniTrace extends Jni_C_Common { * * @return The top event in the stack or null if no event is available. * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ public JniEvent findNextEvent() { return eventsHeap.peek(); @@ -441,7 +437,7 @@ public abstract class JniTrace extends Jni_C_Common { * * @return The next event in the trace or null if no event is available. * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ public JniEvent readNextEvent() { // Get the "next" event on the top of the heap but DO NOT remove it @@ -490,8 +486,8 @@ public abstract class JniTrace extends Jni_C_Common { * * @return The next event in the tracefile or null if no event is available. * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ public JniEvent readNextEvent(JniTracefile targetTracefile) { JniEvent returnedEvent = null; @@ -532,7 +528,7 @@ public abstract class JniTrace extends Jni_C_Common { * * @param seekTime The time where we want to seek to * - * @see org.eclipse.linuxtools.lttng.jni.common.JniTime + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime */ public void seekToTime(JniTime seekTime) { @@ -559,8 +555,8 @@ public abstract class JniTrace extends Jni_C_Common { * @param targetTracefile The tracefile object to read from * @param seekTime The time where we want to seek to * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - * @see org.eclipse.linuxtools.lttng.jni.common.JniTime + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime */ public void seekToTime(JniTime seekTime, JniTracefile targetTracefile) { // Invalidate the current read event @@ -587,8 +583,8 @@ public abstract class JniTrace extends Jni_C_Common { * * @return The event just after the seeked time or null if none available. * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent - * @see org.eclipse.linuxtools.lttng.jni.common.JniTime + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime */ public JniEvent seekAndRead(JniTime seekTime) { JniEvent returnedEvent = null; @@ -607,14 +603,14 @@ public abstract class JniTrace extends Jni_C_Common { * * Calling readNextEvent() after this function will consider this tracefile moved and is then consistent.
    * - * @param targetTracefile The tracefile object to read from + * @param tracefileName The tracefile object to read from * @param seekTime The time where we want to seek to * * @return The event just after the seeked time or null if none available. * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - * @see org.eclipse.linuxtools.lttng.jni.common.JniTime - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ public JniEvent seekAndRead(JniTime seekTime, JniTracefile targetTracefile) { seekToTime(seekTime, targetTracefile); @@ -628,7 +624,7 @@ public abstract class JniTrace extends Jni_C_Common { * * @return The tracefile found or null if none. * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile */ public JniTracefile requestTracefileByName(String tracefileName) { return tracefilesMap.get(tracefileName); @@ -641,7 +637,7 @@ public abstract class JniTrace extends Jni_C_Common { * * @return Event of the tracefile or null if none found. * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniEvent */ public JniEvent requestEventByName(String tracefileName) { JniEvent returnValue = null; @@ -729,7 +725,7 @@ public abstract class JniTrace extends Jni_C_Common { * * @return Time of the last event read * - * @see org.eclipse.linuxtools.lttng.jni.common.JniTime + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.JniTime */ public JniTime getCurrentEventTimestamp() { JniTime returnedTime = null; @@ -753,9 +749,9 @@ public abstract class JniTrace extends Jni_C_Common { * * @return The actual (long converted) pointer or NULL. * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer */ - public Jni_C_Pointer_And_Library_Id getTracePtr() { + public Jni_C_Pointer getTracePtr() { return thisTracePtr; } @@ -777,7 +773,7 @@ public abstract class JniTrace extends Jni_C_Common { * This function will call Ltt to print, so information printed will be the * one from the C structure, not the one populated in java. * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTracefile */ public void printAllTracefilesInformation() { JniTracefile tracefile = null; @@ -795,9 +791,18 @@ public abstract class JniTrace extends Jni_C_Common { * * This function will call Ltt to print, so information printed will be the * one from the C structure, not the one populated in java.

    + *
    + * This function will not throw but will complain loudly if pointer is NULL */ public void printTraceInformation() { - ltt_printTrace(thisTracePtr.getLibraryId(), thisTracePtr.getPointer()); + + // If null pointer, print a warning! + if (thisTracePtr.getPointer() == NULL) { + printlnC("Pointer is NULL, cannot print. (printTraceInformation)"); + } + else { + ltt_printTrace( thisTracePtr.getPointer() ); + } } /** @@ -835,43 +840,8 @@ public abstract class JniTrace extends Jni_C_Common { return returnData; } + public abstract boolean initializeLibrary(); - // **************************** - // **** ABSTRACT FUNCTIONS **** - // You MUST override those in your version specific implementation - - /** - * Function place holder to load the correct C library.

    - *
    - * Can be as simple as calling ltt_initializeHandle(LIBRARY_NAME) with the correct .so instead of LIBRARY_NAME.
    - * You may also want to perform some check or some additionnal validations.
    - *
    - * !! Override this with you version specific implementation.
    - * - * @return integer that is the library id, or -1 if the load was unsuccessful - */ - public abstract int initializeLibrary(); - - - /** - * Function place holder to allocate a new JniTracefile.

    - * - * JniTracefile constructor is non overridable so we need another overridable function to return the correct version of JniTracefile.
    - * Effect of this function should be the same (allocate a fresh new JniTracefile)
    - *
    - * !! Override this with you version specific implementation.
    - * - * @param newPtr The pointer of an already opened LttTracefile C Structure - * @param newParentTrace The JniTrace parent of this tracefile. - * - * @return The newly allocated JniTracefile of the correct version - * - * @throws JniException The construction (allocation) failed. - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id - * @see org.eclipse.linuxtools.lttng.jni.JniTrace - */ - public abstract JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException; + public abstract JniTracefile allocateNewJniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException; -} +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java index 842d23b97d..4b586daa49 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/JniTracefile.java @@ -16,7 +16,6 @@ import java.util.HashMap; import org.eclipse.linuxtools.lttng.jni.common.JniTime; import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; import org.eclipse.linuxtools.lttng.jni.exception.JniException; import org.eclipse.linuxtools.lttng.jni.exception.JniNoSuchEventException; import org.eclipse.linuxtools.lttng.jni.exception.JniTracefileException; @@ -35,15 +34,11 @@ import org.eclipse.linuxtools.lttng.jni.exception.JniTracefileWithoutEventExcept *

  • a reference to a single event object *
  • a HashMap of marker associated with this tracefile * - * NOTE

    - * This class is ABSTRACT, you need to extends it to support your specific LTTng version.
    - * Please look at the abstract functions to override at the bottom of this file.

    - * */ -public abstract class JniTracefile extends Jni_C_Common -{ +public abstract class JniTracefile extends Jni_C_Common { + // Internal C pointer of the JniTracefile used in LTT - private Jni_C_Pointer_And_Library_Id thisTracefilePtr = new Jni_C_Pointer_And_Library_Id(); + private Jni_C_Pointer thisTracefilePtr = new Jni_C_Pointer(); // Reference to the parent trace private JniTrace parentTrace = null; @@ -60,7 +55,6 @@ public abstract class JniTracefile extends Jni_C_Common private long creation = 0; // Internal C pointer for trace and marker - // Note : These are real Jni_C_Pointer, not Jni_C_Pointer_And_Library_Id private Jni_C_Pointer tracePtr = null; private Jni_C_Pointer markerDataPtr = null; @@ -80,7 +74,6 @@ public abstract class JniTracefile extends Jni_C_Common private JniEvent currentEvent = null; // Internal C pointer for trace and marker - // Note : This one is a real Jni_C_Pointer, not Jni_C_Pointer_And_Library_Id private Jni_C_Pointer bufferPtr = null; private long bufferSize = 0; @@ -89,41 +82,46 @@ public abstract class JniTracefile extends Jni_C_Common private HashMap tracefileMarkersMap = null; // Native access functions - protected native boolean ltt_getIsCpuOnline(int libId, long tracefilePtr); - protected native String ltt_getTracefilepath(int libId, long tracefilePtr); - protected native String ltt_getTracefilename(int libId, long tracefilePtr); - protected native long ltt_getCpuNumber(int libId, long tracefilePtr); - protected native long ltt_getTid(int libId, long tracefilePtr); - protected native long ltt_getPgid(int libId, long tracefilePtr); - protected native long ltt_getCreation(int libId, long tracefilePtr); - protected native long ltt_getTracePtr(int libId, long tracefilePtr); - protected native long ltt_getMarkerDataPtr(int libId, long tracefilePtr); - protected native int ltt_getCFileDescriptor(int libId, long tracefilePtr); - protected native long ltt_getFileSize(int libId, long tracefilePtr); - protected native long ltt_getBlockNumber(int libId, long tracefilePtr); - protected native boolean ltt_getIsBytesOrderReversed(int libId, long tracefilePtr); - protected native boolean ltt_getIsFloatWordOrdered(int libId, long tracefilePtr); - protected native long ltt_getAlignement(int libId, long tracefilePtr); - protected native long ltt_getBufferHeaderSize(int libId, long tracefilePtr); - protected native int ltt_getBitsOfCurrentTimestampCounter(int libId, long tracefilePtr); - protected native int ltt_getBitsOfEvent(int libId, long tracefilePtr); - protected native long ltt_getCurrentTimestampCounterMask(int libId, long tracefilePtr); - protected native long ltt_getCurrentTimestampCounterMaskNextBit(int libId, long tracefilePtr); - protected native long ltt_getEventsLost(int libId, long tracefilePtr); - protected native long ltt_getSubBufferCorrupt(int libId, long tracefilePtr); - protected native long ltt_getEventPtr(int libId, long tracefilePtr); - protected native long ltt_getBufferPtr(int libId, long tracefilePtr); - protected native long ltt_getBufferSize(int libId, long tracefilePtr); - + protected native boolean ltt_getIsCpuOnline(long tracefilePtr); + protected native String ltt_getTracefilepath(long tracefilePtr); + protected native String ltt_getTracefilename(long tracefilePtr); + protected native long ltt_getCpuNumber(long tracefilePtr); + protected native long ltt_getTid(long tracefilePtr); + protected native long ltt_getPgid(long tracefilePtr); + protected native long ltt_getCreation(long tracefilePtr); + protected native long ltt_getTracePtr(long tracefilePtr); + protected native long ltt_getMarkerDataPtr(long tracefilePtr); + protected native int ltt_getCFileDescriptor(long tracefilePtr); + protected native long ltt_getFileSize(long tracefilePtr); + protected native long ltt_getBlockNumber(long tracefilePtr); + protected native boolean ltt_getIsBytesOrderReversed(long tracefilePtr); + protected native boolean ltt_getIsFloatWordOrdered(long tracefilePtr); + protected native long ltt_getAlignement(long tracefilePtr); + protected native long ltt_getBufferHeaderSize(long tracefilePtr); + protected native int ltt_getBitsOfCurrentTimestampCounter(long tracefilePtr); + protected native int ltt_getBitsOfEvent(long tracefilePtr); + protected native long ltt_getCurrentTimestampCounterMask(long tracefilePtr); + protected native long ltt_getCurrentTimestampCounterMaskNextBit(long tracefilePtr); + protected native long ltt_getEventsLost(long tracefilePtr); + protected native long ltt_getSubBufferCorrupt(long tracefilePtr); + protected native long ltt_getEventPtr(long tracefilePtr); + protected native long ltt_getBufferPtr(long tracefilePtr); + protected native long ltt_getBufferSize(long tracefilePtr); + // Method to fill a map with marker object - protected native void ltt_feedAllMarkers(int libId, long tracefilePtr); + protected native void ltt_feedAllMarkers(long tracefilePtr); // Debug native function, ask LTT to print tracefile structure - protected native void ltt_printTracefile(int libId, long tracefilePtr); + protected native void ltt_printTracefile(long tracefilePtr); + + static { + System.loadLibrary("lttvtraceread_loader"); + } /* * Default constructor is forbidden */ + @SuppressWarnings("unused") protected JniTracefile() { } @@ -166,25 +164,24 @@ public abstract class JniTracefile extends Jni_C_Common /** * Constructor, using C pointer.

    * - * @param newPtr The pointer of an already opened LttTracefile C Structure - * @param newParentTrace The JniTrace parent of this tracefile. + * @param newPtr The pointer of an already opened LttTracefile C Structure * * @exception JniException * - * @see org.eclipse.linuxtools.lttng.jni.JniTrace - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer */ - public JniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { - thisTracefilePtr = newPtr; + public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { + thisTracefilePtr = newPtr; parentTrace = newParentTrace; tracefileMarkersMap = new HashMap(); // Retrieve the trace file information and load the first event. try { populateTracefileInformation(); - } - catch (JniNoSuchEventException e) { - throw new JniTracefileWithoutEventException("JniEvent constructor reported that no event of this type are usable. (Jni_Tracefile)"); + } catch (JniNoSuchEventException e) { + throw new JniTracefileWithoutEventException( + "JniEvent constructor reported that no event of this type are usable. (Jaf_Tracefile)"); } } @@ -193,9 +190,9 @@ public abstract class JniTracefile extends Jni_C_Common * * Note : If the read succeed, the event will be populated.

    * - * @return LTT read status, as defined in Jni_C_Constant + * @return LTT read status, as defined in Jni_C_Common * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common */ public int readNextEvent() { return currentEvent.readNextEvent(); @@ -208,9 +205,9 @@ public abstract class JniTracefile extends Jni_C_Common * * @param seekTime The timestamp where to seek. * - * @return LTT read status, as defined in Jni_C_Constant + * @return LTT read status, as defined in Jni_C_Common * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Common */ public int seekToTime(JniTime seekTime) { return currentEvent.seekToTime(seekTime); @@ -223,38 +220,39 @@ public abstract class JniTracefile extends Jni_C_Common */ private void populateTracefileInformation() throws JniException { if (thisTracefilePtr.getPointer() == NULL) { - throw new JniTracefileException("Pointer is NULL, trace closed? (populateTracefileInformation)"); + throw new JniTracefileException( + "Pointer is NULL, trace closed? (populateTracefileInformation)"); } - isCpuOnline = ltt_getIsCpuOnline(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()); - tracefilePath = ltt_getTracefilepath(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()); - tracefileName = ltt_getTracefilename(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()); - cpuNumber = ltt_getCpuNumber(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()); - tid = ltt_getTid(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - pgid = ltt_getPgid(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - creation = ltt_getCreation(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - tracePtr = new Jni_C_Pointer(ltt_getTracePtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()) ); - markerDataPtr = new Jni_C_Pointer(ltt_getMarkerDataPtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()) ); - CFileDescriptor = ltt_getCFileDescriptor(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - fileSize = ltt_getFileSize(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - blocksNumber = ltt_getBlockNumber(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - isBytesOrderReversed = ltt_getIsBytesOrderReversed(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - isFloatWordOrdered = ltt_getIsFloatWordOrdered(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - alignement = ltt_getAlignement(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - bufferHeaderSize = ltt_getBufferHeaderSize(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - bitsOfCurrentTimestampCounter = ltt_getBitsOfCurrentTimestampCounter(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - bitsOfEvent = ltt_getBitsOfEvent(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - currentTimestampCounterMask = ltt_getCurrentTimestampCounterMask(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - currentTimestampCounterMaskNextBit = ltt_getCurrentTimestampCounterMaskNextBit(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - eventsLost = ltt_getEventsLost(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - subBufferCorrupt = ltt_getSubBufferCorrupt(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); - bufferPtr = new Jni_C_Pointer(ltt_getBufferPtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()) ); - bufferSize = ltt_getBufferSize(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()); + isCpuOnline = ltt_getIsCpuOnline( thisTracefilePtr.getPointer() ); + tracefilePath = ltt_getTracefilepath( thisTracefilePtr.getPointer() ); + tracefileName = ltt_getTracefilename( thisTracefilePtr.getPointer() ); + cpuNumber = ltt_getCpuNumber( thisTracefilePtr.getPointer() ); + tid = ltt_getTid( thisTracefilePtr.getPointer() ); + pgid = ltt_getPgid( thisTracefilePtr.getPointer() ); + creation = ltt_getCreation( thisTracefilePtr.getPointer() ); + tracePtr = new Jni_C_Pointer(ltt_getTracePtr( thisTracefilePtr.getPointer()) ); + markerDataPtr = new Jni_C_Pointer(ltt_getMarkerDataPtr( thisTracefilePtr.getPointer()) ); + CFileDescriptor = ltt_getCFileDescriptor( thisTracefilePtr.getPointer() ); + fileSize = ltt_getFileSize( thisTracefilePtr.getPointer() ); + blocksNumber = ltt_getBlockNumber( thisTracefilePtr.getPointer() ); + isBytesOrderReversed = ltt_getIsBytesOrderReversed( thisTracefilePtr.getPointer() ); + isFloatWordOrdered = ltt_getIsFloatWordOrdered( thisTracefilePtr.getPointer() ); + alignement = ltt_getAlignement( thisTracefilePtr.getPointer() ); + bufferHeaderSize = ltt_getBufferHeaderSize( thisTracefilePtr.getPointer() ); + bitsOfCurrentTimestampCounter = ltt_getBitsOfCurrentTimestampCounter( thisTracefilePtr.getPointer() ); + bitsOfEvent = ltt_getBitsOfEvent( thisTracefilePtr.getPointer() ); + currentTimestampCounterMask = ltt_getCurrentTimestampCounterMask( thisTracefilePtr.getPointer() ); + currentTimestampCounterMaskNextBit = ltt_getCurrentTimestampCounterMaskNextBit( thisTracefilePtr.getPointer() ); + eventsLost = ltt_getEventsLost( thisTracefilePtr.getPointer() ); + subBufferCorrupt = ltt_getSubBufferCorrupt( thisTracefilePtr.getPointer() ); + bufferPtr = new Jni_C_Pointer(ltt_getBufferPtr( thisTracefilePtr.getPointer()) ); + bufferSize = ltt_getBufferSize( thisTracefilePtr.getPointer() ); // To fill the map is a bit different - ltt_feedAllMarkers(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); + ltt_feedAllMarkers( thisTracefilePtr.getPointer() ); - Jni_C_Pointer_And_Library_Id tmpEventPointer = new Jni_C_Pointer_And_Library_Id(thisTracefilePtr.getLibraryId(), ltt_getEventPtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer())); + Jni_C_Pointer tmpEventPointer = new Jni_C_Pointer(ltt_getEventPtr(thisTracefilePtr.getPointer())); currentEvent = allocateNewJniEvent(tmpEventPointer , tracefileMarkersMap, this); } @@ -268,15 +266,16 @@ public abstract class JniTracefile extends Jni_C_Common * @param markerId Id of the marker (int) * @param markerInfoPtr C Pointer to a marker_info C structure */ - private void addMarkersFromC(int markerId, long markerInfoPtr) { + @SuppressWarnings("unused") + private void addMarkersFromC(int markerId, long markerInfoPtr) { // Create a new tracefile object and insert it in the map // the tracefile fill itself with LTT data while being constructed try { - JniMarker newMarker = allocateNewJniMarker( new Jni_C_Pointer_And_Library_Id(thisTracefilePtr.getLibraryId(), markerInfoPtr) ); + JniMarker newMarker = allocateNewJniMarker( new Jni_C_Pointer(markerInfoPtr) ); tracefileMarkersMap.put(markerId, newMarker); } catch (Exception e) { - printlnC(thisTracefilePtr.getLibraryId(), "Failed to add marker to tracefileMarkersMap!(addMarkersFromC)\n\tException raised : " + e.toString()); + printlnC("Failed to add marker to tracefileMarkersMap!(addMarkersFromC)\n\tException raised : " + e.toString()); } } @@ -390,7 +389,7 @@ public abstract class JniTracefile extends Jni_C_Common * * @return The parent trace * - * @see org.eclipse.linuxtools.lttng.jni.JniTrace + * @see org.eclipse.linuxtools.lttng.jni.eclipse.linuxtools.lttng.jni.JniTrace */ public JniTrace getParentTrace() { return parentTrace; @@ -404,9 +403,9 @@ public abstract class JniTracefile extends Jni_C_Common * * @return The actual (long converted) pointer or NULL. * - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id + * @see org.eclipse.linuxtools.lttng.jni.common.eclipse.linuxtools.lttng.jni.Jni_C_Pointer */ - public Jni_C_Pointer_And_Library_Id getTracefilePtr() { + public Jni_C_Pointer getTracefilePtr() { return thisTracefilePtr; } @@ -416,9 +415,18 @@ public abstract class JniTracefile extends Jni_C_Common * * This function will call Ltt to print, so information printed will be the * one from the C structure, not the one populated in java.

    + * + * This function will not throw but will complain loudly if pointer is NULL. */ public void printTracefileInformation() { - ltt_printTracefile(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() ); + + // If null pointer, print a warning! + if (thisTracefilePtr.getPointer() == NULL) { + printlnC("Pointer is NULL, cannot print. (printTracefileInformation)"); + } + else { + ltt_printTracefile( thisTracefilePtr.getPointer() ); + } } /** @@ -462,52 +470,8 @@ public abstract class JniTracefile extends Jni_C_Common } - // **************************** - // **** ABSTRACT FUNCTIONS **** - // You MUST override those in your version specific implementation - - - /** - * Function place holder to allocate a new JniEvent.

    - *
    - * JniEvent constructor is non overridable so we need another overridable function to return the correct version of JniEvent.
    - * Effect of this function should be the same (allocate a fresh new JniEvent).
    - *
    - * !! Override this with you version specific implementation.
    - * - * @param newEventPtr The pointer of an already opened LttEvent C Structure - * @param newMarkersMap An already populated HashMap of JniMarker objects for this new event - * @param newParentTracefile The JniTrace parent of this tracefile. - * - * @return The newly allocated JniEvent of the correct version - * - * @throws JniException The construction (allocation) failed. - * - * @see org.eclipse.linuxtools.lttng.jni.JniEvent - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id - * @see org.eclipse.linuxtools.lttng.jni.JniMarker - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - public abstract JniEvent allocateNewJniEvent(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException; - - - /** - * Function place holder to allocate a new JniMarker.

    - *
    - * JniMarker constructor is non overridable so we need another overridable function to return the correct version of JniMarker.
    - * Effect of this function should be the same (allocate a fresh new JniMarker).
    - *
    - * !! Override this with you version specific implementation.
    - * - * @param newMarkerPtr The pointer of an already opened marker_info C Structure - * - * @return The newly allocated JniMarker of the correct version - * - * @throws JniException The construction (allocation) failed. - * - * @see org.eclipse.linuxtools.lttng.jni.JniMarker - * @see org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id - */ - public abstract JniMarker allocateNewJniMarker(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException; + public abstract JniEvent allocateNewJniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException; + public abstract JniMarker allocateNewJniMarker(Jni_C_Pointer newMarkerPtr) throws JniException; } + diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java index 2713bd6c84..00f940f833 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Common.java @@ -18,17 +18,18 @@ import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Constant; /** * Jni_C_Common *

    - * Common constants and methods that should be shared between JNI objects. - * - * NOTE

    - * This class is ABSTRACT, and will be extended by each LTTng structure (Trac, Tracefile, Event, ...) - * + * Common constants and methods that should be shared between JNI objects */ -public abstract class Jni_C_Common extends Jni_C_Constant -{ - // Native console printing function - protected native void ltt_printC(int libId, String string_to_print); +public abstract class Jni_C_Common extends Jni_C_Constant { + // Native console printing function + protected native void ltt_printC(String string_to_print); + + // Load LTTV library (order is important) + static { + System.loadLibrary("lttvtraceread_loader"); + } + /** * Java-side console printing function.

    * @@ -36,10 +37,10 @@ public abstract class Jni_C_Common extends Jni_C_Constant * * @param msg The string to print in C. */ - public void printC(int libId, String msg) { + public void printC(String msg) { // Need to escape "%" for C printf msg = msg.replaceAll("%", "%%"); - ltt_printC(libId, msg); + ltt_printC(msg); } /** @@ -49,8 +50,7 @@ public abstract class Jni_C_Common extends Jni_C_Constant * * @param msg The string to print in C. */ - public void printlnC(int libId, String msg) { - printC(libId, msg + "\n"); + public void printlnC(String msg) { + printC(msg + "\n"); } - -} +} \ No newline at end of file diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Pointer.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Pointer.java new file mode 100644 index 0000000000..7cfec13078 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/Jni_C_Pointer.java @@ -0,0 +1,94 @@ +package org.eclipse.linuxtools.lttng.jni; + + +/** + * Jni_C_Pointer + *

    + * Class pointer to handle properly "C pointer"

    + * + * Can transparently handle pointer of 32 or 64 bits. + */ +public class Jni_C_Pointer extends Jni_C_Common { + + private long ptr = NULL; + private boolean isLong = true; + + /** + * Default constructor.

    + * + * Note : Pointer will be set to a 64bits "NULL". + */ + public Jni_C_Pointer() { + ptr = NULL; + } + + /** + * Constructor with parameters for 64bits pointers. + * + * @param newPtr long-converted (64 bits) C pointer. + */ + public Jni_C_Pointer(long newPtr) { + ptr = newPtr; + isLong = true; + } + + /** + * Constructor with parameters for 32bits pointers. + * + * @param newPtr int-converted (32 bits) C pointer. + */ + public Jni_C_Pointer(int newPtr) { + ptr = (long)newPtr; + isLong = false; + } + + /** + * Get the current pointer. + * + * @return The current pointer, in long. + */ + public long getPointer() { + return ptr; + } + + /** + * Set the pointer, as a 64bits pointer. + * + * @param newPtr long-converted (64 bits) C pointer. + */ + public void setPointer(long newPtr) { + ptr = newPtr; + isLong = true; + } + + /** + * Set the pointer, as a 64bits pointer. + * + * @param newPtr int-converted (32 bits) C pointer. + */ + public void setPointer(int newPtr) { + ptr = newPtr; + isLong = false; + } + + /** + * toString() method.

    + * + * Convert the pointer to a nice looking int/long hexadecimal format. + * + * @return Attributes of the object concatenated in String + */ + @Override + public String toString() { + String returnData = "0x"; + + if (isLong == true) { + returnData += Long.toHexString(ptr); + } + else { + returnData += Integer.toHexString((int) ptr); + } + + return returnData; + } +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java index 5f9303da5c..27960f4a2a 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/JniTime.java @@ -1,15 +1,6 @@ package org.eclipse.linuxtools.lttng.jni.common; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ + + /** * JniTime @@ -157,36 +148,6 @@ public class JniTime extends Jni_C_Constant implements Comparable } } - /** - * Overrided equals for JniTime type - * - * @param The object we want to compare too - * - * @return true if the time is the same, false otherwise. - */ - @Override - public boolean equals(Object obj) { - boolean returnedValue = false; - - if ( obj instanceof JniTime ) { - if ( ((JniTime)obj).time == this.time ) { - returnedValue = true; - } - } - - return returnedValue; - } - - /** - * Overridden hash code for JniTime type - * - */ - @Override - public int hashCode() { - return this.toString().hashCode(); - } - - /** * toString() method. * Intended to debug

    diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Constant.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Constant.java index 5cf7a60aaf..652f80f4c1 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Constant.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Constant.java @@ -11,12 +11,11 @@ package org.eclipse.linuxtools.lttng.jni.common; * William Bourque (wbourque@gmail.com) - Initial API and implementation *******************************************************************************/ + /** * Jni_C_Common *

    - * Common constants and methods that should be shared between JNI objects.

    - * - * This class is abstract and is intended to be extended by LTTng modules that need the constants. + * Common constants and methods that should be shared between JNI objects */ public abstract class Jni_C_Constant { @@ -31,12 +30,6 @@ public abstract class Jni_C_Constant { // Timestamps are in nanoseconds, this const ease up the math public static final long NANO = 1000000000; - /** - * Default constructor - */ - public Jni_C_Constant() { - } - /** * "Alternate" .toString()

    * diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Pointer.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Pointer.java index 3519dfe048..0d2d91c942 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Pointer.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/common/Jni_C_Pointer.java @@ -1,15 +1,5 @@ package org.eclipse.linuxtools.lttng.jni.common; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ + /** * Jni_C_Pointer @@ -20,8 +10,8 @@ package org.eclipse.linuxtools.lttng.jni.common; */ public class Jni_C_Pointer extends Jni_C_Constant { - protected long ptr = NULL; - protected boolean isLong = true; + private long ptr = NULL; + private boolean isLong = true; /** * Default constructor.

    diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventException.java index f87ef318a1..a63ac732af 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniEventException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventOutOfRangeException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventOutOfRangeException.java index ccd8b996fc..e751ae9a07 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventOutOfRangeException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniEventOutOfRangeException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniEventOutOfRangeException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerException.java index b6f009b926..ed2e8a6e98 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniMarkerException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerFieldException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerFieldException.java index 123e4714c2..fc78821b51 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerFieldException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniMarkerFieldException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniMarkerFieldException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoNextEventInTraceException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoNextEventInTraceException.java index 76aaa5e28f..87c66b1e88 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoNextEventInTraceException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoNextEventInTraceException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniNoNextEventInTraceException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoSuchEventException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoSuchEventException.java index 478d07953a..9317d6db08 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoSuchEventException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniNoSuchEventException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniNoSuchEventException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniOpenTraceFailedException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniOpenTraceFailedException.java index 963f703b5f..9eb1ffc83f 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniOpenTraceFailedException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniOpenTraceFailedException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniOpenTraceFailedException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceException.java index b89cd0c78f..c84162732f 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniTraceException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceVersionException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceVersionException.java index 2eb3916545..6d07a18e2a 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceVersionException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTraceVersionException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniTraceVersionException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileException.java index 54a26a73dd..1dc0d78347 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniTracefileException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileWithoutEventException.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileWithoutEventException.java index e8cc5227d6..2af158d95d 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileWithoutEventException.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/exception/JniTracefileWithoutEventException.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.exception; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ /** * JniTracefileWithoutEventException diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceFactory.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceFactory.java index ac15628331..01149613e8 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceFactory.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceFactory.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni.factory; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.exception.JniException; @@ -18,72 +7,45 @@ import org.eclipse.linuxtools.lttng.jni_v2_3.JniTrace_v2_3; import org.eclipse.linuxtools.lttng.jni_v2_5.JniTrace_v2_5; import org.eclipse.linuxtools.lttng.jni_v2_6.JniTrace_v2_6; -/** - * JniTraceFactory - *

    - * This class factory is responsible of returning the correct JniTrace implementation from a (valid) trace path.

    - * - * The different version supported are listed below and the same version string are expected to be returned by JniTraceVersion.
    - * Each version need a different Lttv library so each need its liblttvtraceread-X.Y.so installed and available on the system. - * - */ public class JniTraceFactory { - // *** - // Version string of the supported library version - // These will be used in the switch below to find the correct version - // *** static final String TraceVersion_v2_3 = "2.3"; static final String TraceVersion_v2_5 = "2.5"; static final String TraceVersion_v2_6 = "2.6"; - /* - * Default constructor is forbidden - */ private JniTraceFactory(){ + // Default constructor is forbidden } - /** - * Factory function : return the correct version of the JniTrace from a given path

    - * NOTE : The correct Lttv library (liblttvtraceread-X.Y.so) need to be installed and accessible otherwise this - * function will return an Exception. - * - * If the path is wrong or if the library is not supported (bad version or missing library) an Exception will be throwed. - * - * @param path Path of the trace we want to open - * @param show_debug Should JniTrace print debug or not? - * - * @return a newly allocated JniTrace of the correct version - * - * @throws JniException - */ static public JniTrace getJniTrace(String path, boolean show_debug) throws JniException { try { JniTraceVersion traceVersion = new JniTraceVersion(path); - if ( traceVersion.getVersionAsString().equals(TraceVersion_v2_6) ) { - return new JniTrace_v2_6(path, show_debug); + if ( traceVersion.toString().equals(TraceVersion_v2_6) ) { + return new JniTrace_v2_6(path); } - else if ( traceVersion.getVersionAsString().equals(TraceVersion_v2_5) ) { - return new JniTrace_v2_5(path, show_debug); + else if ( traceVersion.toString().equals(TraceVersion_v2_5) ) { + return new JniTrace_v2_5(path); } - else if ( traceVersion.getVersionAsString().equals(TraceVersion_v2_3) ) { - return new JniTrace_v2_3(path, show_debug); + else if ( traceVersion.toString().equals(TraceVersion_v2_3) ) { + return new JniTrace_v2_3(path); } else { - String errMsg = "\nERROR : Unrecognized/unsupported trace version." + - "\nLibrary reported a trace version " + traceVersion.getVersionAsString() + "." + - "\nMake sure you installed the Lttv library that support this version (look for liblttvtraceread-" + traceVersion.getVersionAsString() + ".so).\n"; - throw new JniException(errMsg); + throw new JniException("ERROR : Unrecognized/unsupported trace version."); } } catch (JniTraceVersionException e) { - String errMsg = "\nERROR : Call to JniTraceVersion() failed." + - "\nThis usually means that the library (liblttvtraceread_loader.so) could not be found." + - "\nMake sure the LTTv library is installed and that your LD_LIBRARY_PATH is set correctly (see help for more details)\n."; - throw new JniException(errMsg); + // *** FIXME *** + // We should probably fail if the trace version can't be found, however unless + // the C library is ajusted, we will always ends up here. + // For now, we will default to the trace version 2.5 (what we use for unit tests) so it should still work. + // *** + + //throw new JniException("ERROR : Call to JniTraceVersion() failed."); + System.out.println("WARNING : Call to JniTraceVersion() failed, defaulting to version 2.5."); + return new JniTrace_v2_5(path); } } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceVersion.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceVersion.java index 4b1e6f0e29..9e2854faf6 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceVersion.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni/factory/JniTraceVersion.java @@ -1,236 +1,65 @@ package org.eclipse.linuxtools.lttng.jni.factory; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ -import org.eclipse.linuxtools.lttng.jni.exception.JniException; import org.eclipse.linuxtools.lttng.jni.exception.JniTraceVersionException; -/** - * JniTraceVersion - *

    - * This class is responsible of returning the correct version number of a trace at a certain given path.

    - * - * The class will call the C library to get the correct version number from the trace.

    - * - * Lttv library loader (liblttvtraceread_loader.so) and the default Lttv library (liblttvtraceread.so) must be installed on system and available to java. - * - */ +// *** FIXME *** +// THIS IS A SKELETON IMPLEMENTATION +// Nothing here will work as the C library does not support any of those call YET +// *** + public class JniTraceVersion { - // Native access functions protected native void ltt_getTraceVersion(String tracepath); - // Variables to store version number - private int majorNumber = 0; - private int minorNumber = 0; - - // To store the given tracepath - private String tracepath = ""; - - // Was the trace read already? - private boolean wasTraceRead = false; - - /** - * Default constructor.

    - * - * Do nothing, readVersionFromTrace(path) will need to be called by the user - */ - public JniTraceVersion() { - // Nothing to do - } - - /** - * Constructor that takes a tracepath parameter.

    - * - * This constructor read the version number from the trace, so it might throw. - * - * @param newTracepath The directory of the trace to read. - * - * @exception JniException If the library can not be loaded,if the path is wrong or if something go wrong during the read. - */ - public JniTraceVersion(String newTracepath) throws JniTraceVersionException { - // Read the version number from the trace - readVersionFromTrace(newTracepath); + static { + System.loadLibrary("lttvtraceread"); } - /** - * Copy constructor. - * - * @param oldVersion A reference to the JniTraceVersion to copy. - */ - public JniTraceVersion(JniTraceVersion oldVersion) { - majorNumber = oldVersion.majorNumber; - minorNumber = oldVersion.minorNumber; - } + private int majorNumber = 0; + private int minorNumber = 0; - /* - * Read the version from the (already set) tracepath.

    - * - * This version is used internally and will silently dismiss any exceptions. - * - */ - private void readVersionNumberNofail() { - try { - readVersionFromTrace(tracepath); - } - catch(JniTraceVersionException e) { - // Yes, we do ignore exception. - } + @SuppressWarnings("unused") + private JniTraceVersion() { } - /** - * Read the version from the (already set) tracepath.

    - * - * This function throw if the library can not be loaded, if the path is wrong or if something go wrong during the read. - * - */ - public void readVersionNumber() throws JniTraceVersionException { - readVersionFromTrace(tracepath); + public JniTraceVersion(int newMajor, int newMinor) { + majorNumber = newMajor; + minorNumber = newMinor; } - /** - * Read the version from a given tracepath.

    - * MajorVersion and MinorVersion should be set after a successful execution of this function.
    - * - * This function throw if the library can not be loaded,if the path is wrong or if something go wrong during the read. - * - */ - public void readVersionFromTrace(String newTracepath) throws JniTraceVersionException { - - // Verify that the tracepath isn't obliviously wrong (null or empty) - if ( (newTracepath == null) || (newTracepath.equals("") ) ) { - throw new JniTraceVersionException("ERROR : Tracepath is null or empty! (readVersionNumber)"); - } - else { - // Otherwise set the path in case it was changed - tracepath = newTracepath; - } - + public JniTraceVersion(String tracepath) throws JniTraceVersionException { try { - // Load the C library here. - // If LD_LIBRARY_PATH is not set correctly this will raise a java.lang.UnsatisfiedLinkError - System.loadLibrary("lttvtraceread_loader"); - - // Assuming the C library loaded correctly, call the JNI here. ltt_getTraceVersion(tracepath); - - // We can now assume that the trace was read - wasTraceRead = true; } - // The library was unable to load -> Lttv not installed or bad version of it? catch (java.lang.UnsatisfiedLinkError e) { - throw new JniTraceVersionException("\nERROR : Could not get trace version. Is the library missing?" + - "\nMake sure your \"LD_LIBRARY_PATH\" is setted correctly (readVersionNumber)\n"); + throw new JniTraceVersionException("ERROR : Could not get trace version. Is the library missing?"); } - // Something else failed -> Possibly a bad tracepath was given catch (Exception e) { - throw new JniTraceVersionException("\nERROR : Call to ltt_getTraceVersion failed. (readVersionNumber)\n"); + throw new JniTraceVersionException("ERROR : Call to ltt_getTraceVersion failed."); } } - /** - * Get major version number of the trace.

    - * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored. - * - * @return major version - */ + public JniTraceVersion(JniTraceVersion oldVersion) { + majorNumber = oldVersion.majorNumber; + minorNumber = oldVersion.minorNumber; + } + public int getMajor() { - if ( wasTraceRead == false ) { - readVersionNumberNofail(); - } - return majorNumber; } - /** - * Get minor version number of the trace.

    - * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored. - * - * @return minor version - */ public int getMinor() { - if ( wasTraceRead == false ) { - readVersionNumberNofail(); - } - return minorNumber; } - /** - * Get full version number of the trace.

    - * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored. - * - * @return Full Version as float - */ - public float getVersionAsFloat() { - if ( wasTraceRead == false ) { - readVersionNumberNofail(); - } - - return ((float)majorNumber + ((float)minorNumber)/10); - } - - /** - * Get full version number of the trace.

    - * Note : readVersionFromTrace() will be called if it wasn't done but exception will be silently ignored. - * - * @return Full Version as string - */ - public String getVersionAsString() { - if ( wasTraceRead == false ) { - readVersionNumberNofail(); - } - - return majorNumber + "." + minorNumber; - } - - /** - * Get for the current tracepath - * - * @return The tracepath was are currently using. - */ - public String getTracepath() { - return tracepath; - } - - /** - * Set for the tracepath.

    - * NOTE : Changing this will reset the version number currently loaded. - * NOTE2 : readVersionFromTrace() will be called but exception will be silently ignored. - * - * @param newtracepath The net tracepath - */ - public void setTracepath(String newtracepath) { - majorNumber = 0; - minorNumber = 0; - wasTraceRead = false; - tracepath = newtracepath; - - // Call the read function. This will fill up all the number if it goes well. - readVersionNumberNofail(); - } - - /* - * This function is be called from the C side to assign the version number the Java variable. - */ - private void setTraceVersionFromC(int newMajor, int newMinor) { + @SuppressWarnings("unused") + private void setTraceVersionFromC(int newMajor, int newMinor) { majorNumber = newMajor; minorNumber = newMinor; } - - @Override public String toString() { - return "JniTraceVersion [" + majorNumber + "." + minorNumber + "]"; + return majorNumber + "." + minorNumber; } } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent.java new file mode 100644 index 0000000000..933b68c2cd --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent.java @@ -0,0 +1,34 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +import java.util.HashMap; + +import org.eclipse.linuxtools.lttng.jni.JniMarker; +import org.eclipse.linuxtools.lttng.jni.JniTracefile; +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniEvent extends org.eclipse.linuxtools.lttng.jni.JniEvent { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + protected JniEvent() { + super(); + } + + public JniEvent(JniEvent oldEvent) { + super(oldEvent); + } + + + + public JniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + super(newEventPtr, newMarkersMap, newParentTracefile); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent_v2_3.java index ac6368eb88..63e1809db3 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent_v2_3.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniEvent_v2_3.java @@ -1,46 +1,29 @@ package org.eclipse.linuxtools.lttng.jni_v2_3; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import java.util.HashMap; import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniEvent_v2_3 - *

    - * JniEvent version to support Lttng traceformat of version 2.3
    - * This class extend abstract class JniEvent with (possibly) version specific implementation.
    - *

    - */ public class JniEvent_v2_3 extends JniEvent { + - /* - * Forbid access to the default constructor - */ protected JniEvent_v2_3() { super(); } - public JniEvent_v2_3(JniEvent_v2_3 oldEvent) { super(oldEvent); } - public JniEvent_v2_3(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + + + public JniEvent_v2_3(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { super(newEventPtr, newMarkersMap, newParentTracefile); } + + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker.java new file mode 100644 index 0000000000..f5df48b557 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker.java @@ -0,0 +1,29 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +import java.util.ArrayList; +import java.util.HashMap; + +import org.eclipse.linuxtools.lttng.jni.JniMarkerField; +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniMarker extends org.eclipse.linuxtools.lttng.jni.JniMarker { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + protected JniMarker() { + super(); + } + + + public JniMarker(JniMarker oldMarker) { + super(oldMarker); + } + + + public JniMarker(Jni_C_Pointer newMarkerPtr) throws JniException { + super(newMarkerPtr); + } +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField.java new file mode 100644 index 0000000000..0b756d76e3 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField.java @@ -0,0 +1,26 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniMarkerField extends org.eclipse.linuxtools.lttng.jni.JniMarkerField { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + protected JniMarkerField() { + super(); + } + + + public JniMarkerField(JniMarkerField oldMarkerField) { + super(oldMarkerField); + } + + + public JniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException { + super(newMarkerFieldPtr); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField_v2_3.java index c67e0a7de1..468d6e64c8 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField_v2_3.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarkerField_v2_3.java @@ -1,32 +1,11 @@ package org.eclipse.linuxtools.lttng.jni_v2_3; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniMarkerField; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniMarkerField_v2_3 - *

    - * JniMarkerField version to support Lttng traceformat of version 2.3
    - * This class extend abstract class JniMarkerField with (possibly) version specific implementation.
    - *

    - */ public class JniMarkerField_v2_3 extends JniMarkerField { - /* - * Forbid access to the default constructor - */ protected JniMarkerField_v2_3() { super(); } @@ -36,7 +15,9 @@ public class JniMarkerField_v2_3 extends JniMarkerField { super(oldMarkerField); } - public JniMarkerField_v2_3(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + + public JniMarkerField_v2_3(Jni_C_Pointer newMarkerFieldPtr) throws JniException { super(newMarkerFieldPtr); } + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker_v2_3.java index 58ca0655a2..85bba7a70e 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker_v2_3.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniMarker_v2_3.java @@ -1,33 +1,12 @@ package org.eclipse.linuxtools.lttng.jni_v2_3; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniMarkerField; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniMarker_v2_3 - *

    - * JniMarker version to support Lttng traceformat of version 2.3
    - * This class extend abstract class JniMarker with (possibly) version specific implementation.
    - *

    - */ public class JniMarker_v2_3 extends JniMarker { - - /* - * Forbid access to the default constructor - */ + protected JniMarker_v2_3() { super(); } @@ -37,22 +16,13 @@ public class JniMarker_v2_3 extends JniMarker { super(oldMarker); } - public JniMarker_v2_3(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + + public JniMarker_v2_3(Jni_C_Pointer newMarkerPtr) throws JniException { super(newMarkerPtr); } - /** - * Allocate (call constructor for) a new JniMarkerField.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniMarker - * - * @return JniMarkerField a newly allocated JniMarkerField - * - * @see org.eclipse.linuxtools.lttng.jni.JniMarker - */ - @Override - public JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + public JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException { return new JniMarkerField_v2_3(newMarkerFieldPtr); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser.java new file mode 100644 index 0000000000..272134dd54 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser.java @@ -0,0 +1,12 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +public class JniParser extends org.eclipse.linuxtools.lttng.jni.JniParser { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + protected JniParser() { + super(); + } +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser_v2_3.java index d00636e4be..675ffc1f59 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser_v2_3.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniParser_v2_3.java @@ -1,30 +1,9 @@ package org.eclipse.linuxtools.lttng.jni_v2_3; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniParser; -/** - * JniParser_v2_3 - *

    - * JniParser version to support Lttng traceformat of version 2.3
    - * This class extend abstract class JniParser with (possibly) version specific implementation.
    - *

    - */ public class JniParser_v2_3 extends JniParser { - - /* - * Forbid access to the default constructor - */ + protected JniParser_v2_3() { super(); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTime.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTime.java new file mode 100644 index 0000000000..b2db2d635f --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTime.java @@ -0,0 +1,26 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + + +public class JniTime extends org.eclipse.linuxtools.lttng.jni.JniTime { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + public JniTime() { + super(); + } + + public JniTime(JniTime oldTime) { + super(oldTime); + } + + public JniTime(long newSec, long newNanoSec) { + super(newNanoSec); + } + + public JniTime(long newNanoSecTime) { + super(newNanoSecTime); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace.java new file mode 100644 index 0000000000..d487defe83 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace.java @@ -0,0 +1,35 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +import org.eclipse.linuxtools.lttng.jni.exception.JniException; +import org.eclipse.linuxtools.lttng.jni.exception.JniTracefileWithoutEventException; +import org.eclipse.linuxtools.lttng.jni_v2_3.JniTracefile; +import org.eclipse.linuxtools.lttng.jni_v2_3.Jni_C_Pointer; + +public class JniTrace extends org.eclipse.linuxtools.lttng.jni.JniTrace { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + protected JniTrace() { + super(); + } + + public JniTrace(String newpath, boolean newPrintDebug) throws JniException { + super(newpath, newPrintDebug); + } + + + public JniTrace(JniTrace oldTrace) { + super(oldTrace); + } + + public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException { + super(newPtr, newPrintDebug); + } + + protected JniTracefile createNewTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { + return new JniTracefile(newPtr, newParentTrace); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace_v2_3.java index 5794d57dc5..1b364cfc6d 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace_v2_3.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTrace_v2_3.java @@ -1,45 +1,22 @@ package org.eclipse.linuxtools.lttng.jni_v2_3; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniTrace_v2_3 - *

    - * JniTrace version to support Lttng traceformat of version 2.3.
    - * This class extend abstract class JniTrace with (possibly) version specific implementation.
    - * - * It also make sure the correct library is loaded by liblttvlibraryloader.so - *

    - */ public class JniTrace_v2_3 extends JniTrace { - // This is the dynamic library name that is passed to the library loader (liblttvlibraryloader.so) to load. - // It needs to be a complete name, like "libXYZ.so", unlike java that would take "XYZ". It could also take a complete path. - // The library need to be accessible, i.e. LD_LIBRARY_PATH need to be set correctly. - private static final String LIBRARY_NAME = "liblttvtraceread-2.3.so"; + // *** FIXME *** + // Eventually, it should be something like this : + // private static final String LIBRARY_NAME = "liblttvtraceread2.3.so"; + // However, the C library is not ready yet, so we will keep the general one : + private static final String LIBRARY_NAME = "liblttvtraceread.so"; - /* - * Forbid access to the default constructor - */ protected JniTrace_v2_3() { super(); } - public JniTrace_v2_3(String newpath) throws JniException { super(newpath); } @@ -53,35 +30,20 @@ public class JniTrace_v2_3 extends JniTrace { super(oldTrace); } - public JniTrace_v2_3(Jni_C_Pointer_And_Library_Id newPtr, boolean newPrintDebug) throws JniException { + public JniTrace_v2_3(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException { super(newPtr, newPrintDebug); } - /** - * Initialize the C library.

    - * - * Call the library loader with the .so we wish to load. - * - * @return The library id if sucessful, -1 if something went wrong - */ - @Override - public int initializeLibrary() { + public boolean initializeLibrary() { return ltt_initializeHandle(LIBRARY_NAME); } - /** - * Allocate (call constructor for) a new JniTracefile.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTrace - * - * @return JniTracefile a newly allocated JniTracefile - * - * @see org.eclipse.linuxtools.lttng.jni.JniTrace - */ - @Override - public JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { + public JniTracefile allocateNewJniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { return new JniTracefile_v2_3(newPtr, newParentTrace); } + + + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile.java new file mode 100644 index 0000000000..a05b4a35d3 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile.java @@ -0,0 +1,25 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +import org.eclipse.linuxtools.lttng.jni.JniTrace; +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniTracefile extends org.eclipse.linuxtools.lttng.jni.JniTracefile { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + + protected JniTracefile() { + super(); + } + + public JniTracefile(JniTracefile oldTracefile) { + super(oldTracefile); + } + + public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { + super(newPtr, newParentTrace); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile_v2_3.java index 44254572b4..4c645eff94 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile_v2_3.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/JniTracefile_v2_3.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni_v2_3; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import java.util.HashMap; @@ -17,61 +6,31 @@ import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniTracefile_v2_3 - *

    - * JniTracefile version to support Lttng traceformat of version 2.3
    - * This class extend abstract class JniTracefile with (possibly) version specific implementation.
    - *

    - */ public class JniTracefile_v2_3 extends JniTracefile { - /* - * Forbid access to the default constructor - */ protected JniTracefile_v2_3() { super(); } - public JniTracefile_v2_3(JniTracefile_v2_3 oldTracefile) { super(oldTracefile); } - public JniTracefile_v2_3(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { + public JniTracefile_v2_3(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { super(newPtr, newParentTrace); } - /** - * Allocate (call constructor for) a new JniEvent.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTracefile - * - * @return JniEvent a newly allocated JniEvent - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - @Override - public JniEvent allocateNewJniEvent(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + public JniEvent allocateNewJniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { return new JniEvent_v2_3(newEventPtr, newMarkersMap, newParentTracefile); } - /** - * Allocate (call constructor for) a new JniMarker.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTracefile - * - * @return JniMarker a newly allocated JniMarker - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - @Override - public JniMarker allocateNewJniMarker(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + public JniMarker allocateNewJniMarker(Jni_C_Pointer newMarkerPtr) throws JniException { return new JniMarker_v2_3(newMarkerPtr); } + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/Jni_C_Common_v2_3.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/Jni_C_Common_v2_3.java new file mode 100644 index 0000000000..78df570867 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/Jni_C_Common_v2_3.java @@ -0,0 +1,9 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +public class Jni_C_Common_v2_3 extends org.eclipse.linuxtools.lttng.jni.Jni_C_Common { + + static { + System.loadLibrary("lttvtraceread2.3"); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/Jni_C_Pointer.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/Jni_C_Pointer.java new file mode 100644 index 0000000000..5b2376a3be --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_3/Jni_C_Pointer.java @@ -0,0 +1,17 @@ +package org.eclipse.linuxtools.lttng.jni_v2_3; + +public class Jni_C_Pointer extends org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer { + + public Jni_C_Pointer() { + super(); + } + + public Jni_C_Pointer(long newPtr) { + super(newPtr); + } + + public Jni_C_Pointer(int newPtr) { + super(newPtr); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent.java new file mode 100644 index 0000000000..fca144d0cc --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent.java @@ -0,0 +1,31 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +import java.util.HashMap; + +import org.eclipse.linuxtools.lttng.jni.JniMarker; +import org.eclipse.linuxtools.lttng.jni.JniTracefile; +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniEvent extends org.eclipse.linuxtools.lttng.jni.JniEvent { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + protected JniEvent() { + super(); + } + + public JniEvent(JniEvent oldEvent) { + super(oldEvent); + } + + + + public JniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + super(newEventPtr, newMarkersMap, newParentTracefile); + } + + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent_v2_5.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent_v2_5.java index 26d2563013..046dd456c3 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent_v2_5.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniEvent_v2_5.java @@ -1,46 +1,29 @@ package org.eclipse.linuxtools.lttng.jni_v2_5; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import java.util.HashMap; import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniEvent_v2_5 - *

    - * JniEvent version to support Lttng traceformat of version 2.5
    - * This class extend abstract class JniEvent with (possibly) version specific implementation.
    - *

    - */ public class JniEvent_v2_5 extends JniEvent { + - /* - * Forbid access to the default constructor - */ protected JniEvent_v2_5() { super(); } - public JniEvent_v2_5(JniEvent_v2_5 oldEvent) { super(oldEvent); } - public JniEvent_v2_5(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + + + public JniEvent_v2_5(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { super(newEventPtr, newMarkersMap, newParentTracefile); } + + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker.java new file mode 100644 index 0000000000..c60177cfcf --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker.java @@ -0,0 +1,26 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniMarker extends org.eclipse.linuxtools.lttng.jni.JniMarker { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + protected JniMarker() { + super(); + } + + + public JniMarker(JniMarker oldMarker) { + super(oldMarker); + } + + + public JniMarker(Jni_C_Pointer newMarkerPtr) throws JniException { + super(newMarkerPtr); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField.java new file mode 100644 index 0000000000..77102ac372 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField.java @@ -0,0 +1,27 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniMarkerField extends org.eclipse.linuxtools.lttng.jni.JniMarkerField { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + + protected JniMarkerField() { + super(); + } + + + public JniMarkerField(JniMarkerField oldMarkerField) { + super(oldMarkerField); + } + + + public JniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException { + super(newMarkerFieldPtr); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField_v2_5.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField_v2_5.java index 8900dff6e4..0ebcb14f78 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField_v2_5.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarkerField_v2_5.java @@ -1,32 +1,11 @@ package org.eclipse.linuxtools.lttng.jni_v2_5; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniMarkerField; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniMarkerField_v2_5 - *

    - * JniMarkerField version to support Lttng traceformat of version 2.5
    - * This class extend abstract class JniMarkerField with (possibly) version specific implementation.
    - *

    - */ public class JniMarkerField_v2_5 extends JniMarkerField { - /* - * Forbid access to the default constructor - */ protected JniMarkerField_v2_5() { super(); } @@ -36,7 +15,9 @@ public class JniMarkerField_v2_5 extends JniMarkerField { super(oldMarkerField); } - public JniMarkerField_v2_5(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + + public JniMarkerField_v2_5(Jni_C_Pointer newMarkerFieldPtr) throws JniException { super(newMarkerFieldPtr); } + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker_v2_5.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker_v2_5.java index d7dafc09a8..0ff3acde87 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker_v2_5.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniMarker_v2_5.java @@ -1,58 +1,28 @@ package org.eclipse.linuxtools.lttng.jni_v2_5; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniMarkerField; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniMarker_v2_5 - *

    - * JniMarker version to support Lttng traceformat of version 2.5
    - * This class extend abstract class JniMarker with (possibly) version specific implementation.
    - *

    - */ public class JniMarker_v2_5 extends JniMarker { - /* - * Forbid access to the default constructor - */ protected JniMarker_v2_5() { super(); } - + public JniMarker_v2_5(JniMarker_v2_5 oldMarker) { super(oldMarker); } - public JniMarker_v2_5(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + + public JniMarker_v2_5(Jni_C_Pointer newMarkerPtr) throws JniException { super(newMarkerPtr); } - /** - * Allocate (call constructor for) a new JniMarkerField.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniMarker - * - * @return JniMarkerField a newly allocated JniMarkerField - * - * @see org.eclipse.linuxtools.lttng.jni.JniMarker - */ - @Override - public JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + public JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException { return new JniMarkerField_v2_5(newMarkerFieldPtr); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser.java new file mode 100644 index 0000000000..762e4f3fd3 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser.java @@ -0,0 +1,12 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +public class JniParser extends org.eclipse.linuxtools.lttng.jni.JniParser { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + protected JniParser() { + super(); + } +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser_v2_5.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser_v2_5.java index 81a62cbb77..d8f05b2e0b 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser_v2_5.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniParser_v2_5.java @@ -1,30 +1,9 @@ package org.eclipse.linuxtools.lttng.jni_v2_5; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniParser; -/** - * JniParser_v2_5 - *

    - * JniParser version to support Lttng traceformat of version 2.5
    - * This class extend abstract class JniParser with (possibly) version specific implementation.
    - *

    - */ public class JniParser_v2_5 extends JniParser { - - /* - * Forbid access to the default constructor - */ + protected JniParser_v2_5() { super(); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTime.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTime.java new file mode 100644 index 0000000000..1ddd0b0b0a --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTime.java @@ -0,0 +1,25 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +public class JniTime extends org.eclipse.linuxtools.lttng.jni.JniTime { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + public JniTime() { + super(); + } + + public JniTime(JniTime oldTime) { + super(oldTime); + } + + public JniTime(long newSec, long newNanoSec) { + super(newNanoSec); + } + + public JniTime(long newNanoSecTime) { + super(newNanoSecTime); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace.java new file mode 100644 index 0000000000..b6d647ece7 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace.java @@ -0,0 +1,31 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; +import org.eclipse.linuxtools.lttng.jni.exception.JniTracefileWithoutEventException; +import org.eclipse.linuxtools.lttng.jni_v2_3.JniTracefile; + +public class JniTrace extends org.eclipse.linuxtools.lttng.jni.JniTrace { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + protected JniTrace() { + super(); + } + + + public JniTrace(String newpath, boolean newPrintDebug) throws JniException { + super(newpath, newPrintDebug); + } + + + public JniTrace(JniTrace oldTrace) { + super(oldTrace); + } + + public JniTrace(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException { + super(newPtr, newPrintDebug); + } +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace_v2_5.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace_v2_5.java index ebea39f877..3d94259bc5 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace_v2_5.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTrace_v2_5.java @@ -1,45 +1,22 @@ package org.eclipse.linuxtools.lttng.jni_v2_5; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniTrace_v2_5 - *

    - * JniTrace version to support Lttng traceformat of version 2.5.
    - * This class extend abstract class JniTrace with (possibly) version specific implementation (none yet).
    - * - * It also make sure the correct library is loaded by liblttvlibraryloader.so - *

    - */ public class JniTrace_v2_5 extends JniTrace { - // This is the dynamic library name that is passed to the library loader (liblttvlibraryloader.so) to load. - // It needs to be a complete name, like "libXYZ.so", unlike java that would take "XYZ". It could also take a complete path. - // The library need to be accessible, i.e. LD_LIBRARY_PATH need to be set correctly. - private static final String LIBRARY_NAME = "liblttvtraceread-2.5.so"; + // *** FIXME *** + // Eventually, it should be something like this : + // private static final String LIBRARY_NAME = "liblttvtraceread2.5.so"; + // However, the C library is not ready yet, so we will keep the general one : + private static final String LIBRARY_NAME = "liblttvtraceread.so"; - /* - * Forbid access to the default constructor - */ protected JniTrace_v2_5() { super(); } - public JniTrace_v2_5(String newpath) throws JniException { super(newpath); } @@ -53,34 +30,16 @@ public class JniTrace_v2_5 extends JniTrace { super(oldTrace); } - public JniTrace_v2_5(Jni_C_Pointer_And_Library_Id newPtr, boolean newPrintDebug) throws JniException { + public JniTrace_v2_5(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException { super(newPtr, newPrintDebug); } - /** - * Initialize the C library.

    - * - * Call the library loader with the .so we wish to load. - * - * @return True if the load went successful, false otherwise. - */ - @Override - public int initializeLibrary() { + public boolean initializeLibrary() { return ltt_initializeHandle(LIBRARY_NAME); } - /** - * Allocate (call constructor for) a new JniTracefile.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTrace - * - * @return JniTracefile a newly allocated JniTracefile - * - * @see org.eclipse.linuxtools.lttng.jni.JniTrace - */ - @Override - public JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { + public JniTracefile allocateNewJniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { return new JniTracefile_v2_5(newPtr, newParentTrace); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile.java new file mode 100644 index 0000000000..0136c7b048 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile.java @@ -0,0 +1,25 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +import org.eclipse.linuxtools.lttng.jni.JniTrace; +import org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer; +import org.eclipse.linuxtools.lttng.jni.exception.JniException; + +public class JniTracefile extends org.eclipse.linuxtools.lttng.jni.JniTracefile { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + + protected JniTracefile() { + super(); + } + + public JniTracefile(JniTracefile oldTracefile) { + super(oldTracefile); + } + + public JniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { + super(newPtr, newParentTrace); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile_v2_5.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile_v2_5.java index 6d63a22edd..6f4518bf47 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile_v2_5.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/JniTracefile_v2_5.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni_v2_5; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import java.util.HashMap; @@ -17,61 +6,30 @@ import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniTracefile_v2_5 - *

    - * JniTracefile version to support Lttng traceformat of version 2.5
    - * This class extend abstract class JniTracefile with (possibly) version specific implementation.
    - *

    - */ public class JniTracefile_v2_5 extends JniTracefile { - /* - * Forbid access to the default constructor - */ protected JniTracefile_v2_5() { super(); } - public JniTracefile_v2_5(JniTracefile_v2_5 oldTracefile) { super(oldTracefile); } - public JniTracefile_v2_5(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { + public JniTracefile_v2_5(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { super(newPtr, newParentTrace); } - /** - * Allocate (call constructor for) a new JniEvent.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTracefile - * - * @return JniEvent a newly allocated JniEvent - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - @Override - public JniEvent allocateNewJniEvent(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + public JniEvent allocateNewJniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { return new JniEvent_v2_5(newEventPtr, newMarkersMap, newParentTracefile); } - /** - * Allocate (call constructor for) a new JniMarker.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTracefile - * - * @return JniMarker a newly allocated JniMarker - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - @Override - public JniMarker allocateNewJniMarker(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + public JniMarker allocateNewJniMarker(Jni_C_Pointer newMarkerPtr) throws JniException { return new JniMarker_v2_5(newMarkerPtr); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/Jni_C_Common.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/Jni_C_Common.java new file mode 100644 index 0000000000..73491b0a52 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/Jni_C_Common.java @@ -0,0 +1,9 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +public class Jni_C_Common extends org.eclipse.linuxtools.lttng.jni.Jni_C_Common { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/Jni_C_Pointer.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/Jni_C_Pointer.java new file mode 100644 index 0000000000..0513309517 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_5/Jni_C_Pointer.java @@ -0,0 +1,9 @@ +package org.eclipse.linuxtools.lttng.jni_v2_5; + +public class Jni_C_Pointer extends org.eclipse.linuxtools.lttng.jni.Jni_C_Pointer { + + static { + System.loadLibrary("lttvtraceread2.5"); + } + +} diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniEvent_v2_6.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniEvent_v2_6.java index 9c2bd45920..8477403fcc 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniEvent_v2_6.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniEvent_v2_6.java @@ -1,46 +1,27 @@ package org.eclipse.linuxtools.lttng.jni_v2_6; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import java.util.HashMap; import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniEvent_v2_6 - *

    - * JniEvent version to support Lttng traceformat of version 2.6
    - * This class extend abstract class JniEvent with (possibly) version specific implementation.
    - *

    - */ public class JniEvent_v2_6 extends JniEvent { + - /* - * Forbid access to the default constructor - */ protected JniEvent_v2_6() { super(); } - public JniEvent_v2_6(JniEvent_v2_6 oldEvent) { super(oldEvent); } - public JniEvent_v2_6(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + + + public JniEvent_v2_6(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { super(newEventPtr, newMarkersMap, newParentTracefile); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarkerField_v2_6.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarkerField_v2_6.java index cdff84ac60..67d4dc2d6c 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarkerField_v2_6.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarkerField_v2_6.java @@ -1,32 +1,11 @@ package org.eclipse.linuxtools.lttng.jni_v2_6; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniMarkerField; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniMarkerField_v2_6 - *

    - * JniMarkerField version to support Lttng traceformat of version 2.6
    - * This class extend abstract class JniMarkerField with (possibly) version specific implementation.
    - *

    - */ public class JniMarkerField_v2_6 extends JniMarkerField { - /* - * Forbid access to the default constructor - */ protected JniMarkerField_v2_6() { super(); } @@ -36,7 +15,9 @@ public class JniMarkerField_v2_6 extends JniMarkerField { super(oldMarkerField); } - public JniMarkerField_v2_6(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + + public JniMarkerField_v2_6(Jni_C_Pointer newMarkerFieldPtr) throws JniException { super(newMarkerFieldPtr); } + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarker_v2_6.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarker_v2_6.java index 34ecf1f5f2..f20a3cd4da 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarker_v2_6.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniMarker_v2_6.java @@ -1,58 +1,29 @@ package org.eclipse.linuxtools.lttng.jni_v2_6; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniMarkerField; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniMarker_v2_6 - *

    - * JniMarker version to support Lttng traceformat of version 2.6
    - * This class extend abstract class JniMarker with (possibly) version specific implementation.
    - *

    - */ public class JniMarker_v2_6 extends JniMarker { - /* - * Forbid access to the default constructor - */ protected JniMarker_v2_6() { super(); } - + public JniMarker_v2_6(JniMarker_v2_6 oldMarker) { super(oldMarker); } - public JniMarker_v2_6(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + + public JniMarker_v2_6(Jni_C_Pointer newMarkerPtr) throws JniException { super(newMarkerPtr); } - /** - * Allocate (call constructor for) a new JniMarkerField.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniMarker - * - * @return JniMarkerField a newly allocated JniMarkerField - * - * @see org.eclipse.linuxtools.lttng.jni.JniMarker - */ - @Override - public JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { + public JniMarkerField allocateNewJniMarkerField(Jni_C_Pointer newMarkerFieldPtr) throws JniException { return new JniMarkerField_v2_6(newMarkerFieldPtr); } + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniParser_v2_6.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniParser_v2_6.java index 4d3bc77e92..e6922bdf0d 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniParser_v2_6.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniParser_v2_6.java @@ -1,30 +1,9 @@ package org.eclipse.linuxtools.lttng.jni_v2_6; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniParser; -/** - * JniParser_v2_6 - *

    - * JniParser version to support Lttng traceformat of version 2.6
    - * This class extend abstract class JniParser with (possibly) version specific implementation.
    - *

    - */ public class JniParser_v2_6 extends JniParser { - - /* - * Forbid access to the default constructor - */ + protected JniParser_v2_6() { super(); } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTrace_v2_6.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTrace_v2_6.java index 5339456548..85c3c1f000 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTrace_v2_6.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTrace_v2_6.java @@ -1,45 +1,22 @@ package org.eclipse.linuxtools.lttng.jni_v2_6; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniTrace_v2_6 - *

    - * JniTrace version to support Lttng traceformat of version 2.6.
    - * This class extend abstract class JniTrace with (possibly) version specific implementation (none yet).
    - * - * It also make sure the correct library is loaded by liblttvlibraryloader.so - *

    - */ public class JniTrace_v2_6 extends JniTrace { - // This is the dynamic library name that is passed to the library loader (liblttvlibraryloader.so) to load. - // It needs to be a complete name, like "libXYZ.so", unlike java that would take "XYZ". It could also take a complete path. - // The library need to be accessible, i.e. LD_LIBRARY_PATH need to be set correctly. - private static final String LIBRARY_NAME = "liblttvtraceread-2.6.so"; + // *** FIXME *** + // Eventually, it should be something like this : + // private static final String LIBRARY_NAME = "liblttvtraceread2.6.so"; + // However, the C library is not ready yet, so we will keep the general one : + private static final String LIBRARY_NAME = "liblttvtraceread.so"; - /* - * Forbid access to the default constructor - */ protected JniTrace_v2_6() { super(); } - public JniTrace_v2_6(String newpath) throws JniException { super(newpath); } @@ -48,39 +25,24 @@ public class JniTrace_v2_6 extends JniTrace { super(newpath, newPrintDebug); } + public JniTrace_v2_6(JniTrace_v2_6 oldTrace) { super(oldTrace); } - public JniTrace_v2_6(Jni_C_Pointer_And_Library_Id newPtr, boolean newPrintDebug) throws JniException { + public JniTrace_v2_6(Jni_C_Pointer newPtr, boolean newPrintDebug) throws JniException { super(newPtr, newPrintDebug); } - /** - * Initialize the C library.

    - * - * Call the library loader with the .so we wish to load. - * - * @return True if the load went successful, false otherwise. - */ - @Override - public int initializeLibrary() { + public boolean initializeLibrary() { return ltt_initializeHandle(LIBRARY_NAME); } - - /** - * Allocate (call constructor for) a new JniTracefile.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTrace - * - * @return JniTracefile a newly allocated JniTracefile - * - * @see org.eclipse.linuxtools.lttng.jni.JniTrace - */ - @Override - public JniTracefile allocateNewJniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { + public JniTracefile allocateNewJniTracefile(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { return new JniTracefile_v2_6(newPtr, newParentTrace); } + + + } diff --git a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTracefile_v2_6.java b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTracefile_v2_6.java index 2aeebaa28a..6404ae41b7 100644 --- a/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTracefile_v2_6.java +++ b/org.eclipse.linuxtools.lttng.jni/src/org/eclipse/linuxtools/lttng/jni_v2_6/JniTracefile_v2_6.java @@ -1,15 +1,4 @@ package org.eclipse.linuxtools.lttng.jni_v2_6; -/******************************************************************************* - * Copyright (c) 2009 Ericsson - * - * All rights reserved. This program and the accompanying materials are - * made available under the terms of the Eclipse Public License v1.0 which - * accompanies this distribution, and is available at - * http://www.eclipse.org/legal/epl-v10.html - * - * Contributors: - * William Bourque (wbourque@gmail.com) - Initial API and implementation - *******************************************************************************/ import java.util.HashMap; @@ -17,61 +6,30 @@ import org.eclipse.linuxtools.lttng.jni.JniEvent; import org.eclipse.linuxtools.lttng.jni.JniMarker; import org.eclipse.linuxtools.lttng.jni.JniTrace; import org.eclipse.linuxtools.lttng.jni.JniTracefile; -import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer_And_Library_Id; +import org.eclipse.linuxtools.lttng.jni.common.Jni_C_Pointer; import org.eclipse.linuxtools.lttng.jni.exception.JniException; -/** - * JniTracefile_v2_6 - *

    - * JniTracefile version to support Lttng traceformat of version 2.6
    - * This class extend abstract class JniTracefile with (possibly) version specific implementation.
    - *

    - */ public class JniTracefile_v2_6 extends JniTracefile { - /* - * Forbid access to the default constructor - */ protected JniTracefile_v2_6() { super(); } - public JniTracefile_v2_6(JniTracefile_v2_6 oldTracefile) { super(oldTracefile); } - public JniTracefile_v2_6(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException { + public JniTracefile_v2_6(Jni_C_Pointer newPtr, JniTrace newParentTrace) throws JniException { super(newPtr, newParentTrace); } - /** - * Allocate (call constructor for) a new JniEvent.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTracefile - * - * @return JniEvent a newly allocated JniEvent - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - @Override - public JniEvent allocateNewJniEvent(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { + public JniEvent allocateNewJniEvent(Jni_C_Pointer newEventPtr, HashMap newMarkersMap, JniTracefile newParentTracefile) throws JniException { return new JniEvent_v2_6(newEventPtr, newMarkersMap, newParentTracefile); } - /** - * Allocate (call constructor for) a new JniMarker.

    - * - * This method is made to bypass limitation related to abstract class, see comment in JniTracefile - * - * @return JniMarker a newly allocated JniMarker - * - * @see org.eclipse.linuxtools.lttng.jni.JniTracefile - */ - @Override - public JniMarker allocateNewJniMarker(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException { + public JniMarker allocateNewJniMarker(Jni_C_Pointer newMarkerPtr) throws JniException { return new JniMarker_v2_6(newMarkerPtr); }