| 1 | /******************************************************************************* |
| 2 | * Copyright (c) 2013, 2015 École Polytechnique de Montréal |
| 3 | * |
| 4 | * All rights reserved. This program and the accompanying materials are |
| 5 | * made available under the terms of the Eclipse Public License v1.0 which |
| 6 | * accompanies this distribution, and is available at |
| 7 | * http://www.eclipse.org/legal/epl-v10.html |
| 8 | * |
| 9 | * Contributors: |
| 10 | * Geneviève Bastien - Initial API and implementation |
| 11 | * Mathieu Rail - Provide the requirements of the analysis |
| 12 | *******************************************************************************/ |
| 13 | |
| 14 | package org.eclipse.tracecompass.analysis.os.linux.core.kernelanalysis; |
| 15 | |
| 16 | import static org.eclipse.tracecompass.common.core.NonNullUtils.checkNotNull; |
| 17 | |
| 18 | import java.util.Collections; |
| 19 | import java.util.Set; |
| 20 | |
| 21 | import org.eclipse.jdt.annotation.NonNull; |
| 22 | import org.eclipse.tracecompass.common.core.NonNullUtils; |
| 23 | import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernelanalysis.KernelStateProvider; |
| 24 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelAnalysisEventLayout; |
| 25 | import org.eclipse.tracecompass.analysis.os.linux.core.trace.IKernelTrace; |
| 26 | import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement; |
| 27 | import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider; |
| 28 | import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule; |
| 29 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; |
| 30 | |
| 31 | /** |
| 32 | * State System Module for lttng kernel traces |
| 33 | * |
| 34 | * @author Geneviève Bastien |
| 35 | * @since 1.0 |
| 36 | */ |
| 37 | public class KernelAnalysisModule extends TmfStateSystemAnalysisModule { |
| 38 | |
| 39 | /** |
| 40 | * The file name of the History Tree |
| 41 | */ |
| 42 | public static final String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$ |
| 43 | |
| 44 | /** The ID of this analysis module */ |
| 45 | public static final String ID = "org.eclipse.tracecompass.analysis.os.linux.kernel"; //$NON-NLS-1$ |
| 46 | |
| 47 | /* |
| 48 | * TODO: Decide which events should be mandatory for the analysis, once the |
| 49 | * appropriate error messages and session setup are in place. |
| 50 | */ |
| 51 | // private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of(); |
| 52 | // |
| 53 | // private static final ImmutableSet<String> OPTIONAL_EVENTS = ImmutableSet.of( |
| 54 | // FIXME These cannot be declared statically anymore, they depend on |
| 55 | // the OriginTracer of the kernel trace. |
| 56 | // LttngStrings.EXIT_SYSCALL, |
| 57 | // LttngStrings.IRQ_HANDLER_ENTRY, |
| 58 | // LttngStrings.IRQ_HANDLER_EXIT, |
| 59 | // LttngStrings.SOFTIRQ_ENTRY, |
| 60 | // LttngStrings.SOFTIRQ_EXIT, |
| 61 | // LttngStrings.SOFTIRQ_RAISE, |
| 62 | // LttngStrings.SCHED_PROCESS_FORK, |
| 63 | // LttngStrings.SCHED_PROCESS_EXIT, |
| 64 | // LttngStrings.SCHED_PROCESS_FREE, |
| 65 | // LttngStrings.SCHED_SWITCH, |
| 66 | // LttngStrings.STATEDUMP_PROCESS_STATE, |
| 67 | // LttngStrings.SCHED_WAKEUP, |
| 68 | // LttngStrings.SCHED_WAKEUP_NEW, |
| 69 | // |
| 70 | // /* FIXME Add the prefix for syscalls */ |
| 71 | // LttngStrings.SYSCALL_PREFIX |
| 72 | // ); |
| 73 | |
| 74 | /** The requirements as an immutable set */ |
| 75 | private static final Set<TmfAnalysisRequirement> REQUIREMENTS; |
| 76 | |
| 77 | static { |
| 78 | // /* initialize the requirement: domain and events */ |
| 79 | // TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN); |
| 80 | // domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_KERNEL, ValuePriorityLevel.MANDATORY); |
| 81 | // |
| 82 | // TmfAnalysisRequirement eventReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY); |
| 83 | // eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL); |
| 84 | // |
| 85 | // REQUIREMENTS = checkNotNull(ImmutableSet.of(domainReq, eventReq)); |
| 86 | REQUIREMENTS = checkNotNull(Collections.EMPTY_SET); |
| 87 | } |
| 88 | |
| 89 | @Override |
| 90 | protected @NonNull ITmfStateProvider createStateProvider() { |
| 91 | ITmfTrace trace = checkNotNull(getTrace()); |
| 92 | IKernelAnalysisEventLayout layout; |
| 93 | |
| 94 | if (trace instanceof IKernelTrace) { |
| 95 | layout = ((IKernelTrace) trace).getKernelEventLayout(); |
| 96 | } else { |
| 97 | /* Fall-back to the base LttngEventLayout */ |
| 98 | layout = IKernelAnalysisEventLayout.DEFAULT_LAYOUT; |
| 99 | } |
| 100 | |
| 101 | return new KernelStateProvider(trace, layout); |
| 102 | } |
| 103 | |
| 104 | @Override |
| 105 | @NonNull |
| 106 | protected String getSsFileName() { |
| 107 | return HISTORY_TREE_FILE_NAME; |
| 108 | } |
| 109 | |
| 110 | @Override |
| 111 | protected String getFullHelpText() { |
| 112 | return NonNullUtils.nullToEmptyString(Messages.LttngKernelAnalysisModule_Help); |
| 113 | } |
| 114 | |
| 115 | @Override |
| 116 | public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() { |
| 117 | return REQUIREMENTS; |
| 118 | } |
| 119 | } |