Add support for filter feature of LTTng Tools 2.1
authorBernd Hufmann <bhufmann@gmail.com>
Fri, 21 Dec 2012 18:45:28 +0000 (13:45 -0500)
committerMatthew Khouzam <matthew.khouzam@ericsson.com>
Fri, 11 Jan 2013 16:29:45 +0000 (11:29 -0500)
- Retrieve filter information from target
- Display filter information in Properties View
- Add support for filter configuration for enable-events (UST)
- Display UST event fields in Properties View
- Update JUnit tests

Change-Id: Ibd341bb51059d60027ff9f2722ff15e4d275e9cf
Signed-off-by: Bernd Hufmann <bhufmann@gmail.com>
Reviewed-on: https://git.eclipse.org/r/9362
Tested-by: Hudson CI
IP-Clean: Matthew Khouzam <matthew.khouzam@ericsson.com>
Tested-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
Reviewed-by: Matthew Khouzam <matthew.khouzam@ericsson.com>
39 files changed:
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/AllTests.java
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/BaseEventInfoTest.java
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/ModelImplFactory.java
org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/UstProviderInfoTest.java
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/IBaseEventInfo.java
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/IFieldInfo.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/BaseEventInfo.java
org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/FieldInfo.java [new file with mode: 0644]
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/model/component/TraceControlPropertiesTest.java
org.eclipse.linuxtools.lttng2.ui.tests/src/org/eclipse/linuxtools/lttng2/ui/tests/control/service/LTTngControlServiceTest.java
org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/EnableEventsDialogStub.java
org.eclipse.linuxtools.lttng2.ui.tests/stubs/org/eclipse/linuxtools/internal/lttng2/stubs/dialogs/GetEventInfoDialogStub.java
org.eclipse.linuxtools.lttng2.ui.tests/testfiles/LTTngServiceTest.cfg
org.eclipse.linuxtools.lttng2.ui.tests/testfiles/ListInfoTest.cfg
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableEventsDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/EnableUstEventsComposite.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/GetEventInfoDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/IEnableUstEvents.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/dialogs/IGetEventInfoDialog.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/AssignEventHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/BaseEnableEventHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableEventOnChannelHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableEventOnDomainHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/handlers/EnableEventOnSessionHandler.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/Messages.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/messages/messages.properties
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/BaseEventComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TargetNodeComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceChannelComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceDomainComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceEventComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceProviderGroup.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/model/impl/TraceSessionComponent.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/BaseEventPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/property/TraceEventPropertySource.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/ILttngControlService.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlService.java
org.eclipse.linuxtools.lttng2.ui/src/org/eclipse/linuxtools/internal/lttng2/ui/views/control/service/LTTngControlServiceConstants.java

