1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-08-04 06:45:43 +02:00

Display global variables in the Variables view.

This commit is contained in:
Mikhail Khodjaiants 2004-05-27 21:53:39 +00:00
parent 742d1b1514
commit f7b0d8de3b
25 changed files with 729 additions and 300 deletions

View file

@ -1,3 +1,18 @@
2004-05-27 Mikhail Khodjaiants
Display global variables in the Variables view.
* CDIDebugModel.java
* ICGlobalVariableManager.java: new
* IGlobalVariable.java: removed
* ICGlobalVariable.java
* IExecFileInfo.java
* IGlobalVariableDescriptor.java: new
* CGlobalVariableManager.java: new
* CDebugTarget.java
* CGlobalVariable.java
* CRegister.java
* CStackFrame.java
* CVariable.java
2004-05-20 Mikhail Khodjaiants 2004-05-20 Mikhail Khodjaiants
Removed dependencies on the compatibility plugin and replaced deprecated classes and methods. Removed dependencies on the compatibility plugin and replaced deprecated classes and methods.
Warning cleanup. Warning cleanup.

View file

@ -19,14 +19,17 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint; import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint; import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICWatchpoint; import org.eclipse.cdt.debug.core.model.ICWatchpoint;
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CAddressBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CFunctionBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CLineBreakpoint;
import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint; import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget; import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CExpression; import org.eclipse.cdt.debug.internal.core.model.CExpression;
import org.eclipse.cdt.debug.internal.core.model.CGlobalVariable;
import org.eclipse.core.resources.IMarker; import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IResource; import org.eclipse.core.resources.IResource;
import org.eclipse.core.runtime.CoreException; import org.eclipse.core.runtime.CoreException;
@ -389,4 +392,19 @@ public class CDIDebugModel {
} }
return null; return null;
} }
public static ICGlobalVariable createGlobalVariable( IDebugTarget target, IGlobalVariableDescriptor info ) throws DebugException {
if ( target != null && target instanceof CDebugTarget ) {
ICDIVariableObject vo = null;
try {
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( info.getPath().lastSegment(), null, info.getName() );
ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable( vo );
return new CGlobalVariable( (CDebugTarget)target, cdiVariable );
}
catch( CDIException e ) {
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, (vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null ) ); //$NON-NLS-1$
}
}
return null;
}
} }

View file

@ -0,0 +1,48 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.debug.core.DebugException;
/**
* Manages the collection of global variables added to a debug target.
*/
public interface ICGlobalVariableManager {
/**
* Registers with this manager the global variables specified by given descriptors.
*
* @param descriptors the descriptors of global variables to register with this manager
* @throws DebugException
*/
public void addGlobals( IGlobalVariableDescriptor[] descriptors ) throws DebugException;
/**
* Removes specified global variables from this manager.
*
* @param globals global variables to remove
*/
public void removeGlobals( ICGlobalVariable[] globals );
/**
* Removes all global variables from this manager.
*/
public void removeAllGlobals();
/**
* Returns the array of the global variables descriptors registered with this manager.
*
* @return the array of the global variables descriptors registered with this manager
*/
public IGlobalVariableDescriptor[] getDescriptors();
}

View file

@ -0,0 +1,18 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.core.model;
/**
* Represents a global C/C++ variable.
*/
public interface ICGlobalVariable extends ICVariable {
public void dispose();
}

View file

@ -22,5 +22,5 @@ public interface IExecFileInfo {
public boolean isLittleEndian(); public boolean isLittleEndian();
public IGlobalVariable[] getGlobals() throws DebugException; public IGlobalVariableDescriptor[] getGlobals() throws DebugException;
} }

View file

