1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-07 17:56:01 +02:00

Evaluate expressions on stack frame instead of target to provide evaluation context.

This commit is contained in:
Mikhail Khodjaiants 2004-09-20 20:17:07 +00:00
parent cfb7157606
commit 1c54168e72
14 changed files with 177 additions and 184 deletions

View file

@ -1,3 +1,19 @@
2004-09-20 Mikhail Khodjaiants
Evaluate expressions on stack frame instead of target to provide evaluation context.
* ICDebugTarget.java
* ICStackFrame.java
* ICExpressionEvaluator.java
* AbstractCValue.java
* AbstractCVariable.java
* CArrayPartition.java
* CArrayPartitionValue.java
* CDebugTarget.java
* CFormattedMemoryBlock.java
* CStackFrame.java
* CThread.java
* CValue.java
* CVariable.java
2004-09-17 Alain Magloire 2004-09-17 Alain Magloire
Support for 64 bits application Support for 64 bits application
PR 74056. Pathc from Artyom Kuanbekov PR 74056. Pathc from Artyom Kuanbekov

View file

@ -17,7 +17,6 @@ import org.eclipse.debug.core.model.IDebugTarget;
* C/C++ extension of <code>IDebugTarget</code>. * C/C++ extension of <code>IDebugTarget</code>.
*/ */
public interface ICDebugTarget extends IDebugTarget, public interface ICDebugTarget extends IDebugTarget,
ICExpressionEvaluator,
IExecFileInfo, IExecFileInfo,
IRestart, IRestart,
IRunToLine, IRunToLine,

View file

@ -1,39 +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.model;
import org.eclipse.debug.core.DebugException;
/**
*
* Supports the evaluation of C/C++ expressions.
*
* @since Sep 13, 2002
*/
public interface ICExpressionEvaluator
{
/**
* Evaluates the specified expression and returns evaluation result
* as a string.
*
* @param expression the expression to evaluate
* @return the evaluation result
* @throws DebugException on failure. Reasons include:
*/
String evaluateExpressionToString( String expression ) throws DebugException;
/**
* Returns whether this object can currently evaluate an expression.
*
* @return whether this object can currently evaluate an expression
*/
boolean canEvaluate();
}

View file

@ -66,4 +66,21 @@ public interface ICStackFrame extends IStackFrame, ICDebugElement {
* @throws DebugException if this method fails. * @throws DebugException if this method fails.
*/ */
public IValue evaluateExpression( String expression ) throws DebugException; public IValue evaluateExpression( String expression ) throws DebugException;
/**
* Evaluates the specified expression in the context of this stack frame
* and returns the evaluation result as a string.
*
* @param expression the expression to evaluate
* @return the evaluation result
* @throws DebugException on failure. Reasons include:
*/
public String evaluateExpressionToString( String expression ) throws DebugException;
/**
* Returns whether this stack frame can currently evaluate an expression.
*
* @return whether this stack frame can currently evaluate an expression
*/
boolean canEvaluate();
} }

View file

