diff options
author | Alain Magloire | 2004-10-25 04:21:36 +0000 |
---|---|---|
committer | Alain Magloire | 2004-10-25 04:21:36 +0000 |
commit | 20c3099076a55ee7304932e041565647af5ca983 (patch) | |
tree | 9d27a6aeb0172666b826370cb4e7c2a08e390766 | |
parent | 1c05c517d039842b343004ffe8bceb4adcc93b6c (diff) | |
download | org.eclipse.cdt-20c3099076a55ee7304932e041565647af5ca983.tar.gz org.eclipse.cdt-20c3099076a55ee7304932e041565647af5ca983.tar.xz org.eclipse.cdt-20c3099076a55ee7304932e041565647af5ca983.zip |
2004-10-25 Alain Magloire
Remove of the class ICDIExpressionManager.
instead new clas ICDIExpressionManagegment that is on the ICDITarget
* cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIThreadGroup.java
* cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpressionManagement.java
* CDebugModel.java
* CDIDebugModel.java
* CExpression.java
* CFormattedMemoryBlock.java
* CStackFrame.java
12 files changed, 141 insertions, 107 deletions
diff --git a/debug/org.eclipse.cdt.debug.core/ChangeLog b/debug/org.eclipse.cdt.debug.core/ChangeLog index df60c4d4546..137c3b448b3 100644 --- a/debug/org.eclipse.cdt.debug.core/ChangeLog +++ b/debug/org.eclipse.cdt.debug.core/ChangeLog @@ -1,3 +1,17 @@ +2004-10-25 Alain Magloire
+ Remove of the class ICDIExpressionManager.
+ instead new clas ICDIExpressionManagegment that is on the ICDITarget
+ * cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java
+ * cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java
+ * cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIThreadGroup.java
+ * cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpressionManagement.java
+
+ * CDebugModel.java
+ * CDIDebugModel.java
+ * CExpression.java
+ * CFormattedMemoryBlock.java
+ * CStackFrame.java
+
2004-10-22 Mikhail Khodjaiants
Replaced the deprecated "evaluateExpressionTtoString" method of "ICDITarget.
* CDebugTarget.java
diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java deleted file mode 100644 index de1fe68114e..00000000000 --- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDIExpressionManager.java +++ /dev/null @@ -1,50 +0,0 @@ -/******************************************************************************* - * Copyright (c) 2000, 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.cdi; - -import org.eclipse.cdt.debug.core.cdi.model.ICDIExpression; - -/** - * - * Manages the collection of registered expressions in the - * debug session. - * Auto update is on by default. - * @since Jul 9, 2002 - */ -public interface ICDIExpressionManager extends ICDIManager { - - /** - * Returns an expression specified by the given identifier. - * - * @param expressionId - the expression identifier - * @return ICDIExpression an expression specified by the given identifier - * @throws CDIException on failure. Reasons include: - */ - ICDIExpression createExpression(String name) throws CDIException; - - /** - * Returns a collection of all registered expressions, possibly empty. - * - * @return an array of expressions - * @throws CDIException on failure. Reasons include: - */ - ICDIExpression[] getExpressions() throws CDIException; - - /** - * Removes the given expression from the expression manager. - * - * @param expressions - the expression to remove - * @throws CDIException on failure. Reasons include: - */ - void destroyExpression(ICDIExpression expression) throws CDIException; - -} diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java index 18da7f9f604..c6c00c10857 100644 --- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java +++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java @@ -60,13 +60,6 @@ public interface ICDISession { ICDIVariableManager getVariableManager(); /** - * Returns the expression manager of this debug session. - * - * @return the expression manager - */ - ICDIExpressionManager getExpressionManager(); - - /** * Returns the register manager of this debug session. * * @return the register manager diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java index a87c8f87328..6dbbf58ce75 100644 --- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java +++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpression.java @@ -11,7 +11,7 @@ package org.eclipse.cdt.debug.core.cdi.model; - +import org.eclipse.cdt.debug.core.cdi.CDIException; /** * An expression is a snippet of code that can be evaluated to @@ -19,5 +19,31 @@ package org.eclipse.cdt.debug.core.cdi.model; * * @since Jul 9, 2002 */ -public interface ICDIExpression extends ICDIVariable { +public interface ICDIExpression extends ICDIObject { + + + /** + * Returns the expression snippet of code. + * + * @return the expression + */ + String getExpressionText(); + + /** + * Returns true if the variable Object are the same, + * For example event if the name is the same because of + * casting this may return false; + * @return true if the same + */ + boolean equals(ICDIExpression expr); + + /** + * Returns the value of this expression. + * + * @param ICDIStackFrame frame context + * @return the value of this expression + * @throws CDIException if this method fails. Reasons include: + */ + ICDIValue getValue(ICDIStackFrame context) throws CDIException; + } diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpressionManagement.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpressionManagement.java new file mode 100644 index 00000000000..d7ec014ed84 --- /dev/null +++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIExpressionManagement.java @@ -0,0 +1,48 @@ +/********************************************************************** + * Copyright (c) 2002,2003,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.cdi.model; + +import org.eclipse.cdt.debug.core.cdi.CDIException; + +/** + * ICDIExpressionManagement + */ +public interface ICDIExpressionManagement { + + /** + * Create an expression for code snippet + * @param code + * @return ICDIExpression + * @throws CDIException + */ + ICDIExpression createExpression(String code) throws CDIException; + + /** + * Return all expressions for this target + * @return + * @throws CDIException + */ + ICDIExpression[] getExpressions() throws CDIException; + + /** + * Remove expressions for this target + * + * @param expressions + */ + void destroyExpressions(ICDIExpression[] expressions) throws CDIException; + + /** + * Remove all expressions on this target + * + */ + void destroyAllExpressions() throws CDIException; +} diff --git a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIThreadGroup.java b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIThreadGroup.java index d4be0b9b1c4..c638961f06b 100644 --- a/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIThreadGroup.java +++ b/debug/org.eclipse.cdt.debug.core/cdi/org/eclipse/cdt/debug/core/cdi/model/ICDIThreadGroup.java @@ -14,13 +14,9 @@ package org.eclipse.cdt.debug.core.cdi.model; import org.eclipse.cdt.debug.core.cdi.CDIException; /** - * @author User - * - * TODO To change the template for this generated type comment go to - * Window - Preferences - Java - Code Style - Code Templates */ public interface ICDIThreadGroup extends ICDIBreakpointManagement, ICDIExecuteStep, ICDIExecuteResume, - ICDISuspend, ICDIObject { + ICDISuspend, ICDIExpressionManagement, ICDIObject { /** * Returns the threads contained in this target. 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 71f1d426963..4f99b42433b 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 @@ -490,8 +490,9 @@ public class CDIDebugModel { public static IExpression createExpression(IDebugTarget target, String text) throws DebugException { if (target != null && target instanceof CDebugTarget) { try { - ICDIExpression cdiExpression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression(text); - return new CExpression((CDebugTarget)target, cdiExpression); + 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)); @@ -506,9 +507,10 @@ public class CDIDebugModel { ICDIVariableObject vo = null; try { vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject(fileName.lastSegment(), - null, name); - ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable(vo); - return new CExpression((CDebugTarget)target, cdiVariable); + 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$ 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 06873a76b41..9fb13eb67d9 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 @@ -96,8 +96,8 @@ public class CDebugModel { 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 { - ICDIExpression expression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( addressExpression ); - ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession().getMemoryManager().createMemoryBlock( expression.getName(), wordSize * numberOfRows * numberOfColumns ); + ICDIExpression expression = ((CDebugTarget)target).getCDITarget().createExpression( addressExpression ); + ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession().getMemoryManager().createMemoryBlock( expression.getExpressionText(), wordSize * numberOfRows * numberOfColumns ); return new CFormattedMemoryBlock( (CDebugTarget)target, cdiMemoryBlock, expression, format, wordSize, numberOfRows, numberOfColumns, paddingChar ); } catch( CDIException e ) { @@ -110,8 +110,8 @@ public class CDebugModel { public static IFormattedMemoryBlock createFormattedMemoryBlock( IDebugTarget target, String addressExpression, int format, int wordSize, int numberOfRows, int numberOfColumns ) throws DebugException { if ( target != null && target instanceof CDebugTarget ) { try { - ICDIExpression expression = ((CDebugTarget)target).getCDISession().getExpressionManager().createExpression( addressExpression ); - ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession().getMemoryManager().createMemoryBlock( expression.getName(), wordSize * numberOfRows * numberOfColumns ); + ICDIExpression expression = ((CDebugTarget)target).getCDITarget().createExpression( addressExpression ); + ICDIMemoryBlock cdiMemoryBlock = ((CDebugTarget)target).getCDISession().getMemoryManager().createMemoryBlock( expression.getExpressionText(), wordSize * numberOfRows * numberOfColumns ); return new CFormattedMemoryBlock( (CDebugTarget)target, cdiMemoryBlock, expression, format, wordSize, numberOfRows, numberOfColumns ); } catch( CDIException e ) { 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 index 795c20d5e9e..89ec17611a0 100644 --- 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 @@ -14,6 +14,7 @@ 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; @@ -36,14 +37,15 @@ public class CExpressionTarget { return fDebugTarget; } - public IValue evaluateExpression( String expressionText ) throws DebugException { + 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(); + return expression.getValue(context); + } public void dispose() { 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 a3095faccbc..2c708901dd3 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 @@ -12,13 +12,18 @@ package org.eclipse.cdt.debug.internal.core.model; import org.eclipse.cdt.debug.core.CDebugCorePlugin; import org.eclipse.cdt.debug.core.ICDebugConstants; +import org.eclipse.cdt.debug.core.cdi.CDIException; 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; @@ -28,44 +33,22 @@ import org.eclipse.debug.core.model.IValue; */ public class CExpression extends CVariable implements IExpression { - /** - * Constructor for CExpression. - */ - public CExpression( CDebugTarget target, ICDIExpression cdiExpression ) { - super( target, cdiExpression ); - setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) ); - } + ICDIExpression fCDIExpression; /** * Constructor for CExpression. */ - public CExpression( CDebugTarget target, ICDIVariableObject cdiVariableObject ) { - super( target, cdiVariableObject ); - setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) ); + public CExpression( CDebugTarget target, ICDIExpression cdiExpression, ICDIVariableObject varObject ) { + super( target, varObject ); + setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ))) ; + fCDIExpression = cdiExpression; } /* (non-Javadoc) * @see org.eclipse.debug.core.model.IExpression#getExpressionText() */ public String getExpressionText() { - try { - return getName(); - } - catch( DebugException e ) { - } - return null; - } - - /* (non-Javadoc) - * @see org.eclipse.debug.core.model.IVariable#getValue() - */ - public IValue getValue() { - try { - return super.getValue(); - } - catch( DebugException e ) { - } - return null; + return fCDIExpression.getExpressionText(); } /* (non-Javadoc) @@ -98,7 +81,7 @@ public class CExpression extends CVariable implements IExpression { * @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable() */ public boolean canEnableDisable() { - return false; + return true; } /* (non-Javadoc) @@ -107,4 +90,23 @@ public class CExpression extends CVariable implements IExpression { protected boolean isBookkeepingEnabled() { return false; } + + /* (non-Javadoc) + * @see org.eclipse.debug.core.model.IExpression#getValue() + */ + 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 null; + } + }
\ No newline at end of file diff --git a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java index c23fd2a3fee..76fa964e3c9 100644 --- a/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java +++ b/debug/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CFormattedMemoryBlock.java @@ -385,7 +385,8 @@ public class CFormattedMemoryBlock extends CDebugElement { try { - ((CDebugTarget)getDebugTarget()).getCDISession().getExpressionManager().destroyExpression( fAddressExpression ); + ICDIExpression[] expressions = { fAddressExpression }; + ((CDebugTarget)getDebugTarget()).getCDITarget().destroyExpressions( expressions ); } catch( CDIException e ) { @@ -402,7 +403,7 @@ public class CFormattedMemoryBlock extends CDebugElement */ public String getAddressExpression() { - return fAddressExpression.getName(); + return fAddressExpression.getExpressionText(); } private String[] createData( byte[] bytes, int offset, int length ) 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 939882283b9..73aa19bdadd 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 @@ -633,7 +633,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart */ public IValue evaluateExpression( String expression ) throws DebugException { CExpressionTarget target = (CExpressionTarget)getDebugTarget().getAdapter( CExpressionTarget.class ); - return (target != null) ? target.evaluateExpression( expression ) : null; + return (target != null) ? target.evaluateExpression( getCDIStackFrame(), expression ) : null; } private ICGlobalVariable[] getGlobals() { |