@ -12,7 +12,7 @@ import org.eclipse.core.runtime.IPath;
* *
* @since: Nov 4, 2002 * @since: Nov 4, 2002
*/ */
public interface IGlobalVariable public interface IGlobalVariableDescriptor
{ {
String getName(); String getName();
IPath getPath(); IPath getPath();

View file

@ -0,0 +1,124 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.core;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
import org.eclipse.cdt.debug.internal.core.model.CVariable;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
/**
* Manages all global variables registered with a debug target.
*/
public class CGlobalVariableManager implements ICGlobalVariableManager {
private CDebugTarget fDebugTarget;
private ArrayList fGlobals = new ArrayList( 10 );
/**
* Constructor for CGlobalVariableManager.
*/
public CGlobalVariableManager( CDebugTarget target ) {
super();
setDebugTarget( target );
}
protected CDebugTarget getDebugTarget() {
return fDebugTarget;
}
private void setDebugTarget( CDebugTarget debugTarget ) {
fDebugTarget = debugTarget;
}
public ICGlobalVariable[] getGlobals() {
return (ICGlobalVariable[])fGlobals.toArray( new ICGlobalVariable[fGlobals.size()] );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#addGlobals(IGlobalVariableDescriptor[])
*/
public void addGlobals( IGlobalVariableDescriptor[] descriptors ) throws DebugException {
MultiStatus ms = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(), 0, "", null ); //$NON-NLS-1$
ArrayList globals = new ArrayList( descriptors.length );
for ( int i = 0; i < descriptors.length; ++i ) {
try {
globals.add( CDIDebugModel.createGlobalVariable( getDebugTarget(), descriptors[i] ) );
}
catch( DebugException e ) {
ms.add( e.getStatus() );
}
}
if ( globals.size() > 0 ) {
synchronized( fGlobals ) {
fGlobals.addAll( globals );
}
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
}
if ( !ms.isOK() ) {
throw new DebugException( ms );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#removeGlobals(ICGlobalVariable[])
*/
public void removeGlobals( ICGlobalVariable[] globals ) {
synchronized( fGlobals ) {
fGlobals.removeAll( Arrays.asList( globals ) );
}
for ( int i = 0; i < globals.length; ++i ) {
globals[i].dispose();
}
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#removeAllGlobals()
*/
public void removeAllGlobals() {
ICGlobalVariable[] globals = new ICGlobalVariable[0];
synchronized( fGlobals ) {
globals = (ICGlobalVariable[])fGlobals.toArray( new ICGlobalVariable[fGlobals.size()] );
fGlobals.clear();
}
for ( int i = 0; i < globals.length; ++i ) {
((CVariable)globals[i]).dispose();
}
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
}
public void dispose() {
Iterator it = fGlobals.iterator();
while( it.hasNext() ) {
((ICGlobalVariable)it.next()).dispose();
}
fGlobals.clear();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#getDescriptors()
*/
public IGlobalVariableDescriptor[] getDescriptors() {
// TODO Auto-generated method stub
return null;
}
}

View file

@ -20,6 +20,7 @@ import org.eclipse.cdt.core.model.IParent;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel; import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils; import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
import org.eclipse.cdt.debug.core.ICMemoryManager; import org.eclipse.cdt.debug.core.ICMemoryManager;
import org.eclipse.cdt.debug.core.ICRegisterManager; import org.eclipse.cdt.debug.core.ICRegisterManager;
import org.eclipse.cdt.debug.core.ICSharedLibraryManager; import org.eclipse.cdt.debug.core.ICSharedLibraryManager;
@ -66,7 +67,7 @@ import org.eclipse.cdt.debug.core.model.ICSignal;
import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport; import org.eclipse.cdt.debug.core.model.IDebuggerProcessSupport;
import org.eclipse.cdt.debug.core.model.IDisassembly; import org.eclipse.cdt.debug.core.model.IDisassembly;
import org.eclipse.cdt.debug.core.model.IExecFileInfo; import org.eclipse.cdt.debug.core.model.IExecFileInfo;
import org.eclipse.cdt.debug.core.model.IGlobalVariable; import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.core.model.IJumpToAddress; import org.eclipse.cdt.debug.core.model.IJumpToAddress;
import org.eclipse.cdt.debug.core.model.IJumpToLine; import org.eclipse.cdt.debug.core.model.IJumpToLine;
import org.eclipse.cdt.debug.core.model.IRunToAddress; import org.eclipse.cdt.debug.core.model.IRunToAddress;
@ -75,6 +76,7 @@ import org.eclipse.cdt.debug.core.model.IState;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.CBreakpointManager; import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
import org.eclipse.cdt.debug.internal.core.CExpressionTarget; import org.eclipse.cdt.debug.internal.core.CExpressionTarget;
import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager;
import org.eclipse.cdt.debug.internal.core.CMemoryManager; import org.eclipse.cdt.debug.internal.core.CMemoryManager;
import org.eclipse.cdt.debug.internal.core.CRegisterManager; import org.eclipse.cdt.debug.internal.core.CRegisterManager;
import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager; import org.eclipse.cdt.debug.internal.core.CSharedLibraryManager;
@ -250,6 +252,8 @@ public class CDebugTarget extends CDebugElement
private CExpressionTarget fExpressionTarget; private CExpressionTarget fExpressionTarget;
private CGlobalVariableManager fGlobalVariableManager;
/** /**
* The suspension thread. * The suspension thread.
*/ */
@ -302,6 +306,7 @@ public class CDebugTarget extends CDebugElement
setSignalManager( new CSignalManager( this ) ); setSignalManager( new CSignalManager( this ) );
setRegisterManager( new CRegisterManager( this ) ); setRegisterManager( new CRegisterManager( this ) );
setBreakpointManager( new CBreakpointManager( this ) ); setBreakpointManager( new CBreakpointManager( this ) );
setGlobalVariableManager( new CGlobalVariableManager( this ) );
initialize(); initialize();
DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this ); DebugPlugin.getDefault().getLaunchManager().addLaunchListener( this );
DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this ); DebugPlugin.getDefault().getExpressionManager().addExpressionListener( this );
@ -997,6 +1002,8 @@ public class CDebugTarget extends CDebugElement
return getRegisterManager(); return getRegisterManager();
if ( adapter.equals( CExpressionTarget.class ) ) if ( adapter.equals( CExpressionTarget.class ) )
return getExpressionTarget(); return getExpressionTarget();
if ( adapter.equals( ICGlobalVariableManager.class ) )
return getGlobalVariableManager();
if ( adapter.equals( ICDISession.class ) ) if ( adapter.equals( ICDISession.class ) )
return getCDISession(); return getCDISession();
return super.getAdapter( adapter ); return super.getAdapter( adapter );
@ -1226,6 +1233,7 @@ public class CDebugTarget extends CDebugElement
DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this ); DebugPlugin.getDefault().getBreakpointManager().removeBreakpointListener( this );
DebugPlugin.getDefault().getExpressionManager().removeExpressionListener( this ); DebugPlugin.getDefault().getExpressionManager().removeExpressionListener( this );
DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this ); DebugPlugin.getDefault().getLaunchManager().removeLaunchListener( this );
disposeGlobalVariableManager();
disposeMemoryManager(); disposeMemoryManager();
disposeSharedLibraryManager(); disposeSharedLibraryManager();
disposeSignalManager(); disposeSignalManager();
@ -1988,7 +1996,7 @@ public class CDebugTarget extends CDebugElement
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.IExecFileInfo#getGlobals() * @see org.eclipse.cdt.debug.core.IExecFileInfo#getGlobals()
*/ */
public IGlobalVariable[] getGlobals() throws DebugException public IGlobalVariableDescriptor[] getGlobals() throws DebugException
{ {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) )
@ -1999,7 +2007,7 @@ public class CDebugTarget extends CDebugElement
list.addAll( getCFileGlobals( (IParent)cFile ) ); list.addAll( getCFileGlobals( (IParent)cFile ) );
} }
} }
return (IGlobalVariable[])list.toArray( new IGlobalVariable[list.size()] ); return (IGlobalVariableDescriptor[])list.toArray( new IGlobalVariableDescriptor[list.size()] );
} }
private List getCFileGlobals( IParent file ) throws DebugException private List getCFileGlobals( IParent file ) throws DebugException
@ -2027,9 +2035,9 @@ public class CDebugTarget extends CDebugElement
return list; return list;
} }
private IGlobalVariable createGlobalVariable( final org.eclipse.cdt.core.model.IVariable var ) private IGlobalVariableDescriptor createGlobalVariable( final org.eclipse.cdt.core.model.IVariable var )
{ {
return new IGlobalVariable() return new IGlobalVariableDescriptor()
{ {
public String getName() public String getName()
{ {
@ -2084,6 +2092,10 @@ public class CDebugTarget extends CDebugElement
fRegisterManager.dispose(); fRegisterManager.dispose();
} }
protected void disposeGlobalVariableManager() {
fGlobalVariableManager.dispose();
}
/** /**
* @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(long) * @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(long)
*/ */
@ -2488,4 +2500,12 @@ public class CDebugTarget extends CDebugElement
} }
return fExpressionTarget; return fExpressionTarget;
} }
protected CGlobalVariableManager getGlobalVariableManager() {
return fGlobalVariableManager;
}
private void setGlobalVariableManager( CGlobalVariableManager globalVariableManager ) {
fGlobalVariableManager = globalVariableManager;
}
} }

