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