index 6fa43af6ba2bb59a62ad2ac1455b123c45950b4f..e502b828582a12177fda42524ab38fb6d9680d7f 100644 (file)
@@ -21,6 +21,7 @@ public class AllTests {
 
         TestSuite suite = new TestSuite(AllTests.class.getName());
         //$JUnit-BEGIN$
+        suite.addTestSuite(FieldInfoTest.class);
         suite.addTestSuite(BaseEventInfoTest.class);
         suite.addTestSuite(DomainInfoTest.class);
         suite.addTestSuite(EventInfoTest.class);
index b8520aec02f767447ab91ec161f67bba680fbcde..352a8ffab1c4c0d1a78c3b1d5cc476547d73e595 100644 (file)
  **********************************************************************/
 package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl;
 
+import java.util.LinkedList;
+import java.util.List;
+
 import junit.framework.TestCase;
 
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
 
 /**
  * The class <code>BaseEventInfoTest</code> contains test for the class <code>{@link BaseEventInfo}</code>.
@@ -93,6 +98,15 @@ public class BaseEventInfoTest extends TestCase {
         assertEquals(fEventInfo1.getName(), info.getName());
         assertEquals(fEventInfo1.getEventType(), info.getEventType());
         assertEquals(fEventInfo1.getLogLevel(), info.getLogLevel());
+        assertEquals(fEventInfo1.getFilterExpression(), info.getFilterExpression());
+
+        IFieldInfo[] orignalFields = fEventInfo1.getFields();
+        IFieldInfo[] copiedFields = info.getFields();
+        assertEquals(orignalFields.length, copiedFields.length);
+
+        for (int i = 0; i < copiedFields.length; i++) {
+            assertEquals(orignalFields[i], copiedFields[i]);
+        }
     }
 
     /**
@@ -391,6 +405,64 @@ public class BaseEventInfoTest extends TestCase {
         assertEquals(14, result.ordinal());
     }
 
+    /**
+     * test filter expression
+     */
+     public void testSetFields() {
+         BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
+         info.setFilterExpression("stringfield==test");
+         assertEquals("stringfield==test", info.getFilterExpression());
+     }
+
+
+   /**
+    * test add field
+    */
+    public void testAddField() {
+        BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
+
+        IFieldInfo field =  new FieldInfo("intfield");
+        field.setFieldType("int");
+
+        info.addField(field);
+
+        // Verify the stored events
+        IFieldInfo[] result = info.getFields();
+
+        assertNotNull(result);
+        assertEquals(1, result.length);
+        assertNotNull(result[0]);
+        assertTrue(field.equals(result[0]));
+    }
+
+    /**
+     * test set fields
+     */
+    public void testFields() {
+        BaseEventInfo info = new BaseEventInfo((BaseEventInfo)fEventInfo2);
+
+        IFieldInfo field1 =  new FieldInfo("intfield");
+        field1.setFieldType("int");
+
+        IFieldInfo field2 =  new FieldInfo("stringfield");
+        field2.setFieldType("string");
+
+        List<IFieldInfo> fields = new LinkedList<IFieldInfo>();
+        fields.add(field1);
+        fields.add(field2);
+        info.setFields(fields);
+
+        // Verify the stored events
+        IFieldInfo[] result = info.getFields();
+
+        assertNotNull(result);
+        assertEquals(2, result.length);
+
+        for (int i = 0; i < result.length; i++) {
+            assertNotNull(result[i]);
+            assertTrue(fields.get(i).equals(result[i]));
+        }
+    }
 
     /**
      * Run the String toString() method test.
diff --git a/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java b/org.eclipse.linuxtools.lttng2.core.tests/src/org/eclipse/linuxtools/lttng2/core/tests/control/model/impl/FieldInfoTest.java
new file mode 100644 (file)
index 0000000..9e391b2
--- /dev/null
@@ -0,0 +1,170 @@
+/**********************************************************************
+ * Copyright (c) 2012 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:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.lttng2.core.tests.control.model.impl;
+
+import junit.framework.TestCase;
+
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
+
+/**
+ * The class <code>FieldInfoTest</code> contains test for the class <code>{@link FieldInfo}</code>.
+ */
+@SuppressWarnings({"nls", "javadoc"})
+public class FieldInfoTest extends TestCase {
+
+    // ------------------------------------------------------------------------
+    // Test data
+    // ------------------------------------------------------------------------
+    private IFieldInfo fFieldInfo1 = null;
+    private IFieldInfo fFieldInfo2 = null;
+
+    // ------------------------------------------------------------------------
+    // Housekeeping
+    // ------------------------------------------------------------------------
+    /**
+     * Perform pre-test initialization.
+     *
+     * @throws Exception if the initialization fails for some reason
+     *
+     */
+    @Override
+    public void setUp() throws Exception {
+        super.setUp();
+        ModelImplFactory factory = new ModelImplFactory();
+        fFieldInfo1 = factory.getFieldInfo1();
+        fFieldInfo2 = factory.getFieldInfo2();
+    }
+
+    /**
+     * Perform post-test clean-up.
+     *
+     * @throws Exception if the clean-up fails for some reason
+     *
+     */
+    @Override
+    public void tearDown() throws Exception {
+    }
+
+    // ------------------------------------------------------------------------
+    // Tests
+    // ------------------------------------------------------------------------
+
+    /**
+     * Run the BaseEventInfo() constructor test.
+     *
+     */
+    public void testFiledInfo() {
+        FieldInfo fixture = new FieldInfo("field");
+        assertNotNull(fixture);
+
+        assertEquals("field", fixture.getName());
+        assertNull(fixture.getFieldType());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    public void testEventInfoCopy() {
+        FieldInfo info = new FieldInfo((FieldInfo)fFieldInfo1);
+
+        assertEquals(fFieldInfo1.getName(), info.getName());
+        assertEquals(fFieldInfo1.getFieldType(), info.getFieldType());
+    }
+
+    /**
+     * Test Copy Constructor
+     */
+    public void testEventCopy2() {
+        try {
+            FieldInfo info = null;
+            new FieldInfo(info);
+            fail("null copy");
+        }
+        catch (IllegalArgumentException e) {
+            // Success
+        }
+    }
+
+    /**
+     * Run the TraceEventType getEventType() method test.
+     *
+     * @throws Exception
+     *
+     */
+    public void testSetFieldType() {
+        FieldInfo info = new FieldInfo((FieldInfo)fFieldInfo1);
+
+        info.setFieldType("string");
+        assertEquals("string", info.getFieldType());
+    }
+
+    public void testToString() {
+        String result = fFieldInfo1.toString();
+
+        // add additional test code here
+        assertEquals("[FieldInfo([TraceInfo(Name=intfield)],type=int", result);
+    }
+
+    // ------------------------------------------------------------------------
+    // equals
+    // ------------------------------------------------------------------------
+
+    public void testEqualsReflexivity() {
+        assertTrue("equals", fFieldInfo1.equals(fFieldInfo1));
+        assertTrue("equals", fFieldInfo2.equals(fFieldInfo2));
+
+        assertTrue("equals", !fFieldInfo1.equals(fFieldInfo2));
+        assertTrue("equals", !fFieldInfo2.equals(fFieldInfo1));
+    }
+
+    public void testEqualsSymmetry() {
+        FieldInfo info1 = new FieldInfo((FieldInfo)fFieldInfo1);
+        FieldInfo info2 = new FieldInfo((FieldInfo)fFieldInfo2);
+
+        assertTrue("equals", info1.equals(fFieldInfo1));
+        assertTrue("equals", fFieldInfo1.equals(info1));
+
+        assertTrue("equals", info2.equals(fFieldInfo2));
+        assertTrue("equals", fFieldInfo2.equals(info2));
+    }
+
+    public void testEqualsTransivity() {
+        FieldInfo info1 = new FieldInfo((FieldInfo)fFieldInfo1);
+        FieldInfo info2 = new FieldInfo((FieldInfo)fFieldInfo1);
+        FieldInfo info3 = new FieldInfo((FieldInfo)fFieldInfo1);
+
+        assertTrue("equals", info1.equals(info2));
+        assertTrue("equals", info2.equals(info3));
+        assertTrue("equals", info1.equals(info3));
+    }
+
+    public void testEqualsNull() {
+        assertTrue("equals", !fFieldInfo1.equals(null));
+        assertTrue("equals", !fFieldInfo2.equals(null));
+    }
+
+    // ------------------------------------------------------------------------
+    // hashCode
+    // ------------------------------------------------------------------------
+
+    public void testHashCode() {
+        FieldInfo info1 = new FieldInfo((FieldInfo)fFieldInfo1);
+        FieldInfo info2 = new FieldInfo((FieldInfo)fFieldInfo2);
+
+        assertTrue("hashCode", fFieldInfo1.hashCode() == info1.hashCode());
+        assertTrue("hashCode", fFieldInfo2.hashCode() == info2.hashCode());
+
+        assertTrue("hashCode", fFieldInfo1.hashCode() != info2.hashCode());
+        assertTrue("hashCode", fFieldInfo2.hashCode() != info1.hashCode());
+    }
+}
\ No newline at end of file
index fa92c7c051efe4cdb5b5c25250c20072f435b917..5f8babb9a59dc8423b5ac0407262e7bd2a64a0ab 100644 (file)
@@ -15,6 +15,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
@@ -26,6 +27,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventI
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo;
@@ -45,6 +47,8 @@ public class ModelImplFactory {
     private IEventInfo fEventInfo1 = null;
     private IEventInfo fEventInfo2 = null;
     private IEventInfo fEventInfo3 = null;
+    private IFieldInfo fFieldInfo1 = null;
+    private IFieldInfo fFieldInfo2 = null;
     private IBaseEventInfo fBaseEventInfo1 = null;
     private IBaseEventInfo fBaseEventInfo2 = null;
     private IUstProviderInfo fUstProviderInfo1 = null;
@@ -53,9 +57,19 @@ public class ModelImplFactory {
     private IProbeEventInfo fProbeEventInfo2 = null;
 
     public ModelImplFactory() {
+
+        fFieldInfo1 = new FieldInfo("intfield");
+        fFieldInfo1.setFieldType("int");
+        fFieldInfo2 = new FieldInfo("stringfield");
+        fFieldInfo2.setFieldType("string");
+
         fBaseEventInfo1 = new BaseEventInfo("event1");
         fBaseEventInfo1.setEventType(TraceEventType.UNKNOWN);
         fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_ERR);
+        fBaseEventInfo1.addField(fFieldInfo1);
+        fBaseEventInfo1.addField(fFieldInfo2);
+        fBaseEventInfo1.setFilterExpression("intField==10");
+
         fBaseEventInfo2 = new BaseEventInfo("event2");
         fBaseEventInfo2.setEventType(TraceEventType.TRACEPOINT);
         fBaseEventInfo1.setLogLevel(TraceLogLevel.TRACE_DEBUG);
@@ -192,4 +206,11 @@ public class ModelImplFactory {
         return fProbeEventInfo2;
     }
 
+    public IFieldInfo getFieldInfo1() {
+        return fFieldInfo1;
+    }
+
+    public IFieldInfo getFieldInfo2() {
+        return fFieldInfo2;
+    }
 }
index 9cec2bf8a27285cee390d49e38f4dcf303f487a9..de0facfaf2bc32f148c81811544f163948b9d1c2 100644 (file)
@@ -171,7 +171,10 @@ public class UstProviderInfoTest extends TestCase {
      */
     public void testToString_2() {
         String result = fUstProviderInfo2.toString();
-        assertEquals("[EventInfo([TraceInfo(Name=myUST2)],PID=2345,Events=[BaseEventInfo([TraceInfo(Name=event1)],type=UNKNOWN,level=TRACE_DEBUG)][BaseEventInfo([TraceInfo(Name=event2)],type=TRACEPOINT,level=TRACE_DEBUG)])]", result);
+        assertEquals("[EventInfo([TraceInfo(Name=myUST2)],PID=2345,Events=[BaseEventInfo([TraceInfo(Name=event1)]," +
+                       "type=UNKNOWN,level=TRACE_DEBUG,Fields=[FieldInfo([TraceInfo(Name=intfield)],type=int[FieldInfo" +
+                       "([TraceInfo(Name=stringfield)],type=string,Filter=intField==10)][BaseEventInfo([TraceInfo(Name=event2)]," +
+                       "type=TRACEPOINT,level=TRACE_DEBUG)])]", result);
     }
 
     // ------------------------------------------------------------------------
index d7aac5a449475597866db74e268b786731379ae6..cfca86ab932c0d4cf9d1eb56dcb41e73065357cd 100644 (file)
@@ -1,21 +1,23 @@
 /**********************************************************************
  * Copyright (c) 2012 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: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.core.control.model;
 
+import java.util.List;
+
 /**
  * <p>
  * Interface for retrieval of basic trace event information.
  * </p>
- * 
+ *
  * @author Bernd Hufmann
  */
 public interface IBaseEventInfo extends ITraceInfo {
@@ -24,35 +26,63 @@ public interface IBaseEventInfo extends ITraceInfo {
      * @return the trace event type
      */
     public TraceEventType getEventType();
-    
+
     /**
-     * Sets the trace event type to the given type 
+     * Sets the trace event type to the given type
      * @param type - type to set
      */
     public void setEventType(TraceEventType type);
-    
+
     /**
      * Sets the trace event type to the type specified by the given name.
      * @param typeName - event type name
      */
     public void setEventType(String typeName);
-    
+
     /**
      * @return the trace event log level
      */
     public TraceLogLevel getLogLevel();
-    
+
     /**
-     * Sets the trace event log level to the given level 
+     * Sets the trace event log level to the given level
      * @param level - event log level to set
      */
     public void setLogLevel(TraceLogLevel level);
-    
+
     /**
      * Sets the trace event log level to the level specified by the given name.
      * @param levelName - event log level name
      */
     public void setLogLevel(String levelName);
 
-    
+    /**
+     * Returns the field information (if exists)
+     * @return the field information or null
+     */
+    public IFieldInfo[] getFields();
+
+    /**
+     * @param field The field to add
+     */
+    public void addField(IFieldInfo field);
+
+    /**
+     * Sets the fields
+     * @param fields The fields
+     */
+    public void setFields(List<IFieldInfo> fields);
+
+    /**
+     * Returns filter expression.
+     * @return filter expression
+     */
+    public String getFilterExpression();
+
+    /**
+     * Sets the filter expression.
+     * @param filter The filter expression to set
+     */
+    public void setFilterExpression(String filter);
+
 }
diff --git a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/IFieldInfo.java b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/IFieldInfo.java
new file mode 100644 (file)
index 0000000..f4a13e9
--- /dev/null
@@ -0,0 +1,34 @@
+/**********************************************************************
+ * Copyright (c) 2012 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:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.core.control.model;
+
+/**
+ * <p>
+ * Interface for retrieval of event field information.
+ * </p>
+ *
+ * @author Bernd Hufmann
+ */
+public interface IFieldInfo extends ITraceInfo {
+
+    /**
+     * @return the event field type
+     */
+    public String getFieldType();
+
+    /**
+     * Sets field type string
+     *
+     * @param fieldType - sting of event field type
+     */
+    public void setFieldType(String fieldType);
+}
index 642cce68c1c0aef9fbf6c950526bb3df88f3939f..9ad619b5011f70020f1ac27a3b85c030aceb7dd6 100644 (file)
@@ -1,26 +1,31 @@
 /**********************************************************************
  * Copyright (c) 2012 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: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
 
+import java.util.ArrayList;
+import java.util.Iterator;
+import java.util.List;
+
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 
 /**
 * <p>
 * Implementation of the basic trace event interface (IEventInfo) to store event
-* related data. 
+* related data.
 * </p>
-* 
+*
 * @author Bernd Hufmann
 */
 public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
@@ -36,7 +41,15 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
      * The trace log level.
      */
     private TraceLogLevel fLogLevel = TraceLogLevel.TRACE_DEBUG;
-  
+    /**
+     * The Event fields
+     */
+    private final List<IFieldInfo> fFields = new ArrayList<IFieldInfo>();
+    /**
+     * The filter expression.
+     */
+    private String fFilterExpression;
+
     // ------------------------------------------------------------------------
     // Constructors
     // ------------------------------------------------------------------------
@@ -55,6 +68,17 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
     public BaseEventInfo(BaseEventInfo other) {
         super(other);
         fEventType = other.fEventType;
+        if(other.fFields != null) {
+            for (Iterator<IFieldInfo> iterator = other.fFields.iterator(); iterator.hasNext();) {
+                IFieldInfo field = iterator.next();
+                if (field instanceof FieldInfo) {
+                    fFields.add(new FieldInfo((FieldInfo)field));
+                } else {
+                    fFields.add(field);
+                }
+            }
+        }
+        fFilterExpression = other.fFilterExpression;
     }
 
     // ------------------------------------------------------------------------
@@ -89,7 +113,7 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
         } else if(TraceEventType.SYSCALL.getInName().equals(typeName)) {
             fEventType = TraceEventType.SYSCALL;
         } else if (TraceEventType.PROBE.getInName().equals(typeName)) {
-            fEventType = TraceEventType.PROBE;  
+            fEventType = TraceEventType.PROBE;
         } else {
             fEventType = TraceEventType.UNKNOWN;
         }
@@ -155,23 +179,74 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
             fLogLevel = TraceLogLevel.TRACE_DEBUG;
         }
     }
-    
+
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#hashCode()
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo#getFields()
+     */
+    @Override
+    public IFieldInfo[] getFields() {
+        return fFields.toArray(new IFieldInfo[fFields.size()]);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo#addField(org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo)
+     */
+    @Override
+    public void addField(IFieldInfo field) {
+        fFields.add(field);
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo#setFields(java.util.List)
+     */
+    @Override
+    public void setFields(List<IFieldInfo> fields) {
+        for (Iterator<IFieldInfo> iterator = fields.iterator(); iterator.hasNext();) {
+            IFieldInfo fieldInfo = iterator.next();
+            fFields.add(fieldInfo);
+        }
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo#getFilterExpression()
+     */
+    @Override
+    public String getFilterExpression() {
+        return fFilterExpression;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo#setFilterExpression(java.lang.String)
+     */
+    @Override
+    public void setFilterExpression(String filter) {
+        fFilterExpression = filter;
+    }
+
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#hashCode()
      */
     @Override
     public int hashCode() {
         final int prime = 31;
         int result = super.hashCode();
-        result = prime * result + ((fEventType == null) ? 0 : (fEventType.ordinal() + 1));
-        result = prime * result + ((fLogLevel == null) ? 0 : (fLogLevel.ordinal() + 1));
+        result = prime * result + ((fEventType == null) ? 0 : fEventType.hashCode());
+        result = prime * result + ((fFields == null) ? 0 : fFields.hashCode());
+        result = prime * result + ((fFilterExpression == null) ? 0 : fFilterExpression.hashCode());
+        result = prime * result + ((fLogLevel == null) ? 0 : fLogLevel.hashCode());
         return result;
-    }    
+    }
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#equals(java.lang.Object)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#equals(java.lang.Object)
      */
     @Override
     public boolean equals(Object obj) {
@@ -188,11 +263,25 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
         if (fEventType != other.fEventType) {
             return false;
         }
+        if (fFields == null) {
+            if (other.fFields != null) {
+                return false;
+            }
+        } else if (!fFields.equals(other.fFields)) {
+            return false;
+        }
+        if (fFilterExpression == null) {
+            if (other.fFilterExpression != null) {
+                return false;
+            }
+        } else if (!fFilterExpression.equals(other.fFilterExpression)) {
+            return false;
+        }
         if (fLogLevel != other.fLogLevel) {
             return false;
         }
         return true;
-    }    
+    }
 
     /*
      * (non-Javadoc)
@@ -208,11 +297,18 @@ public class BaseEventInfo extends TraceInfo implements IBaseEventInfo {
             output.append(fEventType);
             output.append(",level=");
             output.append(fLogLevel);
+            if ((fFields != null) && (!fFields.isEmpty())) {
+                output.append(",Fields=");
+                for (Iterator<IFieldInfo> iterator = fFields.iterator(); iterator.hasNext();) {
+                    IFieldInfo field = iterator.next();
+                    output.append(field.toString());
+                }
+            }
+            if (fFilterExpression != null) {
+                output.append(",Filter=");
+                output.append(fFilterExpression);
+            }
             output.append(")]");
             return output.toString();
     }
-
-
-
 }
\ No newline at end of file
diff --git a/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/FieldInfo.java b/org.eclipse.linuxtools.lttng2.core/src/org/eclipse/linuxtools/internal/lttng2/core/control/model/impl/FieldInfo.java
new file mode 100644 (file)
index 0000000..c9b031c
--- /dev/null
@@ -0,0 +1,129 @@
+/**********************************************************************
+ * Copyright (c) 2012 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:
+ *   Bernd Hufmann - Initial API and implementation
+ **********************************************************************/
+package org.eclipse.linuxtools.internal.lttng2.core.control.model.impl;
+
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
+
+/**
+* <p>
+* Implementation of the basic trace event interface (IEventInfo) to store event
+* related data.
+* </p>
+*
+* @author Bernd Hufmann
+*/
+public class FieldInfo extends TraceInfo implements IFieldInfo {
+
+    // ------------------------------------------------------------------------
+    // Attributes
+    // ------------------------------------------------------------------------
+    /**
+     * The trace event type.
+     */
+    private String fFieldType;
+
+    // ------------------------------------------------------------------------
+    // Constructors
+    // ------------------------------------------------------------------------
+    /**
+     * Constructor
+     * @param name - name of base event
+     */
+    public FieldInfo(String name) {
+        super(name);
+    }
+
+    /**
+     * Copy constructor
+     * @param other - the instance to copy
+     */
+    public FieldInfo(FieldInfo other) {
+        super(other);
+        fFieldType = other.fFieldType;
+    }
+
+    // ------------------------------------------------------------------------
+    // Accessors
+    // ------------------------------------------------------------------------
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo#getFieldType()
+     */
+    @Override
+    public String getFieldType() {
+        return fFieldType;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo#setFieldType(java.lang.String)
+     */
+    @Override
+    public void setFieldType(String fieldType) {
+        fFieldType = fieldType;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#hashCode()
+     */
+    @Override
+    public int hashCode() {
+        final int prime = 31;
+        int result = super.hashCode();
+        result = prime * result
+                + ((fFieldType == null) ? 0 : fFieldType.hashCode());
+        return result;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.TraceInfo#equals(java.lang.Object)
+     */
+    @Override
+    public boolean equals(Object obj) {
+        if (this == obj) {
+            return true;
+        }
+        if (!super.equals(obj)) {
+            return false;
+        }
+        if (getClass() != obj.getClass()) {
+            return false;
+        }
+        FieldInfo other = (FieldInfo) obj;
+        if (fFieldType == null) {
+            if (other.fFieldType != null) {
+                return false;
+            }
+        } else if (!fFieldType.equals(other.fFieldType)) {
+            return false;
+        }
+        return true;
+    }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceInfo#toString()
+     */
+    @SuppressWarnings("nls")
+    @Override
+    public String toString() {
+        StringBuffer output = new StringBuffer();
+            output.append("[FieldInfo(");
+            output.append(super.toString());
+            output.append(",type=");
+            output.append(fFieldType);
+            return output.toString();
+    }
+}
\ No newline at end of file
index 3b9f876c2c725b4816a125fc1f6439468d4384b9..4d2dc7ab37cf512ea953d13af93f3a5bdd0cf94e 100644 (file)
@@ -160,7 +160,7 @@ public class TraceControlPropertiesTest extends TestCase {
         assertEquals("myNode", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_NAME_PROPERTY_ID));
         assertEquals("LOCALHOST",  source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_ADDRESS_PROPERTY_ID));
         assertEquals(TargetNodeState.CONNECTED.name(), source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_STATE_PROPERTY_ID));
-        assertEquals("2.0.0", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_VERSION_PROPERTY_ID));
+        assertEquals("2.1.0", source.getPropertyValue(TargetNodePropertySource.TARGET_NODE_VERSION_PROPERTY_ID));
         assertNull(source.getPropertyValue("test"));
 
         adapter = node.getAdapter(IChannelInfo.class);
@@ -225,6 +225,16 @@ public class TraceControlPropertiesTest extends TestCase {
         assertEquals(TraceEventType.TRACEPOINT.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_TYPE_PROPERTY_ID));
         assertEquals(TraceLogLevel.TRACE_DEBUG_MODULE.name(), baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_LOGLEVEL_PROPERTY_ID));
 
+        baseEventInfo = (BaseEventComponent) events[1];
+        assertNotNull(baseEventInfo);
+
+        adapter = baseEventInfo.getAdapter(IPropertySource.class);
+        assertNotNull(adapter);
+        assertTrue(adapter instanceof BaseEventPropertySource);
+        baseSource = (BaseEventPropertySource)adapter;
+        assertNotNull(baseSource.getPropertyDescriptors());
+        assertEquals("doublefield=float;floatfield=float;stringfield=string", baseSource.getPropertyValue(BaseEventPropertySource.BASE_EVENT_FIELDS_PROPERTY_ID));
+
         // ------------------------------------------------------------------------
         // Verify Session Properties (adapter)
         // ------------------------------------------------------------------------
@@ -348,6 +358,13 @@ public class TraceControlPropertiesTest extends TestCase {
         assertEquals("0x0", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_OFFSET_PROPERTY_ID));
         assertEquals("init_post", probeEventSource.getPropertyValue(TraceProbeEventPropertySource.TRACE_EVENT_PROBE_SYMBOL_PROPERTY_ID));
 
+        //-------------------------------------------------------------------------
+        // Verify Filter of UST event
+        //-------------------------------------------------------------------------
+        event = (TraceEventComponent) domains[1].getChildren()[1].getChildren()[0];
+        adapter = event.getAdapter(IPropertySource.class);
+        assertEquals("with filter", event.getFilterExpression());
+
         //-------------------------------------------------------------------------
         // Delete node
         //-------------------------------------------------------------------------
index 4bce2d1eb9cef1bf23214d582747155e0431e6d8..167dd7ef7f1ee853a2a0d4cfba5e9a34acaf66d7 100644 (file)
@@ -28,6 +28,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType;
@@ -66,6 +67,7 @@ public class LTTngControlServiceTest extends TestCase {
     private static final String SCEN_LIST_WITH_NO_KERNEL2 = "ListWithNoKernel2";
     private static final String SCEN_GET_UST_PROVIDER1 = "GetUstProvider1";
     private static final String SCEN_GET_UST_PROVIDER2 = "GetUstProvider2";
+    private static final String SCEN_GET_UST_PROVIDER3 = "GetUstProvider3";
     private static final String SCEN_CREATE_SESSION1 = "CreateSession1";
     private static final String SCEN_CREATE_SESSION_WITH_PROMPT = "CreateSessionWithPrompt";
     private static final String SCEN_CREATE_SESSION_VARIANTS = "CreateSessionVariants";
@@ -473,6 +475,82 @@ public class LTTngControlServiceTest extends TestCase {
         }
     }
 
+    public void testGetUstProvider3() {
+        try {
+            fShell.setScenario(SCEN_GET_UST_PROVIDER3);
+            // Set version
+            ((LTTngControlService)fService).setVersion("2.1.0");
+            List<IUstProviderInfo> providers = fService.getUstProvider();
+
+            // Check all providers
+            assertNotNull(providers);
+            assertEquals(2, providers.size());
+
+            //Verify first provider
+            assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(0).getName());
+            assertEquals(9379, providers.get(0).getPid());
+
+            // Verify event info
+            IBaseEventInfo[] events = providers.get(0).getEvents();
+            assertNotNull(events);
+            assertEquals(2, events.length);
+
+            IBaseEventInfo baseEventInfo = events[0];
+            assertNotNull(baseEventInfo);
+            IFieldInfo[] fields = baseEventInfo.getFields();
+            assertNotNull(fields);
+            assertEquals(0, fields.length);
+
+            baseEventInfo = events[1];
+            fields = baseEventInfo.getFields();
+            assertNotNull(fields);
+            assertEquals(3, fields.length);
+            assertEquals("doublefield", fields[0].getName());
+            assertEquals("float", fields[0].getFieldType());
+
+            assertEquals("floatfield", fields[1].getName());
+            assertEquals("float", fields[1].getFieldType());
+
+            assertEquals("stringfield", fields[2].getName());
+            assertEquals("string", fields[2].getFieldType());
+
+            //Verify second provider
+            assertEquals("/home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello", providers.get(1).getName());
+            assertEquals(4852, providers.get(1).getPid());
+
+            // Verify event info
+            events = providers.get(1).getEvents();
+            assertNotNull(events);
+            assertEquals(2, events.length);
+
+            baseEventInfo = events[0];
+            assertNotNull(baseEventInfo);
+            fields = baseEventInfo.getFields();
+            assertNotNull(fields);
+            assertEquals(0, fields.length);
+
+            baseEventInfo = events[1];
+            fields = baseEventInfo.getFields();
+            assertNotNull(fields);
+            assertEquals(3, fields.length);
+
+            assertEquals("doublefield", fields[0].getName());
+            assertEquals("float", fields[0].getFieldType());
+
+            assertEquals("floatfield", fields[1].getName());
+            assertEquals("float", fields[1].getFieldType());
+
+            assertEquals("stringfield", fields[2].getName());
+            assertEquals("string", fields[2].getFieldType());
+
+            // Reset version
+            ((LTTngControlService)fService).setVersion("2.0.0");
+
+        } catch (ExecutionException e) {
+            fail(e.toString());
+        }
+    }
+
     public void testCreateSession() {
         try {
             fShell.setScenario(SCEN_CREATE_SESSION1);
@@ -673,21 +751,26 @@ public class LTTngControlServiceTest extends TestCase {
             list.add(eventName1);
             list.add(eventName2);
             fShell.setScenario(SCEN_EVENT_HANDLING);
-            fService.enableEvents(sessionName, null, list, true, new NullProgressMonitor());
+            fService.enableEvents(sessionName, null, list, true, null, new NullProgressMonitor());
 
             // 2) session name, channel=mychannel, event name= null, kernel
             String channelName = "mychannel";
-            fService.enableEvents(sessionName, channelName, null, true, new NullProgressMonitor());
+            fService.enableEvents(sessionName, channelName, null, true, null, new NullProgressMonitor());
 
-            // 3) session name, channel=mychannel, 1 event name, ust
+            // 3) session name, channel=mychannel, 1 event name, ust, no filter
             String ustEventName = "ust_tests_hello:tptest_sighandler";
             list.clear();
             list.add(ustEventName);
-            fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
+            fService.enableEvents(sessionName, channelName, list, false, null, new NullProgressMonitor());
 
-            // 4) session name, channel = mychannel, no event name, ust
+            // 4) session name, channel = mychannel, no event name, ust, with filter
+            fService.enableEvents(sessionName, channelName, list, false, "intfield==10", new NullProgressMonitor());
+
+            // 5) session name, channel = mychannel, no event name, ust, no filter
             list.clear();
-            fService.enableEvents(sessionName, channelName, list, false, new NullProgressMonitor());
+            fService.enableEvents(sessionName, channelName, list, false, null, new NullProgressMonitor());
+
+            // TODO add test with filters
 
         } catch (ExecutionException e) {
             fail(e.toString());
@@ -747,10 +830,12 @@ public class LTTngControlServiceTest extends TestCase {
             fShell.setScenario(SCEN_EVENT_HANDLING);
 
             // 1) session name, channel = null, event name, loglevel-only, TRACE_DEBUG
-            fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, new NullProgressMonitor());
+            fService.enableLogLevel(sessionName, null, eventName4, LogLevelType.LOGLEVEL_ONLY, TraceLogLevel.TRACE_DEBUG, null, new NullProgressMonitor());
 
             // 2) session name, channel = mychannel, null, loglevel, TRACE_DEBUG_FUNCTION
-            fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, new NullProgressMonitor());
+            fService.enableLogLevel(sessionName, channelName, eventName5, LogLevelType.LOGLEVEL, TraceLogLevel.TRACE_DEBUG_FUNCTION, null, new NullProgressMonitor());
+
+            // TODO add test with filters
 
         } catch (ExecutionException e) {
             fail(e.toString());
index eadadfbc757d5911a0eb15fa7bbae70aefbe1b55..05e1e53d7df3adbf7f0ffba49b756346b17b270a 100644 (file)
@@ -45,6 +45,7 @@ public class EnableEventsDialogStub implements IEnableEventsDialog {
     private String fLogLevelEventName;
     private TraceLogLevel fLogLevel;
     private LogLevelType fLogLevelType;
+    private String fFilter;
     List<String> fNames = new ArrayList<String>();
 
     // ------------------------------------------------------------------------
@@ -118,6 +119,10 @@ public class EnableEventsDialogStub implements IEnableEventsDialog {
         fNames = names;
     }
 
+    public void setFilterExpression(String filter) {
+        fFilter = filter;
+    }
+
     @Override
     public boolean isTracepoints() {
         return fIsTracePoints;
@@ -220,4 +225,10 @@ public class EnableEventsDialogStub implements IEnableEventsDialog {
     public int open() {
         return 0;
     }
+
+    @Override
+    public String getFilterExpression() {
+        return fFilter;
+    }
+
 }
\ No newline at end of file
index ff4d8c0365dc3f24785f3d59d152db8b2560a853..1a65d75c827d99ed112cd5575efb62040ef8e31b 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
  * Copyright (c) 2012 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: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.stubs.dialogs;
@@ -18,12 +18,13 @@ import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceC
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceSessionComponent;
 
 /**
- * Get event information dialog stub implementation. 
+ * Get event information dialog stub implementation.
  */
 public class GetEventInfoDialogStub implements IGetEventInfoDialog {
 
     private TraceSessionComponent[] fSessions;
-    
+    private String fFilterExpression;
+
     @Override
     public TraceSessionComponent getSession() {
         return fSessions[0];
@@ -47,9 +48,21 @@ public class GetEventInfoDialogStub implements IGetEventInfoDialog {
         fSessions = null;
     }
 
+    @Override
+    public String getFilterExpression() {
+        return fFilterExpression;
+    }
+
     @Override
     public int open() {
         return 0;
     }
+
+    /**
+     * @param filter the filter to set
+     */
+    public void setFilterExpression(String filter) {
+        fFilterExpression = filter;
+    }
 }
 
index 283aa488fb88290ec0420ee6f1530ea1ea20ddb6..dece4277a28deca39056c3d4657b9cfc2b15a949 100644 (file)
@@ -364,6 +364,39 @@ None
 </COMMAND_OUTPUT>
 </SCENARIO>
 
+####################################################################
+# Scenario: Test "lttng list -u -f" with sample output (version 2.1.0) 
+####################################################################
+<SCENARIO>
+GetUstProvider3
+<COMMAND_INPUT>
+lttng list -u -f 
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST events:
+-------------
+
+PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+    ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
+    ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+        field: doublefield (float)
+        field: floatfield (float)
+        field: stringfield (string)
+
+PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
+    ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
+    ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+        field: doublefield (float)
+        field: floatfield (float)
+        field: stringfield (string)
+
+</COMMAND_OUTPUT>
+</SCENARIO>
+
+
 ####################################################################
 # Scenario: Test "lttng create <session>  
 ####################################################################
@@ -587,6 +620,16 @@ lttng enable-event ust_tests_hello:tptest_sighandler -u  -s mysession2 -c mychan
 UST event ust_tests_hello:tptest_sighandler created in channel mychannel
 </COMMAND_OUTPUT>
 
+<COMMAND_INPUT>
+lttng enable-event ust_tests_hello:tptest_sighandler -u  -s mysession2 -c mychannel --tracepoint  --filter 'intfield==10'
+</COMMAND_INPUT>
+<COMMAND_RESULT>
+0
+</COMMAND_RESULT>
+<COMMAND_OUTPUT>
+UST event ust_tests_hello:tptest_sighandler created in channel mychannel
+</COMMAND_OUTPUT>
+
 <COMMAND_INPUT>
 lttng enable-event  -a  -u  -s mysession2 -c mychannel --tracepoint 
 </COMMAND_INPUT>
index 824f8808ddeb4cc3e53914009e7eb5b9b47ee96f..19cbd155330521cf71d485365aec77334358ae0b 100644 (file)
@@ -22,7 +22,7 @@ lttng version
 0
 </COMMAND_RESULT>
 <COMMAND_OUTPUT>
-lttng version 2.0.0 - Annedd'ale
+lttng version 2.1.0 - Basse Messe
 Web site: http://lttng.org/
 
 lttng is free software and under the GPL license and part LGPL
@@ -117,7 +117,7 @@ Channels:
       output: mmap()
 
     Events:
-      ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled]
+      ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_LINE (13)) (type: tracepoint) [disabled] [with filter]
       * (type: tracepoint) [enabled]
 
 </COMMAND_OUTPUT>
@@ -149,7 +149,7 @@ Kernel events
 </COMMAND_OUTPUT>
 
 <COMMAND_INPUT>
-lttng list -u
+lttng list -u -f 
 </COMMAND_INPUT>
 <COMMAND_RESULT>
 0
@@ -161,10 +161,16 @@ UST events:
 PID: 9379 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
     ust_tests_hello:tptest_sighandler (loglevel: TRACE_DEBUG_MODULE (10)) (type: tracepoint)
     ust_tests_hello:tptest (loglevel: TRACE_INFO (6)) (type: tracepoint)
+        field: doublefield (float)
+        field: floatfield (float)
+        field: stringfield (string)
 
 PID: 4852 - Name: /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
     ust_tests_hello:tptest_sighandler (loglevel: TRACE_WARNING (4)) (type: tracepoint)
     ust_tests_hello:tptest (loglevel: TRACE_DEBUG_FUNCTION (12)) (type: tracepoint)
+        field: doublefield (float)
+        field: floatfield (float)
+        field: stringfield (string)
 
 </COMMAND_OUTPUT>
 
index 542b6e6cf06453c9a21fb079b36e70607ba5b4ca..06e88be32288d5d3185764c447922d34f1aec580 100644 (file)
@@ -338,6 +338,18 @@ public class EnableEventsDialog extends Dialog implements IEnableEventsDialog  {
         }
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getFilterExpression()
+     */
+    @Override
+    public String getFilterExpression() {
+        if (!fIsKernel) {
+            return fUstComposite.getFilterExpression();
+        }
+        return null;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
index 8b3ff8628f203c1b6490a2426cb1c8d04a6f463a..cfd581af58e9a3d087cafa67ce968d3625d705f9 100644 (file)
@@ -98,6 +98,11 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
      * A button for selecting the specified log level only.
      */
     private Button fLogLevelOnlyButton;
+    /**
+     * The filter text
+     */
+    private Text fFilterText;
+
     /**
      * The referenced trace provider group containing the UST providers
      * component which contains a list of available tracepoints.
@@ -139,6 +144,10 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
      * The actual selected log level.
      */
     private TraceLogLevel fLogLevel;
+    /**
+     * The filter expression
+     */
+    private String fFilterExpression;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -239,6 +248,15 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         return fLogLevelEventName;
     }
 
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getFilterExpression()
+     */
+    @Override
+    public String getFilterExpression() {
+        return fFilterExpression;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -257,6 +275,9 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         // Log Level Group
         createLogLevelGroup();
 
+        // Filter Group
+        createFilterGroup();
+
         // Set default enablements
         setEnablements(GroupEnum.TRACEPOINTS);
     }
@@ -324,7 +345,7 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
             fLogLevel = levels[id];
         }
 
-        // initialize wildcard with the event name string
+        // initialize wildcard with null
         fWildcard = null;
         if (fIsWildcard) {
             String tempWildcard = fWildcardText.getText();
@@ -341,6 +362,16 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
             }
         }
 
+        // initialize filter with null
+        fFilterExpression = null;
+        if (fProviderGroup.isEventFilteringSupported()) {
+            String tempFilter = fFilterText.getText();
+
+            if(!tempFilter.matches("\\s*")) { //$NON-NLS-1$
+                fFilterExpression = tempFilter;
+            }
+        }
+
         // validation successful -> call super.okPressed()
         return true;
     }
@@ -519,6 +550,22 @@ public class EnableUstEventsComposite extends Composite implements IEnableUstEve
         fLogLevelButton.setLayoutData(data);
     }
 
+    void createFilterGroup() {
+        if (fProviderGroup.isEventFilteringSupported()) {
+            Group filterMainGroup = new Group(this, SWT.SHADOW_NONE);
+            filterMainGroup.setText(Messages.TraceControl_EnableEventsFilterGroupName);
+            GridLayout layout = new GridLayout(3, false);
+            filterMainGroup.setLayout(layout);
+            GridData data = new GridData(GridData.FILL_HORIZONTAL);
+            filterMainGroup.setLayoutData(data);
+
+            fFilterText = new Text(filterMainGroup, SWT.LEFT);
+            fFilterText.setToolTipText(Messages.TraceControl_EnableEventsFilterTooltip);
+            data = new GridData(GridData.FILL_HORIZONTAL);
+            fFilterText.setLayoutData(data);
+        }
+    }
+
     /**
      * Enable/selects widgets depending on the group specified.
      * @param group - group to enable.
index 36568a56e621b7fb72a54c8eb1c7efb4dcfd9505..62af2122e10077edea6d399a3310646a9e0676dc 100644 (file)
@@ -32,6 +32,7 @@ import org.eclipse.swt.widgets.Composite;
 import org.eclipse.swt.widgets.Control;
 import org.eclipse.swt.widgets.Group;
 import org.eclipse.swt.widgets.Shell;
+import org.eclipse.swt.widgets.Text;
 
 /**
  * <p>
@@ -73,6 +74,10 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
      * The channel combo box.
      */
     private CCombo fChannelsCombo = null;
+    /**
+     * The filter text
+     */
+    private Text fFilterText;
     /**
      * The list of available sessions.
      */
@@ -93,6 +98,10 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
      * List of available channels of the selected session.
      */
     private TraceChannelComponent[] fChannels;
+    /**
+     * The filter expression
+     */
+    private String fFilterExpression;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -144,6 +153,14 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
     public void setSessions(TraceSessionComponent[] sessions) {
         fSessions = Arrays.copyOf(sessions, sessions.length);
     }
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IGetEventInfoDialog#getFilterExpression()
+     */
+    @Override
+    public String getFilterExpression() {
+       return fFilterExpression;
+    }
 
     // ------------------------------------------------------------------------
     // Operations
@@ -241,6 +258,21 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
             }
         });
 
