Export-Package: org.eclipse.tracecompass.internal.analysis.os.linux.ui;x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests",
org.eclipse.tracecompass.internal.analysis.os.linux.ui.actions;x-internal:=true,
org.eclipse.tracecompass.internal.analysis.os.linux.ui.perspectives;x-internal:=true,
+ org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry;x-internal:=true,
org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.controlflow;
x-friends:="org.eclipse.tracecompass.analysis.os.linux.ui.swtbot.tests,
org.eclipse.tracecompass.analysis.os.linux.ui.tests,
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry;
+
+import org.eclipse.swt.graphics.RGB;
+import org.eclipse.swt.graphics.RGBA;
+
+/**
+ * A Linux style
+ *
+ * @author Matthew Khouzam
+ */
+public enum LinuxStyle {
+
+ /**
+ * Unknown state for thread or CPU
+ */
+ UNKNOWN(Messages.LinuxStyles_unknown, new RGB(100, 100, 100), 0.33f),
+
+ /**
+ * Wait for an unknown reason
+ */
+ WAIT_UNKNOWN(Messages.LinuxStyles_wait, new RGB(200, 200, 200), 0.50f),
+
+ /**
+ * Wait to be scheduled back in
+ */
+ WAIT_BLOCKED(Messages.LinuxStyles_waitBlocked, new RGB(200, 200, 0), 0.50f),
+
+ /**
+ * Wait for the CPU to be available
+ */
+ WAIT_FOR_CPU(Messages.LinuxStyles_waitForCPU, new RGB(200, 100, 0), 0.50f),
+
+ /**
+ * CPU is idle
+ */
+ IDLE(Messages.LinuxStyles_idle, new RGB(200, 200, 200), 0.66f),
+
+ /**
+ * CPU or thread is in usermode
+ */
+ USERMODE(Messages.LinuxStyles_usermode, new RGB(0, 200, 0), 1.00f),
+
+ /**
+ * CPU or thread is in a system call
+ */
+ SYSCALL(Messages.LinuxStyles_systemCall, new RGB(0, 0, 200), 1.00f),
+
+ /**
+ * CPU is in an IRQ
+ */
+ INTERRUPTED(Messages.LinuxStyles_Interrupt, new RGB(200, 0, 100), 0.75f),
+
+ /**
+ * A Softirq or tasklet is raised
+ */
+ SOFT_IRQ_RAISED(Messages.LinuxStyles_softIrqRaised, new RGB(200, 200, 0), 1.00f),
+
+ /**
+ * CPU is in a softirq or tasklet
+ */
+ SOFT_IRQ(Messages.LinuxStyles_softrq, new RGB(200, 150, 100), 1.00f);
+
+ private final float fHeightFactor;
+ private RGBA fColor;
+ private String fLabel;
+
+ /**
+ * A Linux style
+ *
+ * @param label
+ * The label of the style
+ * @param color
+ * the color
+ * @param heightFactor
+ * the hint of the height
+ */
+ private LinuxStyle(String label, RGB color, float heightFactor) {
+ this(label, new RGBA(color.red, color.green, color.blue, 255), heightFactor);
+ }
+
+ /**
+ * A Linux style
+ *
+ * @param label
+ * the label of the style
+ * @param color
+ * the color
+ * @param heightFactor
+ * the hint of the height, between 0 and 1.0
+ */
+ private LinuxStyle(String label, RGBA color, float heightFactor) {
+ if (heightFactor > 1.0 || heightFactor < 0) {
+ throw new IllegalStateException("Height factor needs to be between 0 and 1.0, given hint : " + heightFactor); //$NON-NLS-1$
+ }
+ fLabel = label;
+ fColor = color;
+ fHeightFactor = heightFactor;
+ }
+
+ /**
+ * Get the label
+ *
+ * @return the label to display
+ */
+ public String getLabel() {
+ return fLabel;
+ }
+
+ /**
+ * Get the color
+ *
+ * @return the color to display
+ */
+ public RGBA getColor() {
+ return fColor;
+ }
+
+ /**
+ * Get the hint height, to be multiplied by the
+ *
+ * @return the heightHint
+ */
+ public float getHeightFactor() {
+ return fHeightFactor;
+ }
+}
--- /dev/null
+/*******************************************************************************
+ * Copyright (c) 2017 Ericsson
+ *
+ * All rights reserved. This program and the accompanying materials are made
+ * available under the terms of the Eclipse Public License v1.0 which
+ * accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *******************************************************************************/
+
+package org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry;
+
+import org.eclipse.osgi.util.NLS;
+
+/**
+ * Messages
+ *
+ * @author Matthew Khouzam
+ */
+public class Messages extends NLS {
+ private static final String BUNDLE_NAME = "org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry.messages"; //$NON-NLS-1$
+ /**
+ * Idle
+ */
+ public static String LinuxStyles_idle;
+ /**
+ * Irq
+ */
+ public static String LinuxStyles_Interrupt;
+ /**
+ * Softirq raised
+ */
+ public static String LinuxStyles_softIrqRaised;
+ /**
+ * Softirq
+ */
+ public static String LinuxStyles_softrq;
+ /**
+ * Syscall
+ */
+ public static String LinuxStyles_systemCall;
+ /**
+ * Unknown
+ */
+ public static String LinuxStyles_unknown;
+ /**
+ * User mode
+ */
+ public static String LinuxStyles_usermode;
+ /**
+ * Wait
+ */
+ public static String LinuxStyles_wait;
+ /**
+ * Wait blocked
+ */
+ public static String LinuxStyles_waitBlocked;
+ /**
+ * Wait for CPU
+ */
+ public static String LinuxStyles_waitForCPU;
+ static {
+ // initialize resource bundle
+ NLS.initializeMessages(BUNDLE_NAME, Messages.class);
+ }
+
+ private Messages() {
+ }
+}
--- /dev/null
+###############################################################################
+# Copyright (c) 2017 Ericsson
+#
+# All rights reserved. This program and the accompanying materials
+# are made available under the terms of the Eclipse Public License v1.0
+# which accompanies this distribution, and is available at
+# http://www.eclipse.org/legal/epl-v10.html
+###############################################################################
+LinuxStyles_idle=Idle
+LinuxStyles_Interrupt=Interrupt
+LinuxStyles_softIrqRaised=Soft Irq raised
+LinuxStyles_softrq=Soft Irq
+LinuxStyles_systemCall=System call
+LinuxStyles_unknown=Unknown
+LinuxStyles_usermode=Usermode
+LinuxStyles_wait=Wait
+LinuxStyles_waitBlocked=Wait blocked
+LinuxStyles_waitForCPU=Wait for CPU
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
+import org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry.LinuxStyle;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.statesystem.core.exceptions.StateSystemDisposedException;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.model.TimeEvent;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
/**
* Presentation provider for the control flow view
*/
public class ControlFlowPresentationProvider extends TimeGraphPresentationProvider {
- private enum State {
- UNKNOWN (new RGB(100, 100, 100)),
- WAIT_UNKNOWN (new RGB(200, 200, 200)),
- WAIT_BLOCKED (new RGB(200, 200, 0)),
- WAIT_FOR_CPU (new RGB(200, 100, 0)),
- USERMODE (new RGB(0, 200, 0)),
- SYSCALL (new RGB(0, 0, 200)),
- INTERRUPTED (new RGB(200, 0, 100));
-
- public final RGB rgb;
+ private static final Map<Integer, StateItem> STATE_MAP;
+ private static final List<StateItem> STATE_LIST;
- private State(RGB rgb) {
- this.rgb = rgb;
- }
+ private static StateItem createState(LinuxStyle style) {
+ return new StateItem(style.getColor().rgb, style.getLabel());
+ }
+ static {
+ ImmutableMap.Builder<Integer, StateItem> builder = new ImmutableMap.Builder<>();
+ builder.put(StateValues.PROCESS_STATUS_UNKNOWN, createState(LinuxStyle.UNKNOWN));
+ builder.put(StateValues.PROCESS_STATUS_RUN_USERMODE, createState(LinuxStyle.USERMODE));
+ builder.put(StateValues.PROCESS_STATUS_RUN_SYSCALL, createState(LinuxStyle.SYSCALL));
+ builder.put(StateValues.PROCESS_STATUS_INTERRUPTED, createState(LinuxStyle.INTERRUPTED));
+ builder.put(StateValues.PROCESS_STATUS_WAIT_BLOCKED, createState(LinuxStyle.WAIT_BLOCKED));
+ builder.put(StateValues.PROCESS_STATUS_WAIT_FOR_CPU, createState(LinuxStyle.WAIT_FOR_CPU));
+ builder.put(StateValues.PROCESS_STATUS_WAIT_UNKNOWN, createState(LinuxStyle.WAIT_UNKNOWN));
+ STATE_MAP = builder.build();
+ STATE_LIST = ImmutableList.copyOf(STATE_MAP.values());
}
/**
super(Messages.ControlFlowView_stateTypeName);
}
- private static State[] getStateValues() {
- return State.values();
- }
-
@Override
public StateItem[] getStateTable() {
- State[] states = getStateValues();
- StateItem[] stateTable = new StateItem[states.length];
- for (int i = 0; i < stateTable.length; i++) {
- State state = states[i];
- stateTable[i] = new StateItem(state.rgb, state.toString());
- }
- return stateTable;
+ return STATE_LIST.toArray(new StateItem[STATE_LIST.size()]);
}
@Override
public int getStateTableIndex(ITimeEvent event) {
if (event instanceof TimeEvent && ((TimeEvent) event).hasValue()) {
int status = ((TimeEvent) event).getValue();
- return getMatchingState(status).ordinal();
+ return STATE_LIST.indexOf(getMatchingState(status));
}
if (event instanceof NullTimeEvent) {
return INVISIBLE;
if (event instanceof TimeEvent) {
TimeEvent ev = (TimeEvent) event;
if (ev.hasValue()) {
- return getMatchingState(ev.getValue()).toString();
+ return getMatchingState(ev.getValue()).getStateString();
}
}
return Messages.ControlFlowView_multipleStates;
}
- private static State getMatchingState(int status) {
- switch (status) {
- case StateValues.PROCESS_STATUS_WAIT_UNKNOWN:
- return State.WAIT_UNKNOWN;
- case StateValues.PROCESS_STATUS_WAIT_BLOCKED:
- return State.WAIT_BLOCKED;
- case StateValues.PROCESS_STATUS_WAIT_FOR_CPU:
- return State.WAIT_FOR_CPU;
- case StateValues.PROCESS_STATUS_RUN_USERMODE:
- return State.USERMODE;
- case StateValues.PROCESS_STATUS_RUN_SYSCALL:
- return State.SYSCALL;
- case StateValues.PROCESS_STATUS_INTERRUPTED:
- return State.INTERRUPTED;
- default:
- return State.UNKNOWN;
- }
+ private static StateItem getMatchingState(int status) {
+ return STATE_MAP.getOrDefault(status, STATE_MAP.get(StateValues.PROCESS_STATUS_WAIT_UNKNOWN));
}
@Override
/*
* Remove the "sys_" or "syscall_entry_" or similar from what we
- * draw in the rectangle. This depends on the trace's event layout.
+ * draw in the rectangle. This depends on the trace's event
+ * layout.
*/
int beginIndex = 0;
ITmfTrace trace = entry.getTrace();
import org.eclipse.swt.SWT;
import org.eclipse.swt.graphics.Color;
import org.eclipse.swt.graphics.GC;
-import org.eclipse.swt.graphics.RGB;
import org.eclipse.swt.graphics.Rectangle;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.KernelAnalysisModule;
import org.eclipse.tracecompass.analysis.os.linux.core.kernel.StateValues;
import org.eclipse.tracecompass.internal.analysis.os.linux.core.kernel.Attributes;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Activator;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.Messages;
+import org.eclipse.tracecompass.internal.analysis.os.linux.ui.registry.LinuxStyle;
import org.eclipse.tracecompass.internal.analysis.os.linux.ui.views.resources.ResourcesEntry.Type;
import org.eclipse.tracecompass.statesystem.core.ITmfStateSystem;
import org.eclipse.tracecompass.statesystem.core.exceptions.AttributeNotFoundException;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.Resolution;
import org.eclipse.tracecompass.tmf.ui.widgets.timegraph.widgets.Utils.TimeFormat;
+import com.google.common.collect.ImmutableList;
+import com.google.common.collect.ImmutableMap;
+
/**
* Presentation provider for the Resource view, based on the generic TMF
* presentation provider.
private Color fColorGray;
private Integer fAverageCharWidth;
- private enum State {
- IDLE (new RGB(200, 200, 200)),
- USERMODE (new RGB( 0, 200, 0)),
- SYSCALL (new RGB( 0, 0, 200)),
- IRQ (new RGB(200, 0, 100)),
- SOFT_IRQ (new RGB(200, 150, 100)),
- IRQ_ACTIVE (new RGB(200, 0, 100)),
- SOFT_IRQ_RAISED (new RGB(200, 200, 0)),
- SOFT_IRQ_ACTIVE (new RGB(200, 150, 100));
+ private static final Map<Integer, StateItem> STATE_MAP;
- public final RGB rgb;
+ private static final List<StateItem> STATE_LIST;
- private State(RGB rgb) {
- this.rgb = rgb;
- }
+ private static StateItem createState(LinuxStyle style) {
+ return new StateItem(style.getColor().rgb, style.getLabel());
+ }
+
+ static {
+ ImmutableMap.Builder<Integer, StateItem> builder = new ImmutableMap.Builder<>();
+ builder.put(StateValues.CPU_STATUS_IDLE, createState(LinuxStyle.IDLE));
+ builder.put(StateValues.CPU_STATUS_RUN_USERMODE, createState(LinuxStyle.USERMODE));
+ builder.put(StateValues.CPU_STATUS_RUN_SYSCALL, createState(LinuxStyle.SYSCALL));
+ builder.put(StateValues.CPU_STATUS_IRQ, createState(LinuxStyle.INTERRUPTED));
+ builder.put(StateValues.CPU_STATUS_SOFTIRQ, createState(LinuxStyle.SOFT_IRQ));
+ builder.put(StateValues.CPU_STATUS_SOFT_IRQ_RAISED, createState(LinuxStyle.SOFT_IRQ_RAISED));
+ STATE_MAP = builder.build();
+ STATE_LIST = ImmutableList.copyOf(STATE_MAP.values());
}
/**
super();
}
- private static State[] getStateValues() {
- return State.values();
- }
-
- private static State getEventState(TimeEvent event) {
+ private static StateItem getEventState(TimeEvent event) {
if (event.hasValue()) {
ResourcesEntry entry = (ResourcesEntry) event.getEntry();
int value = event.getValue();
if (entry.getType() == Type.CPU) {
- if (value == StateValues.CPU_STATUS_IDLE) {
- return State.IDLE;
- } else if (value == StateValues.CPU_STATUS_RUN_USERMODE) {
- return State.USERMODE;
- } else if (value == StateValues.CPU_STATUS_RUN_SYSCALL) {
- return State.SYSCALL;
- } else if (value == StateValues.CPU_STATUS_IRQ) {
- return State.IRQ;
- } else if (value == StateValues.CPU_STATUS_SOFTIRQ) {
- return State.SOFT_IRQ;
- } else if (value == StateValues.CPU_STATUS_SOFT_IRQ_RAISED) {
- return State.SOFT_IRQ_RAISED;
- }
+ return STATE_MAP.getOrDefault(value, STATE_MAP.get(StateValues.PROCESS_STATUS_UNKNOWN));
} else if (entry.getType() == Type.IRQ) {
- return State.IRQ_ACTIVE;
+ return STATE_MAP.get(StateValues.CPU_STATUS_IRQ);
} else if (entry.getType() == Type.SOFT_IRQ) {
if (value == StateValues.CPU_STATUS_SOFT_IRQ_RAISED) {
- return State.SOFT_IRQ_RAISED;
+ return STATE_MAP.get(StateValues.CPU_STATUS_SOFT_IRQ_RAISED);
}
- return State.SOFT_IRQ_ACTIVE;
+ return STATE_MAP.get(StateValues.CPU_STATUS_SOFTIRQ);
}
}
return null;
@Override
public int getStateTableIndex(ITimeEvent event) {
- State state = getEventState((TimeEvent) event);
+ StateItem state = getEventState((TimeEvent) event);
if (state != null) {
- return state.ordinal();
+ return STATE_LIST.indexOf(state);
}
if (event instanceof NullTimeEvent) {
return INVISIBLE;
@Override
public StateItem[] getStateTable() {
- State[] states = getStateValues();
- StateItem[] stateTable = new StateItem[states.length];
- for (int i = 0; i < stateTable.length; i++) {
- State state = states[i];
- stateTable[i] = new StateItem(state.rgb, state.toString());
- }
- return stateTable;
+ return STATE_LIST.toArray(new StateItem[STATE_LIST.size()]);
}
@Override
public String getEventName(ITimeEvent event) {
- State state = getEventState((TimeEvent) event);
+ StateItem state = getEventState((TimeEvent) event);
if (state != null) {
- return state.toString();
+ return state.getStateString();
}
if (event instanceof NullTimeEvent) {
return null;
// Check for IRQ or Soft_IRQ type
if (entry.getType().equals(Type.IRQ) || entry.getType().equals(Type.SOFT_IRQ)) {
- // Get CPU of IRQ or SoftIRQ and provide it for the tooltip display
+ // Get CPU of IRQ or SoftIRQ and provide it for the tooltip
+ // display
int cpu = tcEvent.getValue();
if (cpu >= 0) {
retMap.put(Messages.ResourcesView_attributeCpuName, String.valueOf(cpu));
/* Ignored */
}
} else if (status == StateValues.CPU_STATUS_SOFTIRQ) {
- // In SOFT_IRQ state get the SOFT_IRQ that caused the interruption
+ // In SOFT_IRQ state get the SOFT_IRQ that caused the
+ // interruption
int cpu = entry.getId();
try {
} else if (status == StateValues.CPU_STATUS_RUN_SYSCALL) {
attribute = Attributes.SYSTEM_CALL;
/*
- * Remove the "sys_" or "syscall_entry_" or similar from what we
- * draw in the rectangle. This depends on the trace's event layout.
+ * Remove the "sys_" or "syscall_entry_" or
+ * similar from what we draw in the rectangle.
+ * This depends on the trace's event layout.
*/
ITmfTrace trace = entry.getTrace();
if (trace instanceof IKernelTrace) {
@Override
protected List<String> getLegendValues() {
- return Arrays.asList("UNKNOWN", "WAIT_UNKNOWN", "WAIT_BLOCKED", "WAIT_FOR_CPU", "USERMODE", "SYSCALL", "INTERRUPTED");
+ return Arrays.asList("Unknown", "Usermode", "System call", "Interrupt", "Wait blocked", "Wait for CPU", "Wait");
}
@Override
"Add Bookmark...", "Previous Marker", "Next Marker", SEPARATOR,
"Select Previous Process", "Select Next Process", "Zoom In", "Zoom Out", SEPARATOR,
"Hide Arrows", "Follow CPU Backward", "Follow CPU Forward",
- "Go to previous event of the selected thread", "Go to next event of the selected thread" );
+ "Go to previous event of the selected thread", "Go to next event of the selected thread");
}
/**
timeGraphIsReadyCondition(new TmfTimeRange(START_TIME, START_TIME));
SWTBotView viewBot = getViewBot();
- SWTBotToolbarButton filterButton = viewBot .toolbarButton("Show View Filters");
+ SWTBotToolbarButton filterButton = viewBot.toolbarButton("Show View Filters");
filterButton.click();
fBot.waitUntil(org.eclipse.swtbot.swt.finder.waits.Conditions.shellIsActive("Filter"));
SWTBot bot = fBot.activeShell().bot();
}
private void timeGraphIsReadyCondition(@NonNull TmfTimeRange selectionRange) {
- IWorkbenchPart part = getViewBot() .getViewReference().getPart(false);
+ IWorkbenchPart part = getViewBot().getViewReference().getPart(false);
fBot.waitUntil(ConditionHelpers.timeGraphIsReadyCondition((AbstractTimeGraphView) part, selectionRange, selectionRange.getEndTime()));
}
}
@Override
protected List<String> getLegendValues() {
- return Arrays.asList("IDLE", "USERMODE", "SYSCALL", "IRQ", "SOFT_IRQ", "IRQ_ACTIVE", "SOFT_IRQ_RAISED", "SOFT_IRQ_ACTIVE");
+ return Arrays.asList("Idle", "Usermode", "System call", "Interrupt", "Soft Irq", "Soft Irq raised");
}
@Override