Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Dumais2013-04-12 16:08:54 +0000
committerMarc Khouzam2013-04-16 01:39:35 +0000
commit76b5dde840f5b0f1e50232dbdc28cdd09c63be20 (patch)
treed3e71bb86654aaf2cff3bff5b5b96cba9a5757cd /dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf
parent482e736a08f0955055272340766f496ebed083e4 (diff)
downloadorg.eclipse.cdt-76b5dde840f5b0f1e50232dbdc28cdd09c63be20.tar.gz
org.eclipse.cdt-76b5dde840f5b0f1e50232dbdc28cdd09c63be20.tar.xz
org.eclipse.cdt-76b5dde840f5b0f1e50232dbdc28cdd09c63be20.zip
Bug 399419 - [visualizer] Minimize visualizer model (re-)creation
Change-Id: I74bddda8a2eb814c04b93089d10bbb0683e747f5 Reviewed-on: https://git.eclipse.org/r/11601 IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com> Reviewed-by: William Swanson <traveler@tilera.com> Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com>
Diffstat (limited to 'dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf')
-rwxr-xr-xdsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizer.java41
-rwxr-xr-xdsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerCanvas.java4
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java108
3 files changed, 107 insertions, 46 deletions
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 76910a4fa53..65443da8b91 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
@@ -10,6 +10,7 @@
* IBM Corporation
* Marc Dumais (Ericsson) - Bug 399281
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268)
+ * Marc Dumais (Ericsson) - Bug 399419
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@@ -665,7 +666,8 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
{
// Execute a refresh after any pending UI updates.
GUIUtils.exec( new Runnable() { @Override public void run() {
- MulticoreVisualizer.this.refresh();
+ // check if we need to update the debug context
+ updateDebugContext();
}});
}
};
@@ -692,8 +694,20 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
@Override
public void workbenchSelectionChanged(ISelection selection)
{
- refresh();
-
+ // See if we need to update our debug info from
+ // the workbench selection. This will be done asynchronously.
+ boolean changed = updateDebugContext();
+
+ if (changed) {
+ update();
+ }
+ else {
+ // Even if debug info doesn't change, we still want to
+ // check whether the canvas selection needs to change
+ // to reflect the current workbench selection.
+ updateCanvasSelection();
+ }
+
// Also check whether we need to attach debug view listener.
updateDebugViewListener();
}
@@ -701,14 +715,8 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
/** Refreshes visualizer content from model. */
public void refresh()
{
- // See if we need to update our debug info from
- // the workbench selection. This will be done asynchronously.
- boolean changed = updateDebugContext();
-
- // Even if debug info doesn't change, we still want to
- // check whether the canvas selection needs to change
- // to reflect the current workbench selection.
- if (!changed) updateCanvasSelection();
+ m_canvas.requestRecache();
+ m_canvas.requestUpdate();
}
@@ -829,7 +837,7 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
* Returns true if canvas context actually changes, false if not.
*/
public boolean setDebugSession(String sessionId) {
- boolean changed = true;
+ boolean changed = false;
if (m_sessionState != null &&
! m_sessionState.getSessionID().equals(sessionId))
@@ -854,8 +862,6 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
initializeLoadMeterTimer();
changed = true;
}
-
- if (changed) update();
return changed;
}
@@ -1102,7 +1108,12 @@ public class MulticoreVisualizer extends GraphicCanvasVisualizer
// If we can't get the real Linux OS tid, fallback to using the gdb thread id
int osTid = (osTIDValue == null) ? tid : Integer.parseInt(osTIDValue);
- model.addThread(new VisualizerThread(core, pid, osTid, tid, state));
+ // add thread if not already there - there is a potential race condition where a
+ // thread can be added twice to the model: once at model creation and once more
+ // through the listener. Checking at both places to prevent this.
+ if (model.getThread(tid) == null) {
+ model.addThread(new VisualizerThread(core, pid, osTid, tid, state));
+ }
// keep track of threads visited
done(1, model);
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 9ba43feeb85..6a9e554f4a1 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
@@ -13,6 +13,7 @@
* Marc Dumais (Ericsson) - Bug 396293
* Marc Dumais (Ericsson) - Bug 399281
* Marc Dumais (Ericsson) - Add CPU/core load information to the multicore visualizer (Bug 396268)
+ * Marc Dumais (Ericsson) - Bug 399419
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@@ -970,13 +971,14 @@ public class MulticoreVisualizerCanvas extends GraphicCanvas
@Override
public void setSelection(ISelection selection)
{
- m_selectionManager.setSelection(selection);
+ setSelection(selection, true);
}
/** Sets externally-visible selection. */
public void setSelection(ISelection selection, boolean raiseEvent)
{
m_selectionManager.setSelection(selection, raiseEvent);
+ requestUpdate();
}
/** Sets whether selection events are enabled. */
diff --git a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java
index bd8e70615a7..f33b780800b 100644
--- a/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java
+++ b/dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java
@@ -8,12 +8,14 @@
* Contributors:
* Marc Khouzam (Ericsson) - initial API and implementation
* Marc Dumais (Ericsson) - Bug 400231
+ * Marc Dumais (Ericsson) - Bug 399419
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
import org.eclipse.cdt.dsf.concurrent.ImmediateDataRequestMonitor;
import org.eclipse.cdt.dsf.datamodel.DMContexts;
+import org.eclipse.cdt.dsf.datamodel.DataModelInitializedEvent;
import org.eclipse.cdt.dsf.datamodel.IDMContext;
import org.eclipse.cdt.dsf.debug.service.IProcesses;
import org.eclipse.cdt.dsf.debug.service.IProcesses.IThreadDMContext;
@@ -61,39 +63,72 @@ public class MulticoreVisualizerEventListener {
// --- event handlers ---
- /** Invoked when a thread or process is suspended. */
+ /**
+ * Invoked when a thread or process is suspended.
+ * Updates both state of the thread and the core it's running on
+ */
@DsfServiceEventHandler
- public void handleEvent(ISuspendedDMEvent event) {
+ public void handleEvent(final ISuspendedDMEvent event) {
IDMContext context = event.getDMContext();
if (context instanceof IContainerDMContext) {
// We don't deal with processes
} else if (context instanceof IMIExecutionDMContext) {
// Thread suspended
- int tid = ((IMIExecutionDMContext)context).getThreadId();
-
- VisualizerThread thread = fVisualizer.getModel().getThread(tid);
- if (thread != null) {
- assert thread.getState() == VisualizerExecutionState.RUNNING;
-
- VisualizerExecutionState newState = VisualizerExecutionState.SUSPENDED;
-
- if (event.getReason() == StateChangeReason.SIGNAL) {
- if (event instanceof IMIDMEvent) {
- Object miEvent = ((IMIDMEvent)event).getMIEvent();
- if (miEvent instanceof MISignalEvent) {
- String signalName = ((MISignalEvent)miEvent).getName();
- if (DSFDebugModel.isCrashSignal(signalName)) {
- newState = VisualizerExecutionState.CRASHED;
- }
-
- }
- }
- }
-
- thread.setState(newState);
- fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
- }
+ final IMIExecutionDMContext execDmc = (IMIExecutionDMContext)context;
+ IThreadDMContext threadContext =
+ DMContexts.getAncestorOfType(execDmc, IThreadDMContext.class);
+
+ DsfServicesTracker tracker =
+ new DsfServicesTracker(MulticoreVisualizerUIPlugin.getBundleContext(),
+ execDmc.getSessionId());
+ IProcesses procService = tracker.getService(IProcesses.class);
+ tracker.dispose();
+
+ procService.getExecutionData(threadContext,
+ new ImmediateDataRequestMonitor<IThreadDMData>() {
+ @Override
+ protected void handleSuccess() {
+ IThreadDMData data = getData();
+
+ // Check whether we know about cores
+ if (data instanceof IGdbThreadDMData) {
+ String[] cores = ((IGdbThreadDMData)data).getCores();
+ if (cores != null) {
+ assert cores.length == 1; // A thread belongs to a single core
+ int coreId = Integer.parseInt(cores[0]);
+ VisualizerCore vCore = fVisualizer.getModel().getCore(coreId);
+
+ int tid = execDmc.getThreadId();
+
+ VisualizerThread thread = fVisualizer.getModel().getThread(tid);
+
+ if (thread != null) {
+ assert thread.getState() == VisualizerExecutionState.RUNNING;
+
+ VisualizerExecutionState newState = VisualizerExecutionState.SUSPENDED;
+
+ if (event.getReason() == StateChangeReason.SIGNAL) {
+ if (event instanceof IMIDMEvent) {
+ Object miEvent = ((IMIDMEvent)event).getMIEvent();
+ if (miEvent instanceof MISignalEvent) {
+ String signalName = ((MISignalEvent)miEvent).getName();
+ if (DSFDebugModel.isCrashSignal(signalName)) {
+ newState = VisualizerExecutionState.CRASHED;
+ }
+ }
+ }
+ }
+
+ thread.setState(newState);
+ thread.setCore(vCore);
+ fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
+ }
+ }
+ }
+ }
+ }
+ );
}
}
@@ -165,9 +200,13 @@ public class MulticoreVisualizerEventListener {
// That is ok, we'll be refreshing right away at startup
}
- fVisualizer.getModel().addThread(new VisualizerThread(vCore, pid, osTid, tid, VisualizerExecutionState.RUNNING));
-
- fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
+ // add thread if not already there - there is a potential race condition where a
+ // thread can be added twice to the model: once at model creation and once more
+ // through the listener. Checking at both places to prevent this.
+ if (fVisualizer.getModel().getThread(tid) == null ) {
+ fVisualizer.getModel().addThread(new VisualizerThread(vCore, pid, osTid, tid, VisualizerExecutionState.RUNNING));
+ fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
+ }
}
}
}
@@ -193,6 +232,15 @@ public class MulticoreVisualizerEventListener {
canvas.requestUpdate();
}
}
- }
+ }
+
+
+ /** Invoked when the debug data model is ready */
+ @DsfServiceEventHandler
+ public void handleEvent(DataModelInitializedEvent event) {
+ // re-create the visualizer model now that CPU and core info is available
+ fVisualizer.update();
+ }
+
}

Back to the top