summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Dumais2013-09-05 16:04:41 (EDT)
committer Marc Khouzam2013-09-05 16:11:52 (EDT)
commit02393d61f18f0ac50f4d32e23ba6177cf6e214e2 (patch)
treea6b0877522db785a2d2cf28d2aec841060e8120c
parentcf559e543b7a9a7f7974a89aa3954b08764a908b (diff)
downloadorg.eclipse.cdt-02393d61f18f0ac50f4d32e23ba6177cf6e214e2.zip
org.eclipse.cdt-02393d61f18f0ac50f4d32e23ba6177cf6e214e2.tar.gz
org.eclipse.cdt-02393d61f18f0ac50f4d32e23ba6177cf6e214e2.tar.bz2
Bug 416524 - [Visualizer] NPE first session in C++ perspective
Change-Id: I586bccc85b043d7e1cadf5298aaf3c22bb79e950 Reviewed-on: https://git.eclipse.org/r/16156 Reviewed-by: Alvaro Sanchez-Leon <alvsan09@gmail.com> Reviewed-by: Marc Khouzam <marc.khouzam@ericsson.com> IP-Clean: Marc Khouzam <marc.khouzam@ericsson.com> Tested-by: Marc Khouzam <marc.khouzam@ericsson.com> Signed-off-by: Marc Khouzam <marc.khouzam@ericsson.com> Signed-off-by: Marc Dumais <marc.dumais@ericsson.com>
-rw-r--r--dsf-gdb/org.eclipse.cdt.dsf.gdb.multicorevisualizer.ui/src/org/eclipse/cdt/dsf/gdb/multicorevisualizer/internal/ui/view/MulticoreVisualizerEventListener.java42
1 files changed, 34 insertions, 8 deletions
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 146d195..2438c6d 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
@@ -12,6 +12,7 @@
* Marc Dumais (Ericsson) - Bug 405390
* Marc Dumais (Ericsson) - Bug 396269
* Marc Dumais (Ericsson) - Bug 409512
+ * Marc Dumais (Ericsson) - Bug 416524
*******************************************************************************/
package org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.view;
@@ -32,6 +33,7 @@ import org.eclipse.cdt.dsf.debug.service.IRunControl.StateChangeReason;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.MulticoreVisualizerUIPlugin;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerCore;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerExecutionState;
+import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerModel;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.ui.model.VisualizerThread;
import org.eclipse.cdt.dsf.gdb.multicorevisualizer.internal.utils.DSFDebugModel;
import org.eclipse.cdt.dsf.gdb.service.IGDBProcesses.IGdbThreadDMData;
@@ -72,6 +74,12 @@ public class MulticoreVisualizerEventListener {
*/
@DsfServiceEventHandler
public void handleEvent(final ISuspendedDMEvent event) {
+ // make sure model exists
+ final VisualizerModel model = fVisualizer.getModel();
+ if (model == null) {
+ return;
+ }
+
IDMContext context = event.getDMContext();
if (context instanceof IContainerDMContext) {
// We don't deal with processes
@@ -100,11 +108,11 @@ public class MulticoreVisualizerEventListener {
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);
+ VisualizerCore vCore = model.getCore(coreId);
int tid = execDmc.getThreadId();
- VisualizerThread thread = fVisualizer.getModel().getThread(tid);
+ VisualizerThread thread = model.getThread(tid);
if (thread != null) {
assert thread.getState() == VisualizerExecutionState.RUNNING;
@@ -138,6 +146,12 @@ public class MulticoreVisualizerEventListener {
/** Invoked when a thread or process is resumed. */
@DsfServiceEventHandler
public void handleEvent(IResumedDMEvent event) {
+ // make sure model exists
+ VisualizerModel model = fVisualizer.getModel();
+ if (model == null) {
+ return;
+ }
+
IDMContext context = event.getDMContext();
if (context instanceof IContainerDMContext) {
// We don't deal with processes
@@ -145,7 +159,7 @@ public class MulticoreVisualizerEventListener {
// Thread resumed
int tid = ((IMIExecutionDMContext)context).getThreadId();
- VisualizerThread thread = fVisualizer.getModel().getThread(tid);
+ VisualizerThread thread = model.getThread(tid);
if (thread != null) {
assert thread.getState() == VisualizerExecutionState.SUSPENDED ||
@@ -160,6 +174,12 @@ public class MulticoreVisualizerEventListener {
/** Invoked when a thread or process starts. */
@DsfServiceEventHandler
public void handleEvent(IStartedDMEvent event) {
+ // make sure model exists
+ final VisualizerModel model = fVisualizer.getModel();
+ if (model == null) {
+ return;
+ }
+
IDMContext context = event.getDMContext();
if (context instanceof IContainerDMContext) {
// We don't deal with processes
@@ -189,7 +209,7 @@ public class MulticoreVisualizerEventListener {
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);
+ VisualizerCore vCore = model.getCore(coreId);
// There is a race condition that sometimes happens here. We can reach
// here because we were notified that a thread is started, but the model
// is not yet completely constructed. If the model doesn't yet contain the
@@ -214,8 +234,8 @@ public class MulticoreVisualizerEventListener {
// 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));
+ if (model.getThread(tid) == null ) {
+ model.addThread(new VisualizerThread(vCore, pid, osTid, tid, VisualizerExecutionState.RUNNING));
fVisualizer.getMulticoreVisualizerCanvas().requestUpdate();
}
}
@@ -229,6 +249,12 @@ public class MulticoreVisualizerEventListener {
/** Invoked when a thread or process exits. */
@DsfServiceEventHandler
public void handleEvent(IExitedDMEvent event) {
+ // make sure model exists
+ final VisualizerModel model = fVisualizer.getModel();
+ if (model == null) {
+ return;
+ }
+
IDMContext context = event.getDMContext();
final MulticoreVisualizerCanvas canvas = fVisualizer.getMulticoreVisualizerCanvas();
@@ -256,7 +282,7 @@ public class MulticoreVisualizerEventListener {
for (IDMContext c : contexts) {
if (c instanceof IMIExecutionDMContext) {
int tid = ((IMIExecutionDMContext)c).getThreadId();
- fVisualizer.getModel().markThreadExited(tid);
+ model.markThreadExited(tid);
}
}
@@ -271,7 +297,7 @@ public class MulticoreVisualizerEventListener {
// Thread exited
int tid = ((IMIExecutionDMContext)context).getThreadId();
- fVisualizer.getModel().markThreadExited(tid);
+ model.markThreadExited(tid);
if (canvas != null) {
canvas.requestUpdate();