More javadoc updates
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.jni / src / org / eclipse / linuxtools / lttng / jni / JniTracefile.java
CommitLineData
0152140d
ASL
1package org.eclipse.linuxtools.lttng.jni;
2/*******************************************************************************
3 * Copyright (c) 2009 Ericsson
84b2b1f0 4 *
0152140d
ASL
5 * All rights reserved. This program and the accompanying materials are
6 * made available under the terms of the Eclipse Public License v1.0 which
7 * accompanies this distribution, and is available at
8 * http://www.eclipse.org/legal/epl-v10.html
84b2b1f0 9 *
0152140d
ASL
10 * Contributors:
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
13
14
15import java.util.HashMap;
16
ce38c104
FC
17import org.eclipse.linuxtools.internal.lttng.jni.common.JniTime;
18import org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer;
19import org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id;
20import org.eclipse.linuxtools.internal.lttng.jni.exception.JniException;
21import org.eclipse.linuxtools.internal.lttng.jni.exception.JniNoSuchEventException;
22import org.eclipse.linuxtools.internal.lttng.jni.exception.JniTracefileException;
23import org.eclipse.linuxtools.internal.lttng.jni.exception.JniTracefileWithoutEventException;
0152140d
ASL
24
25/**
0152140d
ASL
26 * A tracefile own an event of a certain type.<br>
27 * Provides access to the LttTracefile C structure in java.
28 * <p>
29 * Most important fields in the JniTracefile are :
30 * <ul>
31 * <li> a JniTracefile path (a tracefile <b>file</b> within a JniTrace directory)
32 * <li> a name (basically the name without the directory part)
33 * <li> a reference to a single event object
34 * <li> a HashMap of marker associated with this tracefile
35 * </ul>
3b7509b0
WB
36 * <b>NOTE</b><p>
37 * This class is ABSTRACT, you need to extends it to support your specific LTTng version.<br>
38 * Please look at the abstract functions to override at the bottom of this file.<p>
84b2b1f0 39 *
d37aaa7f
FC
40 * @version 0.1
41 * @author William Bourque
0152140d 42 */
84b2b1f0 43public abstract class JniTracefile extends Jni_C_Common
c85e8cb2 44{
0152140d 45 // Internal C pointer of the JniTracefile used in LTT
c85e8cb2 46 private Jni_C_Pointer_And_Library_Id thisTracefilePtr = new Jni_C_Pointer_And_Library_Id();
84b2b1f0 47
0152140d
ASL
48 // Reference to the parent trace
49 private JniTrace parentTrace = null;
84b2b1f0 50
0152140d
ASL
51 // Data we should populate from LTT
52 // Note that all type have been scaled up as there is no "unsigned" in java
53 // This might be a problem about "unsigned long" as there is no equivalent in java
54 private boolean isCpuOnline = false;
9c4eb5f7
FC
55 private String tracefilePath = ""; //$NON-NLS-1$
56 private String tracefileName = ""; //$NON-NLS-1$
0152140d
ASL
57 private long cpuNumber = 0;
58 private long tid = 0;
59 private long pgid = 0;
60 private long creation = 0;
84b2b1f0 61
0152140d 62 // Internal C pointer for trace and marker
c85e8cb2 63 // Note : These are real Jni_C_Pointer, not Jni_C_Pointer_And_Library_Id
0152140d
ASL
64 private Jni_C_Pointer tracePtr = null;
65 private Jni_C_Pointer markerDataPtr = null;
84b2b1f0 66
0152140d
ASL
67 private int CFileDescriptor = 0;
68 private long fileSize = 0;
69 private long blocksNumber = 0;
70 private boolean isBytesOrderReversed = false;
71 private boolean isFloatWordOrdered = false;
72 private long alignement = 0;
73 private long bufferHeaderSize = 0;
74 private int bitsOfCurrentTimestampCounter = 0;
75 private int bitsOfEvent = 0;
76 private long currentTimestampCounterMask = 0;
77 private long currentTimestampCounterMaskNextBit = 0;
78 private long eventsLost = 0;
79 private long subBufferCorrupt = 0;
80 private JniEvent currentEvent = null;
84b2b1f0 81
0152140d 82 // Internal C pointer for trace and marker
c85e8cb2 83 // Note : This one is a real Jni_C_Pointer, not Jni_C_Pointer_And_Library_Id
0152140d 84 private Jni_C_Pointer bufferPtr = null;
84b2b1f0 85
0152140d
ASL
86 private long bufferSize = 0;
87
88 // This map will hold markers_info owned by this tracefile
84b2b1f0 89 private HashMap<Integer, JniMarker> tracefileMarkersMap = null;
0152140d
ASL
90
91 // Native access functions
c85e8cb2
WB
92 protected native boolean ltt_getIsCpuOnline(int libId, long tracefilePtr);
93 protected native String ltt_getTracefilepath(int libId, long tracefilePtr);
94 protected native String ltt_getTracefilename(int libId, long tracefilePtr);
95 protected native long ltt_getCpuNumber(int libId, long tracefilePtr);
96 protected native long ltt_getTid(int libId, long tracefilePtr);
97 protected native long ltt_getPgid(int libId, long tracefilePtr);
98 protected native long ltt_getCreation(int libId, long tracefilePtr);
99 protected native long ltt_getTracePtr(int libId, long tracefilePtr);
100 protected native long ltt_getMarkerDataPtr(int libId, long tracefilePtr);
101 protected native int ltt_getCFileDescriptor(int libId, long tracefilePtr);
102 protected native long ltt_getFileSize(int libId, long tracefilePtr);
103 protected native long ltt_getBlockNumber(int libId, long tracefilePtr);
104 protected native boolean ltt_getIsBytesOrderReversed(int libId, long tracefilePtr);
105 protected native boolean ltt_getIsFloatWordOrdered(int libId, long tracefilePtr);
106 protected native long ltt_getAlignement(int libId, long tracefilePtr);
107 protected native long ltt_getBufferHeaderSize(int libId, long tracefilePtr);
108 protected native int ltt_getBitsOfCurrentTimestampCounter(int libId, long tracefilePtr);
109 protected native int ltt_getBitsOfEvent(int libId, long tracefilePtr);
110 protected native long ltt_getCurrentTimestampCounterMask(int libId, long tracefilePtr);
111 protected native long ltt_getCurrentTimestampCounterMaskNextBit(int libId, long tracefilePtr);
112 protected native long ltt_getEventsLost(int libId, long tracefilePtr);
113 protected native long ltt_getSubBufferCorrupt(int libId, long tracefilePtr);
114 protected native long ltt_getEventPtr(int libId, long tracefilePtr);
115 protected native long ltt_getBufferPtr(int libId, long tracefilePtr);
116 protected native long ltt_getBufferSize(int libId, long tracefilePtr);
84b2b1f0 117
0152140d 118 // Method to fill a map with marker object
c85e8cb2 119 protected native void ltt_feedAllMarkers(int libId, long tracefilePtr);
84b2b1f0 120
0152140d 121 // Debug native function, ask LTT to print tracefile structure
c85e8cb2 122 protected native void ltt_printTracefile(int libId, long tracefilePtr);
84b2b1f0 123
0152140d
ASL
124 /*
125 * Default constructor is forbidden
126 */
127 protected JniTracefile() {
128 }
129
130 /**
131 * Copy constructor.<p>
84b2b1f0
AM
132 *
133 * @param oldTracefile Reference to the JniTracefile you want to copy.
0152140d
ASL
134 */
135 public JniTracefile(JniTracefile oldTracefile) {
136 thisTracefilePtr = oldTracefile.thisTracefilePtr;
137 parentTrace = oldTracefile.parentTrace;
138 tracefileMarkersMap = oldTracefile.tracefileMarkersMap;
139 isCpuOnline = oldTracefile.isCpuOnline;
140 tracefilePath = oldTracefile.tracefilePath;
141 tracefileName = oldTracefile.tracefileName;
142 cpuNumber = oldTracefile.cpuNumber;
143 tid = oldTracefile.tid;
144 pgid = oldTracefile.pgid;
145 creation = oldTracefile.creation;
146 tracePtr = oldTracefile.tracePtr;
147 markerDataPtr = oldTracefile.markerDataPtr;
148 CFileDescriptor = oldTracefile.CFileDescriptor;
149 fileSize = oldTracefile.fileSize;
150 blocksNumber = oldTracefile.blocksNumber;
151 isBytesOrderReversed = oldTracefile.isBytesOrderReversed;
152 isFloatWordOrdered = oldTracefile.isFloatWordOrdered;
153 alignement = oldTracefile.alignement;
154 bufferHeaderSize = oldTracefile.bufferHeaderSize;
155 bitsOfCurrentTimestampCounter = oldTracefile.bitsOfCurrentTimestampCounter;
156 bitsOfEvent = oldTracefile.bitsOfEvent;
157 currentTimestampCounterMask = oldTracefile.currentTimestampCounterMask;
158 currentTimestampCounterMaskNextBit = oldTracefile.currentTimestampCounterMaskNextBit;
159 eventsLost = oldTracefile.eventsLost;
160 subBufferCorrupt = oldTracefile.subBufferCorrupt;
161 currentEvent = oldTracefile.currentEvent;
162 bufferPtr = oldTracefile.bufferPtr;
163 bufferSize = oldTracefile.bufferSize;
164 }
165
166 /**
84b2b1f0
AM
167 * Constructor, using C pointer.
168 * <p>
169 *
170 * @param newPtr
171 * The pointer of an already opened LttTracefile C Structure
172 * @param newParentTrace
173 * The JniTrace parent of this tracefile.
0152140d 174 * @exception JniException
84b2b1f0
AM
175 * If the JNI call fails
176 *
c357e4b6 177 * @see org.eclipse.linuxtools.lttng.jni.JniTrace
ce38c104 178 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
0152140d 179 */
c85e8cb2
WB
180 public JniTracefile(Jni_C_Pointer_And_Library_Id newPtr, JniTrace newParentTrace) throws JniException {
181 thisTracefilePtr = newPtr;
0152140d
ASL
182 parentTrace = newParentTrace;
183 tracefileMarkersMap = new HashMap<Integer, JniMarker>();
184
185 // Retrieve the trace file information and load the first event.
186 try {
187 populateTracefileInformation();
84b2b1f0 188 }
c85e8cb2 189 catch (JniNoSuchEventException e) {
9c4eb5f7 190 throw new JniTracefileWithoutEventException("JniEvent constructor reported that no event of this type are usable. (Jni_Tracefile)"); //$NON-NLS-1$
0152140d 191 }
84b2b1f0 192 }
0152140d
ASL
193
194 /**
195 * Read the next event of this tracefile.<p>
84b2b1f0 196 *
0152140d 197 * Note : If the read succeed, the event will be populated.<p>
84b2b1f0 198 *
c357e4b6 199 * @return LTT read status, as defined in Jni_C_Constant
84b2b1f0 200 *
ce38c104 201 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Constant
0152140d
ASL
202 */
203 public int readNextEvent() {
204 return currentEvent.readNextEvent();
84b2b1f0 205 }
0152140d
ASL
206
207 /**
208 * Seek to the given time.<p>
84b2b1f0 209 *
0152140d 210 * Note : If the seek succeed, the event will be populated.
84b2b1f0 211 *
0152140d 212 * @param seekTime The timestamp where to seek.
84b2b1f0 213 *
c357e4b6 214 * @return LTT read status, as defined in Jni_C_Constant
84b2b1f0 215 *
ce38c104 216 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Constant
0152140d
ASL
217 */
218 public int seekToTime(JniTime seekTime) {
219 return currentEvent.seekToTime(seekTime);
220 }
221
84b2b1f0 222 /*
0152140d 223 * This function populates the tracefile data with data from LTT
84b2b1f0 224 *
0152140d
ASL
225 * @throws JniException
226 */
227 private void populateTracefileInformation() throws JniException {
228 if (thisTracefilePtr.getPointer() == NULL) {
9c4eb5f7 229 throw new JniTracefileException("Pointer is NULL, trace closed? (populateTracefileInformation)"); //$NON-NLS-1$
0152140d
ASL
230 }
231
c85e8cb2
WB
232 isCpuOnline = ltt_getIsCpuOnline(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer());
233 tracefilePath = ltt_getTracefilepath(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer());
234 tracefileName = ltt_getTracefilename(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer());
235 cpuNumber = ltt_getCpuNumber(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer());
236 tid = ltt_getTid(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
237 pgid = ltt_getPgid(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
238 creation = ltt_getCreation(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
239 tracePtr = new Jni_C_Pointer(ltt_getTracePtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()) );
240 markerDataPtr = new Jni_C_Pointer(ltt_getMarkerDataPtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()) );
241 CFileDescriptor = ltt_getCFileDescriptor(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
242 fileSize = ltt_getFileSize(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
243 blocksNumber = ltt_getBlockNumber(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
244 isBytesOrderReversed = ltt_getIsBytesOrderReversed(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
245 isFloatWordOrdered = ltt_getIsFloatWordOrdered(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
246 alignement = ltt_getAlignement(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
247 bufferHeaderSize = ltt_getBufferHeaderSize(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
248 bitsOfCurrentTimestampCounter = ltt_getBitsOfCurrentTimestampCounter(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
249 bitsOfEvent = ltt_getBitsOfEvent(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
250 currentTimestampCounterMask = ltt_getCurrentTimestampCounterMask(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
251 currentTimestampCounterMaskNextBit = ltt_getCurrentTimestampCounterMaskNextBit(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
252 eventsLost = ltt_getEventsLost(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
253 subBufferCorrupt = ltt_getSubBufferCorrupt(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
254 bufferPtr = new Jni_C_Pointer(ltt_getBufferPtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()) );
255 bufferSize = ltt_getBufferSize(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer());
0152140d
ASL
256
257 // To fill the map is a bit different
c85e8cb2 258 ltt_feedAllMarkers(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
0152140d 259
c85e8cb2 260 Jni_C_Pointer_And_Library_Id tmpEventPointer = new Jni_C_Pointer_And_Library_Id(thisTracefilePtr.getLibraryId(), ltt_getEventPtr(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer()));
0152140d 261 currentEvent = allocateNewJniEvent(tmpEventPointer , tracefileMarkersMap, this);
84b2b1f0
AM
262 }
263
264 /*
0152140d 265 * Fills a map of all the markers associated with this tracefile.
84b2b1f0 266 *
0152140d
ASL
267 * Note: This function is called from C and there is no way to propagate
268 * exception back to the caller without crashing JNI. Therefore, it MUST
269 * catch all exceptions.
84b2b1f0 270 *
0152140d 271 * @param markerId Id of the marker (int)
84b2b1f0 272 * @param markerInfoPtr C Pointer to a marker_info C structure
0152140d 273 */
687cc7e7 274 private void addMarkersFromC(int markerId, long markerInfoPtr) {
0152140d
ASL
275 // Create a new tracefile object and insert it in the map
276 // the tracefile fill itself with LTT data while being constructed
277 try {
c85e8cb2 278 JniMarker newMarker = allocateNewJniMarker( new Jni_C_Pointer_And_Library_Id(thisTracefilePtr.getLibraryId(), markerInfoPtr) );
0152140d
ASL
279
280 tracefileMarkersMap.put(markerId, newMarker);
281 } catch (Exception e) {
9c4eb5f7 282 printlnC(thisTracefilePtr.getLibraryId(), "Failed to add marker to tracefileMarkersMap!(addMarkersFromC)\n\tException raised : " + e.toString()); //$NON-NLS-1$
0152140d
ASL
283 }
284 }
84b2b1f0
AM
285
286 // Access to class variable. Most of them don't have setters
287
288 /**
289 * Return if the CPU corresponding to this trace file is online or not.
290 *
291 * @return If the CPU is online, true/false
292 */
0152140d
ASL
293 public boolean getIsCpuOnline() {
294 return isCpuOnline;
295 }
84b2b1f0
AM
296
297 /**
298 * Get the complete path to this trace file
299 *
300 * @return The file path
301 */
0152140d
ASL
302 public String getTracefilePath() {
303 return tracefilePath;
304 }
305
84b2b1f0
AM
306 /**
307 * Get the base name of this trace file
308 *
309 * @return The file name
310 */
0152140d
ASL
311 public String getTracefileName() {
312 return tracefileName;
313 }
314
84b2b1f0
AM
315 /**
316 * Get the CPU number corresponding to this file
317 *
318 * @return The CPU number. Yes, as a long. Don't ask.
319 */
0152140d
ASL
320 public long getCpuNumber() {
321 return cpuNumber;
322 }
323
84b2b1f0
AM
324 /**
325 * Get the TID of this trace file (for UST traces)
326 *
327 * @return The TID
328 */
0152140d
ASL
329 public long getTid() {
330 return tid;
331 }
332
84b2b1f0
AM
333 /**
334 * Get the PGID of this trace file (for UST traces)
335 *
336 * @return The PGID
337 */
0152140d
ASL
338 public long getPgid() {
339 return pgid;
340 }
341
84b2b1f0
AM
342 /**
343 * Get the creation time of this process (for UST traces)
344 *
345 * @return The creation timestamp
346 */
0152140d
ASL
347 public long getCreation() {
348 return creation;
349 }
350
84b2b1f0
AM
351 /**
352 * Get the C pointer to the trace
353 *
354 * @return The Jni_C_Pointer to the trace
355 */
0152140d
ASL
356 public Jni_C_Pointer getTracePtr() {
357 return tracePtr;
358 }
359
84b2b1f0
AM
360 /**
361 * Get the C pointer to the marker data object
362 *
363 * @return The Jni_C_Pointer to the marker data
364 */
0152140d
ASL
365 public Jni_C_Pointer getMarkerDataPtr() {
366 return markerDataPtr;
367 }
368
84b2b1f0
AM
369 /**
370 * Get the file descriptor number used for this trace file
371 *
372 * @return The file descriptor index
373 */
0152140d
ASL
374 public int getCFileDescriptor() {
375 return CFileDescriptor;
376 }
377
84b2b1f0
AM
378 /**
379 * Get the size of this file, in bytes
380 *
381 * @return The file size
382 */
0152140d
ASL
383 public long getFileSize() {
384 return fileSize;
385 }
386
84b2b1f0
AM
387 /**
388 * Get the number of blocks in this trace file
389 *
390 * @return The number of blocks
391 */
0152140d
ASL
392 public long getBlocksNumber() {
393 return blocksNumber;
394 }
395
84b2b1f0
AM
396 /**
397 * Return if the byte order is reversed in this trace
398 *
399 * @return If the byte order is reversed, Y/N
400 */
0152140d
ASL
401 public boolean getIsBytesOrderReversed() {
402 return isBytesOrderReversed;
403 }
404
84b2b1f0
AM
405 /**
406 * Return if floats are aligned to words in this trace
407 *
408 * @return If floats are aligned, Y/N
409 */
0152140d
ASL
410 public boolean getIsFloatWordOrdered() {
411 return isFloatWordOrdered;
412 }
413
84b2b1f0
AM
414 /**
415 * Get the byte alignment of this trace
416 *
417 * @return The byte alignment
418 */
0152140d
ASL
419 public long getAlignement() {
420 return alignement;
421 }
422
84b2b1f0
AM
423 /**
424 * Get the size of the buffer headers, in bytes
425 *
426 * @return The buffer header size
427 */
0152140d
ASL
428 public long getBufferHeaderSize() {
429 return bufferHeaderSize;
430 }
431
84b2b1f0
AM
432 /**
433 * Get the number of bits for the current timestamp counter
434 *
435 * @return The number of bits for the TS counter
436 */
0152140d
ASL
437 public int getBitsOfCurrentTimestampCounter() {
438 return bitsOfCurrentTimestampCounter;
439 }
440
84b2b1f0
AM
441 /**
442 * Get the number of bits for the current event
443 *
444 * @return The number of bits for the event
445 */
0152140d
ASL
446 public int getBitsOfEvent() {
447 return bitsOfEvent;
448 }
449
84b2b1f0
AM
450 /**
451 * Get the mask for the current timestamp counter
452 *
453 * @return The TS counter mask
454 */
0152140d
ASL
455 public long getCurrentTimestampCounterMask() {
456 return currentTimestampCounterMask;
457 }
458
84b2b1f0
AM
459 /**
460 * Get the mask of the next bit for the current timestamp counter
461 *
462 * @return The mask of the next bit
463 */
0152140d
ASL
464 public long getCurrentTimestampCounterMaskNextBit() {
465 return currentTimestampCounterMaskNextBit;
466 }
467
84b2b1f0
AM
468 /**
469 * Get the amount of lost events in this trace file
470 *
471 * @return The amount of lost events
472 */
0152140d
ASL
473 public long getEventsLost() {
474 return eventsLost;
475 }
476
84b2b1f0
AM
477 /**
478 * Return if the current subbuffer is corrupted. Or maybe the number of
479 * corrupted subbuffers? I have no idea...
480 *
481 * @return The number of subbuffers
482 */
0152140d
ASL
483 public long getSubBufferCorrupt() {
484 return subBufferCorrupt;
485 }
486
84b2b1f0
AM
487 /**
488 * Get the current event this trace is pointed at.
489 *
490 * @return The current event, as a JniEvent
491 */
0152140d
ASL
492 public JniEvent getCurrentEvent() {
493 return currentEvent;
494 }
495
84b2b1f0
AM
496 /**
497 * Get a pointer to the current subbuffer
498 *
499 * @return Pointer to the current subbuffer
500 */
0152140d
ASL
501 public Jni_C_Pointer getBufferPtr() {
502 return bufferPtr;
503 }
504
84b2b1f0
AM
505 /**
506 * Get the buffer size for this trace, in bytes
507 *
508 * @return The buffer size
509 */
0152140d
ASL
510 public long getBufferSize() {
511 return bufferSize;
512 }
513
84b2b1f0
AM
514 /**
515 * Get the map of markers in this trace file
516 *
517 * @return The map of markers
518 */
0152140d
ASL
519 public HashMap<Integer, JniMarker> getTracefileMarkersMap() {
520 return tracefileMarkersMap;
521 }
522
523 /**
524 * Parent trace of this tracefile.<p>
525 *
526 * @return The parent trace
84b2b1f0 527 *
c357e4b6 528 * @see org.eclipse.linuxtools.lttng.jni.JniTrace
0152140d
ASL
529 */
530 public JniTrace getParentTrace() {
531 return parentTrace;
532 }
84b2b1f0 533
0152140d
ASL
534 /**
535 * Pointer to the LttTracefile C structure<p>
84b2b1f0 536 *
0152140d
ASL
537 * The pointer should only be used <u>INTERNALY</u>, do not use unless you
538 * know what you are doing.<p>
84b2b1f0 539 *
0152140d 540 * @return The actual (long converted) pointer or NULL.
84b2b1f0 541 *
ce38c104 542 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
0152140d 543 */
c85e8cb2 544 public Jni_C_Pointer_And_Library_Id getTracefilePtr() {
0152140d
ASL
545 return thisTracefilePtr;
546 }
84b2b1f0 547
0152140d 548 /**
84b2b1f0 549 * Print information for this tracefile.
0152140d 550 * <u>Intended to debug</u><p>
84b2b1f0 551 *
0152140d
ASL
552 * This function will call Ltt to print, so information printed will be the
553 * one from the C structure, not the one populated in java.<p>
554 */
555 public void printTracefileInformation() {
c85e8cb2 556 ltt_printTracefile(thisTracefilePtr.getLibraryId(), thisTracefilePtr.getPointer() );
0152140d 557 }
84b2b1f0 558
0152140d 559 /**
84b2b1f0 560 * toString() method.
0152140d 561 * <u>Intended to debug</u><p>
84b2b1f0 562 *
0152140d
ASL
563 * @return Attributes of the object concatenated in String
564 */
565 @Override
3b38ea61 566 @SuppressWarnings("nls")
0152140d
ASL
567 public String toString() {
568 String returnData = "";
84b2b1f0 569
0152140d
ASL
570 returnData += "isCpuOnline : " + isCpuOnline + "\n";
571 returnData += "tracefilePath : " + tracefilePath + "\n";
572 returnData += "tracefileName : " + tracefileName + "\n";
573 returnData += "cpuNumber : " + cpuNumber + "\n";
574 returnData += "tid : " + tid + "\n";
575 returnData += "pgid : " + pgid + "\n";
576 returnData += "creation : " + creation + "\n";
577 returnData += "tracePtr : " + tracePtr + "\n";
578 returnData += "markerDataPtr : " + markerDataPtr + "\n";
579 returnData += "CFileDescriptor : " + CFileDescriptor + "\n";
580 returnData += "fileSize : " + fileSize + "\n";
581 returnData += "blocksNumber : " + blocksNumber + "\n";
582 returnData += "isBytesOrderReversed : " + isBytesOrderReversed + "\n";
583 returnData += "isFloatWordOrdered : " + isFloatWordOrdered + "\n";
584 returnData += "alignement : " + alignement + "\n";
585 returnData += "bufferHeaderSize : " + bufferHeaderSize + "\n";
586 returnData += "bitsOfCurrentTimestampCounter : " + bitsOfCurrentTimestampCounter + "\n";
587 returnData += "bitsOfEvent : " + bitsOfEvent + "\n";
588 returnData += "currentTimestampCounterMask : " + currentTimestampCounterMask + "\n";
589 returnData += "currentTimestampCounterMaskNextBit : " + currentTimestampCounterMaskNextBit + "\n";
590 returnData += "eventsLost : " + eventsLost + "\n";
591 returnData += "subBufferCorrupt : " + subBufferCorrupt + "\n";
592 returnData += "currentEvent : " + currentEvent.getReferenceToString() + "\n"; // Hack to avoid ending up with event.toString()
593 returnData += "bufferPtr : " + bufferPtr + "\n";
594 returnData += "bufferSize : " + bufferSize + "\n";
595 returnData += "tracefileMarkersMap : " + tracefileMarkersMap.keySet() + "\n"; // Hack to avoid ending up with tracefileMarkersMap.toString()
596
597 return returnData;
598 }
84b2b1f0
AM
599
600
c357e4b6
WB
601 // ****************************
602 // **** ABSTRACT FUNCTIONS ****
603 // You MUST override those in your version specific implementation
84b2b1f0
AM
604
605
c357e4b6
WB
606 /**
607 * Function place holder to allocate a new JniEvent.<p>
608 * <br>
609 * JniEvent constructor is non overridable so we need another overridable function to return the correct version of JniEvent.<br>
610 * Effect of this function should be the same (allocate a fresh new JniEvent).<br>
611 * <br>
612 * <b>!! Override this with you version specific implementation.</b><br>
84b2b1f0 613 *
c357e4b6
WB
614 * @param newEventPtr The pointer of an already opened LttEvent C Structure
615 * @param newMarkersMap An already populated HashMap of JniMarker objects for this new event
616 * @param newParentTracefile The JniTrace parent of this tracefile.
84b2b1f0 617 *
c357e4b6 618 * @return The newly allocated JniEvent of the correct version
84b2b1f0 619 *
c357e4b6 620 * @throws JniException The construction (allocation) failed.
84b2b1f0 621 *
c357e4b6 622 * @see org.eclipse.linuxtools.lttng.jni.JniEvent
ce38c104 623 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
c357e4b6
WB
624 * @see org.eclipse.linuxtools.lttng.jni.JniMarker
625 * @see org.eclipse.linuxtools.lttng.jni.JniTracefile
626 */
c85e8cb2 627 public abstract JniEvent allocateNewJniEvent(Jni_C_Pointer_And_Library_Id newEventPtr, HashMap<Integer, JniMarker> newMarkersMap, JniTracefile newParentTracefile) throws JniException;
84b2b1f0
AM
628
629
c357e4b6
WB
630 /**
631 * Function place holder to allocate a new JniMarker.<p>
632 * <br>
633 * JniMarker constructor is non overridable so we need another overridable function to return the correct version of JniMarker.<br>
634 * Effect of this function should be the same (allocate a fresh new JniMarker).<br>
635 * <br>
636 * <b>!! Override this with you version specific implementation.</b><br>
84b2b1f0 637 *
c357e4b6 638 * @param newMarkerPtr The pointer of an already opened marker_info C Structure
84b2b1f0 639 *
c357e4b6 640 * @return The newly allocated JniMarker of the correct version
84b2b1f0 641 *
c357e4b6 642 * @throws JniException The construction (allocation) failed.
84b2b1f0 643 *
c357e4b6 644 * @see org.eclipse.linuxtools.lttng.jni.JniMarker
ce38c104 645 * @see org.eclipse.linuxtools.internal.lttng.jni.common.Jni_C_Pointer_And_Library_Id
c357e4b6 646 */
c85e8cb2 647 public abstract JniMarker allocateNewJniMarker(Jni_C_Pointer_And_Library_Id newMarkerPtr) throws JniException;
84b2b1f0 648
0152140d 649}
This page took 0.063346 seconds and 5 git commands to generate.