diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog
index 7104432ce04..cf407e3efac 100644
--- a/debug/org.eclipse.cdt.debug.core/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.core/ChangeLog
@@ -1,3 +1,19 @@
+2004-10-29 Mikhail Khodjaiants
+ Use the new expression API of CDI.
+ * CDebugModel.java
+ * CDIDebugModel.java
+ * CGlobalVariableManager.java
+ * AbstractCValue.java
+ * AbstractCVariable.java
+ * CArrayPartition.java
+ * CArrayPartitionValue.java
+ * CDebugTarget.java
+ * CExpression.java
+ * CStackFrame.java
+ * CValue.java
+ * CVariable.java
+ * CExpressionTarget.java: removed
+
2004-10-29 Alain Magloire
Remove of ICDISharedLibraryManager
* cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java
index 4f99b42433b..aa523e6b200 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDIDebugModel.java
@@ -13,35 +13,26 @@ package org.eclipse.cdt.debug.core;
import java.io.IOException;
import java.text.MessageFormat;
import java.util.HashMap;
-
import org.eclipse.cdt.core.CCorePlugin;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IBinaryParser;
import org.eclipse.cdt.core.ICExtensionReference;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.IBinaryParser.IBinaryFile;
-import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
import org.eclipse.cdt.debug.core.model.ICBreakpoint;
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.ICWatchpoint;
-import org.eclipse.cdt.debug.core.model.IGlobalVariableDescriptor;
import org.eclipse.cdt.debug.internal.core.ICDebugInternalConstants;
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.CLineBreakpoint;
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.CExpression;
-import org.eclipse.cdt.debug.internal.core.model.CVariableFactory;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IMarker;
import org.eclipse.core.resources.IProject;
@@ -49,7 +40,6 @@ import org.eclipse.core.resources.IResource;
import org.eclipse.core.resources.IWorkspaceRunnable;
import org.eclipse.core.resources.ResourcesPlugin;
import org.eclipse.core.runtime.CoreException;
-import org.eclipse.core.runtime.IPath;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.IStatus;
import org.eclipse.core.runtime.Status;
@@ -59,7 +49,6 @@ import org.eclipse.debug.core.IBreakpointManager;
import org.eclipse.debug.core.ILaunch;
import org.eclipse.debug.core.model.IBreakpoint;
import org.eclipse.debug.core.model.IDebugTarget;
-import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IProcess;
/**
@@ -78,115 +67,78 @@ public class CDIDebugModel {
}
/**
- * Creates and returns a debug target for the given CDI target, with the
- * specified name, and associates it with the given process for console I/O.
- * The debug target is added to the given launch.
+ * Creates and returns a debug target for the given CDI target, with the specified name, and associates it with the given process for console I/O. The debug
+ * target is added to the given launch.
*
- * @param launch
- * the launch the new debug target will be contained in
- * @param project
- * the project to use to persist breakpoints.
- * @param cdiTarget
- * the CDI target to create a debug target for
- * @param name
- * the name to associate with this target, which will be returned
- * from IDebugTarget.getName
.
- * @param debuggeeProcess
- * the process to associate with the debug target, which will be
- * returned from IDebugTarget.getProcess
- * @param file
- * the executable to debug.
- * @param allowTerminate
- * allow terminate().
- * @param allowDisconnect
- * allow disconnect().
- * @param stopInMain
- * place temporary breakpoint at main()
- * @param resumeTarget
- * resume target.
+ * @param launch the launch the new debug target will be contained in
+ * @param project the project to use to persist breakpoints.
+ * @param cdiTarget the CDI target to create a debug target for
+ * @param name the name to associate with this target, which will be returned from IDebugTarget.getName
.
+ * @param debuggeeProcess the process to associate with the debug target, which will be returned from IDebugTarget.getProcess
+ * @param file the executable to debug.
+ * @param allowTerminate allow terminate().
+ * @param allowDisconnect allow disconnect().
+ * @param stopInMain place temporary breakpoint at main()
+ * @param resumeTarget resume target.
* @return a debug target
* @throws DebugException
- *
*/
- public static IDebugTarget newDebugTarget(final ILaunch launch, final IProject project, final ICDITarget cdiTarget,
- final String name, final IProcess debuggeeProcess, final IBinaryExecutable file, final boolean allowTerminate,
- final boolean allowDisconnect, final boolean stopInMain, final boolean resumeTarget) throws DebugException {
+ public static IDebugTarget newDebugTarget( final ILaunch launch, final IProject project, final ICDITarget cdiTarget, final String name, final IProcess debuggeeProcess, final IBinaryExecutable file, final boolean allowTerminate, final boolean allowDisconnect, final boolean stopInMain, final boolean resumeTarget ) throws DebugException {
final IDebugTarget[] target = new IDebugTarget[1];
IWorkspaceRunnable r = new IWorkspaceRunnable() {
- public void run(IProgressMonitor m) throws CoreException {
- boolean stopInMain = launch.getLaunchConfiguration().getAttribute(
- ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN,
- false);
- target[0] = new CDebugTarget(launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate,
- allowDisconnect);
+ public void run( IProgressMonitor m ) throws CoreException {
+ boolean stop = launch.getLaunchConfiguration().getAttribute( ICDTLaunchConfigurationConstants.ATTR_DEBUGGER_STOP_AT_MAIN, false );
+ target[0] = new CDebugTarget( launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect );
ICDIConfiguration config = cdiTarget.getSession().getConfiguration();
- if (config.supportsBreakpoints() && stopInMain) {
- stopInMain((CDebugTarget)target[0]);
+ if ( config.supportsBreakpoints() && stop ) {
+ stopInMain( (CDebugTarget)target[0] );
}
- if (config.supportsResume() && resumeTarget) {
+ if ( config.supportsResume() && resumeTarget ) {
target[0].resume();
}
}
};
try {
- ResourcesPlugin.getWorkspace().run(r, null);
- } catch (CoreException e) {
- CDebugCorePlugin.log(e);
- throw new DebugException(e.getStatus());
+ ResourcesPlugin.getWorkspace().run( r, null );
+ }
+ catch( CoreException e ) {
+ CDebugCorePlugin.log( e );
+ throw new DebugException( e.getStatus() );
}
return target[0];
}
/**
- * Creates and returns a debug target for the given CDI target, with the
- * specified name, and associates it with the given process for console I/O.
- * The debug target is added to the given launch.
+ * Creates and returns a debug target for the given CDI target, with the specified name, and associates it with the given process for console I/O. The debug
+ * target is added to the given launch.
*
- * @param launch
- * the launch the new debug target will be contained in
- * @param project
- * the project to use to persist breakpoints.
- * @param cdiTarget
- * the CDI target to create a debug target for
- * @param name
- * the name to associate with this target, which will be returned
- * from IDebugTarget.getName
.
- * @param debuggeeProcess
- * the process to associate with the debug target, which will be
- * returned from IDebugTarget.getProcess
- * @param file
- * the executable to debug.
- * @param allowTerminate
- * allow terminate().
- * @param allowDisconnect
- * allow disconnect().
- * @param resumeTarget
- * resume target.
+ * @param launch the launch the new debug target will be contained in
+ * @param project the project to use to persist breakpoints.
+ * @param cdiTarget the CDI target to create a debug target for
+ * @param name the name to associate with this target, which will be returned from IDebugTarget.getName
.
+ * @param debuggeeProcess the process to associate with the debug target, which will be returned from IDebugTarget.getProcess
+ * @param file the executable to debug.
+ * @param allowTerminate allow terminate().
+ * @param allowDisconnect allow disconnect().
+ * @param resumeTarget resume target.
* @return a debug target
* @throws DebugException
- *
*/
- public static IDebugTarget newDebugTarget(ILaunch launch, IProject project, ICDITarget cdiTarget, final String name,
- IProcess debuggeeProcess, IBinaryExecutable file, boolean allowTerminate, boolean allowDisconnect, boolean resumeTarget)
- throws DebugException {
- return newDebugTarget(launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect, false, resumeTarget);
+ public static IDebugTarget newDebugTarget( ILaunch launch, IProject project, ICDITarget cdiTarget, final String name, IProcess debuggeeProcess, IBinaryExecutable file, boolean allowTerminate, boolean allowDisconnect, boolean resumeTarget ) throws DebugException {
+ return newDebugTarget( launch, project, cdiTarget, name, debuggeeProcess, file, allowTerminate, allowDisconnect, false, resumeTarget );
}
/**
- * Creates and returns a line breakpoint for the source defined by the given
- * source handle, at the given line number. The marker associated with the
+ * Creates and returns a line breakpoint for the source defined by the given source handle, at the given line number. The marker associated with the
* breakpoint will be created on the specified resource.
*
* @param sourceHandle
* the handle to the breakpoint source
* @param resource
- * the resource on which to create the associated breakpoint
- * marker
+ * the resource on which to create the associated breakpoint marker
* @param lineNumber
- * the line number on which the breakpoint is set - line numbers
- * are 1 based, associated with the source file in which the
- * breakpoint is set
+ * the line number on which the breakpoint is set - line numbers are 1 based, associated with the source file in which the breakpoint is set
* @param enabled
* whether to enable or disable this breakpoint
* @param ignoreCount
@@ -199,21 +151,18 @@ public class CDIDebugModel {
* @throws CoreException
* if this method fails. Reasons include:
*
null
if no such breakpoint
* is registered
- * @exception CoreException
- * if unable to retrieve the associated marker attributes
- * (line number).
+ * @exception CoreException if unable to retrieve the associated marker attributes (line number).
*/
- public static ICLineBreakpoint lineBreakpointExists(String sourceHandle, IResource resource, int lineNumber)
- throws CoreException {
+ public static ICLineBreakpoint lineBreakpointExists( String sourceHandle, IResource resource, int lineNumber ) throws CoreException {
String modelId = getPluginIdentifier();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
- IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
- for (int i = 0; i < breakpoints.length; i++) {
- if (! (breakpoints[i] instanceof ICLineBreakpoint)) {
+ IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
+ for( int i = 0; i < breakpoints.length; i++ ) {
+ if ( !(breakpoints[i] instanceof ICLineBreakpoint) ) {
continue;
}
ICLineBreakpoint breakpoint = (ICLineBreakpoint)breakpoints[i];
- if (sourceHandle != null && sourceHandle.equals(breakpoint.getSourceHandle())) {
- if (breakpoint.getMarker().getResource().equals(resource)) {
- if (breakpoint.getLineNumber() == lineNumber) {
+ if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
+ if ( breakpoint.getMarker().getResource().equals( resource ) ) {
+ if ( breakpoint.getLineNumber() == lineNumber ) {
return breakpoint;
}
}
@@ -409,33 +316,28 @@ public class CDIDebugModel {
* manager for a source with the given handle and the given resource at the
* given expression.
*
- * @param sourceHandle
- * the source handle
- * @param resource
- * the breakpoint resource
- * @param expression
- * the expression
+ * @param sourceHandle the source handle
+ * @param resource the breakpoint resource
+ * @param expression the expression
* @return the watchpoint that is already registered with the breakpoint
* manager or null
if no such watchpoint is
* registered
- * @exception CoreException
- * if unable to retrieve the associated marker attributes
- * (line number).
+ * @exception CoreException if unable to retrieve the associated marker attributes (line number).
*/
- public static ICWatchpoint watchpointExists(String sourceHandle, IResource resource, String expression) throws CoreException {
+ public static ICWatchpoint watchpointExists( String sourceHandle, IResource resource, String expression ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CWatchpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
- IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
- for (int i = 0; i < breakpoints.length; i++) {
- if (! (breakpoints[i] instanceof ICWatchpoint)) {
+ IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
+ for( int i = 0; i < breakpoints.length; i++ ) {
+ if ( !(breakpoints[i] instanceof ICWatchpoint) ) {
continue;
}
ICWatchpoint breakpoint = (ICWatchpoint)breakpoints[i];
- if (breakpoint.getMarker().getType().equals(markerType)) {
- if (sourceHandle != null && sourceHandle.equals(breakpoint.getSourceHandle())) {
- if (breakpoint.getMarker().getResource().equals(resource)) {
- if (breakpoint.getExpression().equals(expression)) {
+ if ( breakpoint.getMarker().getType().equals( markerType ) ) {
+ if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
+ if ( breakpoint.getMarker().getResource().equals( resource ) ) {
+ if ( breakpoint.getExpression().equals( expression ) ) {
return breakpoint;
}
}
@@ -450,34 +352,28 @@ public class CDIDebugModel {
* breakpoint manager for a source with the given handle and the given
* resource with the given function name.
*
- * @param sourceHandle
- * the source handle
- * @param resource
- * the breakpoint resource
- * @param function
- * the fully qualified function name
+ * @param sourceHandle the source handle
+ * @param resource the breakpoint resource
+ * @param function the fully qualified function name
* @return the breakpoint that is already registered with the breakpoint
* manager or null
if no such breakpoint is
* registered
- * @exception CoreException
- * if unable to retrieve the associated marker attributes
- * (line number).
+ * @exception CoreException if unable to retrieve the associated marker attributes (line number).
*/
- public static ICFunctionBreakpoint functionBreakpointExists(String sourceHandle, IResource resource, String function)
- throws CoreException {
+ public static ICFunctionBreakpoint functionBreakpointExists( String sourceHandle, IResource resource, String function ) throws CoreException {
String modelId = getPluginIdentifier();
String markerType = CFunctionBreakpoint.getMarkerType();
IBreakpointManager manager = DebugPlugin.getDefault().getBreakpointManager();
- IBreakpoint[] breakpoints = manager.getBreakpoints(modelId);
- for (int i = 0; i < breakpoints.length; i++) {
- if (! (breakpoints[i] instanceof ICFunctionBreakpoint)) {
+ IBreakpoint[] breakpoints = manager.getBreakpoints( modelId );
+ for( int i = 0; i < breakpoints.length; i++ ) {
+ if ( !(breakpoints[i] instanceof ICFunctionBreakpoint) ) {
continue;
}
ICFunctionBreakpoint breakpoint = (ICFunctionBreakpoint)breakpoints[i];
- if (breakpoint.getMarker().getType().equals(markerType)) {
- if (sourceHandle != null && sourceHandle.equals(breakpoint.getSourceHandle())) {
- if (breakpoint.getMarker().getResource().equals(resource)) {
- if (breakpoint.getFunction() != null && breakpoint.getFunction().equals(function)) {
+ if ( breakpoint.getMarker().getType().equals( markerType ) ) {
+ if ( sourceHandle != null && sourceHandle.equals( breakpoint.getSourceHandle() ) ) {
+ if ( breakpoint.getMarker().getResource().equals( resource ) ) {
+ if ( breakpoint.getFunction() != null && breakpoint.getFunction().equals( function ) ) {
return breakpoint;
}
}
@@ -487,136 +383,59 @@ public class CDIDebugModel {
return null;
}
- public static IExpression createExpression(IDebugTarget target, String text) throws DebugException {
- if (target != null && target instanceof CDebugTarget) {
- try {
- ICDIVariableObject vo = null;//((CDebugTarget)target).getCDISession().getVariableManager().getVariableObject(text);
- ICDIExpression cdiExpression = ((CDebugTarget)target).getCDITarget().createExpression(text);
- return new CExpression( (CDebugTarget)target, cdiExpression, vo );
- } catch (CDIException e) {
- throw new DebugException(new Status(IStatus.ERROR, getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED,
- e.getMessage(), null));
- }
- }
- return null;
- }
-
- public static IExpression createExpressionForGlobalVariable(IDebugTarget target, IPath fileName, String name)
- throws DebugException {
- if (target != null && target instanceof CDebugTarget) {
- ICDIVariableObject vo = null;
- try {
- vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject(fileName.lastSegment(),
- null, name);
- //ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable(vo);
- ICDIExpression cdiExpression = ((CDebugTarget)target).getCDITarget().createExpression(name);
- return new CExpression((CDebugTarget)target, cdiExpression, vo);
- } 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;
- }
-
- 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());
- return CVariableFactory.createGlobalVariable((CDebugTarget)target, info, vo);
- } 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;
- }
-
- protected static void stopInMain(CDebugTarget target) throws DebugException {
- ICDILocation location = target.getCDITarget().createLocation("", "main", 0); //$NON-NLS-1$ //$NON-NLS-2$
+ protected static void stopInMain( CDebugTarget target ) throws DebugException {
+ ICDILocation location = target.getCDITarget().createLocation( "", "main", 0 ); //$NON-NLS-1$ //$NON-NLS-2$
try {
- target.setInternalTemporaryBreakpoint(location);
- } catch (DebugException e) {
- String message = MessageFormat.format(
- DebugCoreMessages.getString("CDebugModel.0"), new String[]{e.getStatus().getMessage()}); //$NON-NLS-1$
- IStatus newStatus = new Status(IStatus.WARNING, e.getStatus().getPlugin(),
- ICDebugInternalConstants.STATUS_CODE_QUESTION, message, null);
- if (!CDebugUtils.question(newStatus, target)) {
+ target.setInternalTemporaryBreakpoint( location );
+ }
+ catch( DebugException e ) {
+ String message = MessageFormat.format( DebugCoreMessages.getString( "CDebugModel.0" ), new String[]{ e.getStatus().getMessage() } ); //$NON-NLS-1$
+ IStatus newStatus = new Status( IStatus.WARNING, e.getStatus().getPlugin(), ICDebugInternalConstants.STATUS_CODE_QUESTION, message, null );
+ if ( !CDebugUtils.question( newStatus, target ) ) {
target.terminate();
- throw new DebugException(new Status(IStatus.OK, e.getStatus().getPlugin(), e.getStatus().getCode(),
- e.getStatus().getMessage(), null));
+ throw new DebugException( new Status( IStatus.OK, e.getStatus().getPlugin(), e.getStatus().getCode(), e.getStatus().getMessage(), null ) );
}
}
}
/**
- * @param launch
- * @param target
- * @param string
- * @param iprocess
- * @param debuggerProcess
- * @param exeFile
- * @param b
- * @param c
- * @param stopInMain
- * @throws CoreException
* @deprecated
*/
- public static IDebugTarget newDebugTarget(ILaunch launch, ICDITarget target, String name, IProcess iprocess,
- IProcess debuggerProcess, IFile file, boolean allowTerminate, boolean allowDisconnect, boolean stopInMain)
- throws CoreException {
- IBinaryExecutable exeFile = getBinary(file);
- return newDebugTarget(launch, file.getProject(), target, name, iprocess, exeFile, allowTerminate, allowDisconnect,
- stopInMain, true);
+ public static IDebugTarget newDebugTarget( ILaunch launch, ICDITarget target, String name, IProcess iprocess, IProcess debuggerProcess, IFile file, boolean allowTerminate, boolean allowDisconnect, boolean stopInMain ) throws CoreException {
+ IBinaryExecutable exeFile = getBinary( file );
+ return newDebugTarget( launch, file.getProject(), target, name, iprocess, exeFile, allowTerminate, allowDisconnect, stopInMain, true );
}
/**
- * @param launch
- * @param target
- * @param name
- * @param debuggerProcess
- * @param exeFile
- * @throws CoreException
* @deprecated
*/
- public static IDebugTarget newAttachDebugTarget(ILaunch launch, ICDITarget target, String name, IProcess debuggerProcess,
- IFile file) throws CoreException {
- IBinaryExecutable exeFile = getBinary(file);
- return newDebugTarget(launch, file.getProject(), target, name, null, exeFile, true, true, false);
+ public static IDebugTarget newAttachDebugTarget( ILaunch launch, ICDITarget target, String name, IProcess debuggerProcess, IFile file ) throws CoreException {
+ IBinaryExecutable exeFile = getBinary( file );
+ return newDebugTarget( launch, file.getProject(), target, name, null, exeFile, true, true, false );
}
/**
- * @param launch
- * @param currentTarget
- * @param string
- * @param iprocess
- * @param exeFile
- * @throws CoreException
* @deprecated
*/
- public static IDebugTarget newCoreFileDebugTarget(final ILaunch launch, final ICDITarget target, final String name,
- final IProcess debuggerProcess, final IFile file) throws CoreException {
- IBinaryExecutable exeFile = getBinary(file);
- return newDebugTarget(launch, file.getProject(), target, name, null, exeFile, true, false, false);
+ public static IDebugTarget newCoreFileDebugTarget( final ILaunch launch, final ICDITarget target, final String name, final IProcess debuggerProcess, final IFile file ) throws CoreException {
+ IBinaryExecutable exeFile = getBinary( file );
+ return newDebugTarget( launch, file.getProject(), target, name, null, exeFile, true, false, false );
}
- private static IBinaryExecutable getBinary(IFile file) throws CoreException {
+ private static IBinaryExecutable getBinary( IFile file ) throws CoreException {
IProject project = file.getProject();
- ICExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getBinaryParserExtensions(project);
- for (int i = 0; i < binaryParsersExt.length; i++) {
+ ICExtensionReference[] binaryParsersExt = CCorePlugin.getDefault().getBinaryParserExtensions( project );
+ for( int i = 0; i < binaryParsersExt.length; i++ ) {
IBinaryParser parser = (IBinaryParser)binaryParsersExt[i].createExtension();
try {
- IBinaryFile exe = parser.getBinary(file.getLocation());
- if (exe instanceof IBinaryExecutable) {
+ IBinaryFile exe = parser.getBinary( file.getLocation() );
+ if ( exe instanceof IBinaryExecutable ) {
return (IBinaryExecutable)exe;
}
- } catch (IOException e) {
+ }
+ catch( IOException e ) {
}
}
- throw new CoreException(new Status(IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), -1,
- DebugCoreMessages.getString("CDIDebugModel.0"), null)); //$NON-NLS-1$
+ throw new CoreException( new Status( IStatus.ERROR, CDebugCorePlugin.getUniqueIdentifier(), -1, DebugCoreMessages.getString( "CDIDebugModel.0" ), null ) ); //$NON-NLS-1$
}
}
\ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
index 257206b02fd..16a4dad2950 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/CDebugModel.java
@@ -77,22 +77,6 @@ public class CDebugModel {
return CDIDebugModel.newCoreFileDebugTarget( launch, cdiTarget, name, debuggerProcess, file );
}
- /**
- * @deprecated
- * Use {@link CDIDebugModel#createExpression(IDebugTarget, String)}.
- */
- public static IExpression createExpression( IDebugTarget target, String text ) throws DebugException {
- return CDIDebugModel.createExpression( target, text );
- }
-
- /**
- * @deprecated
- * Use {@link CDIDebugModel#createExpressionForGlobalVariable(IDebugTarget, IPath, String)}.
- */
- public static IExpression createExpressionForGlobalVariable( IDebugTarget target, IPath fileName, String name ) throws DebugException {
- return CDIDebugModel.createExpressionForGlobalVariable( target, fileName, name );
- }
-
public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, String addressExpression, int format, int wordSize, int numberOfRows, int numberOfColumns, char paddingChar ) throws DebugException {
if ( target != null && target instanceof CDebugTarget ) {
try {
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CExpressionTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CExpressionTarget.java
deleted file mode 100644
index 89ec17611a0..00000000000
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CExpressionTarget.java
+++ /dev/null
@@ -1,58 +0,0 @@
-/**********************************************************************
- * 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.HashMap;
-import java.util.Iterator;
-import java.util.Map;
-import org.eclipse.cdt.debug.core.CDIDebugModel;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
-import org.eclipse.cdt.debug.internal.core.model.CDebugTarget;
-import org.eclipse.cdt.debug.internal.core.model.CExpression;
-import org.eclipse.debug.core.DebugException;
-import org.eclipse.debug.core.model.IValue;
-
-/**
- * Implements the expression evaluation target.
- */
-public class CExpressionTarget {
-
- private CDebugTarget fDebugTarget;
- private Map fExpressions = null;
-
- public CExpressionTarget( CDebugTarget target ) {
- fDebugTarget = target;
- fExpressions = new HashMap( 10 );
- }
-
- public CDebugTarget getDebugTarget() {
- return fDebugTarget;
- }
-
- public IValue evaluateExpression( ICDIStackFrame context, String expressionText ) throws DebugException {
- CExpression expression = (CExpression)fExpressions.remove( expressionText );
- if ( expression != null ) {
- expression.dispose();
- }
- expression = (CExpression)CDIDebugModel.createExpression( getDebugTarget(), expressionText );
- fExpressions.put( expressionText, expression );
- return expression.getValue(context);
-
- }
-
- public void dispose() {
- Iterator it = fExpressions.values().iterator();
- while( it.hasNext() ) {
- ((CExpression)it.next()).dispose();
- }
- fExpressions.clear();
- }
-}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java
index 5f64d21f8a0..0287b326e7a 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/CGlobalVariableManager.java
@@ -20,7 +20,6 @@ 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.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugUtils;
import org.eclipse.cdt.debug.core.ICDTLaunchConfigurationConstants;
@@ -102,7 +101,7 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
ArrayList globals = new ArrayList( descriptors.length );
for ( int i = 0; i < descriptors.length; ++i ) {
try {
- globals.add( CDIDebugModel.createGlobalVariable( getDebugTarget(), descriptors[i] ) );
+ globals.add( getDebugTarget().createGlobalVariable( descriptors[i] ) );
}
catch( DebugException e ) {
ms.add( e.getStatus() );
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCValue.java
index f4dcc6034ec..46155b279e9 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCValue.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCValue.java
@@ -60,4 +60,6 @@ public abstract class AbstractCValue extends CDebugElement implements ICValue {
abstract public void dispose();
abstract protected void reset();
+
+ abstract protected void preserve();
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCVariable.java
index baf135743cf..8b3bdbd3616 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCVariable.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/AbstractCVariable.java
@@ -75,4 +75,6 @@ public abstract class AbstractCVariable extends CDebugElement implements ICVaria
protected abstract void resetValue();
protected abstract void setChanged( boolean changed );
+
+ protected abstract void preserve();
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java
index 7048c1231bc..be0d6252575 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java
@@ -339,4 +339,15 @@ public class CArrayPartition extends AbstractCVariable {
fArrayPartitionValue.setChanged( changed );
}
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#preserve()
+ */
+ protected void preserve() {
+ setChanged( false );
+ resetStatus();
+ if ( fArrayPartitionValue != null ) {
+ fArrayPartitionValue.preserve();
+ }
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java
index 8e09a1c323b..e0f9d237e90 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java
@@ -155,4 +155,15 @@ public class CArrayPartitionValue extends AbstractCValue {
public ICType getType() throws DebugException {
return null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#preserve()
+ */
+ protected void preserve() {
+ resetStatus();
+ Iterator it = fVariables.iterator();
+ while( it.hasNext() ) {
+ ((AbstractCVariable)it.next()).preserve();
+ }
+ }
}
\ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
index d18d13003fc..79bad3fd0a5 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CDebugTarget.java
@@ -22,6 +22,7 @@ import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.core.IBinaryParser.IBinaryExecutable;
import org.eclipse.cdt.core.IBinaryParser.IBinaryObject;
import org.eclipse.cdt.core.IBinaryParser.ISymbol;
+import org.eclipse.cdt.debug.core.CDIDebugModel;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
import org.eclipse.cdt.debug.core.CDebugModel;
import org.eclipse.cdt.debug.core.CDebugUtils;
@@ -58,6 +59,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDISharedLibrary;
import org.eclipse.cdt.debug.core.cdi.model.ICDISignal;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
+import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.CDebugElementState;
import org.eclipse.cdt.debug.core.model.IBreakpointTarget;
import org.eclipse.cdt.debug.core.model.ICAddressBreakpoint;
@@ -65,6 +67,7 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICDebugTarget;
+import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSignal;
@@ -78,7 +81,6 @@ import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
import org.eclipse.cdt.debug.internal.core.CBreakpointManager;
-import org.eclipse.cdt.debug.internal.core.CExpressionTarget;
import org.eclipse.cdt.debug.internal.core.CExtendedMemoryBlockRetrieval;
import org.eclipse.cdt.debug.internal.core.CGlobalVariableManager;
import org.eclipse.cdt.debug.internal.core.CMemoryManager;
@@ -184,11 +186,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
*/
private CBreakpointManager fBreakpointManager;
- /**
- * The expression evaluation target.
- */
- private CExpressionTarget fExpressionTarget;
-
/**
* The global variable manager for this target.
*/
@@ -860,8 +857,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return getSignalManager();
if ( adapter.equals( ICRegisterManager.class ) )
return getRegisterManager();
- if ( adapter.equals( CExpressionTarget.class ) )
- return getExpressionTarget();
if ( adapter.equals( ICGlobalVariableManager.class ) )
return getGlobalVariableManager();
if ( adapter.equals( ICDISession.class ) )
@@ -1046,7 +1041,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
disposeDisassembly();
disposeSourceManager();
disposeBreakpointManager();
- disposeExpresionTarget();
removeAllExpressions();
disposePreferences();
}
@@ -1648,13 +1642,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
}
}
- private void disposeExpresionTarget() {
- if ( fExpressionTarget != null ) {
- fExpressionTarget.dispose();
- fExpressionTarget = null;
- }
- }
-
public IFile getCurrentBreakpointFile() {
Object info = getCurrentStateInfo();
if ( info instanceof ICDIBreakpointHit ) {
@@ -1822,13 +1809,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
fPreferences.removePropertyChangeListener( listener );
}
- protected CExpressionTarget getExpressionTarget() {
- if ( fExpressionTarget == null ) {
- fExpressionTarget = new CExpressionTarget( this );
- }
- return fExpressionTarget;
- }
-
protected CGlobalVariableManager getGlobalVariableManager() {
return fGlobalVariableManager;
}
@@ -1890,4 +1870,15 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
private void handleSymbolsLoaded( ICDISharedLibrary library ) {
getSharedLibraryManager().symbolsLoaded( library );
}
+
+ public ICGlobalVariable createGlobalVariable( IGlobalVariableDescriptor info ) throws DebugException {
+ ICDIVariableObject vo = null;
+ try {
+ vo = getCDISession().getVariableManager().getGlobalVariableObject( info.getPath().lastSegment(), null, info.getName() );
+ }
+ catch( CDIException e ) {
+ throw new DebugException( new Status( IStatus.ERROR, CDIDebugModel.getPluginIdentifier(), DebugException.TARGET_REQUEST_FAILED, (vo != null) ? vo.getName() + ": " + e.getMessage() : e.getMessage(), null ) ); //$NON-NLS-1$
+ }
+ return CVariableFactory.createGlobalVariable( this, info, vo );
+ }
}
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java
index 2c708901dd3..23339a7087a 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CExpression.java
@@ -17,13 +17,11 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEvent;
import org.eclipse.cdt.debug.core.cdi.event.ICDIResumedEvent;
import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
-import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
-import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IValue;
@@ -33,15 +31,20 @@ import org.eclipse.debug.core.model.IValue;
*/
public class CExpression extends CVariable implements IExpression {
- ICDIExpression fCDIExpression;
+ private ICDIExpression fCDIExpression;
+
+ private CStackFrame fStackFrame;
+
+ private IValue fValue;
/**
* Constructor for CExpression.
*/
- public CExpression( CDebugTarget target, ICDIExpression cdiExpression, ICDIVariableObject varObject ) {
- super( target, varObject );
+ public CExpression( CStackFrame frame, ICDIExpression cdiExpression, ICDIVariableObject varObject ) {
+ super( frame, varObject );
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ))) ;
fCDIExpression = cdiExpression;
+ fStackFrame = frame;
}
/* (non-Javadoc)
@@ -63,6 +66,7 @@ public class CExpression extends CVariable implements IExpression {
ICDITarget cdiTarget = source.getTarget();
if ( getCDITarget().equals( cdiTarget ) ) {
setChanged( false );
+ resetValue();
}
}
}
@@ -96,17 +100,62 @@ public class CExpression extends CVariable implements IExpression {
*/
public IValue getValue() {
CStackFrame frame = (CStackFrame)getStackFrame();
- return getValue(frame.getCDIStackFrame());
- }
-
- public IValue getValue(ICDIStackFrame context) {
try {
- ICDIValue value = fCDIExpression.getValue(context);
- return CValueFactory.createValue(this, value);
- } catch (CDIException e) {
- // TODO Auto-generated catch block
+ return getValue( frame );
+ }
+ catch( DebugException e ) {
}
return null;
}
+ protected synchronized IValue getValue( CStackFrame context ) throws DebugException {
+ if ( fValue == null ) {
+ if ( context.isSuspended() ) {
+ try {
+ ICDIValue value = fCDIExpression.getValue( context.getCDIStackFrame() );
+ fValue = CValueFactory.createValue( this, value );
+ }
+ catch( CDIException e ) {
+ targetRequestFailed( e.getMessage(), null );
+ }
+ }
+ }
+ return fValue;
+ }
+
+ protected ICStackFrame getStackFrame() {
+ return fStackFrame;
+ }
+
+ protected void resetValue() {
+ if ( fValue instanceof AbstractCValue ) {
+ ((AbstractCValue)fValue).reset();
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#getExpressionString()
+ */
+ public String getExpressionString() throws DebugException {
+ return getExpressionText();
+ }
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#dispose()
+ */
+ public void dispose() {
+ if ( fCDIExpression != null ) {
+ try {
+ getCDITarget().destroyExpressions( new ICDIExpression[] { fCDIExpression } );
+ fCDIExpression = null;
+ }
+ catch( CDIException e ) {
+ }
+ }
+ if ( fValue instanceof AbstractCValue ) {
+ ((AbstractCValue)fValue).dispose();
+ fValue = null;
+ }
+ super.dispose();
+ }
}
\ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
index 73aa19bdadd..cf009f431b4 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
@@ -17,13 +17,13 @@ import java.util.Arrays;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
-
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.core.IAddressFactory;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
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.model.ICDIExpression;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
@@ -33,7 +33,6 @@ import org.eclipse.cdt.debug.core.model.IResumeWithoutSignal;
import org.eclipse.cdt.debug.core.model.IRunToAddress;
import org.eclipse.cdt.debug.core.model.IRunToLine;
import org.eclipse.cdt.debug.core.sourcelookup.ICSourceLocator;
-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.debug.core.DebugException;
@@ -75,6 +74,11 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
*/
private boolean fRefreshVariables = true;
+ /**
+ * List of watch expressions evaluating in the context of this frame.
+ */
+ private List fExpressions;
+
/**
* Constructor for CStackFrame.
*/
@@ -475,6 +479,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
protected void dispose() {
getCDISession().getEventManager().removeEventListener( this );
disposeAllVariables();
+ disposeExpressions();
}
/**
@@ -526,9 +531,21 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
while( it.hasNext() ) {
((CVariable)it.next()).dispose();
}
+ fVariables.clear();
fVariables = null;
}
+ protected void disposeExpressions() {
+ if ( fExpressions != null ) {
+ Iterator it = fExpressions.iterator();
+ while( it.hasNext() ) {
+ ((CExpression)it.next()).dispose();
+ }
+ fExpressions.clear();
+ }
+ fExpressions = null;
+ }
+
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICStackFrame#getAddress()
*/
@@ -567,6 +584,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
protected synchronized void preserve() {
preserveVariables();
+ preserveExpressions();
}
private void preserveVariables() {
@@ -574,7 +592,18 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
return;
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
- ((AbstractCVariable)it.next()).setChanged( false );
+ AbstractCVariable av = (AbstractCVariable)it.next();
+ av.preserve();
+ }
+ }
+
+ private void preserveExpressions() {
+ if ( fExpressions == null )
+ return;
+ Iterator it = fExpressions.iterator();
+ while( it.hasNext() ) {
+ CExpression exp = (CExpression)it.next();
+ exp.preserve();
}
}
@@ -631,9 +660,12 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICStackFrame#evaluateExpression(java.lang.String)
*/
- public IValue evaluateExpression( String expression ) throws DebugException {
- CExpressionTarget target = (CExpressionTarget)getDebugTarget().getAdapter( CExpressionTarget.class );
- return (target != null) ? target.evaluateExpression( getCDIStackFrame(), expression ) : null;
+ public IValue evaluateExpression( String expressionText ) throws DebugException {
+ CExpression expression = getExpression( expressionText );
+ if ( expression != null ) {
+ return expression.getValue( this );
+ }
+ return null;
}
private ICGlobalVariable[] getGlobals() {
@@ -685,4 +717,27 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
targetRequestFailed( e.getMessage(), null );
}
}
+
+ private CExpression getExpression( String expressionText ) throws DebugException {
+ if ( fExpressions == null ) {
+ fExpressions = new ArrayList( 5 );
+ }
+ CExpression expression = null;
+ Iterator it = fExpressions.iterator();
+ while( it.hasNext() ) {
+ expression = (CExpression)it.next();
+ if ( expression.getExpressionText().compareTo( expressionText ) == 0 ) {
+ return expression;
+ }
+ }
+ try {
+ ICDIExpression cdiExpression = ((CDebugTarget)getDebugTarget()).getCDITarget().createExpression( expressionText );
+ expression = new CExpression( this, cdiExpression, null );
+ fExpressions.add( expression );
+ }
+ catch( CDIException e ) {
+ targetRequestFailed( e.getMessage(), null );
+ }
+ return expression;
+ }
}
\ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java
index 5dbb71e0185..339b0bcf941 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java
@@ -84,12 +84,14 @@ public class CValue extends AbstractCValue {
*/
public String getValueString() throws DebugException {
if ( fValueString == null && getUnderlyingValue() != null ) {
- try {
- fValueString = processUnderlyingValue( getUnderlyingValue() );
- resetStatus();
- }
- catch( CDIException e ) {
- setStatus( ICDebugElementStatus.ERROR, e.getMessage() );
+ resetStatus();
+ if ( getParentVariable().getStackFrame().isSuspended() ) {
+ try {
+ fValueString = processUnderlyingValue( getUnderlyingValue() );
+ }
+ catch( CDIException e ) {
+ setStatus( ICDebugElementStatus.ERROR, e.getMessage() );
+ }
}
}
return fValueString;
@@ -430,6 +432,7 @@ public class CValue extends AbstractCValue {
* Invalidates the string cache.
*/
protected void reset() {
+ resetStatus();
fValueString = null;
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
@@ -441,4 +444,16 @@ public class CValue extends AbstractCValue {
AbstractCVariable var = getParentVariable();
return ( var instanceof CVariable ) ? ((CVariable)var).getType() : null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#preserve()
+ */
+ protected void preserve() {
+ setChanged( false );
+ resetStatus();
+ Iterator it = fVariables.iterator();
+ while( it.hasNext() ) {
+ ((AbstractCVariable)it.next()).preserve();
+ }
+ }
}
\ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
index aa501f9438b..2f87af0e579 100644
--- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
+++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
@@ -276,6 +276,13 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
fChanged = changed;
}
+ synchronized void preserve() {
+ setChanged( false );
+ if ( fValue instanceof AbstractCValue ) {
+ ((AbstractCValue)fValue).preserve();
+ }
+ }
+
CVariable getVariable() {
return fVariable;
}
@@ -737,6 +744,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
protected void resetValue() {
InternalVariable iv = getCurrentInternalVariable();
if ( iv != null ) {
+ resetStatus();
iv.resetValue();
fireChangeEvent( DebugEvent.STATE );
}
@@ -792,4 +800,14 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
InternalVariable iv = getCurrentInternalVariable();
return ( iv != null ) ? iv.getQualifiedName() : null;
}
+
+ /* (non-Javadoc)
+ * @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#preserve()
+ */
+ protected void preserve() {
+ resetStatus();
+ InternalVariable iv = getCurrentInternalVariable();
+ if ( iv != null )
+ iv.preserve();
+ }
}
\ No newline at end of file
diff --git a/debug/org.eclipse.cdt.debug.ui/ChangeLog b/debug/org.eclipse.cdt.debug.ui/ChangeLog
index 19008c4a4e8..f67668a78a8 100644
--- a/debug/org.eclipse.cdt.debug.ui/ChangeLog
+++ b/debug/org.eclipse.cdt.debug.ui/ChangeLog
@@ -1,3 +1,8 @@
+2004-10-29 Mikhail Khodjaiants
+ Use the new expression API of CDI.
+ * CDebugUIMessages.properties
+ * CDTDebugModelPresentation.java
+
2004-10-18 Mikhail Khodjaiants
Corrupted plugin.xml.
* plugin.xml
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
index b5ea5646bc1..ead87945293 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDTDebugModelPresentation.java
@@ -507,7 +507,7 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
}
}
if ( expression.isEnabled() ) {
- String valueString = DebugUIPlugin.getModelPresentation().getText( value );
+ String valueString = getValueText( value );
if ( valueString.length() > 0 ) {
result.append( " = " ).append( valueString ); //$NON-NLS-1$
}
@@ -542,7 +542,7 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
label.append( name.trim() );
IValue value = var.getValue();
if ( value != null ) {
- String valueString = DebugUIPlugin.getModelPresentation().getText( value );
+ String valueString = getValueText( value );
if ( !isEmpty( valueString ) ) {
label.append( " = " ); //$NON-NLS-1$
label.append( valueString );
@@ -552,7 +552,7 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
return label.toString();
}
- protected String getValueText( IValue value ) throws DebugException {
+ protected String getValueText( IValue value )/* throws DebugException*/ {
StringBuffer label = new StringBuffer();
if ( value instanceof ICDebugElementStatus && !((ICDebugElementStatus)value).isOK() ) {
label.append( getFormattedString( CDebugUIMessages.getString( "CDTDebugModelPresentation.4" ), ((ICDebugElementStatus)value).getMessage() ) ); //$NON-NLS-1$
@@ -564,30 +564,34 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
}
catch( DebugException e ) {
}
- String valueString = value.getValueString();
- if ( valueString != null ) {
- valueString = valueString.trim();
- if ( type != null && type.isCharacter() ) {
- if ( valueString.length() == 0 )
- valueString = "."; //$NON-NLS-1$
- label.append( valueString );
- }
- else if ( type != null && type.isFloatingPointType() ) {
- Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value );
- if ( CDebugUtils.isNaN( floatingPointValue ) )
- valueString = "NAN"; //$NON-NLS-1$
- if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) )
- valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$
- if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) )
- valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$
- label.append( valueString );
- }
- else if ( type == null || (!type.isArray() && !type.isStructure()) ) {
- if ( valueString.length() > 0 ) {
+ try {
+ String valueString = value.getValueString();
+ if ( valueString != null ) {
+ valueString = valueString.trim();
+ if ( type != null && type.isCharacter() ) {
+ if ( valueString.length() == 0 )
+ valueString = "."; //$NON-NLS-1$
label.append( valueString );
}
+ else if ( type != null && type.isFloatingPointType() ) {
+ Number floatingPointValue = CDebugUtils.getFloatingPointValue( (ICValue)value );
+ if ( CDebugUtils.isNaN( floatingPointValue ) )
+ valueString = "NAN"; //$NON-NLS-1$
+ if ( CDebugUtils.isPositiveInfinity( floatingPointValue ) )
+ valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.23" ); //$NON-NLS-1$
+ if ( CDebugUtils.isNegativeInfinity( floatingPointValue ) )
+ valueString = CDebugUIMessages.getString( "CDTDebugModelPresentation.24" ); //$NON-NLS-1$
+ label.append( valueString );
+ }
+ else if ( type == null || (!type.isArray() && !type.isStructure()) ) {
+ if ( valueString.length() > 0 ) {
+ label.append( valueString );
+ }
+ }
}
}
+ catch( DebugException e1 ) {
+ }
}
return label.toString();
}
diff --git a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties
index b6cee4cfb61..5d456d9843a 100644
--- a/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties
+++ b/debug/org.eclipse.cdt.debug.ui/src/org/eclipse/cdt/debug/internal/ui/CDebugUIMessages.properties
@@ -21,7 +21,7 @@ CDTDebugModelPresentation.6=Exit code = {0}.
CDTDebugModelPresentation.7={0} (Suspended)
CDTDebugModelPresentation.8=Thread [{0}]
CDTDebugModelPresentation.9=Thread [{0}] (Terminated)
-CDTDebugModelPresentation.4=\ =