View file

@ -8,6 +8,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue; import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue; import org.eclipse.debug.core.model.IValue;
@ -17,7 +18,7 @@ import org.eclipse.debug.core.model.IValue;
* *
* @since: Oct 2, 2002 * @since: Oct 2, 2002
*/ */
public class CGlobalVariable extends CModificationVariable public class CGlobalVariable extends CModificationVariable implements ICGlobalVariable
{ {
/** /**
* Constructor for CGlobalVariable. * Constructor for CGlobalVariable.
@ -37,6 +38,8 @@ public class CGlobalVariable extends CModificationVariable
*/ */
public IValue getValue() throws DebugException public IValue getValue() throws DebugException
{ {
if ( !isEnabled() )
return fDisabledValue;
if ( fValue == null ) if ( fValue == null )
{ {
ICDIValue cdiValue = getCurrentValue(); ICDIValue cdiValue = getCurrentValue();
@ -90,4 +93,25 @@ public class CGlobalVariable extends CModificationVariable
} }
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.CVariable#dispose()
*/
public void dispose() {
if ( getShadow() != null )
getShadow().dispose();
try {
getCDISession().getVariableManager().destroyVariable( getCDIVariable() );
}
catch( CDIException e ) {
}
super.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable()
*/
public boolean canEnableDisable() {
return true;
}
} }

View file

@ -69,12 +69,4 @@ public class CRegister extends CGlobalVariable implements IRegister
{ {
return true; return true;
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable()
*/
public boolean canEnableDisable()
{
return false;
}
} }

View file

@ -22,6 +22,7 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener; import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame; import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.IRestart; import org.eclipse.cdt.debug.core.model.IRestart;
import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal; import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal;
@ -29,6 +30,7 @@ import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine; import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator; import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.CExpressionTarget; import org.eclipse.cdt.debug.internal.core.CExpressionTarget;
import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager;
import org.eclipse.core.runtime.IAdaptable; import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegisterGroup; import org.eclipse.debug.core.model.IRegisterGroup;
@ -95,8 +97,12 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
* @see org.eclipse.debug.core.model.IStackFrame#getVariables() * @see org.eclipse.debug.core.model.IStackFrame#getVariables()
*/ */
public IVariable[] getVariables() throws DebugException { public IVariable[] getVariables() throws DebugException {
List list = getVariables0(); ICGlobalVariable[] globals = getGlobals();
return (IVariable[])list.toArray( new IVariable[list.size()] ); List vars = getVariables0();
List all = new ArrayList( globals.length + vars.size() );
all.addAll( Arrays.asList( globals ) );
all.addAll( vars );
return (IVariable[])all.toArray( new IVariable[all.size()] );
} }
protected synchronized List getVariables0() throws DebugException { protected synchronized List getVariables0() throws DebugException {
@ -712,4 +718,12 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
CExpressionTarget target = (CExpressionTarget)getDebugTarget().getAdapter( CExpressionTarget.class ); CExpressionTarget target = (CExpressionTarget)getDebugTarget().getAdapter( CExpressionTarget.class );
return (target != null) ? target.evaluateExpression( expression ) : null; return (target != null) ? target.evaluateExpression( expression ) : null;
} }
private ICGlobalVariable[] getGlobals() {
CGlobalVariableManager gvm = ((CDebugTarget)getDebugTarget()).getGlobalVariableManager();
if ( gvm != null ) {
return gvm.getGlobals();
}
return new ICGlobalVariable[0];
}
} }

View file

@ -350,7 +350,7 @@ public abstract class CVariable extends CDebugElement
* Temporary solution to avoid NPE in VariablesView. * Temporary solution to avoid NPE in VariablesView.
* This is fixed in the Eclipse 2.1.1 Maintenance Build. * This is fixed in the Eclipse 2.1.1 Maintenance Build.
*/ */
static private IValue fDisabledValue = new IValue() static protected IValue fDisabledValue = new IValue()
{ {
public String getReferenceTypeName() throws DebugException public String getReferenceTypeName() throws DebugException
{ {
@ -559,7 +559,7 @@ public abstract class CVariable extends CDebugElement
return ( fValue instanceof CValue ) ? ((CValue)fValue).getUnderlyingValue() : null; return ( fValue instanceof CValue ) ? ((CValue)fValue).getUnderlyingValue() : null;
} }
protected void dispose() public void dispose()
{ {
if ( fValue != null ) if ( fValue != null )
{ {
@ -807,7 +807,7 @@ public abstract class CVariable extends CDebugElement
return ( fOriginal != null ) ? fOriginal.getCDIVariable() : null; return ( fOriginal != null ) ? fOriginal.getCDIVariable() : null;
} }
private InternalVariable getShadow() protected InternalVariable getShadow()
{ {
return fShadow; return fShadow;
} }

View file

@ -1,3 +1,18 @@
2004-05-27 Mikhail Khodjaiants
Display global variables in the Variables view.
* CDebugImages.java
* CDTDebugModelPresentation.java
* AddGlobalsActionDelegate.java
* RemoveAllGlobalsActionDelegate.java: new
* RemoveGlobalsActionDelegate.java: new
* plugin.properties
* plugin.xml
* icons/full/dlcl16/rem_all_co.gif: new
* icons/full/dlcl16/rem_co.gif: new
* icons/full/elcl16/rem_all_co.gif: new
* icons/full/elcl16/rem_co.gif: new
* icons/full/ovr16/global_ovr.gif: new
2004-05-25 Mikhail Khodjaiants 2004-05-25 Mikhail Khodjaiants
New instructuion pointer images for the Disassembly view. New instructuion pointer images for the Disassembly view.
* icons/full/obj16/inst_ptr_top.gif * icons/full/obj16/inst_ptr_top.gif

Binary file not shown.

After

Width:  |  Height:  |  Size: 187 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 159 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 204 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 163 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 54 B

View file

@ -48,6 +48,10 @@ ShowFullPathsAction.tooltip=Show Full Paths
AddGlobalsAction.label=Add Global Variables... AddGlobalsAction.label=Add Global Variables...
AddGlobalsAction.tooltip=Add Global Variables AddGlobalsAction.tooltip=Add Global Variables
RemoveGlobalsAction.label=Remove Global Variables
RemoveGlobalsAction.tooltip=Remove Selected Global Variables
RemoveAllGlobalsAction.label=Remove All Global Variables
RemoveAllGlobalsAction.tooltip=Remove All Global Variables
CVariableFormatMenu.label=Format CVariableFormatMenu.label=Format
HexVariableFormatAction.label=Hexadecimal HexVariableFormatAction.label=Hexadecimal

View file

@ -409,25 +409,6 @@
targetID="org.eclipse.debug.ui.BreakpointView" targetID="org.eclipse.debug.ui.BreakpointView"
id="org.eclipse.cdt.debug.ui.breakpointview.popupMenu"> id="org.eclipse.cdt.debug.ui.breakpointview.popupMenu">
</viewerContribution> </viewerContribution>
<viewerContribution
targetID="org.eclipse.debug.ui.ExpressionView"
id="org.eclipse.debug.ui.expressionView.popupMenu">
<action
label="%AddGlobalsAction.label"
icon="icons/full/clcl16/watch_globals.gif"
helpContextId="add_globals_action_context"
class="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate"
menubarPath="expressionGroup"
enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui">
</pluginState>
</enablement>
</action>
</viewerContribution>
<viewerContribution <viewerContribution
targetID="#ASMEditorRulerContext" targetID="#ASMEditorRulerContext"
id="org.eclipse.cdt.debug.ui.AsmEditorRulerActions"> id="org.eclipse.cdt.debug.ui.AsmEditorRulerActions">
@ -752,7 +733,7 @@
helpContextId="restore_default_type_action_context" helpContextId="restore_default_type_action_context"
tooltip="%RestoreDefaultTypeAction.tooltip" tooltip="%RestoreDefaultTypeAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"
menubarPath="additions" menubarPath="variableGroup"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.RestoreDefaultTypeActionDelegate">
<enablement> <enablement>
@ -768,7 +749,7 @@
helpContextId="cast_to_type_action_context" helpContextId="cast_to_type_action_context"
tooltip="%CastToTypeAction.tooltip" tooltip="%CastToTypeAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"
menubarPath="additions" menubarPath="variableGroup"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.CastToTypeActionDelegate">
<enablement> <enablement>
@ -784,7 +765,7 @@
helpContextId="cast_to_array_action_context" helpContextId="cast_to_array_action_context"
tooltip="%CastToArrayAction.tooltip" tooltip="%CastToArrayAction.tooltip"
class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate" class="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"
menubarPath="additions" menubarPath="variableGroup"
enablesFor="1" enablesFor="1"
id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate"> id="org.eclipse.cdt.debug.internal.ui.actions.CastToArrayActionDelegate">
<enablement> <enablement>
@ -818,6 +799,50 @@
<viewerContribution <viewerContribution
targetID="org.eclipse.debug.ui.VariableView" targetID="org.eclipse.debug.ui.VariableView"
id="org.eclipse.debug.ui.variablesView.popupMenu"> id="org.eclipse.debug.ui.variablesView.popupMenu">
<action
helpContextId="remove_all_globals_action_context"
enablesFor="*"
label="%RemoveAllGlobalsAction.label"
tooltip="%RemoveAllGlobalsAction.tooltip"
icon="icons/full/elcl16/rem_all_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.RemoveAllGlobalsActionDelegate"
menubarPath="additions"
id="org.eclipse.cdt.debug.internal.ui.actions.RemoveAllGlobalsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="remove_globals_action_context"
enablesFor="+"
label="%RemoveGlobalsAction.label"
tooltip="%RemoveGlobalsAction.tooltip"
icon="icons/full/elcl16/rem_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.RemoveGlobalsActionDelegate"
menubarPath="additions"
id="org.eclipse.cdt.debug.internal.ui.actions.RemoveGlobalsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="add_globals_action_context"
enablesFor="1"
label="%AddGlobalsAction.label"
class="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate"
icon="icons/full/clcl16/watch_globals.gif"
menubarPath="additions"
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action <action
label="%DisableVariablesAction.label" label="%DisableVariablesAction.label"
icon="icons/full/clcl16/disabled_co.gif" icon="icons/full/clcl16/disabled_co.gif"
@ -935,24 +960,57 @@
</action> </action>
</viewContribution> </viewContribution>
<viewContribution <viewContribution
targetID="org.eclipse.debug.ui.ExpressionView" targetID="org.eclipse.debug.ui.VariableView"
id="org.eclipse.debug.ui.expressionsView.toolbar"> id="org.eclipse.debug.ui.variablesView.toolbar">
<action <action
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate" helpContextId="remove_all_globals_action_context"
toolbarPath="expressionGroup" disabledIcon="icons/full/dlcl16/rem_all_co.gif"
hoverIcon="icons/full/clcl16/watch_globals.gif" hoverIcon="icons/full/elcl16/rem_all_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate" enablesFor="*"
disabledIcon="icons/full/dlcl16/watch_globals.gif" toolbarPath="additions"
enablesFor="1" label="%RemoveAllGlobalsAction.label"
icon="icons/full/elcl16/watch_globals.gif" tooltip="%RemoveAllGlobalsAction.tooltip"
helpContextId="add_globals_action_context" icon="icons/full/elcl16/rem_all_co.gif"
label="%AddGlobalsAction.label" class="org.eclipse.cdt.debug.internal.ui.actions.RemoveAllGlobalsActionDelegate"
tooltip="%AddGlobalsAction.tooltip"> id="org.eclipse.cdt.debug.internal.ui.actions.RemoveAllGlobalsActionDelegate">
<enablement> <enablement>
<pluginState <pluginState
value="activated" value="activated"
id="org.eclipse.cdt.debug.ui"> id="org.eclipse.cdt.debug.ui"/>
</pluginState> </enablement>
</action>
<action
helpContextId="remove_globals_action_context"
disabledIcon="icons/full/dlcl16/rem_co.gif"
hoverIcon="icons/full/elcl16/rem_co.gif"
enablesFor="+"
toolbarPath="additions"
label="%RemoveGlobalsAction.label"
tooltip="%RemoveGlobalsAction.tooltip"
icon="icons/full/elcl16/rem_co.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.RemoveGlobalsActionDelegate"
id="org.eclipse.cdt.debug.internal.ui.actions.RemoveGlobalsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement>
</action>
<action
helpContextId="add_globals_action_context"
disabledIcon="icons/full/dlcl16/watch_globals.gif"
hoverIcon="icons/full/clcl16/watch_globals.gif"
enablesFor="1"
toolbarPath="additions"
label="%AddGlobalsAction.label"
tooltip="%AddGlobalsAction.tooltip"
icon="icons/full/elcl16/watch_globals.gif"
class="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate"
id="org.eclipse.cdt.debug.internal.ui.actions.AddGlobalsActionDelegate">
<enablement>
<pluginState
value="activated"
id="org.eclipse.cdt.debug.ui"/>
</enablement> </enablement>
</action> </action>
</viewContribution> </viewContribution>

View file

@ -23,6 +23,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus; import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus;
import org.eclipse.cdt.debug.core.model.ICDebugTargetType; import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint; import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary; import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.model.ICStackFrame; import org.eclipse.cdt.debug.core.model.ICStackFrame;
@ -219,6 +220,8 @@ public class CDTDebugModelPresentation extends LabelProvider
overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR; overlays[OverlayImageDescriptor.BOTTOM_LEFT] = CDebugImages.DESC_OVRS_ERROR;
if ( element instanceof ICVariable && ((ICVariable)element).isArgument() ) if ( element instanceof ICVariable && ((ICVariable)element).isArgument() )
overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_ARGUMENT; overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_ARGUMENT;
if ( element instanceof ICGlobalVariable && !(element instanceof IRegister) )
overlays[OverlayImageDescriptor.TOP_RIGHT] = CDebugImages.DESC_OVRS_GLOBAL;
return fImageCache.getImageFor( new OverlayImageDescriptor( baseImage, overlays ) ); return fImageCache.getImageFor( new OverlayImageDescriptor( baseImage, overlays ) );
} }

View file

@ -62,6 +62,7 @@ public class CDebugImages
public static final String IMG_OVRS_SYMBOLS = NAME_PREFIX + "symbols_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_SYMBOLS = NAME_PREFIX + "symbols_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_VARIABLE_CASTED = NAME_PREFIX + "casttype_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_VARIABLE_CASTED = NAME_PREFIX + "casttype_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_ARGUMENT = NAME_PREFIX + "argument_ovr.gif"; //$NON-NLS-1$ public static final String IMG_OVRS_ARGUMENT = NAME_PREFIX + "argument_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OVRS_GLOBAL = NAME_PREFIX + "global_ovr.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_ENABLED = NAME_PREFIX + "brkp_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_BREAKPOINT_ENABLED = NAME_PREFIX + "brkp_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "brkpd_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_BREAKPOINT_DISABLED = NAME_PREFIX + "brkpd_obj.gif"; //$NON-NLS-1$
public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$ public static final String IMG_OBJS_ADDRESS_BREAKPOINT_ENABLED = NAME_PREFIX + "addrbrkp_obj.gif"; //$NON-NLS-1$
@ -137,6 +138,7 @@ public class CDebugImages
public static final ImageDescriptor DESC_OVRS_SYMBOLS = createManaged( T_OVR, IMG_OVRS_SYMBOLS ); public static final ImageDescriptor DESC_OVRS_SYMBOLS = createManaged( T_OVR, IMG_OVRS_SYMBOLS );
public static final ImageDescriptor DESC_OVRS_VARIABLE_CASTED = createManaged( T_OVR, IMG_OVRS_VARIABLE_CASTED ); public static final ImageDescriptor DESC_OVRS_VARIABLE_CASTED = createManaged( T_OVR, IMG_OVRS_VARIABLE_CASTED );
public static final ImageDescriptor DESC_OVRS_ARGUMENT = createManaged( T_OVR, IMG_OVRS_ARGUMENT ); public static final ImageDescriptor DESC_OVRS_ARGUMENT = createManaged( T_OVR, IMG_OVRS_ARGUMENT );
public static final ImageDescriptor DESC_OVRS_GLOBAL = createManaged( T_OVR, IMG_OVRS_GLOBAL );
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_BREAKPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_ENABLED );
public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED ); public static final ImageDescriptor DESC_OBJS_BREAKPOINT_DISABLED = createManaged( T_OBJ, IMG_OBJS_BREAKPOINT_DISABLED );
public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED ); public static final ImageDescriptor DESC_OBJS_WATCHPOINT_ENABLED = createManaged( T_OBJ, IMG_OBJS_WATCHPOINT_ENABLED );