+        // take first session to test whether events filtering is supported or not
+        if (fSessions[0].isEventFilteringSupported() && !fIsKernel) {
+            Group filterMainGroup = new Group(fDialogComposite, SWT.SHADOW_NONE);
+            filterMainGroup.setText(Messages.TraceControl_EnableEventsFilterGroupName);
+            layout = new GridLayout(2, false);
+            filterMainGroup.setLayout(layout);
+            data = new GridData(GridData.FILL_HORIZONTAL);
+            filterMainGroup.setLayoutData(data);
+
+            fFilterText = new Text(filterMainGroup, SWT.LEFT);
+            fFilterText.setToolTipText(Messages.TraceControl_EnableEventsFilterTooltip);
+            data = new GridData(GridData.FILL_HORIZONTAL);
+            fFilterText.setLayoutData(data);
+        }
+
         getShell().setMinimumSize(new Point(300, 200));
 
         return fDialogComposite;
@@ -272,18 +304,22 @@ public class GetEventInfoDialog extends Dialog implements IGetEventInfoDialog {
 
         fSessionIndex = fSessionsCombo.getSelectionIndex();
 
-        if ((fChannels != null) && (fChannels.length > 0) && (fChannelsCombo.getSelectionIndex() < 0)) {
-            MessageDialog.openError(getShell(),
-                    Messages.TraceControl_EnableEventsDialogTitle,
-                    Messages.TraceControl_EnableEventsNoChannelError);
-              return;
-        }
-        // Initialize fChannel to null
+        // if no channel is available or no channel is selected use default channel indicated by fChannel=null
         fChannel = null;
-        if ((fChannels != null) && (fChannels.length > 0)) {
+        if ((fChannels != null) && (fChannelsCombo.getSelectionIndex() >= 0)) {
             fChannel = fChannels[fChannelsCombo.getSelectionIndex()];
         }
 
+        // initialize filter with null
+        fFilterExpression = null;
+        if (fSessions[0].isEventFilteringSupported() && !fIsKernel) {
+            String tempFilter = fFilterText.getText();
+
+            if(!tempFilter.matches("\\s*")) { //$NON-NLS-1$
+                fFilterExpression = tempFilter;
+            }
+        }
+
         super.okPressed();
     }
 }
