1 /*******************************************************************************
2 * Copyright (c) 2012 Ericsson
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 * Patrick Tasse - Initial API and implementation
11 *******************************************************************************/
13 package org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.ui
.views
.controlflow
;
15 import java
.util
.HashMap
;
18 import org
.eclipse
.linuxtools
.internal
.lttng2
.kernel
.ui
.Messages
;
19 import org
.eclipse
.linuxtools
.lttng2
.kernel
.core
.trace
.Attributes
;
20 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.AttributeNotFoundException
;
21 import org
.eclipse
.linuxtools
.tmf
.core
.exceptions
.TimeRangeException
;
22 import org
.eclipse
.linuxtools
.tmf
.core
.interval
.ITmfStateInterval
;
23 import org
.eclipse
.linuxtools
.tmf
.core
.statesystem
.IStateSystemQuerier
;
24 import org
.eclipse
.linuxtools
.tmf
.core
.statevalue
.ITmfStateValue
;
25 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.StateItem
;
26 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.TimeGraphPresentationProvider
;
27 import org
.eclipse
.linuxtools
.tmf
.ui
.widgets
.timegraph
.model
.ITimeEvent
;
28 import org
.eclipse
.swt
.graphics
.RGB
;
30 public class ControlFlowPresentationProvider
extends TimeGraphPresentationProvider
{
33 UNKNOWN (new RGB(100, 100, 100)),
34 WAIT (new RGB(200, 200, 0)),
35 USERMODE (new RGB(0, 200, 0)),
36 SYSCALL (new RGB(0, 0, 200)),
37 INTERRUPTED (new RGB(200, 100, 100));
41 private State (RGB rgb
) {
47 public String
getStateTypeName() {
48 return Messages
.ControlFlowView_stateTypeName
;
52 public StateItem
[] getStateTable() {
53 StateItem
[] stateTable
= new StateItem
[State
.values().length
];
54 for (int i
= 0; i
< stateTable
.length
; i
++) {
55 State state
= State
.values()[i
];
56 stateTable
[i
] = new StateItem(state
.rgb
, state
.toString());
62 public int getStateTableIndex(ITimeEvent event
) {
63 if (event
instanceof ControlFlowEvent
) {
64 int status
= ((ControlFlowEvent
) event
).getStatus();
65 if (status
== Attributes
.STATUS_WAIT
) {
66 return State
.WAIT
.ordinal();
67 } else if (status
== Attributes
.STATUS_RUN_USERMODE
) {
68 return State
.USERMODE
.ordinal();
69 } else if (status
== Attributes
.STATUS_RUN_SYSCALL
) {
70 return State
.SYSCALL
.ordinal();
71 } else if (status
== Attributes
.STATUS_INTERRUPTED
) {
72 return State
.INTERRUPTED
.ordinal();
75 return State
.UNKNOWN
.ordinal();
79 public String
getEventName(ITimeEvent event
) {
80 if (event
instanceof ControlFlowEvent
) {
81 int status
= ((ControlFlowEvent
) event
).getStatus();
82 if (status
== Attributes
.STATUS_WAIT
) {
83 return State
.WAIT
.toString();
84 } else if (status
== Attributes
.STATUS_RUN_USERMODE
) {
85 return State
.USERMODE
.toString();
86 } else if (status
== Attributes
.STATUS_RUN_SYSCALL
) {
87 return State
.SYSCALL
.toString();
88 } else if (status
== Attributes
.STATUS_INTERRUPTED
) {
89 return State
.INTERRUPTED
.toString();
92 return State
.UNKNOWN
.toString();
96 public Map
<String
, String
> getEventHoverToolTipInfo(ITimeEvent event
) {
97 Map
<String
, String
> retMap
= new HashMap
<String
, String
>();
98 if (event
instanceof ControlFlowEvent
) {
99 int status
= ((ControlFlowEvent
) event
).getStatus();
100 if (status
== Attributes
.STATUS_RUN_SYSCALL
) {
101 ControlFlowEntry entry
= (ControlFlowEntry
) event
.getEntry();
102 IStateSystemQuerier ssq
= entry
.getTrace().getStateSystem();
104 int syscallQuark
= ssq
.getQuarkRelative(entry
.getThreadQuark(), Attributes
.SYSTEM_CALL
);
105 ITmfStateInterval value
= ssq
.querySingleState(event
.getTime(), syscallQuark
);
106 if (!value
.getStateValue().isNull()) {
107 ITmfStateValue state
= value
.getStateValue();
108 retMap
.put(Messages
.ControlFlowView_attributeSyscallName
, state
.toString());
111 } catch (AttributeNotFoundException e
) {
113 } catch (TimeRangeException e
) {