summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Dumais2013-05-15 13:35:24 (EDT)
committerMarc-Andre Laperle2013-06-25 13:37:42 (EDT)
commit0f64dbba50eed09c4bcda69fb20508e371098fed (patch)
treefad6a177efa389b8c1bff9e5633fd6af7fa800b5
parent94fd0f7c7dbc60b811fbc117ecf7604fb7d915b6 (diff)
downloadorg.eclipse.cdt-0f64dbba50eed09c4bcda69fb20508e371098fed.zip
org.eclipse.cdt-0f64dbba50eed09c4bcda69fb20508e371098fed.tar.gz
org.eclipse.cdt-0f64dbba50eed09c4bcda69fb20508e371098fed.tar.bz2
Bug 407321 - [visualizer] Make Multicore Visualizer canvas filter awarerefs/changes/41/12841/3
of the current debug session Change-Id: Ib2cbb0cab6589f92609ef5f2ae82e6a6bf3cf656 Reviewed-on: https://git.eclipse.org/r/12841 Reviewed-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> IP-Clean: Marc-Andre Laperle <marc-andre.laperle@ericsson.com> Tested-by: Marc-Andre Laperle <marc-andre.laperle@ericsson.com>
-rwxr-xr-xdsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerModel.java13
-rwxr-xr-xdsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java3
-rwxr-xr-xdsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java54
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvasFilterManager.java141
4 files changed, 186 insertions, 25 deletions
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerModel.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerModel.java
index dfc9b87..0a967ad 100755
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerModel.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/model/VisualizerModel.java
@@ -8,6 +8,7 @@
* Contributors:
* William R. Swanson (Tilera Corporation) - initial API and implementation
* Marc Dumais (Ericsson) - Bug 405390
+ * Marc Dumais (Ericsson) - Bug 407321
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model;
@@ -50,10 +51,14 @@ public class VisualizerModel
protected boolean m_loadMetersEnabled = false;
+ /** data source corresponding to this model */
+ protected String m_sessionId = null;
+
// --- constructors/destructors ---
/** Constructor */
- public VisualizerModel() {
+ public VisualizerModel(String sessionId) {
+ m_sessionId = sessionId;
m_cpus = new ArrayList<VisualizerCPU>();
m_cpuMap = new Hashtable<Integer, VisualizerCPU>();
m_threads = new ArrayList<VisualizerThread>();
@@ -87,6 +92,7 @@ public class VisualizerModel
m_loadTodo.dispose();
m_loadTodo = null;
}
+ m_sessionId = null;
}
@@ -110,6 +116,11 @@ public class VisualizerModel
return m_loadMetersEnabled;
}
+ /** Gets the unique id for the source this model was build from */
+ public String getSessionId() {
+ return m_sessionId;
+ }
+
// --- methods ---
/** Sorts cores, cpus, etc. by IDs. */
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
index c5cc327..a10ec65 100755
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java
@@ -13,6 +13,7 @@
* Marc Dumais (Ericsson) - Bug 399419
* Marc Dumais (Ericsson) - Bug 405390
* Marc Dumais (Ericsson) - Bug 409006
+ * Marc Dumais (Ericsson) - Bug 407321
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@@ -997,7 +998,7 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
*/
@ConfinedToDsfExecutor("getSession().getExecutor()")
public void getVisualizerModel() {
- fDataModel = new VisualizerModel();
+ fDataModel = new VisualizerModel(m_sessionState.getSessionID());
DSFDebugModel.getCPUs(m_sessionState, this, fDataModel);
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java
index ffc3283..f545015 100755
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java
@@ -16,6 +16,7 @@
* Marc Dumais (Ericsson) - Bug 399419
* Marc Dumais (Ericsson) - Bug 404894
* Marc Dumais (Ericsson) - Bug 405390
+ * Marc Dumais (Ericsson) - Bug 407321
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@@ -140,8 +141,8 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
/** Selected PIDs. */
protected HashSet<Integer> m_selectedPIDs = null;
- /** Display filter for the graphical objects */
- protected MulticoreVisualizerCanvasFilter m_canvasFilter = null;
+ /** Canvas filter manager */
+ protected MulticoreVisualizerCanvasFilterManager m_canvasFilterManager = null;
/** Canvas status bar */
protected MulticoreVisualizerStatusBar m_statusBar = null;
@@ -234,9 +235,9 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
};
m_updateTimer.setRepeating(false); // one-shot timer
m_updateTimer.start();
-
- // canvas filter
- m_canvasFilter = new MulticoreVisualizerCanvasFilter(this);
+
+ // filter manager
+ m_canvasFilterManager = new MulticoreVisualizerCanvasFilterManager(this);
// status bar
m_statusBar = new MulticoreVisualizerStatusBar();
@@ -288,9 +289,9 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
m_selectedPIDs.clear();
m_selectedPIDs = null;
}
- if (m_canvasFilter != null) {
- m_canvasFilter.dispose();
- m_canvasFilter = null;
+ if (m_canvasFilterManager != null) {
+ m_canvasFilterManager.dispose();
+ m_canvasFilterManager = null;
}
if (m_statusBar != null) {
m_statusBar.dispose();
@@ -311,8 +312,15 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
public void setModel(VisualizerModel model)
{
m_model = model;
- // TODO : Consider clearing the filter if the model changes,
- // by calling clearFilter()
+
+ // Set filter associated to new model
+ if (m_model != null) {
+ m_canvasFilterManager.setCurrentFilter(m_model.getSessionId());
+ }
+ else {
+ m_canvasFilterManager.setCurrentFilter(null);
+ }
+
requestRecache();
requestUpdate();
}
@@ -380,7 +388,7 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
// clear status bar message
m_statusBar.setMessage(null);
// re-compute filter to reflect latest model changes
- m_canvasFilter.updateFilter();
+ m_canvasFilterManager.updateCurrentFilter();
}
/** Fits n square items into a rectangle of the specified size.
@@ -437,14 +445,14 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
for (VisualizerCPU cpu : m_model.getCPUs()) {
//if (force_cpu_count >= cpu_count) break;
//cpu_count++;
- // filter permits displaying this CPU?
- if (m_canvasFilter.displayObject(cpu)) {
+ // current filter permits displaying this CPU?
+ if (m_canvasFilterManager.displayObject(cpu)) {
MulticoreVisualizerCPU mcpu = new MulticoreVisualizerCPU(cpu.getID());
m_cpus.add(mcpu);
m_cpuMap.put(cpu, mcpu);
for (VisualizerCore core : cpu.getCores()) {
- // filter permits displaying this core?
- if (m_canvasFilter.displayObject(core)) {
+ // current filter permits displaying this core?
+ if(m_canvasFilterManager.displayObject(core)) {
MulticoreVisualizerCore mcore = new MulticoreVisualizerCore(mcpu, core.getID());
m_cores.add(mcore);
m_coreMap.put(core, mcore);
@@ -632,8 +640,8 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
// like processes and threads
for (VisualizerThread thread : m_model.getThreads()) {
- // filter permits displaying this thread?
- if(m_canvasFilter.displayObject(thread)) {
+ // current filter permits displaying this thread?
+ if(m_canvasFilterManager.displayObject(thread)) {
VisualizerCore core = thread.getCore();
MulticoreVisualizerCore mcore = m_coreMap.get(core);
if (mcore != null) {
@@ -722,8 +730,8 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
}
// paint status bar
- if (m_canvasFilter.isFilterActive()) {
- m_statusBar.setMessage(m_canvasFilter.toString());
+ if (m_canvasFilterManager.isCurrentFilterActive()) {
+ m_statusBar.setMessage(m_canvasFilterManager.getCurrentFilter().toString());
m_statusBar.paintContent(gc);
}
@@ -1100,16 +1108,16 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
/** Set-up a canvas white-list filter. */
public void applyFilter() {
- m_canvasFilter.applyFilter();
+ m_canvasFilterManager.applyFilter();
}
- /** Removes any canvas filter currently in place */
+ /** Removes the canvas filter currently in place */
public void clearFilter() {
- m_canvasFilter.clearFilter();
+ m_canvasFilterManager.clearFilter();
}
/** Tells if a canvas filter is currently in place */
public boolean isFilterActive() {
- return m_canvasFilter.isFilterActive();
+ return m_canvasFilterManager.isCurrentFilterActive();
}
}
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvasFilterManager.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvasFilterManager.java
new file mode 100644
index 0000000..a260935
--- /dev/null
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvasFilterManager.java
@@ -0,0 +1,141 @@
+/*******************************************************************************
+ * Copyright (c) 2013 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
+ *
+ * Contributors:
+ * Marc Dumais (Ericsson) - Initial API and implementation (Bug 407321)
+ *******************************************************************************/
+
+package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
+
+import java.util.Hashtable;
+
+import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.IVisualizerModelObject;
+import org.eclipse.cdt.dsf.service.DsfSession;
+import org.eclipse.cdt.dsf.service.DsfSession.SessionEndedListener;
+
+/**
+ * Manages the canvas filters for all current debug sessions.
+ */
+public class MulticoreVisualizerCanvasFilterManager implements SessionEndedListener {
+
+ /** map containing the filter lists for different debug sessions */
+ private Hashtable<String,MulticoreVisualizerCanvasFilter> m_filterSessionMap = null;
+
+ /** reference to the canvas */
+ private MulticoreVisualizerCanvas m_canvas = null;
+
+ /** filter currently in place */
+ private MulticoreVisualizerCanvasFilter m_currentFilter = null;
+
+ /** Constructor */
+ public MulticoreVisualizerCanvasFilterManager(MulticoreVisualizerCanvas canvas) {
+ m_filterSessionMap = new Hashtable<String,MulticoreVisualizerCanvasFilter>();
+ m_canvas = canvas;
+ // add listener to be notified when a debug session ends
+ DsfSession.addSessionEndedListener(this);
+ }
+
+ /** dispose method */
+ public void dispose() {
+ // remove listener
+ DsfSession.removeSessionEndedListener(this);
+
+ // dispose of any filter
+ if (m_filterSessionMap != null) {
+ for (MulticoreVisualizerCanvasFilter filter : m_filterSessionMap.values()) {
+ filter.dispose();
+ }
+ m_filterSessionMap.clear();
+ m_filterSessionMap = null;
+ }
+ m_canvas = null;
+ m_currentFilter = null;
+ }
+
+ /**
+ * Returns existing filter for a given debug session or creates a new
+ * filter if it doesn't exist yet.
+ */
+ public MulticoreVisualizerCanvasFilter getFilter(String sessionId) {
+ MulticoreVisualizerCanvasFilter filter = null;
+ // already a filter for this session ?
+ filter = m_filterSessionMap.get(sessionId);
+
+ // no filter yet for this session? Create one
+ if (filter == null) {
+ // create one
+ filter = new MulticoreVisualizerCanvasFilter(m_canvas);
+ m_filterSessionMap.put(sessionId, filter);
+
+ }
+ return filter;
+ }
+
+ /** Removes the filter in place for a given debug session, if any. */
+ public void removeFilter(String sessionId) {
+ if (m_filterSessionMap.containsKey(sessionId)) {
+ m_filterSessionMap.remove(sessionId);
+ }
+ }
+
+ /** Re-computes the current filter to reflect latest model changes */
+ public void updateCurrentFilter() {
+ if( m_currentFilter != null) {
+ m_currentFilter.updateFilter();
+ }
+ }
+
+ /** Sets-up a filter, based on the current canvas selection */
+ public void applyFilter() {
+ if( m_currentFilter != null) {
+ m_currentFilter.applyFilter();
+ }
+ }
+
+ /** Clears the current filter */
+ public void clearFilter() {
+ if( m_currentFilter != null) {
+ m_currentFilter.clearFilter();
+ }
+ }
+
+ /** Sets the current filter for a given model/session */
+ public void setCurrentFilter(String sessionId) {
+ if (sessionId == null) {
+ m_currentFilter = null;
+ }
+ else {
+ m_currentFilter = getFilter(sessionId);
+ }
+ }
+
+ /** Returns the current filter */
+ public MulticoreVisualizerCanvasFilter getCurrentFilter() {
+ return m_currentFilter;
+ }
+
+ /** Checks if the current filter is active */
+ public boolean isCurrentFilterActive() {
+ if( m_currentFilter != null) {
+ return m_currentFilter.isFilterActive();
+ }
+ return false;
+ }
+
+ /** Checks if the current filter permits the display of an object */
+ public boolean displayObject(final IVisualizerModelObject obj) {
+ if( m_currentFilter != null) {
+ return m_currentFilter.displayObject(obj);
+ }
+ return false;
+ }
+
+ @Override
+ public void sessionEnded(DsfSession session) {
+ removeFilter(session.getId());
+ }
+}