Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBernd Hufmann2013-03-21 16:11:06 +0000
committerBernd Hufmann2013-03-21 19:15:54 +0000
commit298e322ead45337650dd775363d2288a1a13816b (patch)
tree6d1a6cf205818a291842cf87c6c664c8525f50aa
parent62ae8c2f1a6b8dd2de6a857de8efde3b397c4f2f (diff)
downloadorg.eclipse.linuxtools-298e322ead45337650dd775363d2288a1a13816b.tar.gz
org.eclipse.linuxtools-298e322ead45337650dd775363d2288a1a13816b.tar.xz
org.eclipse.linuxtools-298e322ead45337650dd775363d2288a1a13816b.zip
tmf: Generalize the support for call sites and model URIs
The support for source code and model element look-up had been specific to CTF. This commit generalizes the implementation so that other trace extensions can use it. Change-Id: Iff663e85e22a69f48258a5057de15b3e10e76863 Signed-off-by: Bernd Hufmann <bhufmann@gmail.com> Reviewed-on: https://git.eclipse.org/r/11264 Tested-by: Hudson CI Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> IP-Clean: Patrick Tasse <patrick.tasse@gmail.com>
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java3
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java179
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF1
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfCallsite.java107
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java18
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java99
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfCallsite.java47
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfModelLookup.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfSourceLookup.java28
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/TmfCallsite.java150
-rw-r--r--lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java30
12 files changed, 661 insertions, 57 deletions
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
index f38b1a20cc..013c2d59c9 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/AllTests.java
@@ -29,7 +29,8 @@ import org.junit.runners.Suite;
TmfSimpleTimestampTest.class,
TmfTimeRangeTest.class,
TmfTimestampDeltaTest.class,
- TmfTimestampTest.class
+ TmfTimestampTest.class,
+ org.eclipse.linuxtools.tmf.core.tests.event.lookup.AllTests.class
})
public class AllTests {
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java
new file mode 100644
index 0000000000..2db2ab1c80
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/AllTests.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.tmf.core.tests.event.lookup;
+
+import org.eclipse.linuxtools.tmf.core.tests.event.lookup.TmfCallsiteTest;
+import org.junit.runner.RunWith;
+import org.junit.runners.Suite;
+
+/**
+ * Test suite for org.eclipse.linuxtools.tmf.core.event.lookup
+ */
+@RunWith(Suite.class)
+@Suite.SuiteClasses({
+ TmfCallsiteTest.class
+})
+public class AllTests {
+
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java
new file mode 100644
index 0000000000..2839784745
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core.tests/src/org/eclipse/linuxtools/tmf/core/tests/event/lookup/TmfCallsiteTest.java
@@ -0,0 +1,179 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.tmf.core.tests.event.lookup;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
+
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfCallsite;
+import org.eclipse.linuxtools.tmf.core.event.lookup.TmfCallsite;
+import org.junit.Test;
+
+/**
+ * Test suite for the TmfCallsite class.
+ */
+@SuppressWarnings("javadoc")
+public class TmfCallsiteTest {
+
+ // ------------------------------------------------------------------------
+ // Variables
+ // ------------------------------------------------------------------------
+ private final static String fFileName1 = "filename1";
+ private final static String fFunctionName1 = "func1";
+ private final static long fLine1 = 10;
+
+ private final static String fFileName2 = "filename2";
+ private final static String fFunctionName2 = "func2";
+ private final static long fLine2 = 25;
+
+ private final static String fFileName3 = "filename3";
+ private final static String fFunctionName3 = null;
+ private final static long fLine3 = 123;
+
+ private final static ITmfCallsite fCallsite1 = new TmfCallsite(fFileName1, fFunctionName1, fLine1);
+ private final static ITmfCallsite fCallsite2 = new TmfCallsite(fFileName2, fFunctionName2, fLine2);
+ private final static ITmfCallsite fCallsite3 = new TmfCallsite(fFileName3, fFunctionName3, fLine3);
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testDefaultConstructor() {
+ assertEquals(fFileName1, fCallsite1.getFileName());
+ assertEquals(fFunctionName1, fCallsite1.getFunctionName());
+ assertEquals(fLine1, fCallsite1.getLineNumber());
+ }
+
+ @Test
+ public void testCallsiteCopy() {
+ TmfCallsite copy = new TmfCallsite(fCallsite1);
+
+ assertEquals(fFileName1, copy.getFileName());
+ assertEquals(fFunctionName1, copy.getFunctionName());
+ assertEquals(fLine1, copy.getLineNumber());
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testCallsiteCopy2() {
+ new TmfCallsite(null);
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testCallsiteCopy3() {
+ new TmfCallsite(new ITmfCallsite() {
+ @Override
+ public long getLineNumber() {
+ return 0;
+ }
+
+ @Override
+ public String getFunctionName() {
+ return null;
+ }
+
+ @Override
+ public String getFileName() {
+ return null;
+ }
+ });
+ }
+
+ @Test(expected=IllegalArgumentException.class)
+ public void testCallsiteFileNull() {
+ new TmfCallsite(null, fFunctionName1, fLine1);
+ }
+
+ // ------------------------------------------------------------------------
+ // hashCode
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testHashCode() {
+ final ITmfCallsite callsite1b = new TmfCallsite(fCallsite1);
+ final ITmfCallsite callsite2b = new TmfCallsite(fCallsite2);
+
+ assertTrue("hashCode", fCallsite1.hashCode() == callsite1b.hashCode());
+ assertTrue("hashCode", fCallsite2.hashCode() == callsite2b.hashCode());
+
+ assertTrue("hashCode", fCallsite1.hashCode() != fCallsite2.hashCode());
+ assertTrue("hashCode", fCallsite2.hashCode() != fCallsite1.hashCode());
+ }
+
+ // ------------------------------------------------------------------------
+ // equals
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testEqualsReflexivity() {
+ assertTrue("equals", fCallsite1.equals(fCallsite1));
+ assertTrue("equals", fCallsite2.equals(fCallsite2));
+
+ assertFalse("equals", fCallsite1.equals(fCallsite2));
+ assertFalse("equals", fCallsite2.equals(fCallsite1));
+ }
+
+ @Test
+ public void testEqualsSymmetry() {
+ final ITmfCallsite callsite1 = new TmfCallsite(fCallsite1);
+ final ITmfCallsite callsite2 = new TmfCallsite(fCallsite2);
+
+ assertTrue("equals", callsite1.equals(fCallsite1));
+ assertTrue("equals", fCallsite1.equals(callsite1));
+
+ assertTrue("equals", callsite2.equals(fCallsite2));
+ assertTrue("equals", fCallsite2.equals(callsite2));
+ }
+
+ @Test
+ public void testEqualsTransivity() {
+ final ITmfCallsite callsite1 = new TmfCallsite(fCallsite1);
+ final ITmfCallsite callsite2 = new TmfCallsite(fCallsite1);
+ final ITmfCallsite callsite3 = new TmfCallsite(fCallsite1);
+
+ assertTrue("equals", callsite1.equals(callsite2));
+ assertTrue("equals", callsite2.equals(callsite3));
+ assertTrue("equals", callsite1.equals(callsite3));
+ }
+
+ @Test
+ public void testEqualsNull() {
+ assertFalse("equals", fCallsite1.equals(null));
+ assertFalse("equals", fCallsite2.equals(null));
+ assertFalse("equals", fCallsite3.equals(null));
+ }
+
+ @Test
+ public void testNonEqualClasses() {
+ assertFalse("equals", fCallsite1.equals(fCallsite1.getFileName()));
+ }
+
+ @Test
+ public void testNullElements() {
+ ITmfCallsite callsite = new TmfCallsite(fFileName1, null, fLine1);
+ assertFalse("equals", fCallsite1.equals(callsite));
+ assertFalse("equals", callsite.equals(fCallsite1));
+ }
+
+ // ------------------------------------------------------------------------
+ // toString
+ // ------------------------------------------------------------------------
+
+ @Test
+ public void testToString() {
+ assertEquals("toString", "filename1:10 func1()", fCallsite1.toString());
+ assertEquals("toString", "filename2:25 func2()", fCallsite2.toString());
+ assertEquals("toString", "filename3:123", fCallsite3.toString());
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF b/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
index 0f3f649a7a..aef3ccd9e7 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
+++ b/lttng/org.eclipse.linuxtools.tmf.core/META-INF/MANIFEST.MF
@@ -24,6 +24,7 @@ Export-Package: org.eclipse.linuxtools.internal.tmf.core;x-friends:="org.eclipse
org.eclipse.linuxtools.tmf.core.component,
org.eclipse.linuxtools.tmf.core.ctfadaptor,
org.eclipse.linuxtools.tmf.core.event,
+ org.eclipse.linuxtools.tmf.core.event.lookup,
org.eclipse.linuxtools.tmf.core.exceptions,
org.eclipse.linuxtools.tmf.core.filter,
org.eclipse.linuxtools.tmf.core.filter.model,
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfCallsite.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfCallsite.java
index e073984cc4..d929d6b3c8 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfCallsite.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfCallsite.java
@@ -8,70 +8,109 @@
*
* Contributors:
* Patrick Tasse - Initial API and implementation
+ * Bernd Hufmann - Updated for new parent class
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
import org.eclipse.linuxtools.ctf.core.event.CTFCallsite;
+import org.eclipse.linuxtools.tmf.core.event.lookup.TmfCallsite;
/**
- * Callsite information
+ * CTF TMF call site information for source code lookup.
+ *
+ * @author Patrick Tasse
* @since 2.0
*/
-public class CtfTmfCallsite {
+public class CtfTmfCallsite extends TmfCallsite {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /** The event name. */
+ final private String fEventName;
+
+ /** The instruction pointer. */
+ final private long fInstructionPointer;
- private String eventName;
- private String fileName;
- private String functionName;
- private long lineNumber;
- private long ip;
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+ /**
+ * Standard Constructor.
+ *
+ * @param callsite
+ * - a CTF call site
+ */
CtfTmfCallsite(CTFCallsite callsite) {
- eventName = callsite.getEventName();
- fileName = callsite.getFileName();
- functionName = callsite.getFunctionName();
- lineNumber = callsite.getLineNumber();
- ip = callsite.getIp();
+ super(callsite.getFileName(), callsite.getFunctionName(), callsite.getLineNumber());
+ fEventName = callsite.getEventName();
+ fInstructionPointer = callsite.getIp();
}
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
/**
+ * Returns the event name of the call site.
* @return the event name
*/
public String getEventName() {
- return eventName;
+ return fEventName;
}
/**
- * @return the file name
+ * Returns the instruction pointer of the call site.
+ * @return the instruction pointer
*/
- public String getFileName() {
- return fileName;
+ public long getIntructionPointer() {
+ return fInstructionPointer;
}
- /**
- * @return the function name
- */
- public String getFunctionName() {
- return functionName;
- }
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
- /**
- * @return the line number
- */
- public long getLineNumber() {
- return lineNumber;
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = super.hashCode();
+ result = prime * result + ((fEventName == null) ? 0 : fEventName.hashCode());
+ result = prime * result + (int) (fInstructionPointer ^ (fInstructionPointer >>> 32));
+ return result;
}
- /**
- * @return the ip
- */
- public long getIp() {
- return ip;
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (!super.equals(obj)) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ CtfTmfCallsite other = (CtfTmfCallsite) obj;
+ if (fEventName == null) {
+ if (other.fEventName != null) {
+ return false;
+ }
+ } else if (!fEventName.equals(other.fEventName)) {
+ return false;
+ }
+ if (fInstructionPointer != other.fInstructionPointer) {
+ return false;
+ }
+ return true;
}
@Override
public String toString() {
- return eventName + "@0x" + Long.toHexString(ip) + ": " + //$NON-NLS-1$ //$NON-NLS-2$
- fileName + ':' + Long.toString(lineNumber) + ' ' + functionName + "()"; //$NON-NLS-1$
+ return getEventName() + "@0x" + Long.toHexString(fInstructionPointer) + ": " + //$NON-NLS-1$ //$NON-NLS-2$
+ getFileName() + ':' + Long.toString(getLineNumber()) + ' ' + getFileName() + "()"; //$NON-NLS-1$
}
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
index 095f4d2613..2b8aff967e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/ctfadaptor/CtfTmfEvent.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Alexandre Montplaisir - Initial API and implementation
+ * Bernd Hufmann - Updated for source and model lookup interfaces
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.ctfadaptor;
@@ -22,6 +23,8 @@ import org.eclipse.linuxtools.tmf.core.event.ITmfEventType;
import org.eclipse.linuxtools.tmf.core.event.TmfEvent;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventPropertySource;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfModelLookup;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup;
import org.eclipse.linuxtools.tmf.core.trace.ITmfContext;
import org.eclipse.ui.views.properties.IPropertySource;
@@ -33,7 +36,7 @@ import org.eclipse.ui.views.properties.IPropertySource;
* @author Alexandre Montplaisir
* @since 2.0
*/
-public final class CtfTmfEvent extends TmfEvent {
+public final class CtfTmfEvent extends TmfEvent implements ITmfSourceLookup, ITmfModelLookup {
// ------------------------------------------------------------------------
// Constants
@@ -179,11 +182,12 @@ public final class CtfTmfEvent extends TmfEvent {
}
/**
- * Get the callsite for this event.
+ * Get the call site for this event.
*
- * @return the callsite information, or null if there is none
+ * @return the call site information, or null if there is none
* @since 2.0
*/
+ @Override
public CtfTmfCallsite getCallsite() {
CTFCallsite callsite = null;
if (getTrace() == null) {
@@ -209,6 +213,14 @@ public final class CtfTmfEvent extends TmfEvent {
* @since 2.0
*/
@Override
+ public String getModelUri() {
+ return getCustomAttribute(CtfConstants.MODEL_URI_KEY);
+ }
+
+ /**
+ * @since 2.0
+ */
+ @Override
public Object getAdapter(Class adapter) {
if (adapter == IPropertySource.class) {
return new TmfEventPropertySource(this);
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
index 1c9968c49a..47159083dc 100644
--- a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/TmfEventPropertySource.java
@@ -8,6 +8,7 @@
*
* Contributors:
* Patrick Tasse - Initial API and implementation
+ * Bernd Hufmann - Added call site and model URI properties
*******************************************************************************/
package org.eclipse.linuxtools.tmf.core.event;
@@ -15,6 +16,8 @@ package org.eclipse.linuxtools.tmf.core.event;
import java.util.ArrayList;
import java.util.List;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfModelLookup;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup;
import org.eclipse.linuxtools.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.ui.views.properties.IPropertyDescriptor;
import org.eclipse.ui.views.properties.IPropertySource;
@@ -32,11 +35,17 @@ public class TmfEventPropertySource implements IPropertySource {
private static final String ID_TYPE = "event_type"; //$NON-NLS-1$
private static final String ID_REFERENCE = "event_reference"; //$NON-NLS-1$
private static final String ID_CONTENT = "event_content"; //$NON-NLS-1$
+ private static final String ID_SOURCE_LOOKUP = "event_lookup"; //$NON-NLS-1$
+ private static final String ID_MODEL_URI = "model_uri"; //$NON-NLS-1$
+
private static final String NAME_TIMESTAMP = "Timestamp"; //$NON-NLS-1$
private static final String NAME_SOURCE = "Source"; //$NON-NLS-1$
private static final String NAME_TYPE = "Type"; //$NON-NLS-1$
private static final String NAME_REFERENCE = "Reference"; //$NON-NLS-1$
private static final String NAME_CONTENT = "Content"; //$NON-NLS-1$
+ private static final String NAME_SOURCE_LOOKUP = "Call Site"; //$NON-NLS-1$
+ private static final String NAME_MODEL_URI = "Model URI"; //$NON-NLS-1$
+
private ITmfEvent fEvent;
@@ -140,6 +149,72 @@ public class TmfEventPropertySource implements IPropertySource {
}
}
+ private class SourceLookupPropertySource implements IPropertySource {
+
+ private static final String ID_FILE_NAME = "callsite_file"; //$NON-NLS-1$
+ private static final String ID_FUNCTION_NAME = "callsite_function"; //$NON-NLS-1$
+ private static final String ID_LINE_NUMBER = "callsite_line"; //$NON-NLS-1$
+
+ private static final String NAME_FILE_NAME = "File"; //$NON-NLS-1$
+ private static final String NAME_FUNCTION_NAME = "Function"; //$NON-NLS-1$
+ private static final String NAME_LINE_NUMBER = "Line"; //$NON-NLS-1$
+
+ final private ITmfSourceLookup fSourceLookup;
+
+ public SourceLookupPropertySource(ITmfSourceLookup lookup) {
+ fSourceLookup = lookup;
+ }
+
+ @Override
+ public Object getEditableValue() {
+ if (fSourceLookup.getCallsite() != null) {
+ return fSourceLookup.getCallsite().toString();
+ }
+ return null;
+ }
+
+ @Override
+ public IPropertyDescriptor[] getPropertyDescriptors() {
+ List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
+ if (fSourceLookup.getCallsite() != null) {
+ descriptors.add(new PropertyDescriptor(ID_FILE_NAME, NAME_FILE_NAME));
+ descriptors.add(new PropertyDescriptor(ID_LINE_NUMBER, NAME_LINE_NUMBER));
+ // only display function if available
+ if (fSourceLookup.getCallsite().getFunctionName() != null) {
+ descriptors.add(new PropertyDescriptor(ID_FUNCTION_NAME, NAME_FUNCTION_NAME));
+ }
+ }
+ return descriptors.toArray(new IPropertyDescriptor[0]);
+ }
+
+ @Override
+ public Object getPropertyValue(Object id) {
+ if (id.equals(ID_FILE_NAME)) {
+ return fSourceLookup.getCallsite().getFileName();
+ } else if (id.equals(ID_FUNCTION_NAME)) {
+ return fSourceLookup.getCallsite().getFunctionName();
+ } else if (id.equals(ID_LINE_NUMBER)) {
+ return Long.valueOf(fSourceLookup.getCallsite().getLineNumber());
+ }
+ return null;
+ }
+
+ @Override
+ public boolean isPropertySet(Object id) {
+ return false;
+ }
+
+ @Override
+ public void resetPropertyValue(Object id) {
+
+ }
+
+ @Override
+ public void setPropertyValue(Object id, Object value) {
+ }
+ }
+
+
/**
* Default constructor
*
@@ -157,13 +232,19 @@ public class TmfEventPropertySource implements IPropertySource {
@Override
public IPropertyDescriptor[] getPropertyDescriptors() {
- IPropertyDescriptor[] descriptors = new IPropertyDescriptor[5];
- descriptors[0] = new PropertyDescriptor(ID_TIMESTAMP, NAME_TIMESTAMP);
- descriptors[1] = new PropertyDescriptor(ID_SOURCE, NAME_SOURCE);
- descriptors[2] = new PropertyDescriptor(ID_TYPE, NAME_TYPE);
- descriptors[3] = new PropertyDescriptor(ID_REFERENCE, NAME_REFERENCE);
- descriptors[4] = new PropertyDescriptor(ID_CONTENT, NAME_CONTENT);
- return descriptors;
+ List<IPropertyDescriptor> descriptors= new ArrayList<IPropertyDescriptor>();
+ descriptors.add(new PropertyDescriptor(ID_TIMESTAMP, NAME_TIMESTAMP));
+ descriptors.add(new PropertyDescriptor(ID_SOURCE, NAME_SOURCE));
+ descriptors.add(new PropertyDescriptor(ID_TYPE, NAME_TYPE));
+ descriptors.add(new PropertyDescriptor(ID_REFERENCE, NAME_REFERENCE));
+ if ((fEvent instanceof ITmfSourceLookup) && (((ITmfSourceLookup)fEvent).getCallsite() != null)) {
+ descriptors.add(new PropertyDescriptor(ID_SOURCE_LOOKUP, NAME_SOURCE_LOOKUP));
+ }
+ if ((fEvent instanceof ITmfModelLookup) && (((ITmfModelLookup)fEvent).getModelUri() != null)) {
+ descriptors.add(new PropertyDescriptor(ID_MODEL_URI, NAME_MODEL_URI));
+ }
+ descriptors.add(new PropertyDescriptor(ID_CONTENT, NAME_CONTENT));
+ return descriptors.toArray(new IPropertyDescriptor[0]);
}
@Override
@@ -176,6 +257,10 @@ public class TmfEventPropertySource implements IPropertySource {
return fEvent.getType().toString();
} else if (id.equals(ID_REFERENCE) && fEvent.getReference() != null) {
return fEvent.getReference().toString();
+ } else if (id.equals(ID_MODEL_URI)) {
+ return ((ITmfModelLookup)fEvent).getModelUri();
+ } else if (id.equals(ID_SOURCE_LOOKUP)) {
+ return new SourceLookupPropertySource(((ITmfSourceLookup)fEvent));
} else if (id.equals(ID_CONTENT) && fEvent.getContent() != null) {
return new ContentPropertySource(fEvent.getContent());
}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfCallsite.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfCallsite.java
new file mode 100644
index 0000000000..95ef5ff6a9
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfCallsite.java
@@ -0,0 +1,47 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.tmf.core.event.lookup;
+
+
+/**
+ * The generic call site structure in TMF. A call site has:
+ * <ul>
+ * <li> a file name
+ * <li> a function name (optional)
+ * <li> a line number
+ * </ul>
+ *
+ * @author Bernd Hufmann
+ * @since 2.0
+ *
+ * @see TmfCallsite
+ */
+public interface ITmfCallsite {
+ /**
+ * Returns the file name of the call site.
+ * @return the file name
+ */
+ public String getFileName();
+
+ /**
+ * Returns the function name of the call site.
+ * @return the function name or null
+ */
+ public String getFunctionName();
+
+ /**
+ * Returns the line number of the call site.
+ * @return the line number
+ */
+ public long getLineNumber();
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfModelLookup.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfModelLookup.java
new file mode 100644
index 0000000000..b5dbf08583
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfModelLookup.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.tmf.core.event.lookup;
+
+
+/**
+ * Interface for events to implement to provide information for model element lookup.
+ *
+ * @author Bernd Hufmann
+ * @since 2.0
+ */
+public interface ITmfModelLookup {
+ /**
+ * Returns a model URI string.
+ *
+ * @return a model URI string.
+ */
+ public String getModelUri();
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfSourceLookup.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfSourceLookup.java
new file mode 100644
index 0000000000..c3daac9a46
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/ITmfSourceLookup.java
@@ -0,0 +1,28 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.tmf.core.event.lookup;
+
+
+/**
+ * Interface for events to implement to provide information for source lookup.
+ *
+ * @author Bernd Hufmann
+ * @since 2.0
+ */
+public interface ITmfSourceLookup {
+ /**
+ * Returns a call site instance.
+ *
+ * @return a call site instance.
+ */
+ public ITmfCallsite getCallsite();
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/TmfCallsite.java b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/TmfCallsite.java
new file mode 100644
index 0000000000..ca02084663
--- /dev/null
+++ b/lttng/org.eclipse.linuxtools.tmf.core/src/org/eclipse/linuxtools/tmf/core/event/lookup/TmfCallsite.java
@@ -0,0 +1,150 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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.tmf.core.event.lookup;
+
+
+/**
+ * TMF call site information for source code lookup.
+ *
+ * @since 2.0
+ * @author Bernd Hufmann
+ */
+public class TmfCallsite implements ITmfCallsite {
+
+ // ------------------------------------------------------------------------
+ // Attributes
+ // ------------------------------------------------------------------------
+
+ /** The file name string. */
+ final private String fFileName;
+
+ /** The function name. */
+ final private String fFunctionName;
+
+ /** The line number. */
+ final private long fLineNumber;
+
+ // ------------------------------------------------------------------------
+ // Constructors
+ // ------------------------------------------------------------------------
+
+ /**
+ * Default constructor.
+ *
+ * @param fileName
+ * - a file name
+ * @param functionName
+ * - a function name
+ * @param lineNumber
+ * - a line number
+ */
+ public TmfCallsite(String fileName, String functionName, long lineNumber) {
+ if (fileName == null) {
+ throw new IllegalArgumentException();
+ }
+ fFileName = fileName;
+ fFunctionName = functionName;
+ fLineNumber = lineNumber;
+ }
+
+ /**
+ * Copy Constructor.
+ *
+ * @param other
+ * - An other call site implementation
+ */
+ public TmfCallsite(ITmfCallsite other) {
+ if ((other == null) || (other.getFileName() == null)) {
+ throw new IllegalArgumentException();
+ }
+ fFileName = other.getFileName();
+ fFunctionName = other.getFunctionName();
+ fLineNumber = other.getLineNumber();
+ }
+
+ // ------------------------------------------------------------------------
+ // Accessors
+ // ------------------------------------------------------------------------
+
+ @Override
+ public String getFileName() {
+ return fFileName;
+ }
+
+ @Override
+ public String getFunctionName() {
+ return fFunctionName;
+ }
+
+ @Override
+ public long getLineNumber() {
+ return fLineNumber;
+ }
+
+ // ------------------------------------------------------------------------
+ // Operations
+ // ------------------------------------------------------------------------
+
+ @Override
+ public int hashCode() {
+ final int prime = 31;
+ int result = 1;
+ result = prime * result + fFileName.hashCode(); // fFileName cannot be null
+ result = prime * result + ((fFunctionName == null) ? 0 : fFunctionName.hashCode());
+ result = prime * result + (int) (fLineNumber ^ (fLineNumber >>> 32));
+ return result;
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
+ }
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ TmfCallsite other = (TmfCallsite) obj;
+
+ // fFileName cannot be null!
+ if (!fFileName.equals(other.fFileName)) {
+ return false;
+ }
+
+ if (fFunctionName == null) {
+ if (other.fFunctionName != null) {
+ return false;
+ }
+ } else if (!fFunctionName.equals(other.fFunctionName)) {
+ return false;
+ }
+ if (fLineNumber != other.fLineNumber) {
+ return false;
+ }
+ return true;
+ }
+
+ @Override
+ public String toString() {
+ StringBuilder builder = new StringBuilder();
+ builder.append(fFileName).append(':');
+ builder.append(Long.toString(fLineNumber));
+ if (fFunctionName != null) {
+ builder.append(' ');
+ builder.append(fFunctionName).append("()"); //$NON-NLS-1$
+ }
+ return builder.toString();
+ }
+}
diff --git a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
index 0c377277fa..e262b5e62e 100644
--- a/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
+++ b/lttng/org.eclipse.linuxtools.tmf.ui/src/org/eclipse/linuxtools/tmf/ui/viewers/events/TmfEventsTable.java
@@ -12,6 +12,7 @@
* Francois Chouinard - Replaced Table by TmfVirtualTable
* Patrick Tasse - Filter implementation (inspired by www.eclipse.org/mat)
* Ansgar Radermacher - Support navigation to model URIs (Bug 396956)
+ * Bernd Hufmann - Updated call site and model URI implementation
*******************************************************************************/
package org.eclipse.linuxtools.tmf.ui.viewers.events;
@@ -67,12 +68,12 @@ import org.eclipse.linuxtools.internal.tmf.ui.Messages;
import org.eclipse.linuxtools.internal.tmf.ui.dialogs.MultiLineInputDialog;
import org.eclipse.linuxtools.tmf.core.component.ITmfDataProvider;
import org.eclipse.linuxtools.tmf.core.component.TmfComponent;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfConstants;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfCallsite;
-import org.eclipse.linuxtools.tmf.core.ctfadaptor.CtfTmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEvent;
import org.eclipse.linuxtools.tmf.core.event.ITmfEventField;
import org.eclipse.linuxtools.tmf.core.event.TmfEventField;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfCallsite;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfModelLookup;
+import org.eclipse.linuxtools.tmf.core.event.lookup.ITmfSourceLookup;
import org.eclipse.linuxtools.tmf.core.filter.ITmfFilter;
import org.eclipse.linuxtools.tmf.core.filter.model.ITmfFilterTreeNode;
import org.eclipse.linuxtools.tmf.core.filter.model.TmfFilterAndNode;
@@ -594,9 +595,9 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
final TableItem item = items[0];
final Object data = item.getData();
- if (data instanceof CtfTmfEvent) {
- CtfTmfEvent event = (CtfTmfEvent) data;
- CtfTmfCallsite cs = event.getCallsite();
+ if (data instanceof ITmfSourceLookup) {
+ ITmfSourceLookup event = (ITmfSourceLookup) data;
+ ITmfCallsite cs = event.getCallsite();
if (cs == null || cs.getFileName() == null) {
return;
}
@@ -665,8 +666,8 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
final TableItem item = items[0];
final Object eventData = item.getData();
- if (eventData instanceof CtfTmfEvent) {
- String modelURI = ((CtfTmfEvent) eventData).getCustomAttribute(CtfConstants.MODEL_URI_KEY);
+ if (eventData instanceof ITmfModelLookup) {
+ String modelURI = ((ITmfModelLookup) eventData).getModelUri();
if (modelURI != null) {
IWorkbenchPage activePage = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
@@ -792,17 +793,22 @@ public class TmfEventsTable extends TmfComponent implements IGotoMarker, IColorS
if (item != null) {
final Object data = item.getData();
- if (data instanceof CtfTmfEvent) {
- Separator separator = null;
- CtfTmfEvent event = (CtfTmfEvent) data;
+ Separator separator = null;
+ if (data instanceof ITmfSourceLookup) {
+ ITmfSourceLookup event = (ITmfSourceLookup) data;
if (event.getCallsite() != null) {
tablePopupMenu.add(openCallsiteAction);
separator = new Separator();
}
- if (event.listCustomAttributes().contains(CtfConstants.MODEL_URI_KEY)) {
+ }
+
+ if (data instanceof ITmfModelLookup) {
+ ITmfModelLookup event = (ITmfModelLookup) data;
+ if (event.getModelUri() != null) {
tablePopupMenu.add(openModelAction);
separator = new Separator();
}
+
if (separator != null) {
tablePopupMenu.add(separator);
}

Back to the top