org.eclipse.tracecompass.tmf.ctf.core,
org.eclipse.tracecompass.tmf.ctf.core.tests,
org.eclipse.tracecompass.lttng2.ust.core,
- org.eclipse.tracecompass.lttng2.control.core
+ org.eclipse.tracecompass.lttng2.control.core,
+ org.eclipse.tracecompass.analysis.os.linux.core
Export-Package: org.eclipse.tracecompass.lttng2.ust.core.tests,
org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.debuginfo,
org.eclipse.tracecompass.lttng2.ust.core.tests.analysis.memory,
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.tracecompass.internal.lttng2.ust.core.callstack.LttngUstCallStackProvider;
+import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.StateSystemUtils;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.statevalue.ITmfStateValue;
import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
import org.eclipse.tracecompass.tmf.core.callstack.CallStackStateProvider;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.exceptions.TmfAnalysisException;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
/**
* Perform pre-class initialization.
+ *
+ * @throws TmfTraceException
+ * Exception initiating the trace
*/
@Before
- public void setUp() {
+ public void setUp() throws TmfTraceException {
CtfTestTrace testTrace = getTestTrace();
- CtfTmfTrace trace = CtfTmfTestTraceUtils.getTrace(testTrace);
+ CtfTmfTrace ctftrace = CtfTmfTestTraceUtils.getTrace(testTrace);
+ LttngUstTrace trace = new LttngUstTrace();
+ trace.initTrace(null, ctftrace.getPath(), ITmfEvent.class);
fTrace = trace;
fModule = new TestLttngCallStackModule();
try {
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * 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.tests.trace;
+
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+
+import java.io.File;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
+import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
+import org.eclipse.tracecompass.testtraces.ctf.CtfTestTrace;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.exceptions.TmfTraceException;
+import org.eclipse.tracecompass.tmf.core.request.TmfEventRequest;
+import org.eclipse.tracecompass.tmf.core.timestamp.TmfTimeRange;
+import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceManager;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
+import org.eclipse.tracecompass.tmf.ctf.core.tests.shared.CtfTmfTestTraceUtils;
+import org.eclipse.tracecompass.tmf.ctf.core.trace.CtfTmfTrace;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test the {@link LttngUstTrace} class
+ *
+ * @author Geneviève Bastien
+ */
+public class LttngUstTraceTest {
+
+ private static final @NonNull CtfTestTrace TEST_TRACE = CtfTestTrace.CYG_PROFILE;
+
+ private ITmfTrace fTrace;
+
+ /**
+ * Perform pre-class initialization.
+ *
+ * @throws TmfTraceException
+ * Exceptions in trace initialization
+ */
+ @Before
+ public void setUp() throws TmfTraceException {
+ CtfTmfTrace ctftrace = CtfTmfTestTraceUtils.getTrace(TEST_TRACE);
+
+ LttngUstTrace trace = new LttngUstTrace();
+ trace.initTrace(null, ctftrace.getPath(), ITmfEvent.class);
+ fTrace = trace;
+
+ }
+
+ /** Empty and delete a directory */
+ private static void deleteDirectory(File dir) {
+ /* Assuming the dir only contains file or empty directories */
+ for (File file : dir.listFiles()) {
+ file.delete();
+ }
+ dir.delete();
+ }
+
+ /**
+ * Perform post-class clean-up.
+ */
+ @After
+ public void tearDown() {
+ ITmfTrace trace = fTrace;
+ if (trace != null) {
+ trace.dispose();
+ File suppDir = new File(TmfTraceManager.getSupplementaryFileDir(trace));
+ deleteDirectory(suppDir);
+ }
+ }
+
+ private static class TestEventRequest extends TmfEventRequest {
+
+ private String errString = null;
+
+ public TestEventRequest() {
+ super(ITmfEvent.class, TmfTimeRange.ETERNITY, 0, 2, ExecutionType.FOREGROUND);
+ }
+
+ @Override
+ public void handleData(@NonNull ITmfEvent event) {
+ super.handleData(event);
+ Integer tid = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), LinuxTidAspect.class, event);
+ if (tid == null) {
+ errString = "No TID for event " + event;
+ cancel();
+ return;
+ }
+ if (tid.intValue() != 16073) {
+ errString = "Wrong tid: " + tid + " for event";
+ cancel();
+ return;
+ }
+ }
+
+ public String getErrString() {
+ return errString;
+ }
+
+ }
+
+ /**
+ * Test the LinuxTidAspect for this trace
+ *
+ * @throws InterruptedException
+ * exception thrown in the request
+ */
+ @Test
+ public void testTidAspect() throws InterruptedException {
+ ITmfTrace trace = fTrace;
+ assertNotNull(trace);
+
+ TestEventRequest request = new TestEventRequest();
+ trace.sendRequest(request);
+ request.waitForCompletion();
+ assertNull(request.getErrString());
+ }
+}
org.eclipse.tracecompass.internal.lttng2.ust.core.analysis.debuginfo;x-friends:="org.eclipse.tracecompass.lttng2.ust.core.tests",
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.lttng2.ust.ui.swtbot.tests",
+ org.eclipse.tracecompass.internal.lttng2.ust.core.trace;x-internal:=true,
org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout;x-internal:=true,
org.eclipse.tracecompass.lttng2.ust.core.analysis.debuginfo,
org.eclipse.tracecompass.lttng2.ust.core.analysis.memory,
org.eclipse.tracecompass.tmf.core,
org.eclipse.tracecompass.tmf.ctf.core,
org.eclipse.tracecompass.lttng2.control.core,
- org.eclipse.tracecompass.ctf.core
+ org.eclipse.tracecompass.ctf.core,
+ org.eclipse.tracecompass.analysis.os.linux.core
Import-Package: com.google.common.annotations;version="15.0.0",
com.google.common.cache,
com.google.common.collect,
import java.util.Map;
import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystemBuilder;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.statesystem.AbstractTmfStateProvider;
import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import com.google.common.collect.ImmutableMap;
return VERSION;
}
- private Long getVtid(ITmfEvent event) {
- ITmfEventField field = event.getContent().getField(fLayout.contextVtid());
- if (field == null) {
+ private static Long getVtid(ITmfEvent event) {
+ /* We checked earlier that the "vtid" context is present */
+ Integer tid = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), LinuxTidAspect.class, event);
+ if (tid == null) {
return MINUS_ONE;
}
- return (Long) field.getValue();
+ return tid.longValue();
}
private String getProcname(ITmfEvent event) {
import org.eclipse.jdt.annotation.NonNull;
import org.eclipse.jdt.annotation.NonNullByDefault;
import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst20EventLayout;
import org.eclipse.tracecompass.lttng2.ust.core.trace.LttngUstTrace;
import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
+import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils;
import org.eclipse.tracecompass.tmf.ctf.core.event.CtfTmfEvent;
import com.google.common.collect.ImmutableSet;
if (!(event instanceof CtfTmfEvent)) {
return false;
}
- ITmfEventField content = ((CtfTmfEvent) event).getContent();
- if (content.getField(fLayout.contextVtid()) == null) {
+ Object tid = TmfTraceUtils.resolveEventAspectOfClassForEvent(event.getTrace(), LinuxTidAspect.class, event);
+ if (!(tid instanceof Integer)) {
return false;
}
return true;
@Override
protected long getThreadId(ITmfEvent event) {
/* We checked earlier that the "vtid" context is present */
- ITmfEventField content = event.getContent();
- return ((Long) content.getField(fLayout.contextVtid()).getValue()).longValue();
+ Integer tid = TmfTraceUtils.resolveIntEventAspectOfClassForEvent(event.getTrace(), LinuxTidAspect.class, event);
+ if (tid == null) {
+ return UNKNOWN_PID;
+ }
+ return tid.longValue();
}
@Override
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 École Polytechnique de Montréal
+ *
+ * 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;
+
+import org.eclipse.jdt.annotation.NonNull;
+import org.eclipse.jdt.annotation.Nullable;
+import org.eclipse.tracecompass.analysis.os.linux.core.event.aspect.LinuxTidAspect;
+import org.eclipse.tracecompass.lttng2.ust.core.trace.layout.ILttngUstEventLayout;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEvent;
+import org.eclipse.tracecompass.tmf.core.event.ITmfEventField;
+
+/**
+ * A Linux TID event aspect that retrieves the VTID from the context of a
+ * userspace event.
+ *
+ * @since 3.0
+ */
+public class ContextVtidAspect extends LinuxTidAspect {
+
+ private final ILttngUstEventLayout fLayout;
+
+ /**
+ * Constructor with a layout
+ *
+ * @param layout
+ * The event layout used by the trace this aspect is for
+ */
+ public ContextVtidAspect(ILttngUstEventLayout layout) {
+ fLayout = layout;
+ }
+
+ @Override
+ public @Nullable Integer resolve(@NonNull ITmfEvent event) {
+ ITmfEventField content = event.getContent();
+ Long tid = content.getFieldValue(Long.class, fLayout.contextVtid());
+ return tid == null ? null : tid.intValue();
+ }
+
+}
package org.eclipse.tracecompass.lttng2.ust.core.trace;
import java.util.Collection;
+import java.util.HashSet;
import java.util.Map;
import org.eclipse.core.resources.IProject;
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.ContextVtidAspect;
import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.DefaultUstEventLayout;
import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst20EventLayout;
import org.eclipse.tracecompass.internal.lttng2.ust.core.trace.layout.LttngUst27EventLayout;
LTTNG_UST_ASPECTS = builder.build();
}
+ private @NonNull Collection<ITmfEventAspect<?>> fUstTraceAspects = new HashSet<>(LTTNG_UST_ASPECTS);
+
private @Nullable ILttngUstEventLayout fLayout = null;
/**
/* Determine the event layout to use from the tracer's version */
fLayout = getLayoutFromEnv();
+
+ ImmutableSet.Builder<ITmfEventAspect<?>> builder = ImmutableSet.builder();
+ builder.addAll(LTTNG_UST_ASPECTS);
+ builder.add(new ContextVtidAspect(fLayout));
+ fUstTraceAspects = builder.build();
}
private @NonNull ILttngUstEventLayout getLayoutFromEnv() {
@Override
public Iterable<ITmfEventAspect<?>> getEventAspects() {
- return LTTNG_UST_ASPECTS;
+ return fUstTraceAspects;
}
/**