Export-Package: org.eclipse.tracecompass.internal.lttng2.ust.core;x-friends:="org.eclipse.tracecompass.lttng2.ust.core.tests,org.eclipse.tracecompass.lttng2.ust.ui",
org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.memory;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
org.eclipse.tracecompass.internal.lttng2.ust.core.callstack;x-friends:="org.eclipse.tracecompass.lttng2.ust.ui,org.eclipse.tracecompass.lttng2.ust.core.tests",
+ org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout;x-internal:=true,
org.eclipse.tracecompass.lttng2.ust.core.analysis.memory,
- org.eclipse.tracecompass.lttng2.ust.core.trace
+ org.eclipse.tracecompass.lttng2.ust.core.trace,
+ org.eclipse.tracecompass.lttng2.ust.core.trace.layout
Require-Bundle: org.eclipse.core.runtime,
org.eclipse.core.resources,
org.eclipse.tracecompass.common.core,
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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.lttng2.ust.core.trace.layout;
+
+import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
+
+/**
+ * Definitions used in LTTng-UST for versions 2.0 up to 2.6.
+ *
+ * @author Alexandre Montplaisir
+ */
+@SuppressWarnings("nls")
+public class LttngUst20EventLayout implements ILttngUstEventLayout {
+
+ /**
+ * Constructor
+ */
+ protected LttngUst20EventLayout() {}
+
+ private static final LttngUst20EventLayout INSTANCE = new LttngUst20EventLayout();
+
+ /**
+ * Get a singleton instance.
+ *
+ * @return The instance
+ */
+ public static LttngUst20EventLayout getInstance() {
+ return INSTANCE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Event names used in liblttng-ust-libc-wrapper
+ // ------------------------------------------------------------------------
+
+ @Override
+ public String eventLibcMalloc() {
+ return "ust_libc:malloc";
+ }
+
+ @Override
+ public String eventLibcCalloc() {
+ return "ust_libc:calloc";
+ }
+
+ @Override
+ public String eventLibcRealloc() {
+ return "ust_libc:realloc";
+ }
+
+ @Override
+ public String eventLibcFree() {
+ return "ust_libc:free";
+ }
+
+ @Override
+ public String eventLibcMemalign() {
+ return "ust_libc:memalign";
+ }
+
+ @Override
+ public String eventLibcPosixMemalign() {
+ return "ust_libc:posix_memalign";
+ }
+
+ // ------------------------------------------------------------------------
+ // Field names
+ // ------------------------------------------------------------------------
+
+ @Override
+ public String fieldPtr() {
+ return "ptr";
+ }
+
+ @Override
+ public String fieldNmemb() {
+ return "nmemb";
+ }
+
+ @Override
+ public String fieldSize() {
+ return "size";
+ }
+
+ @Override
+ public String fieldOutPtr() {
+ return "out_ptr";
+ }
+
+ @Override
+ public String fieldInPtr() {
+ return "in_ptr";
+ }
+
+ // ------------------------------------------------------------------------
+ // Context field names
+ // Note: The CTF parser exposes contexts as fields called "context._<name>"
+ // ------------------------------------------------------------------------
+
+ @Override
+ public String contextVtid() {
+ return "context._vtid";
+ }
+
+ @Override
+ public String contextProcname() {
+ return "context._procname";
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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.lttng2.ust.core.trace.layout;
+
+/**
+ * Updated event definitions for LTTng-UST 2.7.
+ *
+ * @author Alexandre Montplaisir
+ */
+@SuppressWarnings("nls")
+public class LttngUst27EventLayout extends LttngUst20EventLayout {
+
+ /**
+ * Constructor
+ */
+ protected LttngUst27EventLayout() {}
+
+ private static final LttngUst27EventLayout INSTANCE = new LttngUst27EventLayout();
+
+ /**
+ * Get a singleton instance.
+ *
+ * @return The instance
+ */
+ public static LttngUst27EventLayout getInstance() {
+ return INSTANCE;
+ }
+
+ // ------------------------------------------------------------------------
+ // Event names used in liblttng-ust-libc-wrapper
+ // They are now prefixed with "lttng_*"
+ // ------------------------------------------------------------------------
+
+ @Override
+ public String eventLibcMalloc() {
+ return "lttng_ust_libc:malloc";
+ }
+
+ @Override
+ public String eventLibcCalloc() {
+ return "lttng_ust_libc:calloc";
+ }
+
+ @Override
+ public String eventLibcRealloc() {
+ return "lttng_ust_libc:realloc";
+ }
+
+ @Override
+ public String eventLibcFree() {
+ return "lttng_ust_libc:free";
+ }
+
+ @Override
+ public String eventLibcMemalign() {
+ return "lttng_ust_libc:memalign";
+ }
+
+ @Override
+ public String eventLibcPosixMemalign() {
+ return "lttng_ust_libc:posix_memalign";
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout;
import java.util.Map;
import org.eclipse.core.resources.IProject;
+import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
import org.eclipse.tracecompass.internal.lttng2.ust.core.Activator;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst20EventLayout;
+import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst27EventLayout;
+import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.trace.TraceValidationStatus;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTraceValidationStatus;
private static final int CONFIDENCE = 100;
+ private @Nullable ILttngUstEventLayout fLayout = null;
+
/**
* Default constructor
*/
super();
}
+ /**
+ * Get the event layout to use with this trace. This normally depends on the
+ * tracer's version.
+ *
+ * @return The event layout
+ * @since 2.0
+ */
+ public @NonNull ILttngUstEventLayout getEventLayout() {
+ ILttngUstEventLayout layout = fLayout;
+ if (layout == null) {
+ throw new IllegalStateException("Cannot get the layout of a non-initialized trace!"); //$NON-NLS-1$
+ }
+ return layout;
+ }
+
+ @Override
+ public void initTrace(IResource resource, String path,
+ Class<? extends ITmfEvent> eventType) throws TmfTraceException {
+ super.initTrace(resource, path, eventType);
+
+ /* Determine the event layout to use from the tracer's version */
+ fLayout = getLayoutFromEnv(this.getEnvironment());
+ }
+
+ private static @NonNull ILttngUstEventLayout getLayoutFromEnv(Map<String, String> traceEnv) {
+ String tracerName = traceEnv.get("tracer_name"); //$NON-NLS-1$
+ String tracerMajor = traceEnv.get("tracer_major"); //$NON-NLS-1$
+ String tracerMinor = traceEnv.get("tracer_minor"); //$NON-NLS-1$
+
+ if ("\"lttng-ust\"".equals(tracerName) && tracerMajor != null && tracerMinor != null) { //$NON-NLS-1$
+ if (Integer.valueOf(tracerMajor) >= 2) {
+ if (Integer.valueOf(tracerMinor) >= 7) {
+ return LttngUst27EventLayout.getInstance();
+ }
+ return LttngUst20EventLayout.getInstance();
+ }
+ }
+
+ /* Fallback to the UST 2.0 layout and hope for the best */
+ return LttngUst20EventLayout.getInstance();
+ }
+
/**
* {@inheritDoc}
* <p>
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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.lttng2.ust.core.trace.layout;
+
+/**
+ * This interface defines concepts exposed by liblttng-ust libraries and traces.
+ * Actual implementations can differ between different versions of the tracer.
+ *
+ * @author Alexandre Montplaisir
+ * @since 2.0
+ */
+@SuppressWarnings("javadoc")
+public interface ILttngUstEventLayout {
+
+ // ------------------------------------------------------------------------
+ // Event names used in liblttng-ust-libc-wrapper
+ // ------------------------------------------------------------------------
+
+ String eventLibcMalloc();
+ String eventLibcCalloc();
+ String eventLibcRealloc();
+ String eventLibcFree();
+ String eventLibcMemalign();
+ String eventLibcPosixMemalign();
+
+ // ------------------------------------------------------------------------
+ // Field names
+ // ------------------------------------------------------------------------
+
+ String fieldPtr();
+ String fieldNmemb();
+ String fieldSize();
+ String fieldOutPtr();
+ String fieldInPtr();
+
+ // ------------------------------------------------------------------------
+ // Context field names
+ // ------------------------------------------------------------------------
+
+ String contextVtid();
+ String contextProcname();
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2015 EfficiOS Inc., Alexandre Montplaisir
+ *
+ * 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
+ *******************************************************************************/
+
+@org.eclipse.jdt.annotation.NonNullByDefault
+package org.eclipse.tracecompass.lttng2.ust.core.trace.layout;