index 035a0977d8d6cfd5db1c2aa3bc1198460e829513..c7907a6527a495f74a85ff0ee06e43c0540d2f34 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
  * Copyright (c) 2012 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: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
@@ -20,7 +20,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
  * <p>
  * Interface for providing information about UST events to be enabled.
  * </p>
- * 
+ *
  * @author Bernd Hufmann
  */
 public interface IEnableUstEvents {
@@ -28,12 +28,12 @@ public interface IEnableUstEvents {
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
+
     /**
      * @return a flag whether the tracepoints shall be configured.
      */
     public boolean isTracepoints();
-    
+
     /**
      * @return a flag indicating whether all tracepoints shall be enabled or not.
      */
@@ -50,12 +50,12 @@ public interface IEnableUstEvents {
     public boolean isWildcard();
 
     /**
-     * @return a wildcard 
+     * @return a wildcard
      */
     public String getWildcard();
 
     /**
-     * @return a flag whether events using log levels should be enabled 
+     * @return a flag whether events using log levels should be enabled
      */
     public boolean isLogLevel();
 
@@ -63,7 +63,7 @@ public interface IEnableUstEvents {
      * @return a log level type (loglevel or loglevel-only)
      */
     public LogLevelType getLogLevelType();
-    
+
     /**
      * @return a log level
      */
@@ -73,5 +73,10 @@ public interface IEnableUstEvents {
      * @return a event name for the log level enable action
      */
     public String getLogLevelEventName();
-   
+
+    /**
+     * @return a filter expression
+     */
+    public String getFilterExpression();
+
 }
\ No newline at end of file
index 4a2b52c4123d0e4f45d27b27e6ae6c9f9df24a0a..9eb823ce4178df687ff977e2586cbd21a3c7af2c 100644 (file)
@@ -1,12 +1,12 @@
 /**********************************************************************
  * Copyright (c) 2012 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: 
+ *
+ * Contributors:
  *   Bernd Hufmann - Initial API and implementation
  **********************************************************************/
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs;
@@ -18,11 +18,11 @@ import org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceS
  * <p>
  * Interface for a dialog box for collecting information about the events to enable.
  * </p>
- * 
+ *
  * @author Bernd Hufmann
  */
 public interface IGetEventInfoDialog {
-    
+
     // ------------------------------------------------------------------------
     // Accessors
     // ------------------------------------------------------------------------
@@ -35,19 +35,25 @@ public interface IGetEventInfoDialog {
      * @return the channel the events shall be enabled. Null for default channel.
      */
     public TraceChannelComponent getChannel();
-    
+
     /**
      * Sets flag about domain.
      * @param isKernel - true for kernel, false for UST
      */
     public void setIsKernel(boolean isKernel);
-    
+
     /**
      * Sets available session.
      * @param sessions - a array of available sessions.
      */
     public void setSessions(TraceSessionComponent[] sessions);
 
+    /**
+     * Returns the filter expression.
+     * @return the filter expression or null for no filtering
+     */
+    public String getFilterExpression();
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
index 8aae5261fb992f434f60d24eb64d1eee54ea8d42..b889d4333328b623e25a45b8767f1fb3c8d0a5fb 100644 (file)
@@ -100,9 +100,9 @@ public class AssignEventHandler extends BaseControlViewHandler {
                         TraceChannelComponent channel = dialog.getChannel();
                         if (channel == null) {
                             // enable events on default channel (which will be created by lttng-tools)
-                            dialog.getSession().enableEvents(eventNames, param.isKernel(), monitor);
+                            dialog.getSession().enableEvents(eventNames, param.isKernel(), dialog.getFilterExpression(), monitor);
                         } else {
-                            channel.enableEvents(eventNames, monitor);
+                            channel.enableEvents(eventNames, dialog.getFilterExpression(), monitor);
                         }
 
                     } catch (ExecutionException e) {
index 7b95a44306a722348cb4ac165fa62da87c8f6643..fb9d80695098791acc0c121bc81b6b0742a793da 100644 (file)
@@ -63,12 +63,14 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
      *            - list of event names
      * @param isKernel
      *            - true if kernel domain else false
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails for some reason
      */
-    abstract public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException;
+    abstract public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, String filterExpression, IProgressMonitor monitor) throws ExecutionException;
 
     /**
      * Enables all syscall events.
@@ -111,12 +113,14 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails for some reason
      */
-    abstract public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException;
+    abstract public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExpression, IProgressMonitor monitor) throws ExecutionException;
 
     /**
      * @param param
@@ -159,14 +163,16 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
                     Exception error = null;
 
                     try {
+                        String filter = dialog.getFilterExpression();
+
                         // Enable tracepoint events
                         if (dialog.isTracepoints()) {
                             if (dialog.isAllTracePoints()) {
-                                enableEvents(param, null, dialog.isKernel(), monitor);
+                                enableEvents(param, null, dialog.isKernel(), filter, monitor);
                             } else {
                                 List<String> eventNames = dialog.getEventNames();
                                 if (!eventNames.isEmpty()) {
-                                    enableEvents(param, eventNames, dialog.isKernel(), monitor);
+                                    enableEvents(param, eventNames, dialog.isKernel(), filter, monitor);
                                 }
                             }
                         }
@@ -192,13 +198,13 @@ abstract public class BaseEnableEventHandler extends BaseControlViewHandler {
                             eventNames.add(dialog.getWildcard());
 
                             if (!eventNames.isEmpty()) {
-                                enableEvents(param, eventNames, dialog.isKernel(), monitor);
+                                enableEvents(param, eventNames, dialog.isKernel(), filter, monitor);
                             }
                         }
 
                         // Enable events using log level
                         if (dialog.isLogLevel()) {
-                            enableLogLevel(param, dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), monitor);
+                            enableLogLevel(param, dialog.getLogLevelEventName(), dialog.getLogLevelType(), dialog.getLogLevel(), filter, monitor);
                         }
 
                     } catch (ExecutionException e) {
index 2997f76569fa0f0330a6d39c70f27754aa794a94..f83283b9b1402020d4757c1eae30fe48ce57f4f4 100644 (file)
@@ -44,12 +44,12 @@ public class EnableEventOnChannelHandler extends BaseEnableEventHandler {
     // ------------------------------------------------------------------------
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+    public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, String filterExression, IProgressMonitor monitor) throws ExecutionException {
         if (param instanceof ChannelCommandParameter) {
-            ((ChannelCommandParameter)param).getChannel().enableEvents(eventNames, monitor);
+            ((ChannelCommandParameter)param).getChannel().enableEvents(eventNames, filterExression, monitor);
         }
     }
 
@@ -77,12 +77,12 @@ public class EnableEventOnChannelHandler extends BaseEnableEventHandler {
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+    public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExression, IProgressMonitor monitor) throws ExecutionException {
         if (param instanceof ChannelCommandParameter) {
-            ((ChannelCommandParameter)param).getChannel().enableLogLevel(eventName, logLevelType, level, monitor);
+            ((ChannelCommandParameter)param).getChannel().enableLogLevel(eventName, logLevelType, level, filterExression, monitor);
         }
     }
 
index bbb47f90b262ba85cc3f3a208f2a89438cef9cfd..0944c3c98953ff1b0198154c1396f5671da38211 100644 (file)
@@ -45,10 +45,10 @@ public class EnableEventOnDomainHandler extends BaseEnableEventHandler {
     // ------------------------------------------------------------------------
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+    public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, String filterExression, IProgressMonitor monitor) throws ExecutionException {
         if (param instanceof DomainCommandParameter) {
             ((DomainCommandParameter)param).getDomain().enableEvents(eventNames, monitor);
         }
@@ -78,12 +78,12 @@ public class EnableEventOnDomainHandler extends BaseEnableEventHandler {
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+    public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExression, IProgressMonitor monitor) throws ExecutionException {
         if (param instanceof DomainCommandParameter) {
-            ((DomainCommandParameter)param).getDomain().enableLogLevel(eventName, logLevelType, level, monitor);
+            ((DomainCommandParameter)param).getDomain().enableLogLevel(eventName, logLevelType, level, filterExression, monitor);
         }
     }
 
index 2c827142c0590c7beccf5318c3f663d56434364f..6cbbfd0f946095af96a158ffd05a55b3b4526410 100644 (file)
@@ -45,11 +45,11 @@ public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
     // ------------------------------------------------------------------------
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableEvents(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.util.List, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
-        param.getSession().enableEvents(eventNames, isKernel, monitor);
+    public void enableEvents(CommandParameter param, List<String> eventNames, boolean isKernel, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
+        param.getSession().enableEvents(eventNames, isKernel, filterExpression, monitor);
     }
 
     /*
@@ -72,14 +72,13 @@ public class EnableEventOnSessionHandler extends BaseEnableEventHandler {
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#enableLogLevel(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter, java.lang.String, org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
-        param.getSession().enableLogLevel(eventName, logLevelType, level, monitor);
+    public void enableLogLevel(CommandParameter param, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
+        param.getSession().enableLogLevel(eventName, logLevelType, level, filterExpression, monitor);
     }
 
-
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.BaseEnableEventHandler#getDomain(org.eclipse.linuxtools.internal.lttng2.ui.views.control.handlers.CommandParameter)
index de3c0420ed262c413fa1e10301b8bda459ee6d01..20b285aa28d1e2500107eca8de245be516ac04ae 100644 (file)
@@ -154,6 +154,8 @@ final public class Messages extends NLS {
     public static String TraceControl_EnableEventsLogLevelOnlyTypeTooltip;
     public static String TraceControl_EnableEventsLogLevelTooltip;
     public static String TraceControl_EnableEventsLoglevelEventNameTooltip;
+    public static String TraceControl_EnableEventsFilterGroupName;
+    public static String TraceControl_EnableEventsFilterTooltip;
 
     public static String TraceControl_InvalidProbeNameError;
     public static String TraceControl_InvalidWildcardError;
@@ -200,6 +202,8 @@ final public class Messages extends NLS {
     public static String TraceControl_EventNamePropertyName;
     public static String TraceControl_EventTypePropertyName;
     public static String TraceControl_LogLevelPropertyName;
+    public static String TraceControl_FieldsPropertyName;
+    public static String TraceControl_FilterPropertyName;
     public static String TraceControl_StatePropertyName;
     public static String TraceControl_VersionPropertyName;
     public static String TraceControl_DomainNamePropertyName;
index f0d1e50f0ae2156ce24a8729b197037a9962f644..55573d4509080f3c4d889620caee3128c631655d 100644 (file)
@@ -137,6 +137,8 @@ TraceControl_EnableEventsLogLevelOnlyTypeName=loglevel-only
 TraceControl_EnableEventsLogLevelOnlyTypeTooltip=The tracepoint log level (only this loglevel)
 TraceControl_EnableEventsLogLevelTooltip=The available log levels
 TraceControl_EnableEventsLoglevelEventNameTooltip=Event name for enabling log levels
+TraceControl_EnableEventsFilterGroupName=Filter Expression
+TraceControl_EnableEventsFilterTooltip=Filter expression on event field.
 
 TraceControl_InvalidProbeNameError=The probe name is invalid 
 TraceControl_InvalidWildcardError=The wild card name is invalid
@@ -183,6 +185,8 @@ TraceControl_SessionNamePropertyName=Session Name
 TraceControl_EventNamePropertyName=Event Name
 TraceControl_EventTypePropertyName=Event Type
 TraceControl_LogLevelPropertyName=Log Level
+TraceControl_FieldsPropertyName=Fields
+TraceControl_FilterPropertyName=Filter
 TraceControl_StatePropertyName=State
 TraceControl_VersionPropertyName=Version
 TraceControl_DomainNamePropertyName=Domain Name
index a3a34f93af6078606fd0bea9962400ec3bce2bb3..fc382f7034c5584deb29742f7d075a4953227da8 100644 (file)
@@ -12,6 +12,7 @@
 package org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl;
 
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceEventType;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
@@ -115,6 +116,26 @@ public class BaseEventComponent extends TraceControlComponent {
         fEventInfo.setLogLevel(levelName);
     }
 
+    /**
+     * @return a String containing pairs if field name and data type
+     */
+    public String getFieldString() {
+        IFieldInfo[] fields = fEventInfo.getFields();
+        if ((fields != null) && (fields.length > 0)) {
+            StringBuffer buffer = new StringBuffer();
+            for (int i = 0; i < fields.length; i++) {
+                buffer.append(fields[i].getName());
+                buffer.append("="); //$NON-NLS-1$
+                buffer.append(fields[i].getFieldType());
+                if (i != fields.length-1) {
+                    buffer.append(";"); //$NON-NLS-1$
+                }
+            }
+            return buffer.toString();
+        }
+        return null;
+    }
+
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
index 94a6678ba0ce6f7af535a330d66aa8bd9f233431..8a46ce1747e719ee322779106ac2db086b02ff58 100644 (file)
@@ -217,6 +217,14 @@ public class TargetNodeComponent extends TraceControlComponent implements ICommu
         return ""; //$NON-NLS-1$
     }
 
+    /**
+     * Returns if node supports filtering of events
+     * @return <code>true</code> if node supports filtering else <code>false</code>
+     */
+    public boolean isEventFilteringSupported() {
+        return getControlService().isVersionSupported("2.1.0"); //$NON-NLS-1$
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
index 39ae17e0bc079711a7ac5f4f9e5cfdf36209cf03..ce0855357c0ba8857892500330a4c0a9c0c74927 100644 (file)
@@ -286,7 +286,23 @@ public class TraceChannelComponent extends TraceControlComponent {
      *             If the command fails
      */
     public void enableEvents(List<String> eventNames, IProgressMonitor monitor) throws ExecutionException {
-        getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), monitor);
+        enableEvents(eventNames, null,  monitor);
+    }
+
+    /**
+     * Enables a list of events with no additional parameters.
+     *
+     * @param eventNames
+     *            - a list of event names to enabled.
+     * @param filterExpression
+     *            - a filter expression
+     * @param monitor
+     *            - a progress monitor
+     * @throws ExecutionException
+     *             If the command fails
+     */
+    public void enableEvents(List<String> eventNames, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
+        getControlService().enableEvents(getSessionName(), getName(), eventNames, isKernel(), filterExpression,  monitor);
     }
 
     /**
@@ -356,12 +372,14 @@ public class TraceChannelComponent extends TraceControlComponent {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level) throws ExecutionException {
-        enableLogLevel(eventName, logLevelType, level, new NullProgressMonitor());
+            TraceLogLevel level, String filterExpression) throws ExecutionException {
+        enableLogLevel(eventName, logLevelType, level, filterExpression, new NullProgressMonitor());
     }
 
     /**
@@ -373,15 +391,17 @@ public class TraceChannelComponent extends TraceControlComponent {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level, IProgressMonitor monitor)
+            TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
             throws ExecutionException {
-        getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, monitor);
+        getControlService().enableLogLevel(getSessionName(), getName(), eventName, logLevelType, level, filterExpression, monitor);
     }
 
     /**
index 7c01dd77df36828cbf5193c4b73262abeb8d39ab..d088bd38a7438e198489978d4f4ca56b520dda1f 100644 (file)
@@ -245,7 +245,7 @@ public class TraceDomainComponent extends TraceControlComponent {
     public void enableEvents(List<String> eventNames, IProgressMonitor monitor)
             throws ExecutionException {
         getControlService().enableEvents(getSessionName(), null, eventNames,
-                isKernel(), monitor);
+                isKernel(), null, monitor);
     }
 
     /**
@@ -318,12 +318,14 @@ public class TraceDomainComponent extends TraceControlComponent {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level) throws ExecutionException {
-        enableLogLevel(eventName, logLevelType, level,
+            TraceLogLevel level, String filterExpression) throws ExecutionException {
+        enableLogLevel(eventName, logLevelType, level, filterExpression,
                 new NullProgressMonitor());
     }
 
@@ -336,16 +338,18 @@ public class TraceDomainComponent extends TraceControlComponent {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level, IProgressMonitor monitor)
+            TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
             throws ExecutionException {
         getControlService().enableLogLevel(getSessionName(), null, eventName,
-                logLevelType, level, monitor);
+                logLevelType, level, filterExpression, monitor);
     }
 
     /**
index 14d3930126c5cfa59a6cdce1a250ea9e204824b8..ff40447bd48940f2a919df5dc976099fbdf47883 100644 (file)
@@ -169,6 +169,22 @@ public class TraceEventComponent extends TraceControlComponent {
         fEventInfo.setLogLevel(levelName);
     }
 
+    /**
+     * Returns filter expression.
+     * @return filter expression
+     */
+    public String getFilterExpression() {
+        return fEventInfo.getFilterExpression();
+    }
+
+    /**
+     * Sets the filter expression.
+     * @param filter The filter expression to set
+     */
+    public void setFilterExpression(String filter) {
+        fEventInfo.setFilterExpression(filter);
+    }
+
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.impl.TraceControlComponent#getAdapter(java.lang.Class)
index 448dfa5a6c2ae28aea658472c9accde15e0e1b5f..96e7f536818d32af0aa33e5ea07c0feffd38254a 100644 (file)
@@ -104,5 +104,13 @@ public class TraceProviderGroup extends TraceControlComponent {
         List<ITraceControlComponent> kernelList = getChildren(KernelProviderComponent.class);
         return !kernelList.isEmpty();
     }
+
+    /**
+     * Returns if node supports filtering of events
+     * @return <code>true</code> if node supports filtering else <code>false</code>
+     */
+    public boolean isEventFilteringSupported() {
+        return ((TargetNodeComponent)getParent()).isEventFilteringSupported();
+    }
 }
 
index b02bc546c4e46ece5354b8b53d898badc519880a..7fec67c21e650dddbc35e6f9b418ebf47d1ea541 100644 (file)
@@ -201,6 +201,14 @@ public class TraceSessionComponent extends TraceControlComponent {
         return (!providerGroups.isEmpty() ? ((TraceProviderGroup) providerGroups.get(0)).hasKernelProvider() : false);
     }
 
+    /**
+     * Returns if node supports filtering of events
+     * @return <code>true</code> if node supports filtering else <code>false</code>
+     */
+    public boolean isEventFilteringSupported() {
+        return ((TargetNodeComponent)getParent().getParent()).isEventFilteringSupported();
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -332,12 +340,14 @@ public class TraceSessionComponent extends TraceControlComponent {
      *            - a list of event names to enabled.
      * @param isKernel
      *            - a flag for indicating kernel or UST.
+     * @param filterExpression
+     *            - a filter expression
      * @throws ExecutionException
      *             If the command fails
      */
-    public void enableEvent(List<String> eventNames, boolean isKernel)
+    public void enableEvent(List<String> eventNames, boolean isKernel, String filterExpression)
             throws ExecutionException {
-        enableEvents(eventNames, isKernel, new NullProgressMonitor());
+        enableEvents(eventNames, isKernel, filterExpression, new NullProgressMonitor());
     }
 
     /**
@@ -347,15 +357,17 @@ public class TraceSessionComponent extends TraceControlComponent {
      *            - a list of event names to enabled.
      * @param isKernel
      *            - a flag for indicating kernel or UST.
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableEvents(List<String> eventNames, boolean isKernel,
-            IProgressMonitor monitor) throws ExecutionException {
+            String filterExpression, IProgressMonitor monitor) throws ExecutionException {
         getControlService().enableEvents(getName(), null, eventNames, isKernel,
-                monitor);
+                filterExpression, monitor);
     }
 
     /**
@@ -427,12 +439,14 @@ public class TraceSessionComponent extends TraceControlComponent {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level) throws ExecutionException {
-        enableLogLevel(eventName, logLevelType, level,
+            TraceLogLevel level, String filterExpression) throws ExecutionException {
+        enableLogLevel(eventName, logLevelType, level, filterExpression,
                 new NullProgressMonitor());
     }
 
@@ -445,16 +459,18 @@ public class TraceSessionComponent extends TraceControlComponent {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableLogLevel(String eventName, LogLevelType logLevelType,
-            TraceLogLevel level, IProgressMonitor monitor)
+            TraceLogLevel level, String filterExpression, IProgressMonitor monitor)
             throws ExecutionException {
         getControlService().enableLogLevel(getName(), null, eventName,
-                logLevelType, level, monitor);
+                logLevelType, level, null, monitor);
     }
 
     /**
index 77b8123124160822c9ed67f564709e6f93f458d9..733e500482f4aea3fec000a02d06a48ff6171009 100644 (file)
@@ -45,6 +45,10 @@ public class BaseEventPropertySource extends BasePropertySource {
      * The base event 'log level' property ID.
      */
     public static final String BASE_EVENT_LOGLEVEL_PROPERTY_ID = "base.event.loglevel"; //$NON-NLS-1$
+    /**
+     * The base event 'fields' property ID.
+     */
+    public static final String BASE_EVENT_FIELDS_PROPERTY_ID = "base.event.fields"; //$NON-NLS-1$
     /**
      *  The base event 'name' property name.
      */
@@ -57,6 +61,10 @@ public class BaseEventPropertySource extends BasePropertySource {
      * The base event 'log level' property name.
      */
     public static final String BASE_EVENT_LOGLEVEL_PROPERTY_NAME = Messages.TraceControl_LogLevelPropertyName;
+    /**
+     * The base event 'fields' property name.
+     */
+    public static final String BASE_EVENT_FIELDS_PROPERTY_NAME = Messages.TraceControl_FieldsPropertyName;
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -92,6 +100,9 @@ public class BaseEventPropertySource extends BasePropertySource {
         if (fBaseEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
             list.add(new TextPropertyDescriptor(BASE_EVENT_LOGLEVEL_PROPERTY_ID, BASE_EVENT_LOGLEVEL_PROPERTY_NAME));
         }
+        if (fBaseEvent.getFieldString() != null) {
+            list.add(new TextPropertyDescriptor(BASE_EVENT_FIELDS_PROPERTY_ID, BASE_EVENT_FIELDS_PROPERTY_NAME));
+        }
         return list.toArray(new IPropertyDescriptor[list.size()]);
     }
 
@@ -110,6 +121,9 @@ public class BaseEventPropertySource extends BasePropertySource {
         if (BASE_EVENT_LOGLEVEL_PROPERTY_ID.equals(id)) {
             return fBaseEvent.getLogLevel().name();
         }
+        if (BASE_EVENT_FIELDS_PROPERTY_ID.equals(id)) {
+            return fBaseEvent.getFieldString();
+        }
         return null;
     }
 
index 124890e38626e1b9d22c2bf853e8e66af6b14e64..f38d09afd1ea34daded9d05adab90b36fe8e4fbd 100644 (file)
@@ -48,6 +48,11 @@ public class TraceEventPropertySource extends BasePropertySource {
      * The trace event 'state' property ID.
      */
     public static final String TRACE_EVENT_STATE_PROPERTY_ID = "trace.event.state"; //$NON-NLS-1$
+    /**
+     * The trace event 'filter' property ID.
+     */
+    public static final String TRACE_EVENT_FILTER_PROPERTY_ID = "trace.event.filter"; //$NON-NLS-1$
+
     /**
      *  The trace event 'name' property name.
      */
@@ -64,6 +69,10 @@ public class TraceEventPropertySource extends BasePropertySource {
      * The trace event 'state' property name.
      */
     public static final String TRACE_EVENT_STATE_PROPERTY_NAME = Messages.TraceControl_StatePropertyName;
+    /**
+     * The trace event 'filter' property name.
+     */
+    public static final String TRACE_EVENT_FILTER_PROPERTY_NAME = Messages.TraceControl_FilterPropertyName;
 
     // ------------------------------------------------------------------------
     // Attributes
@@ -100,6 +109,9 @@ public class TraceEventPropertySource extends BasePropertySource {
         if (fEvent.getLogLevel() != TraceLogLevel.LEVEL_UNKNOWN) {
             list.add(new TextPropertyDescriptor(TRACE_EVENT_LOGLEVEL_PROPERTY_ID, TRACE_EVENT_LOGLEVEL_PROPERTY_NAME));
         }
+        if (fEvent.getFilterExpression() != null) {
+            list.add(new TextPropertyDescriptor(TRACE_EVENT_FILTER_PROPERTY_ID, TRACE_EVENT_FILTER_PROPERTY_NAME));
+        }
         return list.toArray(new IPropertyDescriptor[list.size()]);
     }
 
@@ -121,6 +133,10 @@ public class TraceEventPropertySource extends BasePropertySource {
         if (TRACE_EVENT_STATE_PROPERTY_ID.equals(id)) {
             return fEvent.getState().name();
         }
+        if (TRACE_EVENT_FILTER_PROPERTY_ID.equals(id)) {
+            return fEvent.getFilterExpression();
+        }
+
         return null;
     }
 
index 753150de0a041e4e8334e26d8b844b70557f1945..4499a09dd9c30305f85e54433c87f4d92b0915c8 100644 (file)
@@ -37,6 +37,14 @@ public interface ILttngControlService {
      */
     public String getVersion();
 
+    /**
+     * Checks if given version is supported by this ILTTngControlService implementation.
+     *
+     * @param version The version to check
+     * @return <code>true</code> if version is supported else <code>false</code>
+     */
+    public boolean isVersionSupported(String version);
+
     /**
      * Retrieves the existing sessions names from the node.
      *
@@ -206,15 +214,19 @@ public interface ILttngControlService {
      *            0)for all events .
      * @param isKernel
      *            - a flag for indicating kernel or UST.
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
      *             If the command fails
      */
     public void enableEvents(String sessionName, String channelName,
-            List<String> eventNames, boolean isKernel, IProgressMonitor monitor)
+            List<String> eventNames, boolean isKernel, String filterExpression,
+            IProgressMonitor monitor)
             throws ExecutionException;
 
+
     /**
      * Enables all syscall events.
      *
@@ -265,6 +277,8 @@ public interface ILttngControlService {
      *            - a log level type
      * @param level
      *            - a log level
+     * @param filterExpression
+     *            - a filter expression
      * @param monitor
      *            - a progress monitor
      * @throws ExecutionException
@@ -272,6 +286,7 @@ public interface ILttngControlService {
      */
     public void enableLogLevel(String sessionName, String channelName,
             String eventName, LogLevelType logLevelType, TraceLogLevel level,
+            String filterExpression,
             IProgressMonitor monitor) throws ExecutionException;
 
     /**
index a533cbb0288509194cb2585b50058717240ced37..af5aa746a65e05381742e337f5eb0172c9480539 100644 (file)
@@ -23,6 +23,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.IBaseEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IDomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IEventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.IFieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.ISessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.IUstProviderInfo;
@@ -33,6 +34,7 @@ import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.BaseEventI
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ChannelInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.DomainInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.EventInfo;
+import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.FieldInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.ProbeEventInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.SessionInfo;
 import org.eclipse.linuxtools.internal.lttng2.core.control.model.impl.UstProviderInfo;
@@ -41,6 +43,7 @@ import org.eclipse.linuxtools.internal.lttng2.ui.views.control.messages.Messages
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.preferences.ControlPreferences;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandResult;
 import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandShell;
+import org.osgi.framework.Version;
 
 /**
  * <p>
@@ -51,7 +54,6 @@ import org.eclipse.linuxtools.internal.lttng2.ui.views.control.remote.ICommandSh
  */
 public class LTTngControlService implements ILttngControlService {
 
-
     // ------------------------------------------------------------------------
     // Attributes
     // ------------------------------------------------------------------------
@@ -63,7 +65,7 @@ public class LTTngControlService implements ILttngControlService {
     /**
      * The version string.
      */
-    protected String fVersion = "Unknown"; //$NON-NLS-1$
+    protected Version fVersion = null;
 
     // ------------------------------------------------------------------------
     // Constructors
@@ -88,7 +90,10 @@ public class LTTngControlService implements ILttngControlService {
      */
     @Override
     public String getVersion() {
-        return fVersion;
+        if (fVersion == null) {
+            return "Unknown"; //$NON-NLS-1$
+        }
+        return fVersion.toString();
     }
 
     /**
@@ -96,8 +101,19 @@ public class LTTngControlService implements ILttngControlService {
      * @param version - a version to set
      */
     public void setVersion(String version) {
-        fVersion = version;
+        fVersion = new Version(version);
     }
+
+    /*
+     * (non-Javadoc)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#isVersionSupported(java.lang.String)
+     */
+    @Override
+    public boolean isVersionSupported(String version) {
+        Version tmp = new Version(version);
+        return (fVersion != null && fVersion.compareTo(tmp) >= 0) ? true : false;
+    }
+
     // ------------------------------------------------------------------------
     // Operations
     // ------------------------------------------------------------------------
@@ -117,10 +133,8 @@ public class LTTngControlService implements ILttngControlService {
 
         // Output:
         // Available tracing sessions:
-        // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928)
-        // [inactive]
-        // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318)
-        // [inactive]
+        // 1) mysession1 (/home/user/lttng-traces/mysession1-20120123-083928) [inactive]
+        // 2) mysession (/home/user/lttng-traces/mysession-20120123-083318) [inactive]
         //
         // Use lttng list <session_name> for more details
 
@@ -278,8 +292,14 @@ public class LTTngControlService implements ILttngControlService {
     public List<IUstProviderInfo> getUstProvider(IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_LIST_UST);
 
+        if (isVersionSupported("2.1.0")) { //$NON-NLS-1$
+            command.append(LTTngControlServiceConstants.OPTION_FIELDS);
+        }
+
         ICommandResult result = executeCommand(command.toString(), monitor);
 
+        // Note that field print-outs exists for version >= 2.1.0
+        //
         // UST events:
         // -------------
         //
@@ -288,12 +308,18 @@ public class LTTngControlService implements ILttngControlService {
         // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
         // tracepoint)
         // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
+        //    field: doublefield (float)
+        //    field: floatfield (float)
+        //    field: stringfield (string)
         //
         // PID: 6459 - Name:
         // /home/user/git/lttng-ust/tests/hello.cxx/.libs/lt-hello
         // ust_tests_hello:tptest_sighandler (loglevel: TRACE_EMERG0) (type:
         // tracepoint)
         // ust_tests_hello:tptest (loglevel: TRACE_EMERG0) (type: tracepoint)
+        //    field: doublefield (float)
+        //    field: floatfield (float)
+        //    field: stringfield (string)
 
         List<IUstProviderInfo> allProviders = new ArrayList<IUstProviderInfo>();
         IUstProviderInfo provider = null;
@@ -303,14 +329,12 @@ public class LTTngControlService implements ILttngControlService {
             String line = result.getOutput()[index];
             Matcher matcher = LTTngControlServiceConstants.UST_PROVIDER_PATTERN.matcher(line);
             if (matcher.matches()) {
-
                 provider = new UstProviderInfo(matcher.group(2).trim());
                 provider.setPid(Integer.valueOf(matcher.group(1).trim()));
                 List<IBaseEventInfo> events = new ArrayList<IBaseEventInfo>();
                 index = getProviderEventInfo(result.getOutput(), ++index, events);
                 provider.setEvents(events);
                 allProviders.add(provider);
-
             } else {
                 index++;
             }
@@ -531,10 +555,10 @@ public class LTTngControlService implements ILttngControlService {
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableEvents(java.lang.String, java.lang.String, java.util.List, boolean, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, IProgressMonitor monitor) throws ExecutionException {
+    public void enableEvents(String sessionName, String channelName, List<String> eventNames, boolean isKernel, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
 
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT);
 
@@ -571,6 +595,13 @@ public class LTTngControlService implements ILttngControlService {
 
         command.append(LTTngControlServiceConstants.OPTION_TRACEPOINT);
 
+        if (filterExpression != null) {
+            command.append(LTTngControlServiceConstants.OPTION_FILTER);
+            command.append('\'');
+            command.append(filterExpression);
+            command.append('\'');
+        }
+
         executeCommand(command.toString(), monitor);
 
     }
@@ -634,10 +665,10 @@ public class LTTngControlService implements ILttngControlService {
 
     /*
      * (non-Javadoc)
-     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.ui.views.control.model.TraceLogLevel, org.eclipse.core.runtime.IProgressMonitor)
+     * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#enableLogLevel(java.lang.String, java.lang.String, java.lang.String, org.eclipse.linuxtools.internal.lttng2.core.control.model.LogLevelType, org.eclipse.linuxtools.internal.lttng2.core.control.model.TraceLogLevel, java.lang.String, org.eclipse.core.runtime.IProgressMonitor)
      */
     @Override
-    public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, IProgressMonitor monitor) throws ExecutionException {
+    public void enableLogLevel(String sessionName, String channelName, String eventName, LogLevelType logLevelType, TraceLogLevel level, String filterExpression, IProgressMonitor monitor) throws ExecutionException {
         StringBuffer command = createCommand(LTTngControlServiceConstants.COMMAND_ENABLE_EVENT);
 
         command.append(eventName);
@@ -663,9 +694,10 @@ public class LTTngControlService implements ILttngControlService {
         command.append(level.getInName());
 
         executeCommand(command.toString(), monitor);
-
     }
 
+
+
     /*
      * (non-Javadoc)
      * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.service.ILttngControlService#disableEvent(java.lang.String, java.lang.String, java.util.List, boolean, org.eclipse.core.runtime.IProgressMonitor)
@@ -984,6 +1016,11 @@ public class LTTngControlService implements ILttngControlService {
                 eventInfo.setLogLevel(matcher.group(2).trim());
                 eventInfo.setEventType(matcher.group(3).trim());
                 eventInfo.setState(matcher.group(4));
+                String filter = matcher.group(5);
+                if (filter != null) {
+                    filter = filter.substring(1, filter.length() - 1); // remove '[' and ']'
+                    eventInfo.setFilterExpression(filter);
+                }
                 events.add(eventInfo);
                 index++;
             } else if (matcher2.matches()) {
@@ -991,6 +1028,11 @@ public class LTTngControlService implements ILttngControlService {
                 eventInfo.setLogLevel(TraceLogLevel.LEVEL_UNKNOWN);
                 eventInfo.setEventType(matcher2.group(2).trim());
                 eventInfo.setState(matcher2.group(3));
+                String filter = matcher2.group(4);
+                if (filter != null) {
+                    filter = filter.substring(1, filter.length() - 1); // remove '[' and ']'
+                    eventInfo.setFilterExpression(filter);
+                }
 
                 if (eventInfo.getEventType() == TraceEventType.PROBE) {
                     IProbeEventInfo probeEvent = new ProbeEventInfo(eventInfo.getName());
@@ -1078,16 +1120,49 @@ public class LTTngControlService implements ILttngControlService {
      */
     protected int getProviderEventInfo(String[] output, int currentIndex, List<IBaseEventInfo> events) {
         int index = currentIndex;
+        IBaseEventInfo eventInfo = null;
         while (index < output.length) {
             String line = output[index];
             Matcher matcher = LTTngControlServiceConstants.PROVIDER_EVENT_PATTERN.matcher(line);
             if (matcher.matches()) {
-                // sched_kthread_stop (loglevel: TRACE_EMERG0) (type:
-                // tracepoint)
-                IBaseEventInfo eventInfo = new BaseEventInfo(matcher.group(1).trim());
+                // sched_kthread_stop (loglevel: TRACE_EMERG0) (type: tracepoint)
+                eventInfo = new BaseEventInfo(matcher.group(1).trim());
                 eventInfo.setLogLevel(matcher.group(2).trim());
                 eventInfo.setEventType(matcher.group(3).trim());
                 events.add(eventInfo);
+                index++;
+            } else if (LTTngControlServiceConstants.EVENT_FIELD_PATTERN.matcher(line).matches()) {
+                if (eventInfo != null) {
+                    List<IFieldInfo> fields = new ArrayList<IFieldInfo>();
+                    index = getFieldInfo(output, index, fields);
+                    eventInfo.setFields(fields);
+                } else {
+                    index++;
+                }
+            }
+            else if (LTTngControlServiceConstants.UST_PROVIDER_PATTERN.matcher(line).matches()) {
+                return index;
+            } else {
+                index++;
+            }
+        }
+        return index;
+    }
+
+
+    protected int getFieldInfo(String[] output, int currentIndex, List<IFieldInfo> fields) {
+        int index = currentIndex;
+        IFieldInfo fieldInfo = null;
+        while (index < output.length) {
+            String line = output[index];
+            Matcher matcher = LTTngControlServiceConstants.EVENT_FIELD_PATTERN.matcher(line);
+            if (matcher.matches()) {
+                // field: content (string)
+                fieldInfo = new FieldInfo(matcher.group(2).trim());
+                fieldInfo.setFieldType(matcher.group(3).trim());
+                fields.add(fieldInfo);
+            } else if (LTTngControlServiceConstants.PROVIDER_EVENT_PATTERN.matcher(line).matches()) {
+                return index;
             } else if (LTTngControlServiceConstants.UST_PROVIDER_PATTERN.matcher(line).matches()) {
                 return index;
             }
@@ -1096,6 +1171,8 @@ public class LTTngControlService implements ILttngControlService {
         return index;
     }
 
+
+
     /**
      * Formats a command parameter for the command execution i.e. adds quotes
      * at the beginning and end if necessary.
index d73ca76e4b223a752568d0024d49821cda04651d..81b01b7cbd8a9cc4388ea67c98f9703e671b8745 100644 (file)
@@ -193,6 +193,15 @@ public class LTTngControlServiceConstants {
      * Command line option for printing the help of a specif command
      */
     public final static String OPTION_HELP = " -h ";  //$NON-NLS-1$
+    /**
+     * Command line option for listing the fields of UST tracepoints
+     */
+    public final static String OPTION_FIELDS = " -f "; //$NON-NLS-1$
+    /**
+     * Command line option for configuring event's filter
+     */
+    public final static String OPTION_FILTER = " --filter "; //$NON-NLS-1$
+
 
     // ------------------------------------------------------------------------
     // Parsing constants
@@ -244,11 +253,11 @@ public class LTTngControlServiceConstants {
     /**
      * Pattern to match for event information (lttng list <session>)
      */
-    public final static Pattern EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
+    public final static Pattern EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\]\\s*(\\[.*\\]){0,1}.*"); //$NON-NLS-1$
     /**
      * Pattern to match a wildcarded event information (lttng list <session>)
      */
-    public final static Pattern WILDCARD_EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\].*"); //$NON-NLS-1$
+    public final static Pattern WILDCARD_EVENT_PATTERN = Pattern.compile("\\s+(.*)\\s+\\(type:\\s+(.*)\\)\\s+\\[(enabled|disabled)\\]\\s*(\\[.*\\]){0,1}.*"); //$NON-NLS-1$
     /**
      * Pattern to match a probe address information (lttng list <session>)
      */
@@ -293,6 +302,11 @@ public class LTTngControlServiceConstants {
      * Pattern to match for provider information (lttng list -k/-u)
      */
     public final static Pattern PROVIDER_EVENT_PATTERN = Pattern.compile("\\s*(.*)\\s+\\(loglevel:\\s+(.*)\\s+\\(\\d*\\)\\)\\s+\\(type:\\s+(.*)\\)"); //$NON-NLS-1$
+    /**
+     * Pattern to match event fields
+     */
+    //                                                                 field: content (string)
+    public final static Pattern EVENT_FIELD_PATTERN = Pattern.compile("\\s*(field:)\\s+(.*)\\s+\\((.*)\\)"); //$NON-NLS-1$
     /**
      * Pattern to match for UST provider information (lttng list -u)
      */
This page took 0.108046 seconds and 5 git commands to generate.