mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-08-01 05:15:43 +02:00
Made global variables persistent.
This commit is contained in:
parent
0b88e30bae
commit
dee933ea8c
12 changed files with 261 additions and 56 deletions
|
@ -1,3 +1,17 @@
|
||||||
|
2004-09-03 Mikhail Khodjaiants
|
||||||
|
Made global variables persistent.
|
||||||
|
* CDIDebugModel.java
|
||||||
|
* ICDTLaunchConfigurationConstants.java
|
||||||
|
* ICGlobalVariableManager.java
|
||||||
|
* ICGlobalVariable.java
|
||||||
|
* IGlobalVariableDescriptor.java
|
||||||
|
* InternalDebugCoreMessages.properties
|
||||||
|
* CGlobalVariableManager.java
|
||||||
|
* CDebugTarget.java
|
||||||
|
* CGlobalVariable.java
|
||||||
|
* CRegister.java
|
||||||
|
* CVariableFactory.java
|
||||||
|
|
||||||
2004-09-01 Mikhail Khodjaiants
|
2004-09-01 Mikhail Khodjaiants
|
||||||
Breakpoint filtering by targets (core).
|
Breakpoint filtering by targets (core).
|
||||||
* ICBreakpoint.java
|
* ICBreakpoint.java
|
||||||
|
|
|
@ -542,7 +542,7 @@ public class CDIDebugModel {
|
||||||
ICDIVariableObject vo = null;
|
ICDIVariableObject vo = null;
|
||||||
try {
|
try {
|
||||||
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( info.getPath().lastSegment(), null, info.getName() );
|
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( info.getPath().lastSegment(), null, info.getName() );
|
||||||
return CVariableFactory.createGlobalVariable( (CDebugTarget)target, vo );
|
return CVariableFactory.createGlobalVariable( (CDebugTarget)target, info, vo );
|
||||||
}
|
}
|
||||||
catch( CDIException e ) {
|
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$
|
throw new DebugException( new Status( IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, (vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null ) ); //$NON-NLS-1$
|
||||||
|
|
|
@ -102,6 +102,11 @@ public interface ICDTLaunchConfigurationConstants {
|
||||||
*/
|
*/
|
||||||
public static final String ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_VARIABLE_BOOKKEEPING"; //$NON-NLS-1$
|
public static final String ATTR_DEBUGGER_ENABLE_VARIABLE_BOOKKEEPING = CDT_LAUNCH_ID + ".ENABLE_VARIABLE_BOOKKEEPING"; //$NON-NLS-1$
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Launch configuration attribute key. The value is a global variables' memento.
|
||||||
|
*/
|
||||||
|
public static final String ATTR_DEBUGGER_GLOBAL_VARIABLES = CDT_LAUNCH_ID + ".GLOBAL_VARIABLES"; //$NON-NLS-1$
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Launch configuration attribute value. The key is ATTR_DEBUGGER_STOP_AT_MAIN.
|
* Launch configuration attribute value. The key is ATTR_DEBUGGER_STOP_AT_MAIN.
|
||||||
*/
|
*/
|
||||||
|
|
|
@ -38,11 +38,4 @@ public interface ICGlobalVariableManager {
|
||||||
* Removes all global variables from this manager.
|
* Removes all global variables from this manager.
|
||||||
*/
|
*/
|
||||||
public void removeAllGlobals();
|
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();
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,4 +14,11 @@ package org.eclipse.cdt.debug.core.model;
|
||||||
* Represents a global C/C++ variable.
|
* Represents a global C/C++ variable.
|
||||||
*/
|
*/
|
||||||
public interface ICGlobalVariable extends ICVariable {
|
public interface ICGlobalVariable extends ICVariable {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the descriptor of this variable.
|
||||||
|
*
|
||||||
|
* @return the descriptor of this variable
|
||||||
|
*/
|
||||||
|
public IGlobalVariableDescriptor getDescriptor();
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,12 +13,22 @@ package org.eclipse.cdt.debug.core.model;
|
||||||
import org.eclipse.core.runtime.IPath;
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enter type comment.
|
* Provides the description of a global variable.
|
||||||
*
|
|
||||||
* @since: Nov 4, 2002
|
|
||||||
*/
|
*/
|
||||||
public interface IGlobalVariableDescriptor
|
public interface IGlobalVariableDescriptor {
|
||||||
{
|
|
||||||
String getName();
|
/**
|
||||||
IPath getPath();
|
* Returns the name of the global variable
|
||||||
|
*
|
||||||
|
* @return the name of the global variable
|
||||||
|
*/
|
||||||
|
public String getName();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns the path of the source file that contains
|
||||||
|
* the definition of the global variable.
|
||||||
|
*
|
||||||
|
* @return the path of the source file
|
||||||
|
*/
|
||||||
|
public IPath getPath();
|
||||||
}
|
}
|
|
@ -10,28 +10,59 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.core;
|
package org.eclipse.cdt.debug.internal.core;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.StringReader;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.parsers.ParserConfigurationException;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
import org.eclipse.cdt.debug.core.CDIDebugModel;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
|
import org.eclipse.cdt.debug.core.CDebugUtils;
|
||||||
|
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
|
||||||
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
|
import org.eclipse.cdt.debug.core.ICGlobalVariableManager;
|
||||||
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
|
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
|
||||||
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
|
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.CDebugTarget;
|
||||||
import org.eclipse.cdt.debug.internal.core.model.CVariable;
|
import org.eclipse.cdt.debug.internal.core.model.CVariable;
|
||||||
|
import org.eclipse.cdt.debug.internal.core.model.CVariableFactory;
|
||||||
|
import org.eclipse.core.runtime.CoreException;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.IStatus;
|
||||||
import org.eclipse.core.runtime.MultiStatus;
|
import org.eclipse.core.runtime.MultiStatus;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.core.DebugPlugin;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfiguration;
|
||||||
|
import org.eclipse.debug.core.ILaunchConfigurationWorkingCopy;
|
||||||
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.Element;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
|
import org.w3c.dom.NodeList;
|
||||||
|
import org.xml.sax.InputSource;
|
||||||
|
import org.xml.sax.SAXException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Manages all global variables registered with a debug target.
|
* Manages all global variables registered with a debug target.
|
||||||
*/
|
*/
|
||||||
public class CGlobalVariableManager implements ICGlobalVariableManager {
|
public class CGlobalVariableManager implements ICGlobalVariableManager {
|
||||||
|
|
||||||
|
private static final String GLOBAL_VARIABLE_LIST = "globalVariableList"; //$NON-NLS-1$
|
||||||
|
private static final String GLOBAL_VARIABLE = "globalVariable"; //$NON-NLS-1$
|
||||||
|
private static final String ATTR_GLOBAL_VARIABLE_PATH = "path"; //$NON-NLS-1$
|
||||||
|
private static final String ATTR_GLOBAL_VARIABLE_NAME = "name"; //$NON-NLS-1$
|
||||||
|
|
||||||
private CDebugTarget fDebugTarget;
|
private CDebugTarget fDebugTarget;
|
||||||
|
|
||||||
private ArrayList fGlobals = new ArrayList( 10 );
|
private IGlobalVariableDescriptor[] fInitialDescriptors = new IGlobalVariableDescriptor[0];
|
||||||
|
|
||||||
|
private ArrayList fGlobals;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CGlobalVariableManager.
|
* Constructor for CGlobalVariableManager.
|
||||||
|
@ -39,6 +70,7 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
|
||||||
public CGlobalVariableManager( CDebugTarget target ) {
|
public CGlobalVariableManager( CDebugTarget target ) {
|
||||||
super();
|
super();
|
||||||
setDebugTarget( target );
|
setDebugTarget( target );
|
||||||
|
initialize();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected CDebugTarget getDebugTarget() {
|
protected CDebugTarget getDebugTarget() {
|
||||||
|
@ -50,6 +82,14 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public ICGlobalVariable[] getGlobals() {
|
public ICGlobalVariable[] getGlobals() {
|
||||||
|
if ( fGlobals == null ) {
|
||||||
|
try {
|
||||||
|
addGlobals( getInitialDescriptors() );
|
||||||
|
}
|
||||||
|
catch( DebugException e ) {
|
||||||
|
DebugPlugin.log( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
return (ICGlobalVariable[])fGlobals.toArray( new ICGlobalVariable[fGlobals.size()] );
|
return (ICGlobalVariable[])fGlobals.toArray( new ICGlobalVariable[fGlobals.size()] );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -57,6 +97,7 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
|
||||||
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#addGlobals(IGlobalVariableDescriptor[])
|
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#addGlobals(IGlobalVariableDescriptor[])
|
||||||
*/
|
*/
|
||||||
public void addGlobals( IGlobalVariableDescriptor[] descriptors ) throws DebugException {
|
public void addGlobals( IGlobalVariableDescriptor[] descriptors ) throws DebugException {
|
||||||
|
fGlobals = new ArrayList( 10 );
|
||||||
MultiStatus ms = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(), 0, "", null ); //$NON-NLS-1$
|
MultiStatus ms = new MultiStatus( CDebugCorePlugin.getUniqueIdentifier(), 0, "", null ); //$NON-NLS-1$
|
||||||
ArrayList globals = new ArrayList( descriptors.length );
|
ArrayList globals = new ArrayList( descriptors.length );
|
||||||
for ( int i = 0; i < descriptors.length; ++i ) {
|
for ( int i = 0; i < descriptors.length; ++i ) {
|
||||||
|
@ -109,18 +150,123 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
|
||||||
}
|
}
|
||||||
|
|
||||||
public void dispose() {
|
public void dispose() {
|
||||||
Iterator it = fGlobals.iterator();
|
if ( fGlobals != null ) {
|
||||||
while( it.hasNext() ) {
|
Iterator it = fGlobals.iterator();
|
||||||
((CVariable)it.next()).dispose();
|
while( it.hasNext() ) {
|
||||||
|
((CVariable)it.next()).dispose();
|
||||||
|
}
|
||||||
|
fGlobals.clear();
|
||||||
|
fGlobals = null;
|
||||||
}
|
}
|
||||||
fGlobals.clear();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
public String getMemento() {
|
||||||
* @see org.eclipse.cdt.debug.core.ICGlobalVariableManager#getDescriptors()
|
Document document = null;
|
||||||
*/
|
try {
|
||||||
public IGlobalVariableDescriptor[] getDescriptors() {
|
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
|
||||||
// TODO Auto-generated method stub
|
Element node = document.createElement( GLOBAL_VARIABLE_LIST );
|
||||||
|
document.appendChild( node );
|
||||||
|
ICGlobalVariable[] globals = getGlobals();
|
||||||
|
for ( int i = 0; i < globals.length; ++i ) {
|
||||||
|
IGlobalVariableDescriptor descriptor = globals[i].getDescriptor();
|
||||||
|
Element child = document.createElement( GLOBAL_VARIABLE );
|
||||||
|
child.setAttribute( ATTR_GLOBAL_VARIABLE_NAME, descriptor.getName() );
|
||||||
|
child.setAttribute( ATTR_GLOBAL_VARIABLE_PATH, descriptor.getPath().toOSString() );
|
||||||
|
node.appendChild( child );
|
||||||
|
}
|
||||||
|
return CDebugUtils.serializeDocument( document );
|
||||||
|
}
|
||||||
|
catch( ParserConfigurationException e ) {
|
||||||
|
DebugPlugin.log( e );
|
||||||
|
}
|
||||||
|
catch( IOException e ) {
|
||||||
|
DebugPlugin.log( e );
|
||||||
|
}
|
||||||
|
catch( TransformerException e ) {
|
||||||
|
DebugPlugin.log( e );
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void initializeFromMemento( String memento ) throws CoreException {
|
||||||
|
Exception ex = null;
|
||||||
|
try {
|
||||||
|
Element root = null;
|
||||||
|
DocumentBuilder parser = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
|
StringReader reader = new StringReader( memento );
|
||||||
|
InputSource source = new InputSource( reader );
|
||||||
|
root = parser.parse( source ).getDocumentElement();
|
||||||
|
if ( root.getNodeName().equalsIgnoreCase( GLOBAL_VARIABLE_LIST ) ) {
|
||||||
|
List descriptors = new ArrayList();
|
||||||
|
NodeList list = root.getChildNodes();
|
||||||
|
int length = list.getLength();
|
||||||
|
for( int i = 0; i < length; ++i ) {
|
||||||
|
Node node = list.item( i );
|
||||||
|
short type = node.getNodeType();
|
||||||
|
if ( type == Node.ELEMENT_NODE ) {
|
||||||
|
Element entry = (Element)node;
|
||||||
|
if ( entry.getNodeName().equalsIgnoreCase( GLOBAL_VARIABLE ) ) {
|
||||||
|
String name = entry.getAttribute( ATTR_GLOBAL_VARIABLE_NAME );
|
||||||
|
String pathString = entry.getAttribute( ATTR_GLOBAL_VARIABLE_PATH );
|
||||||
|
IPath path = new Path( pathString );
|
||||||
|
if ( path.isValidPath( pathString ) ) {
|
||||||
|
descriptors.add( CVariableFactory.createGlobalVariableDescriptor( name, path ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fInitialDescriptors = (IGlobalVariableDescriptor[])descriptors.toArray( new IGlobalVariableDescriptor[descriptors.size()] );
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( ParserConfigurationException e ) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
catch( SAXException e ) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
catch( IOException e ) {
|
||||||
|
ex = e;
|
||||||
|
}
|
||||||
|
abort( InternalDebugCoreMessages.getString( "CGlobalVariableManager.0" ), ex ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
|
||||||
|
private void initialize() {
|
||||||
|
ILaunchConfiguration config = getDebugTarget().getLaunch().getLaunchConfiguration();
|
||||||
|
try {
|
||||||
|
String memento = config.getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_GLOBAL_VARIABLES, "" ); //$NON-NLS-1$
|
||||||
|
if ( memento != null && memento.trim().length() != 0 )
|
||||||
|
initializeFromMemento( memento );
|
||||||
|
}
|
||||||
|
catch( CoreException e ) {
|
||||||
|
DebugPlugin.log( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Throws an internal error exception
|
||||||
|
*/
|
||||||
|
private void abort( String message, Throwable e ) throws CoreException {
|
||||||
|
IStatus s = new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), CDebugCorePlugin.INTERNAL_ERROR, message, e );
|
||||||
|
throw new CoreException( s );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return Returns the initialDescriptors.
|
||||||
|
*/
|
||||||
|
private IGlobalVariableDescriptor[] getInitialDescriptors() {
|
||||||
|
return fInitialDescriptors;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
ILaunchConfiguration config = getDebugTarget().getLaunch().getLaunchConfiguration();
|
||||||
|
try {
|
||||||
|
ILaunchConfigurationWorkingCopy wc = config.getWorkingCopy();
|
||||||
|
wc.setAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_GLOBAL_VARIABLES, getMemento() );
|
||||||
|
wc.doSave();
|
||||||
|
}
|
||||||
|
catch( CoreException e ) {
|
||||||
|
DebugPlugin.log( e );
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,3 +14,4 @@ CBreakpointManager.2=Set breakpoint failed. Reason: {0}.
|
||||||
CBreakpointManager.3=Delete breakpoint failed. Reason: {0}.
|
CBreakpointManager.3=Delete breakpoint failed. Reason: {0}.
|
||||||
CBreakpointManager.4=Change breakpoint properties failed. Reason: {0}.
|
CBreakpointManager.4=Change breakpoint properties failed. Reason: {0}.
|
||||||
CBreakpointManager.5=Change breakpoint properties failed. Reason: {0}.
|
CBreakpointManager.5=Change breakpoint properties failed. Reason: {0}.
|
||||||
|
CGlobalVariableManager.0=Invalid global variables data.
|
||||||
|
|
|
@ -19,7 +19,6 @@ import org.eclipse.cdt.core.CCorePlugin;
|
||||||
import org.eclipse.cdt.core.model.CModelException;
|
import org.eclipse.cdt.core.model.CModelException;
|
||||||
import org.eclipse.cdt.core.model.CoreModel;
|
import org.eclipse.cdt.core.model.CoreModel;
|
||||||
import org.eclipse.cdt.core.model.IBinary;
|
import org.eclipse.cdt.core.model.IBinary;
|
||||||
import org.eclipse.cdt.core.model.IBinaryModule;
|
|
||||||
import org.eclipse.cdt.core.model.ICElement;
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
import org.eclipse.cdt.core.model.IParent;
|
import org.eclipse.cdt.core.model.IParent;
|
||||||
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
|
||||||
|
@ -92,10 +91,8 @@ import org.eclipse.core.resources.IMarkerDelta;
|
||||||
import org.eclipse.core.resources.IResourceChangeListener;
|
import org.eclipse.core.resources.IResourceChangeListener;
|
||||||
import org.eclipse.core.runtime.CoreException;
|
import org.eclipse.core.runtime.CoreException;
|
||||||
import org.eclipse.core.runtime.IAdaptable;
|
import org.eclipse.core.runtime.IAdaptable;
|
||||||
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.core.runtime.MultiStatus;
|
||||||
import org.eclipse.core.runtime.Path;
|
|
||||||
import org.eclipse.core.runtime.Preferences;
|
import org.eclipse.core.runtime.Preferences;
|
||||||
import org.eclipse.core.runtime.Status;
|
import org.eclipse.core.runtime.Status;
|
||||||
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
import org.eclipse.core.runtime.Preferences.IPropertyChangeListener;
|
||||||
|
@ -1015,6 +1012,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
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 );
|
||||||
|
saveGlobalVariables();
|
||||||
disposeGlobalVariableManager();
|
disposeGlobalVariableManager();
|
||||||
disposeMemoryManager();
|
disposeMemoryManager();
|
||||||
disposeSharedLibraryManager();
|
disposeSharedLibraryManager();
|
||||||
|
@ -1471,7 +1469,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
ICElement[] elements = file.getChildren();
|
ICElement[] elements = file.getChildren();
|
||||||
for( int i = 0; i < elements.length; ++i ) {
|
for( int i = 0; i < elements.length; ++i ) {
|
||||||
if ( elements[i] instanceof org.eclipse.cdt.core.model.IVariable ) {
|
if ( elements[i] instanceof org.eclipse.cdt.core.model.IVariable ) {
|
||||||
list.add( createGlobalVariable( (org.eclipse.cdt.core.model.IVariable)elements[i] ) );
|
list.add( CVariableFactory.createGlobalVariableDescriptor( (org.eclipse.cdt.core.model.IVariable)elements[i] ) );
|
||||||
}
|
}
|
||||||
else if ( elements[i] instanceof org.eclipse.cdt.core.model.IParent ) {
|
else if ( elements[i] instanceof org.eclipse.cdt.core.model.IParent ) {
|
||||||
list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) );
|
list.addAll( getCFileGlobals( (org.eclipse.cdt.core.model.IParent)elements[i] ) );
|
||||||
|
@ -1484,24 +1482,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
private IGlobalVariableDescriptor createGlobalVariable( final org.eclipse.cdt.core.model.IVariable var ) {
|
|
||||||
return new IGlobalVariableDescriptor() {
|
|
||||||
|
|
||||||
public String getName() {
|
|
||||||
return var.getElementName();
|
|
||||||
}
|
|
||||||
|
|
||||||
public IPath getPath() {
|
|
||||||
IPath path = new Path( "" ); //$NON-NLS-1$
|
|
||||||
ICElement parent = var.getParent();
|
|
||||||
if ( parent instanceof IBinaryModule ) {
|
|
||||||
path = ((IBinaryModule)parent).getPath();
|
|
||||||
}
|
|
||||||
return path;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
protected void setSharedLibraryManager( CSharedLibraryManager libman ) {
|
protected void setSharedLibraryManager( CSharedLibraryManager libman ) {
|
||||||
fSharedLibraryManager = libman;
|
fSharedLibraryManager = libman;
|
||||||
}
|
}
|
||||||
|
@ -1530,6 +1510,10 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
|
||||||
fRegisterManager.dispose();
|
fRegisterManager.dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected void saveGlobalVariables() {
|
||||||
|
fGlobalVariableManager.save();
|
||||||
|
}
|
||||||
|
|
||||||
protected void disposeGlobalVariableManager() {
|
protected void disposeGlobalVariableManager() {
|
||||||
fGlobalVariableManager.dispose();
|
fGlobalVariableManager.dispose();
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,24 +16,29 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
|
||||||
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
|
||||||
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.ICGlobalVariable;
|
||||||
|
import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents a global variable.
|
* Represents a global variable.
|
||||||
*/
|
*/
|
||||||
public class CGlobalVariable extends CVariable implements ICGlobalVariable {
|
public class CGlobalVariable extends CVariable implements ICGlobalVariable {
|
||||||
|
|
||||||
|
private IGlobalVariableDescriptor fDescriptor;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CGlobalVariable.
|
* Constructor for CGlobalVariable.
|
||||||
*/
|
*/
|
||||||
protected CGlobalVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) {
|
protected CGlobalVariable( CDebugElement parent, IGlobalVariableDescriptor descriptor, ICDIVariableObject cdiVariableObject ) {
|
||||||
super( parent, cdiVariableObject );
|
super( parent, cdiVariableObject );
|
||||||
|
fDescriptor = descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CGlobalVariable.
|
* Constructor for CGlobalVariable.
|
||||||
*/
|
*/
|
||||||
protected CGlobalVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject, String message ) {
|
protected CGlobalVariable( CDebugElement parent, IGlobalVariableDescriptor descriptor, ICDIVariableObject cdiVariableObject, String message ) {
|
||||||
super( parent, cdiVariableObject, message );
|
super( parent, cdiVariableObject, message );
|
||||||
|
fDescriptor = descriptor;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -61,4 +66,11 @@ public class CGlobalVariable extends CVariable implements ICGlobalVariable {
|
||||||
}
|
}
|
||||||
super.handleDebugEvents( events );
|
super.handleDebugEvents( events );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* (non-Javadoc)
|
||||||
|
* @see org.eclipse.cdt.debug.core.model.ICGlobalVariable#getDescriptor()
|
||||||
|
*/
|
||||||
|
public IGlobalVariableDescriptor getDescriptor() {
|
||||||
|
return fDescriptor;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -28,7 +28,7 @@ public class CRegister extends CGlobalVariable implements IRegister {
|
||||||
* Constructor for CRegister.
|
* Constructor for CRegister.
|
||||||
*/
|
*/
|
||||||
protected CRegister( CRegisterGroup parent, ICDIRegister cdiRegister ) {
|
protected CRegister( CRegisterGroup parent, ICDIRegister cdiRegister ) {
|
||||||
super( parent, cdiRegister );
|
super( parent, null, cdiRegister );
|
||||||
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ public class CRegister extends CGlobalVariable implements IRegister {
|
||||||
* Constructor for CRegister.
|
* Constructor for CRegister.
|
||||||
*/
|
*/
|
||||||
protected CRegister( CRegisterGroup parent, ICDIRegisterObject registerObject, String message ) {
|
protected CRegister( CRegisterGroup parent, ICDIRegisterObject registerObject, String message ) {
|
||||||
super( parent, registerObject, message );
|
super( parent, null, registerObject, message );
|
||||||
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,7 +10,13 @@
|
||||||
***********************************************************************/
|
***********************************************************************/
|
||||||
package org.eclipse.cdt.debug.internal.core.model;
|
package org.eclipse.cdt.debug.internal.core.model;
|
||||||
|
|
||||||
|
import java.text.MessageFormat;
|
||||||
|
import org.eclipse.cdt.core.model.IBinaryModule;
|
||||||
|
import org.eclipse.cdt.core.model.ICElement;
|
||||||
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.IGlobalVariableDescriptor;
|
||||||
|
import org.eclipse.core.runtime.IPath;
|
||||||
|
import org.eclipse.core.runtime.Path;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Provides factory methods for the variable types.
|
* Provides factory methods for the variable types.
|
||||||
|
@ -25,7 +31,34 @@ public class CVariableFactory {
|
||||||
return new CVariable( parent, cdiVariableObject, message );
|
return new CVariable( parent, cdiVariableObject, message );
|
||||||
}
|
}
|
||||||
|
|
||||||
public static CGlobalVariable createGlobalVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) {
|
public static IGlobalVariableDescriptor createGlobalVariableDescriptor( final String name, final IPath path ) {
|
||||||
return new CGlobalVariable( parent, cdiVariableObject );
|
|
||||||
|
return new IGlobalVariableDescriptor() {
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public IPath getPath() {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toString() {
|
||||||
|
return MessageFormat.format( "{0}::{1}", new String[] { getPath().toOSString(), getName() } ); //$NON-NLS-1$
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public static IGlobalVariableDescriptor createGlobalVariableDescriptor( final org.eclipse.cdt.core.model.IVariable var ) {
|
||||||
|
IPath path = new Path( "" ); //$NON-NLS-1$
|
||||||
|
ICElement parent = var.getParent();
|
||||||
|
if ( parent instanceof IBinaryModule ) {
|
||||||
|
path = ((IBinaryModule)parent).getPath();
|
||||||
|
}
|
||||||
|
return createGlobalVariableDescriptor( var.getElementName(), path );
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CGlobalVariable createGlobalVariable( CDebugElement parent, IGlobalVariableDescriptor descriptor, ICDIVariableObject cdiVariableObject ) {
|
||||||
|
return new CGlobalVariable( parent, descriptor, cdiVariableObject );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue