2010-11-05 Francois Chouinard <fchouinard@gmail.com> Fix for Bug329473
[deliverable/tracecompass.git] / org.eclipse.linuxtools.lttng.headless / src / JniTraceTest.java
CommitLineData
9cb4892d
WB
1/*******************************************************************************
2 * Copyright (c) 2009 Ericsson
3 *
4 * All rights reserved. This program and the accompanying materials are
5 * made available under the terms of the Eclipse Public License v1.0 which
6 * accompanies this distribution, and is available at
7 * http://www.eclipse.org/legal/epl-v10.html
8 *
9 * Contributors:
10 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
12
13import java.util.ArrayList;
14import org.eclipse.linuxtools.lttng.jni.JniEvent;
15import org.eclipse.linuxtools.lttng.jni.JniMarkerField;
16import org.eclipse.linuxtools.lttng.jni.JniTrace;
17import org.eclipse.linuxtools.lttng.jni.common.JniTime;
18import org.eclipse.linuxtools.lttng.jni.factory.JniTraceFactory;
19
20
21public class JniTraceTest {
22
23 public static void main(String[] args) {
24
25 // Path of the trace
26 final String TRACE_PATH = "/home/william/trace-614601events-nolost-newformat";
27
28 // *** Change this to run several time over the same trace
29 final int NB_OF_PASS = 1;
30
31 // *** Change this to true to parse all the events in the trace
32 // Otherwise, events are just read
33 final boolean PARSE_EVENTS = true;
34
35
36 // Work variables
37 JniTrace tmptrace = null;
38 JniEvent tmpevent = null;
39 Long nbEvent = 0L;
40
41 try {
42 // Get the trace from the Factory...
43 // This assume the path is correct and that the correct version of the lib is installed
44 tmptrace = JniTraceFactory.getJniTrace(TRACE_PATH, false);
45
46 // Seek beginning
47 tmptrace.seekToTime(new JniTime(0L));
48
49 // Run up to "NB_OF_PASS" on the same trace
50 for (int x=0; x<NB_OF_PASS; x++ ){
51 tmpevent = tmptrace.readNextEvent();
52 nbEvent++;
53
54 while ( tmpevent != null ) {
55
56 // Parse event if asked
57 if ( PARSE_EVENTS ) {
58 ArrayList<JniMarkerField> tmpFields = tmpevent.getMarkersMap().get(tmpevent.getEventMarkerId()).getMarkerFieldsArrayList();
59 for ( int pos=0; pos<tmpFields.size(); pos++ ) {
60 @SuppressWarnings("unused")
61 Object newValue = tmpevent.parseFieldById(pos);
62
63 // *** Uncomment the following to print the parsed content
64 // Warning : this is VERY intensive
65 //if ( pos == (tmpFields.size() -1) ) {
2f17867c 66 // tmptrace.printC(tmpevent.getEventPtr().getLibraryId(), tmpFields.get(pos).getField() + ":" + newValue + " ");
9cb4892d 67 //} else {
2f17867c 68 // tmptrace.printlnC(tmpevent.getEventPtr().getLibraryId(), tmpFields.get(pos).getField() + ":" + newValue + " ");
9cb4892d
WB
69 //}
70 }
71 }
72
73 tmpevent = tmptrace.readNextEvent();
74 nbEvent++;
75 }
76 }
77
78 System.out.println("NB Events read : " + nbEvent);
79 }
80 catch (Exception e) {
81 e.printStackTrace();
82 }
83 }
84
85}
This page took 0.02707 seconds and 5 git commands to generate.