Commit | Line | Data |
---|---|---|
ace2121d FG |
1 | /******************************************************************************* |
2 | * Copyright (c) 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 | ||
10 | package org.eclipse.tracecompass.internal.lttng2.kernel.ui.criticalpath; | |
11 | ||
ace2121d FG |
12 | import org.eclipse.tracecompass.analysis.graph.core.criticalpath.CriticalPathModule; |
13 | import org.eclipse.tracecompass.analysis.os.linux.core.model.HostThread; | |
926c10d3 | 14 | import org.eclipse.tracecompass.analysis.os.linux.core.signals.TmfThreadSelectedSignal; |
ace2121d FG |
15 | import org.eclipse.tracecompass.internal.lttng2.kernel.core.analysis.graph.model.LttngWorker; |
16 | import org.eclipse.tracecompass.tmf.core.analysis.IAnalysisModule; | |
17 | import org.eclipse.tracecompass.tmf.core.analysis.TmfAbstractAnalysisParamProvider; | |
926c10d3 MK |
18 | import org.eclipse.tracecompass.tmf.core.signal.TmfSignalHandler; |
19 | import org.eclipse.tracecompass.tmf.core.signal.TmfSignalManager; | |
ace2121d | 20 | import org.eclipse.tracecompass.tmf.core.trace.ITmfTrace; |
ace2121d FG |
21 | |
22 | /** | |
23 | * Class that provides parameters to the critical path analysis for lttng kernel | |
24 | * traces | |
25 | * | |
26 | * @author Geneviève Bastien | |
27 | */ | |
28 | public class CriticalPathParameterProvider extends TmfAbstractAnalysisParamProvider { | |
29 | ||
ace2121d FG |
30 | private static final String NAME = "Critical Path Lttng kernel parameter provider"; //$NON-NLS-1$ |
31 | ||
926c10d3 | 32 | private HostThread fCurrentHostThread = null; |
ace2121d FG |
33 | |
34 | /** | |
35 | * Constructor | |
36 | */ | |
37 | public CriticalPathParameterProvider() { | |
38 | super(); | |
926c10d3 | 39 | TmfSignalManager.register(this); |
ace2121d FG |
40 | } |
41 | ||
42 | @Override | |
43 | public String getName() { | |
44 | return NAME; | |
45 | } | |
46 | ||
47 | @Override | |
48 | public Object getParameter(String name) { | |
ace2121d | 49 | if (name.equals(CriticalPathModule.PARAM_WORKER)) { |
926c10d3 MK |
50 | final HostThread currentHostThread = fCurrentHostThread; |
51 | if (currentHostThread == null) { | |
52 | return null; | |
53 | } | |
ace2121d FG |
54 | /* Try to find the worker for the critical path */ |
55 | IAnalysisModule mod = getModule(); | |
56 | if ((mod != null) && (mod instanceof CriticalPathModule)) { | |
926c10d3 | 57 | LttngWorker worker = new LttngWorker(currentHostThread, "", 0); //$NON-NLS-1$ |
ace2121d FG |
58 | return worker; |
59 | } | |
ace2121d FG |
60 | } |
61 | return null; | |
62 | } | |
63 | ||
64 | @Override | |
65 | public boolean appliesToTrace(ITmfTrace trace) { | |
66 | return true; | |
67 | } | |
68 | ||
926c10d3 MK |
69 | private void setCurrentHostThread(HostThread hostThread) { |
70 | if (!hostThread.equals(fCurrentHostThread)) { | |
71 | fCurrentHostThread = hostThread; | |
72 | notifyParameterChanged(CriticalPathModule.PARAM_WORKER); | |
ace2121d FG |
73 | } |
74 | } | |
75 | ||
926c10d3 MK |
76 | /** |
77 | * Signal handler to know that a thread was selected | |
78 | * | |
79 | * @param signal | |
80 | * the thread was selected | |
81 | */ | |
82 | @TmfSignalHandler | |
83 | public void tmfThreadSelectedSignalHander(TmfThreadSelectedSignal signal) { | |
84 | final TmfThreadSelectedSignal threadSignal = signal; | |
85 | if (threadSignal != null) { | |
86 | setCurrentHostThread(new HostThread(threadSignal.getTraceHost(), threadSignal.getThreadId())); | |
ace2121d FG |
87 | } |
88 | } | |
89 | ||
90 | } |