/******************************************************************************* * Copyright (c) 2016 É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.analysis.os.linux.core.inputoutput; import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; import java.util.HashSet; import java.util.Set; import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule; import org.eclipse.tracecompass.analysis.os.linux.core.trace.DefaultEventLayout; 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.inputoutput.InputOutputStateProvider; import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; import org.eclipse.tracecompass.tmf.core.trace.TmfTraceUtils; /** * State System Module for Input Output traces * * @author Houssem Daoud */ public class InputOutputAnalysisModule extends TmfStateSystemAnalysisModule { /** The ID of this analysis module */ public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.inputoutput"; //$NON-NLS-1$ @Override protected ITmfStateProvider createStateProvider() { ITmfTrace trace = checkNotNull(getTrace()); IKernelAnalysisEventLayout layout; if (trace instanceof IKernelTrace) { layout = ((IKernelTrace) trace).getKernelEventLayout(); } else { /* Fall-back to the base LttngEventLayout */ layout = DefaultEventLayout.getInstance(); } return new InputOutputStateProvider(trace, layout); } @Override protected StateSystemBackendType getBackendType() { return StateSystemBackendType.FULL; } @Override protected Iterable<IAnalysisModule> getDependentAnalyses() { Set<IAnalysisModule> modules = new HashSet<>(); ITmfTrace trace = getTrace(); if (trace == null) { throw new IllegalStateException(); } /* * This analysis depends on the LTTng kernel analysis, so it's added to * dependent modules. */ Iterable<KernelAnalysisModule> kernelModules = TmfTraceUtils.getAnalysisModulesOfClass(trace, KernelAnalysisModule.class); for (KernelAnalysisModule kernelModule : kernelModules) { /* Only add the first one we find, if there is one */ modules.add(kernelModule); break; } return modules; } }