1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-22 14:12:10 +02:00

Patch by Alena Laskavaia for 186172: NullPointerException in debugger console

This commit is contained in:
Anton Leherbauer 2008-01-15 09:12:57 +00:00
parent b90fcb3b0c
commit b127b4265f
3 changed files with 49 additions and 25 deletions

View file

@ -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,6 +7,7 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
* Alena Laskavaia (QNX) - Fix for 186172
*******************************************************************************/
package org.eclipse.cdt.debug.mi.core;
@ -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() {

View file

@ -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) {
}
}
}

View file

@ -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,10 +7,12 @@
*
* 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;
@ -20,22 +22,30 @@ import org.eclipse.jface.action.Action;
*
*/
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());
}
}