Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Leherbauer2008-01-15 04:17:01 -0500
committerAnton Leherbauer2008-01-15 04:17:01 -0500
commit48ed21f9a50a88ee6e0c46a4864ff624da2a0236 (patch)
treeedea6de8b98427bb9d11340bae3d191f54d3e93b
parent23bdd46fd90bb4daff3b7e7ccfac8b9abc978081 (diff)
downloadorg.eclipse.cdt-48ed21f9a50a88ee6e0c46a4864ff624da2a0236.tar.gz
org.eclipse.cdt-48ed21f9a50a88ee6e0c46a4864ff624da2a0236.tar.xz
org.eclipse.cdt-48ed21f9a50a88ee6e0c46a4864ff624da2a0236.zip
Patch by Alena Laskavaia for 186172: NullPointerException in debugger console
-rw-r--r--debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java11
-rw-r--r--debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java29
-rw-r--r--debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java34
3 files changed, 49 insertions, 25 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java
index bb7e5ce15d..c2af352362 100644
--- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java
+++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/GDBProcess.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2004, 2006 QNX Software Systems and others.
+ * Copyright (c) 2004, 2008 QNX Software Systems and others.
* 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
@@ -7,8 +7,9 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
+ * Alena Laskavaia (QNX) - Fix for 186172
*******************************************************************************/
-package org.eclipse.cdt.debug.mi.core;
+package org.eclipse.cdt.debug.mi.core;
import java.util.Map;
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
@@ -17,11 +18,13 @@ import org.eclipse.debug.core.model.RuntimeProcess;
public class GDBProcess extends RuntimeProcess {
- private Target fTarget;
+ // volatile because the field may be accessed concurrently during construction
+ private volatile Target fTarget;
- public GDBProcess( Target target, ILaunch launch, Process process, String name, Map attributes ) {
+ public GDBProcess(Target target, ILaunch launch, Process process, String name, Map attributes) {
super( launch, process, name, attributes );
fTarget = target;
+ fireChangeEvent();
}
public Target getTarget() {
diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java
index 94564d8688..78010df070 100644
--- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java
+++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/MiConsolePageParticipant.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 STMicroelectronics.
+ * Copyright (c) 2006, 2008 STMicroelectronics and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* STMicroelectronics - Process console enhancements
+ * Alena Laskavaia (QNX) - Fix for 186172
*******************************************************************************/
package org.eclipse.cdt.debug.mi.ui.console;
@@ -14,6 +15,7 @@ import java.util.Observable;
import java.util.Observer;
import org.eclipse.cdt.debug.mi.core.GDBProcess;
+import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleSaveAction;
import org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleVerboseModeAction;
import org.eclipse.debug.core.DebugEvent;
@@ -44,7 +46,7 @@ public class MiConsolePageParticipant implements IConsolePageParticipant, IDebug
}
public void dispose() {
- if(GDBProcess != null) {
+ if (GDBProcess != null) {
DebugPlugin.getDefault().removeDebugEventListener(this);
}
fSaveConsole = null;
@@ -73,9 +75,13 @@ public class MiConsolePageParticipant implements IConsolePageParticipant, IDebug
// add a debug event listener
DebugPlugin.getDefault().addDebugEventListener(this);
-
- // register this object as MISession observer
- GDBProcess.getTarget().getMISession().addObserver(this);
+ // if we miss change event update enablement manually
+ fVerboseMode.updateStateAndEnablement();
+ Target target = GDBProcess.getTarget();
+ if (target != null) {
+ // register this object as MISession observer
+ target.getMISession().addObserver(this);
+ }
}
}
}
@@ -89,7 +95,12 @@ public class MiConsolePageParticipant implements IConsolePageParticipant, IDebug
DebugEvent event = events[i];
if (event.getSource().equals(GDBProcess)) {
if (fVerboseMode != null) {
- fVerboseMode.setEnabled(!GDBProcess.isTerminated());
+ fVerboseMode.updateStateAndEnablement();
+ Target target = GDBProcess.getTarget();
+ if (target != null) {
+ // register this object as MISession observer
+ target.getMISession().addObserver(this);
+ }
}
}
}
@@ -101,9 +112,9 @@ public class MiConsolePageParticipant implements IConsolePageParticipant, IDebug
public void update(Observable arg0, Object arg1) {
if((arg1!=null) && (arg1 instanceof VerboseModeChangedEvent) && (fVerboseMode != null)) {
try {
- fVerboseMode.setChecked(GDBProcess.getTarget().isVerboseModeEnabled());
- } catch (Exception e) {
- }
+ fVerboseMode.updateStateAndEnablement();
+ } catch (Exception e) {
+ }
}
}
diff --git a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java
index 205445b287..6fe1ad28f1 100644
--- a/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java
+++ b/debug/org.eclipse.cdt.debug.mi.ui/src/org/eclipse/cdt/debug/mi/ui/console/actions/MiConsoleVerboseModeAction.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2006 STMicroelectronics.
+ * Copyright (c) 2006, 2008 STMicroelectronics and others.
* 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
@@ -7,35 +7,45 @@
*
* Contributors:
* STMicroelectronics - Process console enhancements
+ * Alena Laskavaia (QNX) - Fix for 186172
*******************************************************************************/
package org.eclipse.cdt.debug.mi.ui.console.actions;
import org.eclipse.cdt.debug.mi.core.GDBProcess;
+import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
import org.eclipse.cdt.debug.mi.internal.ui.MIUIPlugin;
import org.eclipse.debug.ui.console.IConsole;
import org.eclipse.jface.action.Action;
/**
* Verbose console mode switcher
- *
+ *
*/
public class MiConsoleVerboseModeAction extends Action {
-
private IConsole fConsole;
-
+
public MiConsoleVerboseModeAction(IConsole console) {
- super();
- setToolTipText(MiConsoleMessages.verboseActionTooltip);
- setImageDescriptor(MIUIPlugin.imageDescriptorFromPlugin(MIUIPlugin.PLUGIN_ID,IMiConsoleImagesConst.IMG_VERBOSE_CONSOLE));
- fConsole = console;
- GDBProcess fProcess = (GDBProcess) fConsole.getProcess();
- setChecked(fProcess.getTarget().getMISession().isVerboseModeEnabled());
+ super();
+ setToolTipText(MiConsoleMessages.verboseActionTooltip);
+ setImageDescriptor(MIUIPlugin.imageDescriptorFromPlugin(MIUIPlugin.PLUGIN_ID, IMiConsoleImagesConst.IMG_VERBOSE_CONSOLE));
+ fConsole = console;
}
-
+
+ public void updateStateAndEnablement() {
+ // initialize button
+ GDBProcess gdbProcess = (GDBProcess) fConsole.getProcess();
+ setEnabled(!gdbProcess.isTerminated());
+ Target target = gdbProcess.getTarget();
+ if (target != null) {
+ setChecked(target.isVerboseModeEnabled());
+ } else {
+ setChecked(false);
+ }
+ }
+
public void run() {
GDBProcess fProcess = (GDBProcess) fConsole.getProcess();
fProcess.getTarget().enableVerboseMode(isChecked());
}
-
}

Back to the top