1 /*******************************************************************************
2 * Copyright (c) 2015 Keba AG
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
10 * Christian Mansky - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.tracecompass
.internal
.analysis
.os
.linux
.ui
.views
.controlflow
;
15 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernel
.KernelAnalysisModule
;
16 import org
.eclipse
.tracecompass
.analysis
.os
.linux
.core
.kernel
.StateValues
;
17 import org
.eclipse
.tracecompass
.statesystem
.core
.ITmfStateSystem
;
18 import org
.eclipse
.tracecompass
.statesystem
.core
.exceptions
.StateSystemDisposedException
;
19 import org
.eclipse
.tracecompass
.statesystem
.core
.interval
.ITmfStateInterval
;
20 import org
.eclipse
.tracecompass
.tmf
.core
.statesystem
.TmfStateSystemAnalysisModule
;
21 import org
.eclipse
.tracecompass
.tmf
.core
.timestamp
.TmfTimeRange
;
22 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.ITmfTrace
;
23 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceContext
;
24 import org
.eclipse
.tracecompass
.tmf
.core
.trace
.TmfTraceManager
;
25 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.dialogs
.ITimeGraphEntryActiveProvider
;
26 import org
.eclipse
.tracecompass
.tmf
.ui
.widgets
.timegraph
.model
.ITimeGraphEntry
;
29 * Provides Functionality for check Active / uncheck inactive
31 * @noinstantiate This class is not intended to be instantiated by clients.
32 * @noextend This class is not intended to be subclassed by clients.
35 public class ControlFlowCheckActiveProvider
implements ITimeGraphEntryActiveProvider
{
46 public ControlFlowCheckActiveProvider(String label
, String tooltip
) {
52 public String
getLabel() {
57 public String
getTooltip() {
62 public boolean isActive(ITimeGraphEntry element
) {
63 if (element
instanceof ControlFlowEntry
) {
64 ControlFlowEntry cfe
= (ControlFlowEntry
) element
;
66 TmfTraceManager traceManager
= TmfTraceManager
.getInstance();
67 TmfTraceContext traceContext
= traceManager
.getCurrentTraceContext();
68 TmfTimeRange winRange
= traceContext
.getWindowRange();
69 TmfTimeRange selRange
= traceContext
.getSelectionRange();
71 /* Take precedence of selection over window range. */
72 long beginTS
= selRange
.getStartTime().getValue();
73 long endTS
= selRange
.getEndTime().getValue();
75 /* No selection, take window range */
76 if (beginTS
== endTS
) {
77 beginTS
= winRange
.getStartTime().getValue();
78 endTS
= winRange
.getEndTime().getValue();
81 ITmfTrace trace
= cfe
.getTrace();
82 ITmfStateSystem ssq
= TmfStateSystemAnalysisModule
.getStateSystem(trace
, KernelAnalysisModule
.ID
);
84 beginTS
= Math
.max(beginTS
, ssq
.getStartTime());
85 endTS
= Math
.min(endTS
, ssq
.getCurrentEndTime());
86 if (beginTS
> endTS
) {
90 int statusQuark
= cfe
.getThreadQuark();
92 /* Get the initial state at beginTS */
93 ITmfStateInterval currentInterval
= ssq
.querySingleState(beginTS
, statusQuark
);
94 if (isIntervalInStateActive(currentInterval
)) {
98 /* Get the following state changes */
99 long ts
= currentInterval
.getEndTime();
100 while (ts
!= -1 && ts
< endTS
) {
101 ts
++; /* To "jump over" to the next state in the history */
102 currentInterval
= ssq
.querySingleState(ts
, statusQuark
);
103 if (isIntervalInStateActive(currentInterval
)) {
106 ts
= currentInterval
.getEndTime();
108 } catch (StateSystemDisposedException e
) {
117 private static boolean isIntervalInStateActive (ITmfStateInterval ival
) {
118 int value
= ival
.getStateValue().unboxInt();
119 /* An entry is only active when running */
120 if (value
== StateValues
.PROCESS_STATUS_RUN_USERMODE
|| value
== StateValues
.PROCESS_STATUS_RUN_SYSCALL
||
121 value
== StateValues
.PROCESS_STATUS_INTERRUPTED
) {