1
package org.eclipse.linuxtools.lttng.jni;
3
import org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id;
4
import org.eclipse.linuxtools.internal.lttng.jni.exception.JniException;
5
import org.eclipse.linuxtools.internal.lttng.jni.exception.JniMarkerFieldException;
9
* A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p>
11
* Provides access to the marker_field C structure (from LTT) in java.<p>
13
* Most important attributes in the JniMarkerField are :
15
* <li> the name (field) of in String
16
* <li> the marker field format (in C style printf format)
20
* This class is ABSTRACT, you need to extends it to support your specific LTTng version.<p>
23
* @author William Bourque
25
public abstract class JniMarkerField extends Jni_C_Common
27
// Internal C pointer of the JniEvent used in LTT
28
private Jni_C_Pointer_And_Library_Id thisMarkerFieldPtr = new Jni_C_Pointer_And_Library_Id();
30
private String field = ""; //$NON-NLS-1$
31
private String format = ""; //$NON-NLS-1$
33
// Native access method
34
protected native String ltt_getField(int libId, long markerFieldPtr);
35
protected native int ltt_getType(int libId, long markerFieldPtr);
36
protected native long ltt_getOffset(int libId, long markerFieldPtr);
37
protected native long ltt_getSize(int libId, long markerFieldPtr);
38
protected native long ltt_getAlignment(int libId, long markerFieldPtr);
39
protected native long ltt_getAttributes(int libId, long markerFieldPtr);
40
protected native int ltt_getStatic_offset(int libId, long markerFieldPtr);
41
protected native String ltt_getFormat(int libId, long markerFieldPtr);
43
// Debug native function, ask LTT to print marker structure
44
protected native void ltt_printMarkerField(int libId, long markerFieldPtr);
47
* Default constructor is forbidden
49
protected JniMarkerField() {
53
* Copy constructor.<p>
55
* @param oldMarkerField Reference to the JniMarkerField you want to copy.
57
public JniMarkerField(JniMarkerField oldMarkerField) {
58
thisMarkerFieldPtr = oldMarkerField.getMarkerFieldPtr();
59
field = oldMarkerField.getField();
60
format = oldMarkerField.getFormat();
64
* Constructor, using pointer.
67
* @param newMarkerFieldPtr
68
* Pointer to a C marker_field structure
69
* @exception JniException
70
* If the JNI call fails
72
* @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
74
public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException {
75
thisMarkerFieldPtr = newMarkerFieldPtr;
77
// Populate the marker field
78
populateMarkerFieldInformation();
82
* This function populates the marker field data with data from LTT
85
private void populateMarkerFieldInformation() throws JniException {
86
if (thisMarkerFieldPtr.getPointer() == NULL) {
87
throw new JniMarkerFieldException(
88
"Pointer is NULL, trace closed? (populateMarkerInformation)"); //$NON-NLS-1$
90
field = ltt_getField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
91
format = ltt_getFormat(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
95
* Get the field of this marker
97
* @return The field name
99
public String getField() {
104
* Get the format of this marker
106
* @return The format, as a String
108
public String getFormat() {
113
* Pointer to the marker_field C structure.<p>
115
* The pointer should only be used <u>INTERNALY</u>, do not use these unless you
116
* know what you are doing.<p>
118
* @return The actual (long converted) pointer or NULL
120
* @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
122
public Jni_C_Pointer_And_Library_Id getMarkerFieldPtr() {
123
return thisMarkerFieldPtr;
127
* Print information for this event. <u>Intended to debug</u><br>
129
* This function will call Ltt to print, so information printed will be the one from
130
* the C structure, not the one populated in java.<p>
132
public void printMarkerFieldInformation() {
133
ltt_printMarkerField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer());
138
* <u>Intended to debug</u><br>
140
* @return Attributes of the object concatenated in String
143
@SuppressWarnings("nls")
144
public String toString() {
145
String returnData = "";
146
returnData += "field : " + field + "\n";
147
returnData += "format : " + format + "\n";