1 /*******************************************************************************
2 * Copyright (c) 2009 Ericsson
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
10 * William Bourque (wbourque@gmail.com) - Initial API and implementation
11 *******************************************************************************/
13 import java
.util
.ArrayList
;
14 import org
.eclipse
.linuxtools
.lttng
.jni
.JniEvent
;
15 import org
.eclipse
.linuxtools
.lttng
.jni
.JniMarkerField
;
16 import org
.eclipse
.linuxtools
.lttng
.jni
.JniTrace
;
17 import org
.eclipse
.linuxtools
.lttng
.jni
.common
.JniTime
;
18 import org
.eclipse
.linuxtools
.lttng
.jni
.factory
.JniTraceFactory
;
21 @SuppressWarnings("nls")
22 public class JniTraceTest
{
24 public static void main(String
[] args
) {
27 final String TRACE_PATH
= "/home/william/trace-614601events-nolost-newformat";
29 // *** Change this to run several time over the same trace
30 final int NB_OF_PASS
= 1;
32 // *** Change this to true to parse all the events in the trace
33 // Otherwise, events are just read
34 final boolean PARSE_EVENTS
= true;
38 JniTrace tmptrace
= null;
39 JniEvent tmpevent
= null;
43 // Get the trace from the Factory...
44 // This assume the path is correct and that the correct version of the lib is installed
45 tmptrace
= JniTraceFactory
.getJniTrace(TRACE_PATH
, false);
48 tmptrace
.seekToTime(new JniTime(0L));
50 // Run up to "NB_OF_PASS" on the same trace
51 for (int x
=0; x
<NB_OF_PASS
; x
++ ){
52 tmpevent
= tmptrace
.readNextEvent();
55 while ( tmpevent
!= null ) {
57 // Parse event if asked
59 ArrayList
<JniMarkerField
> tmpFields
= tmpevent
.getMarkersMap().get(tmpevent
.getEventMarkerId()).getMarkerFieldsArrayList();
60 for ( int pos
=0; pos
<tmpFields
.size(); pos
++ ) {
61 @SuppressWarnings("unused")
62 Object newValue
= tmpevent
.parseFieldById(pos
);
64 // *** Uncomment the following to print the parsed content
65 // Warning : this is VERY intensive
66 //if ( pos == (tmpFields.size() -1) ) {
67 // tmptrace.printC(tmpevent.getEventPtr().getLibraryId(), tmpFields.get(pos).getField() + ":" + newValue + " ");
69 // tmptrace.printlnC(tmpevent.getEventPtr().getLibraryId(), tmpFields.get(pos).getField() + ":" + newValue + " ");
74 tmpevent
= tmptrace
.readNextEvent();
79 System
.out
.println("NB Events read : " + nbEvent
);
This page took 0.032561 seconds and 5 git commands to generate.