@ -17,11 +17,21 @@ import org.eclipse.cdt.debug.core.model.ICValue;
*/ */
public abstract class AbstractCValue extends CDebugElement implements ICValue { public abstract class AbstractCValue extends CDebugElement implements ICValue {
/**
* Parent variable.
*/
private AbstractCVariable fParent = null;
/** /**
* Constructor for AbstractCValue. * Constructor for AbstractCValue.
*/ */
public AbstractCValue( CDebugTarget target ) { public AbstractCValue( AbstractCVariable parent ) {
super( target ); super( (CDebugTarget)parent.getDebugTarget() );
fParent = parent;
}
public AbstractCVariable getParentVariable() {
return fParent;
} }
abstract protected void setChanged( boolean changed ); abstract protected void setChanged( boolean changed );

View file

@ -10,6 +10,7 @@
***********************************************************************/ ***********************************************************************/
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICVariable; import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
@ -18,11 +19,37 @@ import org.eclipse.debug.core.DebugException;
*/ */
public abstract class AbstractCVariable extends CDebugElement implements ICVariable { public abstract class AbstractCVariable extends CDebugElement implements ICVariable {
/**
* The parent object this variable is contained in.
*/
private CDebugElement fParent;
/** /**
* Constructor for AbstractCVariable. * Constructor for AbstractCVariable.
*/ */
public AbstractCVariable( CDebugTarget target ) { public AbstractCVariable( CDebugElement parent ) {
super( target ); super( (CDebugTarget)parent.getDebugTarget() );
setParent( parent );
}
protected CDebugElement getParent() {
return fParent;
}
private void setParent( CDebugElement parent ) {
fParent = parent;
}
protected ICStackFrame getStackFrame() {
CDebugElement parent = getParent();
if ( parent instanceof AbstractCValue ) {
AbstractCVariable pv = ((AbstractCValue)parent).getParentVariable();
if ( pv != null )
return pv.getStackFrame();
}
if ( parent instanceof CStackFrame )
return (CStackFrame)parent;
return null;
} }
/** /**

View file

@ -51,7 +51,7 @@ public class CArrayPartition extends AbstractCVariable {
* Constructor for CArrayPartition. * Constructor for CArrayPartition.
*/ */
private CArrayPartition( CDebugElement parent, ICDIVariable cdiVariable, int start, int end ) { private CArrayPartition( CDebugElement parent, ICDIVariable cdiVariable, int start, int end ) {
super( (CDebugTarget)parent.getDebugTarget() ); super( parent );
fStart = start; fStart = start;
fEnd = end; fEnd = end;
fCDIVariable = cdiVariable; fCDIVariable = cdiVariable;

View file

@ -15,7 +15,7 @@ import java.util.Iterator;
import java.util.List; import java.util.List;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator; import org.eclipse.cdt.debug.core.model.ICStackFrame;
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.model.IVariable; import org.eclipse.debug.core.model.IVariable;
@ -30,11 +30,6 @@ public class CArrayPartitionValue extends AbstractCValue {
*/ */
private ICDIVariable fCDIVariable; private ICDIVariable fCDIVariable;
/**
* Parent variable.
*/
private AbstractCVariable fParent = null;
/** /**
* List of child variables. * List of child variables.
*/ */
@ -48,9 +43,8 @@ public class CArrayPartitionValue extends AbstractCValue {
* Constructor for CArrayPartitionValue. * Constructor for CArrayPartitionValue.
*/ */
public CArrayPartitionValue( AbstractCVariable parent, ICDIVariable cdiVariable, int start, int end ) { public CArrayPartitionValue( AbstractCVariable parent, ICDIVariable cdiVariable, int start, int end ) {
super( (CDebugTarget)parent.getDebugTarget() ); super( parent );
fCDIVariable = cdiVariable; fCDIVariable = cdiVariable;
fParent = parent;
fStart = start; fStart = start;
fEnd = end; fEnd = end;
} }
@ -134,30 +128,23 @@ public class CArrayPartitionValue extends AbstractCValue {
} }
} }
/*
* (non-Javadoc)
*
* @see org.eclipse.cdt.debug.core.model.ICValue#computeDetail()
*/
public String evaluateAsExpression() { public String evaluateAsExpression() {
ICExpressionEvaluator ee = (ICExpressionEvaluator)getDebugTarget().getAdapter( ICExpressionEvaluator.class );
String valueString = null; String valueString = null;
if ( ee != null && ee.canEvaluate() ) { AbstractCVariable parent = getParentVariable();
try { if ( parent != null ) {
if ( getParentVariable() != null ) ICStackFrame frame = parent.getStackFrame();
valueString = ee.evaluateExpressionToString( getParentVariable().getExpressionString() ); if ( frame != null && frame.canEvaluate() ) {
} try {
catch( DebugException e ) { valueString = frame.evaluateExpressionToString( parent.getExpressionString() );
valueString = e.getMessage(); }
catch( DebugException e ) {
valueString = e.getMessage();
}
} }
} }
return valueString; return valueString;
} }
public AbstractCVariable getParentVariable() {
return fParent;
}
protected ICDIVariable getCDIVariable() { protected ICDIVariable getCDIVariable() {
return fCDIVariable; return fCDIVariable;
} }

View file

@ -68,7 +68,6 @@ import org.eclipse.cdt.debug.core.model.ICBreakpoint;
import org.eclipse.cdt.debug.core.model.ICDebugElement; import org.eclipse.cdt.debug.core.model.ICDebugElement;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICDebugTarget; import org.eclipse.cdt.debug.core.model.ICDebugTarget;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator;
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint; import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
import org.eclipse.cdt.debug.core.model.ICSharedLibrary; import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
import org.eclipse.cdt.debug.core.model.ICSignal; import org.eclipse.cdt.debug.core.model.ICSignal;
@ -760,8 +759,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long) * @see org.eclipse.debug.core.model.IMemoryBlockRetrieval#getMemoryBlock(long, long)
*/ */
public IMemoryBlock getMemoryBlock( long startAddress, long length ) throws DebugException { public IMemoryBlock getMemoryBlock( long startAddress, long length ) throws DebugException {
//TODO:IPF_TODO look into implementation return null;
throw new RuntimeException("Method getMemoryBlock should not be called from CDT");
} }
/* (non-Javadoc) /* (non-Javadoc)
@ -819,8 +817,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return this; return this;
if ( adapter.equals( ICDITarget.class ) ) if ( adapter.equals( ICDITarget.class ) )
return fCDITarget; return fCDITarget;
if ( adapter.equals( ICExpressionEvaluator.class ) )
return this;
if ( adapter.equals( ICMemoryManager.class ) ) if ( adapter.equals( ICMemoryManager.class ) )
return getMemoryManager(); return getMemoryManager();
if ( adapter.equals( IDebuggerProcessSupport.class ) ) if ( adapter.equals( IDebuggerProcessSupport.class ) )
@ -1288,26 +1284,6 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return getConfiguration().supportsExpressionEvaluation(); return getConfiguration().supportsExpressionEvaluation();
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICExpressionEvaluator#evaluateExpressionToString(java.lang.String)
*/
public String evaluateExpressionToString( String expression ) throws DebugException {
try {
return getCDITarget().evaluateExpressionToString( expression );
}
catch( CDIException e ) {
targetRequestFailed( e.getMessage(), null );
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICExpressionEvaluator#canEvaluate()
*/
public boolean canEvaluate() {
return supportsExpressionEvaluation() && isSuspended();
}
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.IExpressionListener#expressionAdded(org.eclipse.debug.core.model.IExpression) * @see org.eclipse.debug.core.IExpressionListener#expressionAdded(org.eclipse.debug.core.model.IExpression)
*/ */
@ -1503,7 +1479,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(long) * @see org.eclipse.cdt.debug.core.model.IRunToAddress#canRunToAddress(org.eclipse.cdt.core.IAddress)
*/ */
public boolean canRunToAddress( IAddress address ) { public boolean canRunToAddress( IAddress address ) {
// for now // for now
@ -1511,7 +1487,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IRunToAddress#runToAddress(long, boolean) * @see org.eclipse.cdt.debug.core.model.IRunToAddress#runToAddress(org.eclipse.cdt.core.IAddress, boolean)
*/ */
public void runToAddress( IAddress address, boolean skipBreakpoints ) throws DebugException { public void runToAddress( IAddress address, boolean skipBreakpoints ) throws DebugException {
if ( !canRunToAddress( address ) ) if ( !canRunToAddress( address ) )
@ -1607,7 +1583,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IJumpToAddress#canJumpToAddress(long) * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#canJumpToAddress(org.eclipse.cdt.core.IAddress)
*/ */
public boolean canJumpToAddress( IAddress address ) { public boolean canJumpToAddress( IAddress address ) {
// check if supports jump to address // check if supports jump to address
@ -1615,7 +1591,7 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IJumpToAddress#jumpToAddress(long) * @see org.eclipse.cdt.debug.core.model.IJumpToAddress#jumpToAddress(org.eclipse.cdt.core.IAddress)
*/ */
public void jumpToAddress( IAddress address ) throws DebugException { public void jumpToAddress( IAddress address ) throws DebugException {
if ( !canJumpToAddress( address ) ) if ( !canJumpToAddress( address ) )
@ -1846,20 +1822,15 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
return false; return false;
} }
public IAddressFactory getAddressFactory() public IAddressFactory getAddressFactory() {
{ if ( fAddressFactory == null ) {
if ( fAddressFactory == null ) if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) {
{ ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() );
if ( getExecFile() != null && CoreModel.getDefault().isBinary( getExecFile() ) ) if ( cFile instanceof IBinary ) {
{ fAddressFactory = ((IBinary)cFile).getAddressFactory();
ICElement cFile = CCorePlugin.getDefault().getCoreModel().create( getExecFile() ); }
if ( cFile instanceof IBinary ) }
{ }
fAddressFactory = ((IBinary)cFile).getAddressFactory(); return fAddressFactory;
} }
}
}
return fAddressFactory;
}
} }

View file

@ -288,8 +288,7 @@ public class CFormattedMemoryBlock extends CDebugElement
*/ */
public long getStartAddress() public long getStartAddress()
{ {
//IPF_TODO look into implementation return 0;
throw new RuntimeException("Method IMemoryBlock.getStartAddress shoud not be called in CDT debug");
} }
public IAddress getRealStartAddress() public IAddress getRealStartAddress()
@ -301,6 +300,7 @@ public class CFormattedMemoryBlock extends CDebugElement
} }
return factory.getZero(); return factory.getZero();
} }
/* (non-Javadoc) /* (non-Javadoc)
* @see org.eclipse.debug.core.model.IMemoryBlock#getLength() * @see org.eclipse.debug.core.model.IMemoryBlock#getLength()
*/ */

View file

@ -655,4 +655,25 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
return e.getLocalizedMessage(); return e.getLocalizedMessage();
} }
} }
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICStackFrame#evaluateExpressionToString(java.lang.String)
*/
public String evaluateExpressionToString( String expression ) throws DebugException {
try {
return getCDITarget().evaluateExpressionToString( expression );
}
catch( CDIException e ) {
targetRequestFailed( e.getMessage(), null );
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICStackFrame#canEvaluate()
*/
public boolean canEvaluate() {
CDebugTarget target = ((CDebugTarget)getDebugTarget());
return target.supportsExpressionEvaluation() && target.isSuspended();
}
} }

