lttng: Add interface to abstract the event layout away
[deliverable/tracecompass.git] / org.eclipse.tracecompass.lttng2.kernel.core / src / org / eclipse / tracecompass / lttng2 / kernel / core / analysis / kernel / LttngKernelAnalysis.java
1 /*******************************************************************************
2 * Copyright (c) 2013, 2014 É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.lttng2.kernel.core.analysis.kernel;
15
16 import org.eclipse.jdt.annotation.NonNull;
17 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.IKernelAnalysisEventLayout;
18 import org.eclipse.tracecompass.internal.lttng2.kernel.core.trace.layout.LttngEventLayout;
19 import org.eclipse.tracecompass.lttng2.control.core.session.SessionConfigStrings;
20 import org.eclipse.tracecompass.lttng2.kernel.core.trace.LttngKernelTrace;
21 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement;
22 import org.eclipse.tracecompass.tmf.core.analysis.TmfAnalysisRequirement.ValuePriorityLevel;
23 import org.eclipse.tracecompass.tmf.core.statesystem.ITmfStateProvider;
24 import org.eclipse.tracecompass.tmf.core.statesystem.TmfStateSystemAnalysisModule;
25 import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace;
26
27 import com.google.common.collect.ImmutableSet;
28
29 /**
30 * State System Module for lttng kernel traces
31 *
32 * @author Geneviève Bastien
33 * @since 3.0
34 */
35 public class LttngKernelAnalysis extends TmfStateSystemAnalysisModule {
36
37 /**
38 * The file name of the History Tree
39 */
40 public static final @NonNull String HISTORY_TREE_FILE_NAME = "stateHistory.ht"; //$NON-NLS-1$
41
42 /** The ID of this analysis module */
43 public static final @NonNull String ID = "org.eclipse.linuxtools.lttng2.kernel.analysis"; //$NON-NLS-1$
44
45 /*
46 * TODO: Decide which events should be mandatory for the analysis, once the
47 * appropriate error messages and session setup are in place.
48 */
49 private static final ImmutableSet<String> REQUIRED_EVENTS = ImmutableSet.of();
50
51 private static final ImmutableSet<String> OPTIONAL_EVENTS = ImmutableSet.of(
52 // FIXME These cannot be declared statically anymore, they depend on
53 // the OriginTracer of the kernel trace.
54 // LttngStrings.EXIT_SYSCALL,
55 // LttngStrings.IRQ_HANDLER_ENTRY,
56 // LttngStrings.IRQ_HANDLER_EXIT,
57 // LttngStrings.SOFTIRQ_ENTRY,
58 // LttngStrings.SOFTIRQ_EXIT,
59 // LttngStrings.SOFTIRQ_RAISE,
60 // LttngStrings.SCHED_PROCESS_FORK,
61 // LttngStrings.SCHED_PROCESS_EXIT,
62 // LttngStrings.SCHED_PROCESS_FREE,
63 // LttngStrings.SCHED_SWITCH,
64 // LttngStrings.STATEDUMP_PROCESS_STATE,
65 // LttngStrings.SCHED_WAKEUP,
66 // LttngStrings.SCHED_WAKEUP_NEW,
67 //
68 // /* FIXME Add the prefix for syscalls */
69 // LttngStrings.SYSCALL_PREFIX
70 );
71
72 /** The requirements as an immutable set */
73 private static final ImmutableSet<TmfAnalysisRequirement> REQUIREMENTS;
74
75 static {
76 /* initialize the requirement: domain and events */
77 TmfAnalysisRequirement domainReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_DOMAIN);
78 domainReq.addValue(SessionConfigStrings.CONFIG_DOMAIN_TYPE_KERNEL, ValuePriorityLevel.MANDATORY);
79
80 TmfAnalysisRequirement eventReq = new TmfAnalysisRequirement(SessionConfigStrings.CONFIG_ELEMENT_EVENT, REQUIRED_EVENTS, ValuePriorityLevel.MANDATORY);
81 eventReq.addValues(OPTIONAL_EVENTS, ValuePriorityLevel.OPTIONAL);
82
83 REQUIREMENTS = ImmutableSet.of(domainReq, eventReq);
84 }
85
86 @Override
87 protected @NonNull ITmfStateProvider createStateProvider() {
88 ITmfTrace trace = getTrace();
89 IKernelAnalysisEventLayout layout;
90
91 if (trace instanceof LttngKernelTrace) {
92 layout = ((LttngKernelTrace) trace).getEventLayout();
93 } else {
94 /* Fall-back to the base LttngEventLayout */
95 layout = LttngEventLayout.getInstance();
96 }
97
98 return new LttngKernelStateProvider(trace, layout);
99 }
100
101 @Override
102 @NonNull
103 protected String getSsFileName() {
104 return HISTORY_TREE_FILE_NAME;
105 }
106
107 @Override
108 protected String getFullHelpText() {
109 return Messages.LttngKernelAnalysisModule_Help;
110 }
111
112 @Override
113 public Iterable<TmfAnalysisRequirement> getAnalysisRequirements() {
114 return REQUIREMENTS;
115 }
116 }
This page took 0.05478 seconds and 5 git commands to generate.