First set of standalone LTTng "applications". Useful for debug
authorWilliam Bourque <william.bourque@polymtl.ca>
Mon, 22 Mar 2010 17:16:37 +0000 (17:16 +0000)
committerWilliam Bourque <william.bourque@polymtl.ca>
Mon, 22 Mar 2010 17:16:37 +0000 (17:16 +0000)
org.eclipse.linuxtools.lttng.headless/.classpath [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/.project [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/.settings/org.eclipse.jdt.core.prefs [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/META-INF/MANIFEST.MF [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/build.properties [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/src/JniTraceTest.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/src/LttngTraceTest.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng.headless/src/TmfTraceTest.java [new file with mode: 0644]

diff --git a/org.eclipse.linuxtools.lttng.headless/.classpath b/org.eclipse.linuxtools.lttng.headless/.classpath
new file mode 100644 (file)
index 0000000..64c5e31
--- /dev/null
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<classpath>
+       <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/J2SE-1.5"/>
+       <classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/>
+       <classpathentry kind="src" path="src"/>
+       <classpathentry kind="output" path="bin"/>
+</classpath>
diff --git a/org.eclipse.linuxtools.lttng.headless/.project b/org.eclipse.linuxtools.lttng.headless/.project
new file mode 100644 (file)
index 0000000..c5c7240
--- /dev/null
@@ -0,0 +1,28 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<projectDescription>
+       <name>org.eclipse.linuxtools.lttng.headless</name>
+       <comment></comment>
+       <projects>
+       </projects>
+       <buildSpec>
+               <buildCommand>
+                       <name>org.eclipse.jdt.core.javabuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.ManifestBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+               <buildCommand>
+                       <name>org.eclipse.pde.SchemaBuilder</name>
+                       <arguments>
+                       </arguments>
+               </buildCommand>
+       </buildSpec>
+       <natures>
+               <nature>org.eclipse.pde.PluginNature</nature>
+               <nature>org.eclipse.jdt.core.javanature</nature>
+       </natures>
+</projectDescription>
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 (file)
index 0000000..6f7fc9a
--- /dev/null
@@ -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 (file)
index 0000000..02daf55
--- /dev/null
@@ -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 (file)
index 0000000..34d2e4d
--- /dev/null
@@ -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 (file)
index 0000000..575f7b2
--- /dev/null
@@ -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<NB_OF_PASS; x++ ){
+               tmpevent = tmptrace.readNextEvent();
+               nbEvent++;
+               
+               while ( tmpevent != null ) {
+                       
+                       // Parse event if asked
+                       if ( PARSE_EVENTS ) {
+                               ArrayList<JniMarkerField> tmpFields = tmpevent.getMarkersMap().get(tmpevent.getEventMarkerId()).getMarkerFieldsArrayList();
+                               for ( int pos=0; pos<tmpFields.size(); pos++ ) {
+                                   @SuppressWarnings("unused")
+                                                       Object newValue = tmpevent.parseFieldById(pos);
+                                   
+                                   // *** Uncomment the following to print the parsed content
+                                   // Warning : this is VERY intensive
+                                   //if ( pos == (tmpFields.size() -1) ) {
+                                   //  tracetest.printC(tmpFields.get(pos).getField() + ":" + newValue + " ");
+                                   //} else {
+                                   //  tracetest.printlnC(tmpFields.get(pos).getField() + ":" + newValue + " ");
+                                   //} 
+                               }
+                       }
+                    
+                       tmpevent = tmptrace.readNextEvent();
+                       nbEvent++;
+                   }
+            }
+            
+            System.out.println("NB Events read : " + nbEvent);
+        }
+        catch (Exception e) {
+            e.printStackTrace();
+        }
+    }
+
+}
diff --git a/org.eclipse.linuxtools.lttng.headless/src/LttngTraceTest.java b/org.eclipse.linuxtools.lttng.headless/src/LttngTraceTest.java
new file mode 100644 (file)
index 0000000..5b71399
--- /dev/null
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * 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 org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngLocation;
+import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.trace.LTTngTextTrace;
+import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
+import org.eclipse.linuxtools.tmf.trace.TmfContext;
+import org.eclipse.linuxtools.tmf.trace.TmfTrace;
+
+
+public class LttngTraceTest {
+
+       /**
+        * @param args
+        */
+       public static void main(String[] args) {
+               
+               // Path of the trace
+        final String TRACE_PATH = "/home/william/trace-614601events-nolost-newformat";
+               
+        // *** Change to true to use the "fake" LttngTextTrace instead of LTTngTrace
+        // To use this, you need a ".txt" trace. 
+        // You can get it using LTTv with the command "lttv -m textDump -t /tmp/sometrace > 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<LttngEvent> 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<NB_OF_PASS; nb++) {
+                           
+                               // Seek to the beginning of the trace
+                           tmpContext = tmptrace.seekEvent( tmpTime  );
+                               tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext);
+                               
+                               while ( tmpevent != null ) {
+                                       tmpevent = (LttngEvent)tmptrace.getNextEvent(tmpContext);
+                                       
+                                       // Parse the events if it was asked
+                                       if ( (tmpevent != null) && (PARSE_EVENTS) ) {
+                                               tmpevent.getContent().getFields();
+                                               
+                                               // *** Uncomment the following to print the parsed content
+                           // Warning : this is VERY intensive
+                                               //
+                                               //System.out.println(testEvent.toString());
+                                               //System.out.println(testEvent.getContent().toString());
+                                       }
+                                       
+                                       nbEvent++;
+                               }
+                       }
+                       
+                       System.out.println("NB events : " + nbEvent);
+                       
+               }
+               catch (Exception e) {
+                       e.printStackTrace();
+               }
+
+       }
+
+}
diff --git a/org.eclipse.linuxtools.lttng.headless/src/TmfTraceTest.java b/org.eclipse.linuxtools.lttng.headless/src/TmfTraceTest.java
new file mode 100644 (file)
index 0000000..32b99ff
--- /dev/null
@@ -0,0 +1,128 @@
+/*******************************************************************************
+ * 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 org.eclipse.linuxtools.lttng.event.LttngEvent;
+import org.eclipse.linuxtools.lttng.event.LttngTimestamp;
+import org.eclipse.linuxtools.lttng.trace.LTTngTrace;
+import org.eclipse.linuxtools.tmf.event.TmfEvent;
+import org.eclipse.linuxtools.tmf.event.TmfTimeRange;
+import org.eclipse.linuxtools.tmf.experiment.TmfExperiment;
+import org.eclipse.linuxtools.tmf.request.TmfEventRequest;
+import org.eclipse.linuxtools.tmf.trace.ITmfTrace;
+
+public class TmfTraceTest extends TmfEventRequest<LttngEvent> {
+    
+    @SuppressWarnings("unchecked")
+       public TmfTraceTest(Class<? extends TmfEvent> dataType, TmfTimeRange range, int nbRequested) {
+        super((Class<LttngEvent>)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<LttngEvent> 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>(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<NB_OF_PASS; x++ ) {
+                request = new TmfTraceTest(LttngEvent.class, tmpRange, Integer.MAX_VALUE );
+                       fExperiment.sendRequest(request);
+                       nbPassDone++;
+            }
+        }
+               catch (NullPointerException e) {
+                       // Silently dismiss Null pointer exception
+                       // The only way to "finish" the threads in TMF is by crashing them with null
+               }
+               catch (Exception e) {
+            e.printStackTrace();
+        }
+
+       }
+
+
+       @Override
+    public void handleData() {
+        TmfEvent[] result = getData();
+        TmfEvent[] evt = new TmfEvent[1];
+        
+        evt[0] = (result.length > 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() {
+    }
+
+}
This page took 0.030408 seconds and 5 git commands to generate.