View file

@ -1,23 +1,24 @@
/* /**********************************************************************
*(c) Copyright QNX Software Systems Ltd. 2002. * Copyright (c) 2004 QNX Software Systems and others.
* All Rights Reserved. * All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
* *
*/ * Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions; package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; import java.util.Arrays;
import org.eclipse.cdt.debug.core.CDebugModel; import java.util.List;
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
import org.eclipse.cdt.debug.core.model.IExecFileInfo; import org.eclipse.cdt.debug.core.model.IExecFileInfo;
import org.eclipse.cdt.debug.core.model.IGlobalVariable; import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin; import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IStatus; import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.MultiStatus;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IDebugElement; import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.core.model.IDebugTarget;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.ui.DebugUITools; import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.debug.ui.IDebugUIConstants; import org.eclipse.debug.ui.IDebugUIConstants;
import org.eclipse.jface.action.IAction; import org.eclipse.jface.action.IAction;
@ -40,354 +41,256 @@ import org.eclipse.ui.actions.ActionDelegate;
import org.eclipse.ui.dialogs.ListSelectionDialog; import org.eclipse.ui.dialogs.ListSelectionDialog;
/** /**
* Enter type comment. * A delegate for the "Add Globals" action.
*
* @since: Nov 4, 2002
*/ */
public class AddGlobalsActionDelegate extends ActionDelegate public class AddGlobalsActionDelegate extends ActionDelegate implements IViewActionDelegate, ISelectionListener, IPartListener {
implements IViewActionDelegate,
ISelectionListener,
IPartListener
{
protected class Global
{
private String fName;
private IPath fPath;
/** private IGlobalVariableDescriptor[] fGlobals;
* Constructor for Global.
*/
public Global( String name, IPath path )
{
fName = name;
fPath = path;
}
public String getName()
{
return fName;
}
public IPath getPath()
{
return fPath;
}
}
private Global[] fGlobals;
private IViewPart fView = null; private IViewPart fView = null;
private IAction fAction; private IAction fAction;
private IStructuredSelection fSelection; private IStructuredSelection fSelection;
private IStatus fStatus = null; private IStatus fStatus = null;
/** /*
* Constructor for AddGlobalsActionDelegate. * (non-Javadoc)
*/ *
public AddGlobalsActionDelegate()
{
super();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(IViewPart) * @see org.eclipse.ui.IViewActionDelegate#init(IViewPart)
*/ */
public void init( IViewPart view ) public void init( IViewPart view ) {
{
fView = view; fView = view;
view.getSite().getPage().addPartListener( this ); view.getSite().getPage().addPartListener( this );
view.getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); view.getSite().getPage().addSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection) * @see org.eclipse.ui.ISelectionListener#selectionChanged(IWorkbenchPart, ISelection)
*/ */
public void selectionChanged( IWorkbenchPart part, ISelection selection ) public void selectionChanged( IWorkbenchPart part, ISelection selection ) {
{ if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) {
if ( part != null && part.getSite().getId().equals( IDebugUIConstants.ID_DEBUG_VIEW ) ) if ( selection instanceof IStructuredSelection ) {
{
if ( selection instanceof IStructuredSelection )
{
setSelection( (IStructuredSelection)selection ); setSelection( (IStructuredSelection)selection );
} }
else else {
{
setSelection( null ); setSelection( null );
} }
update( getAction() ); update( getAction() );
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#run(IAction) * @see org.eclipse.ui.IActionDelegate#run(IAction)
*/ */
public void run( IAction action ) public void run( IAction action ) {
{
final IStructuredSelection selection = getSelection(); final IStructuredSelection selection = getSelection();
if ( selection != null && selection.size() != 1 ) if ( selection != null && selection.size() != 1 )
return; return;
BusyIndicator.showWhile( Display.getCurrent(), BusyIndicator.showWhile( Display.getCurrent(), new Runnable() {
new Runnable()
{ public void run() {
public void run() try {
{
try
{
doAction( selection.getFirstElement() ); doAction( selection.getFirstElement() );
setStatus( null ); setStatus( null );
} }
catch( DebugException e ) catch( DebugException e ) {
{
setStatus( e.getStatus() ); setStatus( e.getStatus() );
} }
} }
} ); } );
if ( getStatus() != null && !getStatus().isOK() ) if ( getStatus() != null && !getStatus().isOK() ) {
{ IWorkbenchWindow window = CDebugUIPlugin.getActiveWorkbenchWindow();
IWorkbenchWindow window= CDebugUIPlugin.getActiveWorkbenchWindow(); if ( window != null ) {
if ( window != null )
{
CDebugUIPlugin.errorDialog( getErrorDialogMessage(), getStatus() ); CDebugUIPlugin.errorDialog( getErrorDialogMessage(), getStatus() );
} }
else else {
{
CDebugUIPlugin.log( getStatus() ); CDebugUIPlugin.log( getStatus() );
} }
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection) * @see org.eclipse.ui.IActionDelegate#selectionChanged(IAction, ISelection)
*/ */
public void selectionChanged( IAction action, ISelection selection ) public void selectionChanged( IAction action, ISelection selection ) {
{
setAction( action ); setAction( action );
if ( getView() != null ) if ( getView() != null ) {
{
update( action ); update( action );
} }
} }
protected void update( IAction action ) protected void update( IAction action ) {
{ if ( action != null ) {
if ( action != null )
{
action.setEnabled( getEnableStateForSelection( getSelection() ) ); action.setEnabled( getEnableStateForSelection( getSelection() ) );
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partActivated(IWorkbenchPart)
*/ */
public void partActivated( IWorkbenchPart part ) public void partActivated( IWorkbenchPart part ) {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partBroughtToTop(IWorkbenchPart)
*/ */
public void partBroughtToTop( IWorkbenchPart part ) public void partBroughtToTop( IWorkbenchPart part ) {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partClosed(IWorkbenchPart)
*/ */
public void partClosed( IWorkbenchPart part ) public void partClosed( IWorkbenchPart part ) {
{ if ( part.equals( getView() ) ) {
if ( part.equals( getView() ) )
{
dispose(); dispose();
} }
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partDeactivated(IWorkbenchPart)
*/ */
public void partDeactivated( IWorkbenchPart part ) public void partDeactivated( IWorkbenchPart part ) {
{
} }
/* (non-Javadoc) /*
* (non-Javadoc)
*
* @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart) * @see org.eclipse.ui.IPartListener#partOpened(IWorkbenchPart)
*/ */
public void partOpened( IWorkbenchPart part ) public void partOpened( IWorkbenchPart part ) {
{
} }
protected IViewPart getView() protected IViewPart getView() {
{
return fView; return fView;
} }
protected void setView( IViewPart viewPart ) protected void setView( IViewPart viewPart ) {
{
fView = viewPart; fView = viewPart;
} }
protected void setAction( IAction action ) protected void setAction( IAction action ) {
{
fAction = action; fAction = action;
} }
protected IAction getAction() protected IAction getAction() {
{
return fAction; return fAction;
} }
private void setSelection( IStructuredSelection selection ) private void setSelection( IStructuredSelection selection ) {
{
fSelection = selection; fSelection = selection;
} }
private IStructuredSelection getSelection() private IStructuredSelection getSelection() {
{
return fSelection; return fSelection;
} }
public void dispose() public void dispose() {
{ if ( getView() != null ) {
if ( getView() != null )
{
getView().getViewSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this ); getView().getViewSite().getPage().removeSelectionListener( IDebugUIConstants.ID_DEBUG_VIEW, this );
getView().getViewSite().getPage().removePartListener( this ); getView().getViewSite().getPage().removePartListener( this );
} }
} }
protected boolean getEnableStateForSelection( IStructuredSelection selection ) protected boolean getEnableStateForSelection( IStructuredSelection selection ) {
{ if ( selection == null || selection.size() != 1 ) {
if ( selection == null || selection.size() != 1 )
{
return false; return false;
} }
Object element = selection.getFirstElement(); Object element = selection.getFirstElement();
return ( element != null && return (element != null && element instanceof IDebugElement && ((IDebugElement)element).getDebugTarget().getAdapter( IExecFileInfo.class ) != null);
element instanceof IDebugElement &&
((IDebugElement)element).getDebugTarget().getAdapter( IExecFileInfo.class ) != null );
} }
private ListSelectionDialog createDialog() private ListSelectionDialog createDialog() {
{ return new ListSelectionDialog( getView().getSite().getShell(), fGlobals, new IStructuredContentProvider() {
return new ListSelectionDialog( getView().getSite().getShell(),
fGlobals, public void inputChanged( Viewer viewer, Object oldInput, Object newInput ) {
new IStructuredContentProvider()
{
public void inputChanged( Viewer viewer, Object oldInput, Object newInput )
{
} }
public void dispose() public void dispose() {
{
} }
public Object[] getElements( Object parent ) public Object[] getElements( Object parent ) {
{
return getGlobals(); return getGlobals();
} }
}, }, new LabelProvider() {
new LabelProvider()
{ public String getText( Object element ) {
public String getText( Object element ) if ( element instanceof IGlobalVariableDescriptor ) {
{
if ( element instanceof Global )
{
String path = ""; //$NON-NLS-1$ String path = ""; //$NON-NLS-1$
if ( ((Global)element).getPath() != null ) if ( ((IGlobalVariableDescriptor)element).getPath() != null ) {
{ path = ((IGlobalVariableDescriptor)element).getPath().toString();
path = ((Global)element).getPath().toString();
int index = path.lastIndexOf( '/' ); int index = path.lastIndexOf( '/' );
if ( index != -1 ) if ( index != -1 )
path = path.substring( index + 1 ); path = path.substring( index + 1 );
} }
return ( path.length() > 0 ? ( '\'' + path + "\'::" ) : "" ) + ((Global)element).getName(); //$NON-NLS-1$ //$NON-NLS-2$ return (path.length() > 0 ? ('\'' + path + "\'::") : "") + ((IGlobalVariableDescriptor)element).getName(); //$NON-NLS-1$ //$NON-NLS-2$
} }
return null; return null;
} }
}, }, CDebugUIPlugin.getResourceString( "internal.ui.actions.AddGlobalsActionDelegate.Select_Variables" ) ); //$NON-NLS-1$
CDebugUIPlugin.getResourceString("internal.ui.actions.AddGlobalsActionDelegate.Select_Variables") ); //$NON-NLS-1$
} }
protected Global[] getGlobals() protected IGlobalVariableDescriptor[] getGlobals() {
{
return fGlobals; return fGlobals;
} }
protected void doAction( Object element ) throws DebugException protected void doAction( Object element ) throws DebugException {
{
if ( getView() == null ) if ( getView() == null )
return; return;
if ( element != null && element instanceof IDebugElement ) if ( element != null && element instanceof IDebugElement ) {
{
IExecFileInfo info = (IExecFileInfo)((IDebugElement)element).getDebugTarget().getAdapter( IExecFileInfo.class ); IExecFileInfo info = (IExecFileInfo)((IDebugElement)element).getDebugTarget().getAdapter( IExecFileInfo.class );
if ( info != null ) ICGlobalVariableManager gvm = (ICGlobalVariableManager)((IDebugElement)element).getDebugTarget().getAdapter( ICGlobalVariableManager.class );
{ if ( info != null && gvm != null ) {
IGlobalVariable[] globalVars = info.getGlobals(); fGlobals = info.getGlobals();
fGlobals = new Global[globalVars.length];
for ( int i = 0; i < globalVars.length; ++i )
{
fGlobals[i] = new Global( globalVars[i].getName(), globalVars[i].getPath() );
}
ListSelectionDialog dlg = createDialog(); ListSelectionDialog dlg = createDialog();
if ( dlg.open() == Window.OK ) if ( dlg.open() == Window.OK ) {
{ List list = Arrays.asList( dlg.getResult() );
MultiStatus ms = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(), DebugException.REQUEST_FAILED, getStatusMessage(), null ); IGlobalVariableDescriptor[] selections = (IGlobalVariableDescriptor[])list.toArray( new IGlobalVariableDescriptor[list.size()] );
Object[] selections = dlg.getResult(); gvm.addGlobals( selections );
for ( int i = 0; i < selections.length; ++i )
{
try
{
createExpression( ((IDebugElement)element).getDebugTarget(), (Global)selections[i] );
}
catch( DebugException e )
{
ms.merge( e.getStatus() );
}
}
if ( !ms.isOK() )
{
throw new DebugException( ms );
} }
} }
} }
} }
}
protected String getStatusMessage()
{
return CDebugUIPlugin.getResourceString("internal.ui.actions.AddGlobalsActionDelegate.Exceptions_occurred_attempting_to_add_global_variables."); //$NON-NLS-1$
}
/** /**
* @see AbstractDebugActionDelegate#getErrorDialogMessage() * @see AbstractDebugActionDelegate#getErrorDialogMessage()
*/ */
protected String getErrorDialogMessage() protected String getErrorDialogMessage() {
{ return CDebugUIPlugin.getResourceString( "internal.ui.actions.AddGlobalsActionDelegate.Add_global_variables_failed" ); //$NON-NLS-1$
return CDebugUIPlugin.getResourceString("internal.ui.actions.AddGlobalsActionDelegate.Add_global_variables_failed"); //$NON-NLS-1$
} }
protected void setStatus( IStatus status ) protected void setStatus( IStatus status ) {
{
fStatus = status; fStatus = status;
} }
protected IStatus getStatus() protected IStatus getStatus() {
{
return fStatus; return fStatus;
} }
private void createExpression( IDebugTarget target, Global global ) throws DebugException /*
{ * (non-Javadoc)
IExpression expression = CDebugModel.createExpressionForGlobalVariable( target, global.getPath(), global.getName() ); *
DebugPlugin.getDefault().getExpressionManager().addExpression( expression );
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction) * @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
*/ */
public void init( IAction action ) public void init( IAction action ) {
{
super.init( action ); super.init( action );
Object element = DebugUITools.getDebugContext(); Object element = DebugUITools.getDebugContext();
setSelection( (element != null ) ? new StructuredSelection( element ) : new StructuredSelection() ); setSelection( (element != null) ? new StructuredSelection( element ) : new StructuredSelection() );
update( action ); update( action );
} }
} }

View file

@ -0,0 +1,51 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IDebugElement;
import org.eclipse.debug.ui.DebugUITools;
import org.eclipse.jface.action.IAction;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
/**
* A delegate for the "Remove All Globals" action.
*/
public class RemoveAllGlobalsActionDelegate extends ActionDelegate implements IViewActionDelegate {
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
public void init( IViewPart view ) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action ) {
IAdaptable context = DebugUITools.getDebugContext();
if ( context instanceof IDebugElement ) {
final ICGlobalVariableManager gvm = (ICGlobalVariableManager)((IDebugElement)context).getDebugTarget().getAdapter( ICGlobalVariableManager.class );
if ( gvm != null ) {
DebugPlugin.getDefault().asyncExec(
new Runnable() {
public void run() {
gvm.removeAllGlobals();
}
} );
}
}
}
}

View file

@ -0,0 +1,120 @@
/**********************************************************************
* Copyright (c) 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Common Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.jface.action.IAction;
import org.eclipse.jface.viewers.ISelection;
import org.eclipse.jface.viewers.IStructuredSelection;
import org.eclipse.ui.IViewActionDelegate;
import org.eclipse.ui.IViewPart;
import org.eclipse.ui.actions.ActionDelegate;
/**
* A delegate for the "Remove Globals" action.
*/
public class RemoveGlobalsActionDelegate extends ActionDelegate implements IViewActionDelegate {
private IAction fAction;
private ISelection fSelection;
/* (non-Javadoc)
* @see org.eclipse.ui.IViewActionDelegate#init(org.eclipse.ui.IViewPart)
*/
public void init( IViewPart view ) {
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate2#init(org.eclipse.jface.action.IAction)
*/
public void init( IAction action ) {
setAction( action );
update();
}
/* (non-Javadoc)
* @see org.eclipse.ui.IActionDelegate#run(org.eclipse.jface.action.IAction)
*/
public void run( IAction action ) {
ISelection selection = getSelection();
if ( !(selection instanceof IStructuredSelection) )
return;
IStructuredSelection ss = (IStructuredSelection)selection;
final Iterator enum = ss.iterator();
ArrayList list = new ArrayList( ss.size() );
while( enum.hasNext() ) {
Object obj = enum.next();
if ( obj instanceof ICGlobalVariable )
list.add( obj );
}
if ( list.size() == 0 )
return;
final ICGlobalVariable[] globals = (ICGlobalVariable[])list.toArray( new ICGlobalVariable[list.size()] );
final ICGlobalVariableManager gvm = (ICGlobalVariableManager)globals[0].getDebugTarget().getAdapter( ICGlobalVariableManager.class );
if ( gvm == null )
return;
Runnable r = new Runnable() {
public void run() {
gvm.removeGlobals( globals );
}
};
DebugPlugin.getDefault().asyncExec( r );
}
/*
* (non-Javadoc)
*
* @see org.eclipse.ui.IActionDelegate#selectionChanged(org.eclipse.jface.action.IAction, org.eclipse.jface.viewers.ISelection)
*/
public void selectionChanged( IAction action, ISelection selection ) {
setSelection( selection );
update();
}
protected IAction getAction() {
return fAction;
}
protected ISelection getSelection() {
return fSelection;
}
private void setAction( IAction action ) {
fAction = action;
}
private void setSelection( ISelection selection ) {
fSelection = selection;
}
private void update() {
IAction action = getAction();
if ( action != null ) {
ISelection selection = getSelection();
boolean enabled = false;
if ( selection instanceof IStructuredSelection ) {
Iterator it = ((IStructuredSelection)selection).iterator();
while( it.hasNext() ) {
if ( it.next() instanceof ICGlobalVariable ) {
enabled = true;
break;
}
}
}
action.setEnabled( enabled );
}
}
}