1 package org
.eclipse
.linuxtools
.lttng
.core
.tests
.headless
;
2 /*******************************************************************************
3 * Copyright (c) 2009 Ericsson
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
11 * William Bourque (wbourque@gmail.com) - Initial API and implementation
12 *******************************************************************************/
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
;
22 @SuppressWarnings("nls")
23 public class JniTraceTest
{
25 public static void main(String
[] args
) {
28 final String TRACE_PATH
= "/home/william/trace-614601events-nolost-newformat";
30 // *** Change this to run several time over the same trace
31 final int NB_OF_PASS
= 1;
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;
39 JniTrace tmptrace
= null;
40 JniEvent tmpevent
= null;
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
, null, false);
49 tmptrace
.seekToTime(new JniTime(0L));
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();
56 while ( tmpevent
!= null ) {
58 // Parse event if asked
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
);
65 // *** Uncomment the following to print the parsed content
66 // Warning : this is VERY intensive
67 //if ( pos == (tmpFields.size() -1) ) {
68 // tmptrace.printC(tmpevent.getEventPtr().getLibraryId(), tmpFields.get(pos).getField() + ":" + newValue + " ");
70 // tmptrace.printlnC(tmpevent.getEventPtr().getLibraryId(), tmpFields.get(pos).getField() + ":" + newValue + " ");
75 tmpevent
= tmptrace
.readNextEvent();
80 System
.out
.println("NB Events read : " + nbEvent
);
This page took 0.031598 seconds and 5 git commands to generate.