Commit | Line | Data |
---|---|---|
0152140d ASL |
1 | package org.eclipse.linuxtools.lttng.jni; |
2 | ||
ce38c104 FC |
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; | |
0152140d ASL |
6 | |
7 | ||
8 | /** | |
9 | * <b><u>JniMarkerField</u></b> <p> | |
10 | * A JniMarkerField is one of the field of the unparsed content (payload) of an event. <p> | |
11 | * | |
12 | * Provides access to the marker_field C structure (from LTT) in java.<p> | |
13 | * | |
14 | * Most important attributes in the JniMarkerField are : | |
15 | * <ul> | |
16 | * <li> the name (field) of in String | |
17 | * <li> the marker field format (in C style printf format) | |
18 | * </ul> | |
3b7509b0 WB |
19 | * |
20 | * <b>NOTE</b><p> | |
21 | * This class is ABSTRACT, you need to extends it to support your specific LTTng version.<p> | |
22 | * | |
0152140d ASL |
23 | */ |
24 | public abstract class JniMarkerField extends Jni_C_Common | |
25 | { | |
26 | // Internal C pointer of the JniEvent used in LTT | |
c85e8cb2 | 27 | private Jni_C_Pointer_And_Library_Id thisMarkerFieldPtr = new Jni_C_Pointer_And_Library_Id(); |
0152140d | 28 | |
3b38ea61 FC |
29 | private String field = ""; //$NON-NLS-1$ |
30 | private String format = ""; //$NON-NLS-1$ | |
0152140d ASL |
31 | |
32 | // Native access method | |
c85e8cb2 WB |
33 | protected native String ltt_getField(int libId, long markerFieldPtr); |
34 | protected native int ltt_getType(int libId, long markerFieldPtr); | |
35 | protected native long ltt_getOffset(int libId, long markerFieldPtr); | |
36 | protected native long ltt_getSize(int libId, long markerFieldPtr); | |
37 | protected native long ltt_getAlignment(int libId, long markerFieldPtr); | |
38 | protected native long ltt_getAttributes(int libId, long markerFieldPtr); | |
39 | protected native int ltt_getStatic_offset(int libId, long markerFieldPtr); | |
40 | protected native String ltt_getFormat(int libId, long markerFieldPtr); | |
0152140d ASL |
41 | |
42 | // Debug native function, ask LTT to print marker structure | |
c85e8cb2 | 43 | protected native void ltt_printMarkerField(int libId, long markerFieldPtr); |
a9fcdd8d | 44 | |
0152140d ASL |
45 | /* |
46 | * Default constructor is forbidden | |
47 | */ | |
48 | protected JniMarkerField() { | |
49 | } | |
50 | ||
51 | /** | |
52 | * Copy constructor.<p> | |
53 | * | |
54 | * @param oldMarkerField Reference to the JniMarkerField you want to copy. | |
55 | */ | |
56 | public JniMarkerField(JniMarkerField oldMarkerField) { | |
57 | thisMarkerFieldPtr = oldMarkerField.getMarkerFieldPtr(); | |
58 | field = oldMarkerField.getField(); | |
59 | format = oldMarkerField.getFormat(); | |
60 | } | |
61 | ||
62 | /** | |
63 | * Constructor, using pointer.<p> | |
64 | * | |
65 | * @param newMarkerFieldPtr Pointer to a C marker_field structure | |
66 | * | |
67 | * @exception JniException | |
c357e4b6 | 68 | * |
ce38c104 | 69 | * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id |
0152140d | 70 | */ |
c85e8cb2 | 71 | public JniMarkerField(Jni_C_Pointer_And_Library_Id newMarkerFieldPtr) throws JniException { |
0152140d ASL |
72 | thisMarkerFieldPtr = newMarkerFieldPtr; |
73 | ||
74 | // Populate the marker field | |
75 | populateMarkerFieldInformation(); | |
76 | } | |
77 | ||
78 | /* | |
79 | * This function populates the marker field data with data from LTT | |
80 | * | |
81 | */ | |
82 | private void populateMarkerFieldInformation() throws JniException { | |
83 | if (thisMarkerFieldPtr.getPointer() == NULL) { | |
84 | throw new JniMarkerFieldException( | |
9c4eb5f7 | 85 | "Pointer is NULL, trace closed? (populateMarkerInformation)"); //$NON-NLS-1$ |
0152140d | 86 | } else { |
c85e8cb2 WB |
87 | field = ltt_getField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer()); |
88 | format = ltt_getFormat(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer()); | |
0152140d ASL |
89 | } |
90 | } | |
91 | ||
92 | public String getField() { | |
93 | return field; | |
94 | } | |
95 | ||
96 | public String getFormat() { | |
97 | return format; | |
98 | } | |
99 | ||
100 | /** | |
101 | * Pointer to the marker_field C structure.<p> | |
102 | * | |
103 | * The pointer should only be used <u>INTERNALY</u>, do not use these unless you | |
104 | * know what you are doing.<p> | |
105 | * | |
106 | * @return The actual (long converted) pointer or NULL | |
107 | * | |
ce38c104 | 108 | * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id |
0152140d | 109 | */ |
c85e8cb2 | 110 | public Jni_C_Pointer_And_Library_Id getMarkerFieldPtr() { |
0152140d ASL |
111 | return thisMarkerFieldPtr; |
112 | } | |
113 | ||
114 | /** | |
115 | * Print information for this event. <u>Intended to debug</u><br> | |
116 | * | |
117 | * This function will call Ltt to print, so information printed will be the one from | |
118 | * the C structure, not the one populated in java.<p> | |
119 | */ | |
120 | public void printMarkerFieldInformation() { | |
c85e8cb2 | 121 | ltt_printMarkerField(thisMarkerFieldPtr.getLibraryId(), thisMarkerFieldPtr.getPointer()); |
0152140d ASL |
122 | } |
123 | ||
124 | /** | |
125 | * toString() method. | |
126 | * <u>Intended to debug</u><br> | |
127 | * | |
128 | * @return Attributes of the object concatenated in String | |
129 | */ | |
3b38ea61 FC |
130 | @Override |
131 | @SuppressWarnings("nls") | |
0152140d ASL |
132 | public String toString() { |
133 | String returnData = ""; | |
134 | returnData += "field : " + field + "\n"; | |
135 | returnData += "format : " + format + "\n"; | |
136 | ||
137 | return returnData; | |
138 | } | |
c357e4b6 | 139 | |
0152140d | 140 | } |