mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-04-22 06:02:11 +02:00
Patch by Alena Laskavaia for 186172: NullPointerException in debugger console
This commit is contained in:
parent
b90fcb3b0c
commit
b127b4265f
3 changed files with 49 additions and 25 deletions
|
@ -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
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,8 +7,9 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* QNX Software Systems - Initial API and implementation
|
* 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 java.util.Map;
|
||||||
import org.eclipse.cdt.debug.mi.core.cdi.model.Target;
|
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 {
|
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 );
|
super( launch, process, name, attributes );
|
||||||
fTarget = target;
|
fTarget = target;
|
||||||
|
fireChangeEvent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Target getTarget() {
|
public Target getTarget() {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 STMicroelectronics.
|
* Copyright (c) 2006, 2008 STMicroelectronics and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,6 +7,7 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* STMicroelectronics - Process console enhancements
|
* STMicroelectronics - Process console enhancements
|
||||||
|
* Alena Laskavaia (QNX) - Fix for 186172
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.ui.console;
|
package org.eclipse.cdt.debug.mi.ui.console;
|
||||||
|
|
||||||
|
@ -14,6 +15,7 @@ import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.GDBProcess;
|
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.MiConsoleSaveAction;
|
||||||
import org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleVerboseModeAction;
|
import org.eclipse.cdt.debug.mi.ui.console.actions.MiConsoleVerboseModeAction;
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
|
@ -44,7 +46,7 @@ public class MiConsolePageParticipant implements IConsolePageParticipant, IDebug
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
if(GDBProcess != null) {
|
if (GDBProcess != null) {
|
||||||
DebugPlugin.getDefault().removeDebugEventListener(this);
|
DebugPlugin.getDefault().removeDebugEventListener(this);
|
||||||
}
|
}
|
||||||
fSaveConsole = null;
|
fSaveConsole = null;
|
||||||
|
@ -73,9 +75,13 @@ public class MiConsolePageParticipant implements IConsolePageParticipant, IDebug
|
||||||
|
|
||||||
// add a debug event listener
|
// add a debug event listener
|
||||||
DebugPlugin.getDefault().addDebugEventListener(this);
|
DebugPlugin.getDefault().addDebugEventListener(this);
|
||||||
|
// if we miss change event update enablement manually
|
||||||
// register this object as MISession observer
|
fVerboseMode.updateStateAndEnablement();
|
||||||
GDBProcess.getTarget().getMISession().addObserver(this);
|
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];
|
DebugEvent event = events[i];
|
||||||
if (event.getSource().equals(GDBProcess)) {
|
if (event.getSource().equals(GDBProcess)) {
|
||||||
if (fVerboseMode != null) {
|
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) {
|
public void update(Observable arg0, Object arg1) {
|
||||||
if((arg1!=null) && (arg1 instanceof VerboseModeChangedEvent) && (fVerboseMode != null)) {
|
if((arg1!=null) && (arg1 instanceof VerboseModeChangedEvent) && (fVerboseMode != null)) {
|
||||||
try {
|
try {
|
||||||
fVerboseMode.setChecked(GDBProcess.getTarget().isVerboseModeEnabled());
|
fVerboseMode.updateStateAndEnablement();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
* Copyright (c) 2006 STMicroelectronics.
|
* Copyright (c) 2006, 2008 STMicroelectronics and others.
|
||||||
* All rights reserved. This program and the accompanying materials
|
* All rights reserved. This program and the accompanying materials
|
||||||
* are made available under the terms of the Eclipse Public License v1.0
|
* are made available under the terms of the Eclipse Public License v1.0
|
||||||
* which accompanies this distribution, and is available at
|
* which accompanies this distribution, and is available at
|
||||||
|
@ -7,35 +7,45 @@
|
||||||
*
|
*
|
||||||
* Contributors:
|
* Contributors:
|
||||||
* STMicroelectronics - Process console enhancements
|
* STMicroelectronics - Process console enhancements
|
||||||
|
* Alena Laskavaia (QNX) - Fix for 186172
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
package org.eclipse.cdt.debug.mi.ui.console.actions;
|
package org.eclipse.cdt.debug.mi.ui.console.actions;
|
||||||
|
|
||||||
import org.eclipse.cdt.debug.mi.core.GDBProcess;
|
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.cdt.debug.mi.internal.ui.MIUIPlugin;
|
||||||
import org.eclipse.debug.ui.console.IConsole;
|
import org.eclipse.debug.ui.console.IConsole;
|
||||||
import org.eclipse.jface.action.Action;
|
import org.eclipse.jface.action.Action;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Verbose console mode switcher
|
* Verbose console mode switcher
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public class MiConsoleVerboseModeAction extends Action {
|
public class MiConsoleVerboseModeAction extends Action {
|
||||||
|
|
||||||
private IConsole fConsole;
|
private IConsole fConsole;
|
||||||
|
|
||||||
public MiConsoleVerboseModeAction(IConsole console) {
|
public MiConsoleVerboseModeAction(IConsole console) {
|
||||||
super();
|
super();
|
||||||
setToolTipText(MiConsoleMessages.verboseActionTooltip);
|
setToolTipText(MiConsoleMessages.verboseActionTooltip);
|
||||||
setImageDescriptor(MIUIPlugin.imageDescriptorFromPlugin(MIUIPlugin.PLUGIN_ID,IMiConsoleImagesConst.IMG_VERBOSE_CONSOLE));
|
setImageDescriptor(MIUIPlugin.imageDescriptorFromPlugin(MIUIPlugin.PLUGIN_ID, IMiConsoleImagesConst.IMG_VERBOSE_CONSOLE));
|
||||||
fConsole = console;
|
fConsole = console;
|
||||||
GDBProcess fProcess = (GDBProcess) fConsole.getProcess();
|
|
||||||
setChecked(fProcess.getTarget().getMISession().isVerboseModeEnabled());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
public void run() {
|
||||||
GDBProcess fProcess = (GDBProcess) fConsole.getProcess();
|
GDBProcess fProcess = (GDBProcess) fConsole.getProcess();
|
||||||
fProcess.getTarget().enableVerboseMode(isChecked());
|
fProcess.getTarget().enableVerboseMode(isChecked());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue