From 9cb4892d832283591f19e1d59c01519f0e00ba13 Mon Sep 17 00:00:00 2001 From: William Bourque Date: Mon, 22 Mar 2010 17:16:37 +0000 Subject: [PATCH] First set of standalone LTTng "applications". Useful for debug --- .../.classpath | 7 + .../.project | 28 ++++ .../.settings/org.eclipse.jdt.core.prefs | 8 ++ .../META-INF/MANIFEST.MF | 9 ++ .../build.properties | 4 + .../src/JniTraceTest.java | 85 ++++++++++++ .../src/LttngTraceTest.java | 95 +++++++++++++ .../src/TmfTraceTest.java | 128 ++++++++++++++++++ 8 files changed, 364 insertions(+) create mode 100644 org.eclipse.linuxtools.lttng.headless/.classpath create mode 100644 org.eclipse.linuxtools.lttng.headless/.project create mode 100644 org.eclipse.linuxtools.lttng.headless/.settings/org.eclipse.jdt.core.prefs create mode 100644 org.eclipse.linuxtools.lttng.headless/META-INF/MANIFEST.MF create mode 100644 org.eclipse.linuxtools.lttng.headless/build.properties create mode 100644 org.eclipse.linuxtools.lttng.headless/src/JniTraceTest.java create mode 100644 org.eclipse.linuxtools.lttng.headless/src/LttngTraceTest.java create mode 100644 org.eclipse.linuxtools.lttng.headless/src/TmfTraceTest.java diff --git a/org.eclipse.linuxtools.lttng.headless/.classpath b/org.eclipse.linuxtools.lttng.headless/.classpath new file mode 100644 index 0000000000..64c5e31b7a --- /dev/null +++ b/org.eclipse.linuxtools.lttng.headless/.classpath @@ -0,0 +1,7 @@ + + + + + + + diff --git a/org.eclipse.linuxtools.lttng.headless/.project b/org.eclipse.linuxtools.lttng.headless/.project new file mode 100644 index 0000000000..c5c7240eec --- /dev/null +++ b/org.eclipse.linuxtools.lttng.headless/.project @@ -0,0 +1,28 @@ + + + org.eclipse.linuxtools.lttng.headless + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.pde.ManifestBuilder + + + + + org.eclipse.pde.SchemaBuilder + + + + + + org.eclipse.pde.PluginNature + org.eclipse.jdt.core.javanature + + diff --git a/org.eclipse.linuxtools.lttng.headless/.settings/org.eclipse.jdt.core.prefs b/org.eclipse.linuxtools.lttng.headless/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000000..6f7fc9aa37 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.headless/.settings/org.eclipse.jdt.core.prefs @@ -0,0 +1,8 @@ +#Mon Mar 22 12:32:38 EDT 2010 +eclipse.preferences.version=1 +org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled +org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.5 +org.eclipse.jdt.core.compiler.compliance=1.5 +org.eclipse.jdt.core.compiler.problem.assertIdentifier=error +org.eclipse.jdt.core.compiler.problem.enumIdentifier=error +org.eclipse.jdt.core.compiler.source=1.5 diff --git a/org.eclipse.linuxtools.lttng.headless/META-INF/MANIFEST.MF b/org.eclipse.linuxtools.lttng.headless/META-INF/MANIFEST.MF new file mode 100644 index 0000000000..02daf55301 --- /dev/null +++ b/org.eclipse.linuxtools.lttng.headless/META-INF/MANIFEST.MF @@ -0,0 +1,9 @@ +Manifest-Version: 1.0 +Bundle-ManifestVersion: 2 +Bundle-Name: Standalone LTTng application +Bundle-SymbolicName: org.eclipse.linuxtools.lttng.headless +Bundle-Version: 0.2.0.qualifier +Bundle-RequiredExecutionEnvironment: J2SE-1.5 +Require-Bundle: org.eclipse.linuxtools.lttng;bundle-version="0.2.0", + org.eclipse.linuxtools.lttng.jni;bundle-version="0.2.0", + org.eclipse.linuxtools.tmf;bundle-version="0.2.0" diff --git a/org.eclipse.linuxtools.lttng.headless/build.properties b/org.eclipse.linuxtools.lttng.headless/build.properties new file mode 100644 index 0000000000..34d2e4d2da --- /dev/null +++ b/org.eclipse.linuxtools.lttng.headless/build.properties @@ -0,0 +1,4 @@ +source.. = src/ +output.. = bin/ +bin.includes = META-INF/,\ + . diff --git a/org.eclipse.linuxtools.lttng.headless/src/JniTraceTest.java b/org.eclipse.linuxtools.lttng.headless/src/JniTraceTest.java new file mode 100644 index 0000000000..575f7b2b6e --- /dev/null +++ b/org.eclipse.linuxtools.lttng.headless/src/JniTraceTest.java @@ -0,0 +1,85 @@ +/******************************************************************************* + * Copyright (c) 2009 Ericsson + * + * All rights reserved. This program and the accompanying materials are + * made available under the terms of the Eclipse Public License v1.0 which + * accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * William Bourque (wbourque@gmail.com) - Initial API and implementation + *******************************************************************************/ + +import java.util.ArrayList; +import org.eclipse.linuxtools.lttng.jni.JniEvent; +import org.eclipse.linuxtools.lttng.jni.JniMarkerField; +import org.eclipse.linuxtools.lttng.jni.JniTrace; +import org.eclipse.linuxtools.lttng.jni.common.JniTime; +import org.eclipse.linuxtools.lttng.jni.factory.JniTraceFactory; + + +public class JniTraceTest { + + public static void main(String[] args) { + + // Path of the trace + final String TRACE_PATH = "/home/william/trace-614601events-nolost-newformat"; + + // *** Change this to run several time over the same trace + final int NB_OF_PASS = 1; + + // *** Change this to true to parse all the events in the trace + // Otherwise, events are just read + final boolean PARSE_EVENTS = true; + + + // Work variables + JniTrace tmptrace = null; + JniEvent tmpevent = null; + Long nbEvent = 0L; + + try { + // Get the trace from the Factory... + // This assume the path is correct and that the correct version of the lib is installed + tmptrace = JniTraceFactory.getJniTrace(TRACE_PATH, false); + + // Seek beginning + tmptrace.seekToTime(new JniTime(0L)); + + // Run up to "NB_OF_PASS" on the same trace + for (int x=0; x tmpFields = tmpevent.getMarkersMap().get(tmpevent.getEventMarkerId()).getMarkerFieldsArrayList(); + for ( int pos=0; pos mytrace.txt" + final boolean USE_TEXT_TRACE = false; + + // *** Change this to run several time over the same trace + final int NB_OF_PASS = 1; + + // *** Change this to true to parse all the events in the trace + // Otherwise, events are just read + final boolean PARSE_EVENTS = true; + + + // Work variables + TmfTrace tmptrace = null; + LttngEvent tmpevent = null; + TmfContext tmpContext = null; + Long nbEvent = 0L; + + try { + // ** Use TextTrace (slow!) if it was asked + if ( USE_TEXT_TRACE ) { + tmptrace = new LTTngTextTrace(TRACE_PATH, true); + } else { + tmptrace = new LTTngTrace(TRACE_PATH, true, true); + } + + LttngTimestamp tmpTime = new LttngTimestamp(0L); + tmpContext = new TmfContext(new LttngLocation(0L), 0); + + for ( int nb=0; nb { + + @SuppressWarnings("unchecked") + public TmfTraceTest(Class dataType, TmfTimeRange range, int nbRequested) { + super((Class)dataType, range, nbRequested, 1); + } + + + // Path of the trace + public static final String TRACE_PATH = "/home/william/trace-614601events-nolost-newformat"; + + // *** Change this to run several time over the same trace + public static final int NB_OF_PASS = 1; + + // *** Change this to true to parse all the events in the trace + // Otherwise, events are just read + public final boolean PARSE_EVENTS = true; + + + // Work variables + public static int nbEvent = 0; + public static int nbPassDone = 0; + public static TmfExperiment fExperiment = null; + + + public static void main(String[] args) { + + try { + // OUr experiment will contains ONE trace + ITmfTrace[] traces = new ITmfTrace[1]; + traces[0] = new LTTngTrace(TRACE_PATH); + // Create our new experiment + fExperiment = new TmfExperiment(LttngEvent.class, "Headless", traces); + + + // Create a new time range from -infinity to +infinity + // That way, we will get "everything" in the trace + LttngTimestamp ts1 = new LttngTimestamp(Long.MIN_VALUE); + LttngTimestamp ts2 = new LttngTimestamp(Long.MAX_VALUE); + TmfTimeRange tmpRange = new TmfTimeRange(ts1, ts2); + + + // We will issue a request for each "pass". + // TMF will then process them synchonously + TmfTraceTest request = null; + for ( int x=0; x 0) ? result[0] : null; + + if ( (evt[0] != null) && (PARSE_EVENTS) ) { + ((LttngEvent)evt[0]).getContent().getFields(); + + // *** Uncomment the following to print the parsed content + // Warning : this is VERY intensive + // + //System.out.println((LttngEvent)evt[0]); + //System.out.println(((LttngEvent)evt[0]).getContent()); + + nbEvent++; + } + } + + @Override + public void handleCompleted() { + if ( nbPassDone >= NB_OF_PASS ) { + try { + System.out.println("Nb events : " + nbEvent); + + fExperiment.sendRequest(null); + } + catch (Exception e) {} + } + } + + @Override + public void handleSuccess() { + } + + @Override + public void handleFailure() { + } + + @Override + public void handleCancel() { + } + +} -- 2.34.1