Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthew Khouzam2019-06-19 16:17:25 -0400
committerPatrick Tasse2019-07-04 16:42:15 -0400
commit702a98e185b0dc578559e93be2a4152606266e43 (patch)
tree67bf1ceb59b3bd4741f0a17a0de1086598bffbaf
parent1edbecf2c3f1c7ce25cdd392a8c7a65b09dac147 (diff)
downloadorg.eclipse.tracecompass-702a98e185b0dc578559e93be2a4152606266e43.tar.gz
org.eclipse.tracecompass-702a98e185b0dc578559e93be2a4152606266e43.tar.xz
org.eclipse.tracecompass-702a98e185b0dc578559e93be2a4152606266e43.zip
tmf.ui: add notion of callsite aspects
This allows code lookup in the kernel. The location of the files is known, so enable the user to load them. [Added] Default way to get callsites from events [Added] Source code lookup for Linux System Calls Change-Id: I80e6ad9d3d210b869f476836ff1042082f2f6890 Signed-off-by: Matthew Khouzam <matthew.khouzam@ericsson.com> Reviewed-on: https://git.eclipse.org/r/144492 Reviewed-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: Patrick Tasse <patrick.tasse@gmail.com> Tested-by: CI Bot
-rw-r--r--analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelUtils.java2
-rw-r--r--analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelCallsiteAspect.java88
-rw-r--r--ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java18
-rw-r--r--ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/lookup/CtfTmfCallsite.java16
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF1
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/Messages.java36
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/messages.properties15
-rw-r--r--tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfCallsiteAspect.java37
8 files changed, 211 insertions, 2 deletions
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelUtils.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelUtils.java
index 6fe16e9f25..f87e5eaa82 100644
--- a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelUtils.java
+++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/analysis/os/linux/core/kernel/KernelUtils.java
@@ -12,6 +12,7 @@ package org.eclipse.tracecompass.analysis.os.linux.core.kernel;
import java.util.Collection;
import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.ThreadPriorityAspect;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.KernelCallsiteAspect;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.KernelPidAspect;
import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
@@ -35,6 +36,7 @@ public final class KernelUtils {
builder.add(KernelTidAspect.INSTANCE);
builder.add(ThreadPriorityAspect.INSTANCE);
builder.add(KernelPidAspect.INSTANCE);
+ builder.add(KernelCallsiteAspect.getInstance());
KERNEL_ASPECTS = builder.build();
}
diff --git a/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelCallsiteAspect.java b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelCallsiteAspect.java
new file mode 100644
index 0000000000..86279d0e1e
--- /dev/null
+++ b/analysis/org.eclipse.tracecompass.analysis.os.linux.core/src/org/eclipse/tracecompass/internal/analysis/os/linux/core/kernel/KernelCallsiteAspect.java
@@ -0,0 +1,88 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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
+ ******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel;
+
+import java.util.Collections;
+import java.util.List;
+
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout;
+import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace;
+import org.eclipse.tracecompass.internal.analysis.os.linux.core.SyscallLookup;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCallsiteAspect;
+import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
+import org.eclipse.tracecompass.tmf.core.event.lookup.TmfCallsite;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+
+/**
+ * Get the source location of known trace points.
+ *
+ * @author Matthew Khouzam
+ */
+public final class KernelCallsiteAspect extends TmfCallsiteAspect {
+
+ private static @Nullable KernelCallsiteAspect sInstance = null;
+
+ /**
+ * Get the singleton instance
+ *
+ * @return the instance
+ */
+ public static KernelCallsiteAspect getInstance() {
+ KernelCallsiteAspect instance = sInstance;
+ if (instance == null) {
+ instance = new KernelCallsiteAspect();
+ sInstance = instance;
+ }
+ return instance;
+ }
+
+ private KernelCallsiteAspect() {
+ // do nothing
+ }
+
+ @Override
+ public @Nullable List<ITmfCallsite> resolve(ITmfEvent event) {
+ ITmfTrace trace = event.getTrace();
+ if (trace instanceof IKernelTrace) {
+ IKernelAnalysisEventLayout layout = ((IKernelTrace) trace).getKernelEventLayout();
+ String syscallName = truncateEntry(layout, event.getName());
+ if (syscallName == null) {
+ syscallName = truncateExit(layout, event.getName());
+ }
+ if (syscallName != null) {
+ String file = SyscallLookup.getInstance().getFile(syscallName);
+ if (!file.isEmpty()) {
+ return Collections.<ITmfCallsite> singletonList(new TmfCallsite(file, Long.valueOf(0)));
+ }
+ }
+ }
+ return null;
+ }
+
+ private static @Nullable String truncateEntry(IKernelAnalysisEventLayout layout, String syscallName) {
+ if (syscallName.startsWith(layout.eventCompatSyscallEntryPrefix())) {
+ return syscallName.substring(layout.eventCompatSyscallEntryPrefix().length());
+ } else if (syscallName.startsWith(layout.eventSyscallEntryPrefix())) {
+ return syscallName.substring(layout.eventSyscallEntryPrefix().length());
+ }
+ return null;
+ }
+
+ private static @Nullable String truncateExit(IKernelAnalysisEventLayout layout, String syscallName) {
+ if (syscallName.startsWith(layout.eventCompatSyscallExitPrefix())) {
+ return syscallName.substring(layout.eventCompatSyscallExitPrefix().length());
+ } else if (syscallName.startsWith(layout.eventSyscallExitPrefix())) {
+ return syscallName.substring(layout.eventSyscallExitPrefix().length());
+ }
+ return null;
+ }
+}
diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java
index 2c2d8ca7e1..db596a8ad5 100644
--- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java
+++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/CtfTmfEvent.java
@@ -34,6 +34,8 @@ import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventType;
import org.eclipse.tracecompass.tmf.core.event.TmfEvent;
import org.eclipse.tracecompass.tmf.core.event.TmfEventField;
+import org.eclipse.tracecompass.tmf.core.event.aspect.ITmfEventAspect;
+import org.eclipse.tracecompass.tmf.core.event.aspect.TmfCallsiteAspect;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfModelLookup;
import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfSourceLookup;
@@ -41,7 +43,6 @@ import org.eclipse.tracecompass.tmf.core.timestamp.ITmfTimestamp;
import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimestamp;
import org.eclipse.tracecompass.tmf.core.trace.ITmfContext;
import org.eclipse.tracecompass.tmf.ctf.core.CtfConstants;
-import org.eclipse.tracecompass.tmf.ctf.core.event.lookup.CtfTmfCallsite;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
/**
@@ -349,7 +350,7 @@ public class CtfTmfEvent extends TmfEvent
*/
@Override
public @Nullable ITmfCallsite getCallsite() {
- CtfTmfCallsite callsite = null;
+ ITmfCallsite callsite = null;
ITmfEventField ipField = getContent().getField(CtfConstants.CONTEXT_FIELD_PREFIX + CtfConstants.IP_KEY);
if (ipField != null && ipField.getValue() instanceof Long) {
@@ -363,6 +364,19 @@ public class CtfTmfEvent extends TmfEvent
return callsite;
}
+ @Override
+ public @Nullable List<@NonNull ITmfCallsite> getCallsites() {
+ for (ITmfEventAspect<?> aspect : getTrace().getEventAspects()) {
+ if (aspect instanceof TmfCallsiteAspect) {
+ List<ITmfCallsite> callsite = ((TmfCallsiteAspect) aspect).resolve(this);
+ if (callsite != null) {
+ return callsite;
+ }
+ }
+ }
+ return ITmfSourceLookup.super.getCallsites();
+ }
+
// ------------------------------------------------------------------------
// ITmfModelLookup
// ------------------------------------------------------------------------
diff --git a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/lookup/CtfTmfCallsite.java b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/lookup/CtfTmfCallsite.java
index 630c6030cc..9d0b095f4d 100644
--- a/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/lookup/CtfTmfCallsite.java
+++ b/ctf/org.eclipse.tracecompass.tmf.ctf.core/src/org/eclipse/tracecompass/tmf/ctf/core/event/lookup/CtfTmfCallsite.java
@@ -16,6 +16,7 @@ package org.eclipse.tracecompass.tmf.ctf.core.event.lookup;
import java.util.Objects;
import org.eclipse.tracecompass.ctf.core.event.CTFCallsite;
+import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
import org.eclipse.tracecompass.tmf.core.event.lookup.TmfCallsite;
/**
@@ -52,6 +53,21 @@ public class CtfTmfCallsite extends TmfCallsite {
fInstructionPointer = callsite.getIp();
}
+ /**
+ * Constructor to wrap a ITmfCallsite
+ *
+ * @param callsite
+ * the callsite
+ * @param eventName
+ * the event name
+ * @since 4.1
+ */
+ public CtfTmfCallsite(ITmfCallsite callsite, String eventName) {
+ super(callsite.getFileName(), callsite.getLineNo());
+ fEventName = eventName;
+ fInstructionPointer = 0;
+ }
+
// ------------------------------------------------------------------------
// Accessors
// ------------------------------------------------------------------------
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF b/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF
index 96b6a4bc73..58307f8776 100644
--- a/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF
+++ b/tmf/org.eclipse.tracecompass.tmf.core/META-INF/MANIFEST.MF
@@ -24,6 +24,7 @@ Export-Package: org.eclipse.tracecompass.internal.provisional.tmf.core.model.eve
org.eclipse.tracecompass.internal.provisional.tmf.core.model.timegraph;x-friends:="org.eclipse.tracecompass.analysis.os.linux.core,org.eclipse.tracecompass.analysis.os.linux.ui",
org.eclipse.tracecompass.internal.tmf.core;x-friends:="org.eclipse.tracecompass.tmf.core.tests,org.eclipse.tracecompass.tmf.ui.swtbot.tests",
org.eclipse.tracecompass.internal.tmf.core.analysis;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
+ org.eclipse.tracecompass.internal.tmf.core.aspect;x-internal:=true,
org.eclipse.tracecompass.internal.tmf.core.callstack;x-friends:="org.eclipse.tracecompass.tmf.ui,org.eclipse.tracecompass.tmf.core.tests",
org.eclipse.tracecompass.internal.tmf.core.component;x-friends:="org.eclipse.tracecompass.tmf.core.tests",
org.eclipse.tracecompass.internal.tmf.core.filter;x-friends:="org.eclipse.tracecompass.tmf.core.tests,org.eclipse.tracecompass.tmf.ui",
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/Messages.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/Messages.java
new file mode 100644
index 0000000000..e9355fe8e5
--- /dev/null
+++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/Messages.java
@@ -0,0 +1,36 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.tmf.core.aspect;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.tmf.core.aspect.messages"; //$NON-NLS-1$
+
+ /**
+ * Callsite name
+ */
+ public static String TmfCallsiteAspect_name;
+
+ /**
+ * Callsite description
+ */
+ public static String TmfCallsiteAspect_description;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/messages.properties b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/messages.properties
new file mode 100644
index 0000000000..8c94b2bd39
--- /dev/null
+++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/internal/tmf/core/aspect/messages.properties
@@ -0,0 +1,15 @@
+###############################################################################
+# Copyright (c) 2019 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:
+# Ericsson - Initial API and implementation
+###############################################################################
+
+
+TmfCallsiteAspect_description=Callsite
+TmfCallsiteAspect_name=The callsites of the event, its source location
diff --git a/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfCallsiteAspect.java b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfCallsiteAspect.java
new file mode 100644
index 0000000000..b265f6daee
--- /dev/null
+++ b/tmf/org.eclipse.tracecompass.tmf.core/src/org/eclipse/tracecompass/tmf/core/event/aspect/TmfCallsiteAspect.java
@@ -0,0 +1,37 @@
+/*******************************************************************************
+ * Copyright (c) 2019 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
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.tmf.core.event.aspect;
+
+import java.util.List;
+import java.util.Objects;
+
+import org.eclipse.tracecompass.internal.tmf.core.aspect.Messages;
+import org.eclipse.tracecompass.tmf.core.event.lookup.ITmfCallsite;
+
+/**
+ * This aspect finds the call sites of the code that are running when the event
+ * occurred.
+ *
+ * @author Matthew Khouzam
+ * @since 5.0
+ */
+public abstract class TmfCallsiteAspect implements ITmfEventAspect<List<ITmfCallsite>> {
+
+ @Override
+ public final String getName() {
+ return Objects.requireNonNull(Messages.TmfCallsiteAspect_name);
+ }
+
+ @Override
+ public final String getHelpText() {
+ return Objects.requireNonNull(Messages.TmfCallsiteAspect_description);
+ }
+
+} \ No newline at end of file

Back to the top