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);
**********************************************************************/
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>.
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]);
+ }
}
/**
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.
--- /dev/null
+/**********************************************************************
+ * 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
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;
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;
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;
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);
return fProbeEventInfo2;
}
+ public IFieldInfo getFieldInfo1() {
+ return fFieldInfo1;
+ }
+
+ public IFieldInfo getFieldInfo2() {
+ return fFieldInfo2;
+ }
}
*/
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);
}
// ------------------------------------------------------------------------
/**********************************************************************
* 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 {
* @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);
+
}
--- /dev/null
+/**********************************************************************
+ * 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);
+}
/**********************************************************************
* 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 {
* 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
// ------------------------------------------------------------------------
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;
}
// ------------------------------------------------------------------------
} 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;
}
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) {
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)
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
--- /dev/null
+/**********************************************************************
+ * 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
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);
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)
// ------------------------------------------------------------------------
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
//-------------------------------------------------------------------------
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;
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";
}
}
+ 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);
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());
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());
private String fLogLevelEventName;
private TraceLogLevel fLogLevel;
private LogLevelType fLogLevelType;
+ private String fFilter;
List<String> fNames = new ArrayList<String>();
// ------------------------------------------------------------------------
fNames = names;
}
+ public void setFilterExpression(String filter) {
+ fFilter = filter;
+ }
+
@Override
public boolean isTracepoints() {
return fIsTracePoints;
public int open() {
return 0;
}
+
+ @Override
+ public String getFilterExpression() {
+ return fFilter;
+ }
+
}
\ No newline at end of file
/**********************************************************************
* 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;
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];
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;
+ }
}
</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>
####################################################################
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>
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
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>
</COMMAND_OUTPUT>
<COMMAND_INPUT>
-lttng list -u
+lttng list -u -f
</COMMAND_INPUT>
<COMMAND_RESULT>
0
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>
}
}
+ /*
+ * (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
// ------------------------------------------------------------------------
* 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.
* The actual selected log level.
*/
private TraceLogLevel fLogLevel;
+ /**
+ * The filter expression
+ */
+ private String fFilterExpression;
// ------------------------------------------------------------------------
// Constructors
return fLogLevelEventName;
}
+ /*
+ * (non-Javadoc)
+ * @see org.eclipse.linuxtools.internal.lttng2.ui.views.control.dialogs.IEnableUstEvents#getFilterExpression()
+ */
+ @Override
+ public String getFilterExpression() {
+ return fFilterExpression;
+ }
+
// ------------------------------------------------------------------------
// Operations
// ------------------------------------------------------------------------
// Log Level Group
createLogLevelGroup();
+ // Filter Group
+ createFilterGroup();
+
// Set default enablements
setEnablements(GroupEnum.TRACEPOINTS);
}
fLogLevel = levels[id];
}
- // initialize wildcard with the event name string
+ // initialize wildcard with null
fWildcard = null;
if (fIsWildcard) {
String tempWildcard = fWildcardText.getText();
}
}
+ // 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;
}
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.
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>
* The channel combo box.
*/
private CCombo fChannelsCombo = null;
+ /**
+ * The filter text
+ */
+ private Text fFilterText;
/**
* The list of available sessions.
*/
* List of available channels of the selected session.
*/
private TraceChannelComponent[] fChannels;
+ /**
+ * The filter expression
+ */
+ private String fFilterExpression;
// ------------------------------------------------------------------------
// Constructors
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
}
});
+ // 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;
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();
}
}
/**********************************************************************
* 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;
* <p>
* Interface for providing information about UST events to be enabled.
* </p>
- *
+ *
* @author Bernd Hufmann
*/
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.
*/
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();
* @return a log level type (loglevel or loglevel-only)
*/
public LogLevelType getLogLevelType();
-
+
/**
* @return a log level
*/
* @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
/**********************************************************************
* 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;
* <p>
* Interface for a dialog box for collecting information about the events to enable.
* </p>
- *
+ *
* @author Bernd Hufmann
*/
public interface IGetEventInfoDialog {
-
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
* @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
// ------------------------------------------------------------------------
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) {
* - 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.
* - 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
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);
}
}
}
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) {
// ------------------------------------------------------------------------
/*
* (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);
}
}
/*
* (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);
}
}
// ------------------------------------------------------------------------
/*
* (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);
}
/*
* (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);
}
}
// ------------------------------------------------------------------------
/*
* (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);
}
/*
/*
* (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)
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;
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;
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
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
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;
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)
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
// ------------------------------------------------------------------------
* 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);
}
/**
* - 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());
}
/**
* - 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);
}
/**
public void enableEvents(List<String> eventNames, IProgressMonitor monitor)
throws ExecutionException {
getControlService().enableEvents(getSessionName(), null, eventNames,
- isKernel(), monitor);
+ isKernel(), null, monitor);
}
/**
* - 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());
}
* - 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);
}
/**
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)
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();
+ }
}
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
// ------------------------------------------------------------------------
* - 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());
}
/**
* - 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);
}
/**
* - 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());
}
* - 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);
}
/**
* 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.
*/
* 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
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()]);
}
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;
}
* 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.
*/
* 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
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()]);
}
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;
}
*/
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.
*
* 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.
*
* - a log level type
* @param level
* - a log level
+ * @param filterExpression
+ * - a filter expression
* @param monitor
* - a progress monitor
* @throws ExecutionException
*/
public void enableLogLevel(String sessionName, String channelName,
String eventName, LogLevelType logLevelType, TraceLogLevel level,
+ String filterExpression,
IProgressMonitor monitor) throws ExecutionException;
/**
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;
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;
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>
*/
public class LTTngControlService implements ILttngControlService {
-
// ------------------------------------------------------------------------
// Attributes
// ------------------------------------------------------------------------
/**
* The version string.
*/
- protected String fVersion = "Unknown"; //$NON-NLS-1$
+ protected Version fVersion = null;
// ------------------------------------------------------------------------
// Constructors
*/
@Override
public String getVersion() {
- return fVersion;
+ if (fVersion == null) {
+ return "Unknown"; //$NON-NLS-1$
+ }
+ return fVersion.toString();
}
/**
* @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
// ------------------------------------------------------------------------
// 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
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:
// -------------
//
// 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;
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++;
}
/*
* (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);
command.append(LTTngControlServiceConstants.OPTION_TRACEPOINT);
+ if (filterExpression != null) {
+ command.append(LTTngControlServiceConstants.OPTION_FILTER);
+ command.append('\'');
+ command.append(filterExpression);
+ command.append('\'');
+ }
+
executeCommand(command.toString(), monitor);
}
/*
* (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);
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)
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()) {
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());
*/
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;
}
return index;
}
+
+
/**
* Formats a command parameter for the command execution i.e. adds quotes
* at the beginning and end if necessary.
* 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
/**
* 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>)
*/
* 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)
*/