View file

@ -37,6 +37,7 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDIThread; import org.eclipse.cdt.debug.core.cdi.model.ICDIThread;
import org.eclipse.cdt.debug.core.model.CDebugElementState; import org.eclipse.cdt.debug.core.model.CDebugElementState;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICThread; import org.eclipse.cdt.debug.core.model.ICThread;
import org.eclipse.cdt.debug.core.model.IDummyStackFrame; import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
import org.eclipse.cdt.debug.core.model.IRestart; import org.eclipse.cdt.debug.core.model.IRestart;
@ -830,6 +831,14 @@ public class CThread extends CDebugElement implements ICThread, IRestart, IResum
return this; return this;
if ( adapter.equals( CDebugElementState.class ) ) if ( adapter.equals( CDebugElementState.class ) )
return this; return this;
if ( adapter == ICStackFrame.class ) {
try {
return (ICStackFrame)getTopStackFrame();
}
catch( DebugException e ) {
// do nothing
}
}
return super.getAdapter( adapter ); return super.getAdapter( adapter );
} }

View file

@ -34,7 +34,7 @@ import org.eclipse.cdt.debug.core.cdi.model.type.ICDIShortValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIWCharValue; import org.eclipse.cdt.debug.core.cdi.model.type.ICDIWCharValue;
import org.eclipse.cdt.debug.core.model.CVariableFormat; import org.eclipse.cdt.debug.core.model.CVariableFormat;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus; import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator; import org.eclipse.cdt.debug.core.model.ICStackFrame;
import org.eclipse.cdt.debug.core.model.ICType; import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable; import org.eclipse.debug.core.model.IVariable;
@ -44,11 +44,6 @@ import org.eclipse.debug.core.model.IVariable;
*/ */
public class CValue extends AbstractCValue { public class CValue extends AbstractCValue {
/**
* Parent variable.
*/
private CVariable fParent = null;
/** /**
* Cached value. * Cached value.
*/ */
@ -68,8 +63,7 @@ public class CValue extends AbstractCValue {
* Constructor for CValue. * Constructor for CValue.
*/ */
protected CValue( CVariable parent, ICDIValue cdiValue ) { protected CValue( CVariable parent, ICDIValue cdiValue ) {
super( (CDebugTarget)parent.getDebugTarget() ); super( parent );
fParent = parent;
fCDIValue = cdiValue; fCDIValue = cdiValue;
} }
@ -77,8 +71,7 @@ public class CValue extends AbstractCValue {
* Constructor for CValue. * Constructor for CValue.
*/ */
protected CValue( CVariable parent, String message ) { protected CValue( CVariable parent, String message ) {
super( (CDebugTarget)parent.getDebugTarget() ); super( parent );
fParent = parent;
setStatus( ICDebugElementStatus.ERROR, message ); setStatus( ICDebugElementStatus.ERROR, message );
} }
@ -196,10 +189,6 @@ public class CValue extends AbstractCValue {
} }
} }
public CVariable getParentVariable() {
return fParent;
}
private String processUnderlyingValue( ICDIValue cdiValue ) throws CDIException { private String processUnderlyingValue( ICDIValue cdiValue ) throws CDIException {
if ( cdiValue != null ) { if ( cdiValue != null ) {
if ( cdiValue instanceof ICDICharValue ) if ( cdiValue instanceof ICDICharValue )
@ -362,42 +351,41 @@ public class CValue extends AbstractCValue {
return null; return null;
} }
private String getPointerValueString( ICDIPointerValue value ) throws CDIException private String getPointerValueString( ICDIPointerValue value ) throws CDIException {
{ //TODO:IPF_TODO Workaround to solve incorrect handling of structures referenced by pointers or references
//TODO:IPF_TODO Workaround to solve incorrect handling of structures referenced by pointers or references
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory(); IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
IAddress address = factory.createAddress(value.pointerValue().toString()); IAddress address = factory.createAddress( value.pointerValue().toString() );
if ( address == null ) if ( address == null )
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
CVariableFormat format = getParentVariable().getFormat(); CVariableFormat format = getParentVariable().getFormat();
if( CVariableFormat.NATURAL.equals( format ) || if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.HEXADECIMAL.equals( format ) )
CVariableFormat.HEXADECIMAL.equals( format ) ) return address.toHexAddressString();
return address.toHexAddressString(); if ( CVariableFormat.DECIMAL.equals( format ) )
if( CVariableFormat.DECIMAL.equals( format )) return address.toString();
return address.toString();
return null; return null;
} }
private String getReferenceValueString( ICDIReferenceValue value ) throws CDIException private String getReferenceValueString( ICDIReferenceValue value ) throws CDIException {
{ //NOTE: Reference should be displayed identically to address
//NOTE: Reference should be displayed identically to address //TODO:IPF_TODO Workaround to solve incoorect handling of structures referenced by pointers or references
//TODO:IPF_TODO Workaround to solve incoorect handling of structures referenced by pointers or references
IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory(); IAddressFactory factory = ((CDebugTarget)getDebugTarget()).getAddressFactory();
IAddress address = factory.createAddress( value.referenceValue().toString() ); BigInteger refValue = value.referenceValue();
if (address == null) if ( refValue == null )
return ""; //$NON-NLS-1$ return ""; //$NON-NLS-1$
IAddress address = factory.createAddress( refValue.toString() );
if ( address == null )
return ""; //$NON-NLS-1$
CVariableFormat format = getParentVariable().getFormat(); CVariableFormat format = getParentVariable().getFormat();
if( CVariableFormat.NATURAL.equals( format ) || if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.HEXADECIMAL.equals( format ) )
CVariableFormat.HEXADECIMAL.equals( format ) ) return address.toHexAddressString();
return address.toHexAddressString(); if ( CVariableFormat.DECIMAL.equals( format ) )
if( CVariableFormat.DECIMAL.equals( format )) return address.toString();
return address.toString();
return null; return null;
} }
private String getWCharValueString( ICDIWCharValue value ) throws CDIException { private String getWCharValueString( ICDIWCharValue value ) throws CDIException {
if ( getParentVariable() != null ) { if ( getParentVariable() instanceof CVariable ) {
int size = getParentVariable().sizeof(); int size = ((CVariable)getParentVariable()).sizeof();
if ( size == 2 ) { if ( size == 2 ) {
CVariableFormat format = getParentVariable().getFormat(); CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) { if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
@ -441,15 +429,17 @@ public class CValue extends AbstractCValue {
* @see org.eclipse.cdt.debug.core.model.ICValue#evaluateAsExpression() * @see org.eclipse.cdt.debug.core.model.ICValue#evaluateAsExpression()
*/ */
public String evaluateAsExpression() { public String evaluateAsExpression() {
ICExpressionEvaluator ee = (ICExpressionEvaluator)getDebugTarget().getAdapter( ICExpressionEvaluator.class );
String valueString = null; String valueString = null;
if ( ee != null && ee.canEvaluate() ) { AbstractCVariable parent = getParentVariable();
try { if ( parent != null ) {
if ( getParentVariable() != null ) ICStackFrame frame = parent.getStackFrame();
valueString = ee.evaluateExpressionToString( getParentVariable().getExpressionString() ); if ( frame != null && frame.canEvaluate() ) {
} try {
catch( DebugException e ) { valueString = frame.evaluateExpressionToString( parent.getExpressionString() );
valueString = e.getMessage(); }
catch( DebugException e ) {
valueString = e.getMessage();
}
} }
} }
return valueString; return valueString;

View file

@ -306,11 +306,6 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
*/ */
private boolean fIsEnabled = true; private boolean fIsEnabled = true;
/**
* The parent object this variable is contained in.
*/
private CDebugElement fParent;
/** /**
* The original internal variable. * The original internal variable.
*/ */
@ -335,8 +330,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
* Constructor for CVariable. * Constructor for CVariable.
*/ */
protected CVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) { protected CVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) {
super( (CDebugTarget)parent.getDebugTarget() ); super( parent );
setParent( parent );
if ( cdiVariableObject != null ) { if ( cdiVariableObject != null ) {
fName = cdiVariableObject.getName(); fName = cdiVariableObject.getName();
createOriginal( cdiVariableObject ); createOriginal( cdiVariableObject );
@ -349,8 +343,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
* Constructor for CVariable. * Constructor for CVariable.
*/ */
protected CVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject, String errorMessage ) { protected CVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject, String errorMessage ) {
super( (CDebugTarget)parent.getDebugTarget() ); super( parent );
setParent( parent );
if ( cdiVariableObject != null ) { if ( cdiVariableObject != null ) {
fName = cdiVariableObject.getName(); fName = cdiVariableObject.getName();
createOriginal( cdiVariableObject ); createOriginal( cdiVariableObject );
@ -701,14 +694,6 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
fOriginal = original; fOriginal = original;
} }
protected CDebugElement getParent() {
return fParent;
}
private void setParent( CDebugElement parent ) {
fParent = parent;
}
private InternalVariable getShadow() { private InternalVariable getShadow() {
return fShadow; return fShadow;
} }