1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-23 14:42:11 +02:00

New implementation of expressions.

Large arrays partitioning based on the framework model.
This commit is contained in:
Mikhail Khodjaiants 2004-11-03 22:34:49 +00:00
parent 1ca094c613
commit 0edfd9947c
9 changed files with 364 additions and 548 deletions

View file

@ -1,3 +1,16 @@
2004-11-03 Mikhail Khodjaiants
New implementation of expressions.
Large arrays partitioning based on the framework model.
* CoreModelMessages.properties
* AbstractCValue.java
* CExpression.java
* CIndexedValue.java: new
* CValue.java
* CValueFactory.java
* CVariable.java
* CArrayPartition.java: removed
* CArrayPartitionValue.java: removed
2004-11-02 Alain Magloire
Refactor ICDIConfiguratio --> ICDISessionConfiguration and ICDITargetConfiguration
* cdi/org/eclipse/cdt/debug/core/cdi/ICDISession.java

View file

@ -1,354 +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.model;
import java.util.ArrayList;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
/**
* A sub-range of an array.
*/
public class CArrayPartition extends AbstractCVariable {
static final protected int SLOT_SIZE = 100;
private int fStart;
private int fEnd;
private ICDIVariableDescriptor fCDIVariableObject;
private ICDIVariable fCDIVariable;
private ICType fType = null;
private String fQualifiedName = null;
/**
* Cached value.
*/
private CArrayPartitionValue fArrayPartitionValue = null;
/**
* Constructor for CArrayPartition.
*/
private CArrayPartition( CDebugElement parent, ICDIVariable cdiVariable, int start, int end ) {
super( parent );
fStart = start;
fEnd = end;
fCDIVariable = cdiVariable;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#getType()
*/
public ICType getType() throws DebugException {
if ( fType == null ) {
try {
ICDIVariableDescriptor varObject = getVariableObject();
if ( varObject != null )
fType = new CType( varObject.getType() );
}
catch( CDIException e ) {
requestFailed( CoreModelMessages.getString( "CArrayPartition.0" ), e ); //$NON-NLS-1$
}
}
return fType;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#isEnabled()
*/
public boolean isEnabled() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#setEnabled(boolean)
*/
public void setEnabled( boolean enabled ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable()
*/
public boolean canEnableDisable() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#isArgument()
*/
public boolean isArgument() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getValue()
*/
public IValue getValue() throws DebugException {
if ( fArrayPartitionValue == null ) {
fArrayPartitionValue = CValueFactory.createArrayValue( this, getCDIVariable(), getStart(), getEnd() );
}
return fArrayPartitionValue;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getName()
*/
public String getName() throws DebugException {
StringBuffer name = new StringBuffer();
name.append( '[' );
name.append( fStart );
name.append( ".." ); //$NON-NLS-1$
name.append( fEnd );
name.append( ']' );
return name.toString();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException {
ICType type = getType();
return ( type != null ) ? type.getName() : null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
*/
public boolean hasValueChanged() throws DebugException {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IFormatSupport#supportsFormatting()
*/
public boolean supportsFormatting() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IFormatSupport#getFormat()
*/
public CVariableFormat getFormat() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.IFormatSupport#changeFormat(org.eclipse.cdt.debug.core.model.CVariableFormat)
*/
public void changeFormat( CVariableFormat format ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToArray#canCastToArray()
*/
public boolean canCastToArray() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToArray#castToArray(int, int)
*/
public void castToArray( int startIndex, int length ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#setValue(java.lang.String)
*/
public void setValue( String expression ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#setValue(org.eclipse.debug.core.model.IValue)
*/
public void setValue( IValue value ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
*/
public boolean supportsValueModification() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#verifyValue(java.lang.String)
*/
public boolean verifyValue( String expression ) throws DebugException {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#verifyValue(org.eclipse.debug.core.model.IValue)
*/
public boolean verifyValue( IValue value ) throws DebugException {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToType#canCast()
*/
public boolean canCast() {
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToType#getCurrentType()
*/
public String getCurrentType() {
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToType#cast(java.lang.String)
*/
public void cast( String type ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToType#restoreOriginal()
*/
public void restoreOriginal() throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICastToType#isCasted()
*/
public boolean isCasted() {
return false;
}
private ICDIVariableDescriptor getVariableObject() throws CDIException {
if ( fCDIVariableObject == null ) {
fCDIVariableObject = getCDIVariable().getVariableDescriptorAsArray(getStart(), getEnd() - getStart() + 1 );
//fCDIVariableObject = getCDISession().getVariableManager().getVariableObjectAsArray( getCDIVariable(), getStart(), getEnd() - getStart() + 1 );
}
return fCDIVariableObject;
}
private ICDIVariable getCDIVariable() {
return fCDIVariable;
}
private int getEnd() {
return fEnd;
}
private int getStart() {
return fStart;
}
static public List splitArray( CDebugElement parent, ICDIVariable cdiVariable, int start, int end ) throws DebugException {
ArrayList children = new ArrayList();
int len = end - start + 1;
int perSlot = 1;
while( len > perSlot * SLOT_SIZE ) {
perSlot *= SLOT_SIZE;
}
if ( perSlot == 1 ) {
try {
ICDIValue value = cdiVariable.getValue();
if ( value instanceof ICDIArrayValue ) {
ICDIVariable[] cdiVars = ((ICDIArrayValue)value).getVariables( start, len );
for( int i = 0; i < cdiVars.length; ++i )
children.add( CVariableFactory.createVariable( parent, cdiVars[i] ) );
}
}
catch( CDIException e ) {
requestFailed( e.getMessage(), e );
}
}
else {
int pos = start;
while( pos <= end ) {
if ( pos + perSlot > end ) {
perSlot = end - pos + 1;
}
children.add( new CArrayPartition( parent, cdiVariable, pos, pos + perSlot - 1 ) );
pos += perSlot;
}
}
return children;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#getExpressionString()
*/
public String getExpressionString() throws DebugException {
if ( fQualifiedName == null ) {
try {
if ( getVariableObject() != null ) {
fQualifiedName = getVariableObject().getQualifiedName();
}
}
catch( CDIException e ) {
requestFailed( CoreModelMessages.getString( "CArrayPartition.1" ), e ); //$NON-NLS-1$
}
}
return fQualifiedName;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#dispose()
*/
public void dispose() {
if ( fType != null ) {
((CType)fType).dispose();
fType = null;
}
if ( fArrayPartitionValue != null ) {
fArrayPartitionValue.dispose();
fArrayPartitionValue = null;
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#resetValue()
*/
protected void resetValue() {
if ( fArrayPartitionValue != null ) {
fArrayPartitionValue.reset();
fireChangeEvent( DebugEvent.STATE );
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#setChanged(boolean)
*/
protected void setChanged( boolean changed ) {
if ( fArrayPartitionValue != null ) {
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();
}
}
}

View file

@ -1,169 +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.internal.core.model;
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.debug.core.DebugEvent;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
/**
* A value for an array partition.
*/
public class CArrayPartitionValue extends AbstractCValue {
/**
* The underlying CDI variable.
*/
private ICDIVariable fCDIVariable;
/**
* List of child variables.
*/
private List fVariables = Collections.EMPTY_LIST;
private int fStart;
private int fEnd;
/**
* Constructor for CArrayPartitionValue.
*/
public CArrayPartitionValue( AbstractCVariable parent, ICDIVariable cdiVariable, int start, int end ) {
super( parent );
fCDIVariable = cdiVariable;
fStart = start;
fEnd = end;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException {
return ( getParentVariable() != null ) ? getParentVariable().getReferenceTypeName() : null;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#getValueString()
*/
public String getValueString() throws DebugException {
return ""; //$NON-NLS-1$
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#isAllocated()
*/
public boolean isAllocated() throws DebugException {
return true;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#getVariables()
*/
public IVariable[] getVariables() throws DebugException {
List list = getVariables0();
return (IVariable[])list.toArray( new IVariable[list.size()] );
}
protected synchronized List getVariables0() throws DebugException {
if ( !isAllocated() || !hasVariables() )
return Collections.EMPTY_LIST;
if ( fVariables.size() == 0 ) {
try {
fVariables = CArrayPartition.splitArray( this, getCDIVariable(), getStart(), getEnd() );
}
catch( DebugException e ) {
setStatus( ICDebugElementStatus.ERROR, e.getMessage() );
getParentVariable().fireChangeEvent( DebugEvent.STATE );
}
}
return fVariables;
}
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#hasVariables()
*/
public boolean hasVariables() throws DebugException {
return true;
}
protected int getStart() {
return fStart;
}
protected int getEnd() {
return fEnd;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#setChanged(boolean)
*/
protected void setChanged( boolean changed ) {
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
((AbstractCVariable)it.next()).setChanged( changed );
}
}
protected ICDIVariable getCDIVariable() {
return fCDIVariable;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#dispose()
*/
public void dispose() {
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
((AbstractCVariable)it.next()).dispose();
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#reset()
*/
protected void reset() {
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
((AbstractCVariable)it.next()).resetValue();
}
}
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();
}
}
}

View file

@ -20,8 +20,10 @@ import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
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;
@ -37,6 +39,8 @@ public class CExpression extends CVariable implements IExpression {
private IValue fValue;
private ICType fType;
/**
* Constructor for CExpression.
*/
@ -113,7 +117,25 @@ public class CExpression extends CVariable implements IExpression {
if ( context.isSuspended() ) {
try {
ICDIValue value = fCDIExpression.getValue( context.getCDIStackFrame() );
fValue = CValueFactory.createValue( this, value );
if ( value != null ) {
if ( value instanceof ICDIArrayValue ) {
ICType type = null;
try {
type = new CType( value.getType() );
}
catch( CDIException e ) {
// ignore and use default type
}
if ( type != null && type.isArray() ) {
int[] dims = type.getArrayDimensions();
if ( dims.length > 0 && dims[0] > 0 )
fValue = CValueFactory.createIndexedValue( this, (ICDIArrayValue)value, 0, dims[0] - 1 );
}
}
else {
fValue = CValueFactory.createValue( this, value );
}
}
}
catch( CDIException e ) {
targetRequestFailed( e.getMessage(), null );
@ -159,4 +181,28 @@ public class CExpression extends CVariable implements IExpression {
}
super.dispose();
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#getType()
*/
public ICType getType() throws DebugException {
if ( fType == null ) {
if ( fValue != null ) {
synchronized( this ) {
if ( fType == null ) {
fType = ((AbstractCValue)fValue).getType();
}
}
}
}
return fType;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException {
ICType type = getType();
return ( type != null ) ? type.getName() : ""; //$NON-NLS-1$
}
}

View file

@ -0,0 +1,259 @@
/**********************************************************************
* 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.model;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IIndexedValue;
import org.eclipse.debug.core.model.IVariable;
/**
* A value containing an array of variables.
*/
public class CIndexedValue extends AbstractCValue implements IIndexedValue {
/**
* The underlying CDI value.
*/
private ICDIArrayValue fCDIValue;
/**
* List of child variables.
*/
private IVariable[] fVariables;
/**
* The index of the first variable contained in this value.
*/
private int fOffset;
/**
* The number of entries in this indexed collection.
*/
private int fSize;
/**
* The type of this value.
*/
private ICType fType;
/**
* Constructor for CIndexedValue.
*/
public CIndexedValue( AbstractCVariable parent, ICDIArrayValue cdiValue, int offset, int size ) {
super( parent );
fVariables = new IVariable[ size ];
fCDIValue = cdiValue;
fOffset = offset;
fSize = size;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#setChanged(boolean)
*/
protected void setChanged( boolean changed ) {
for ( int i = 0; i < fVariables.length; ++i ) {
if ( fVariables[i] != null ) {
((AbstractCVariable)fVariables[i]).setChanged( changed );
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#dispose()
*/
public void dispose() {
for ( int i = 0; i < fVariables.length; ++i ) {
if ( fVariables[i] != null ) {
((AbstractCVariable)fVariables[i]).dispose();
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#reset()
*/
protected void reset() {
for ( int i = 0; i < fVariables.length; ++i ) {
if ( fVariables[i] != null ) {
((AbstractCVariable)fVariables[i]).resetValue();
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCValue#preserve()
*/
protected void preserve() {
resetStatus();
for ( int i = 0; i < fVariables.length; ++i ) {
if ( fVariables[i] != null ) {
((AbstractCVariable)fVariables[i]).preserve();
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICValue#getType()
*/
public ICType getType() throws DebugException {
if ( fType == null ) {
synchronized( this ) {
if ( fType == null ) {
try {
ICDIType cdiType = getCDIValue().getType();
if ( cdiType != null )
fType = new CType( cdiType );
}
catch( CDIException e ) {
targetRequestFailed( e.getMessage(), null );
}
}
}
}
return fType;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException {
ICType type = getType();
return ( type != null ) ? type.getName() : ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#getValueString()
*/
public String getValueString() throws DebugException {
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#isAllocated()
*/
public boolean isAllocated() throws DebugException {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#getVariables()
*/
public IVariable[] getVariables() throws DebugException {
return getVariables0( getInitialOffset(), getSize() );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#hasVariables()
*/
public boolean hasVariables() throws DebugException {
return getSize() > 0;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IIndexedValue#getVariable(int)
*/
public IVariable getVariable( int offset ) throws DebugException {
if ( offset >= getSize() ) {
requestFailed( CoreModelMessages.getString( "CIndexedValue.0" ), null ); //$NON-NLS-1$
}
return getVariables0( offset, 1 )[0];
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IIndexedValue#getVariables(int, int)
*/
public IVariable[] getVariables( int offset, int length ) throws DebugException {
if ( offset >= getSize() ) {
requestFailed( CoreModelMessages.getString( "CIndexedValue.1" ), null ); //$NON-NLS-1$
}
if ( (offset + length - 1) >= getSize() ) {
requestFailed( CoreModelMessages.getString( "CIndexedValue.2" ), null ); //$NON-NLS-1$
}
return getVariables0( offset, length );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IIndexedValue#getSize()
*/
public int getSize() throws DebugException {
return getSize0();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IIndexedValue#getInitialOffset()
*/
public int getInitialOffset() {
return fOffset;
}
protected ICDIArrayValue getCDIValue() {
return fCDIValue;
}
private int getPartitionSize( int index ) {
int psize = getPreferredPartitionSize();
int size = getSize0();
int pcount = size/psize + 1;
if ( pcount - 1 < index )
return 0;
return ( pcount - 1 == index ) ? size % psize : psize;
}
private int getPartitionIndex( int offset ) {
return offset / getPreferredPartitionSize();
}
private int getPreferredPartitionSize() {
return 100;
}
private IVariable[] getVariables0( int offset, int length ) throws DebugException {
IVariable[] result = new IVariable[length];
int firstIndex = getPartitionIndex( offset );
int lastIndex = getPartitionIndex( offset + length );
for ( int i = firstIndex; i <= lastIndex; ++i ) {
synchronized( this ) {
if ( !isPartitionLoaded( i ) ) {
loadPartition( i );
}
}
}
System.arraycopy( fVariables, offset, result, 0, length );
return result;
}
private boolean isPartitionLoaded( int index ) {
return fVariables[index * getPreferredPartitionSize()] != null;
}
private void loadPartition( int index ) throws DebugException {
int prefSize = getPreferredPartitionSize();
int psize = getPartitionSize( index );
ICDIVariable[] cdiVars = new ICDIVariable[0];
try {
cdiVars = getCDIValue().getVariables( index * prefSize, psize );
}
catch( CDIException e ) {
requestFailed( e.getMessage(), null );
}
for( int i = 0; i < cdiVars.length; ++i )
fVariables[i + index * prefSize] = CVariableFactory.createVariable( getParentVariable(), cdiVars[i] );
}
private int getSize0() {
return fSize;
}
}

View file

@ -57,6 +57,8 @@ public class CValue extends AbstractCValue {
*/
private List fVariables = Collections.EMPTY_LIST;
private CType fType;
/**
* Constructor for CValue.
*/
@ -444,8 +446,24 @@ public class CValue extends AbstractCValue {
}
public ICType getType() throws DebugException {
AbstractCVariable var = getParentVariable();
return ( var instanceof CVariable ) ? ((CVariable)var).getType() : null;
ICDIValue cdiValue = getUnderlyingValue();
if ( fType == null ) {
if ( cdiValue != null ) {
synchronized( this ) {
if ( fType == null ) {
try {
fType = new CType( cdiValue.getType() );
}
catch( CDIException e ) {
requestFailed( e.getMessage(), null );
}
}
}
}
}
return fType;
// AbstractCVariable var = getParentVariable();
// return ( var instanceof CVariable ) ? ((CVariable)var).getType() : null;
}
/* (non-Javadoc)

View file

@ -11,7 +11,7 @@
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointValue;
import org.eclipse.cdt.debug.core.model.ICValue;
@ -27,8 +27,8 @@ public class CValueFactory {
return new CValue( parent, cdiValue );
}
static public CArrayPartitionValue createArrayValue( AbstractCVariable parent, ICDIVariable cdiVariable, int start, int end ) {
return new CArrayPartitionValue( parent, cdiVariable, start, end );
static public CIndexedValue createIndexedValue( AbstractCVariable parent, ICDIArrayValue cdiValue, int start, int end ) {
return new CIndexedValue( parent, cdiValue, start, end - start );
}
static public CValue createGlobalValue( CVariable parent, ICDIValue cdiValue ) {

View file

@ -25,6 +25,8 @@ 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.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableDescriptor;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICType;
@ -225,27 +227,25 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
if ( fValue == null ) {
ICDIVariable var = getCDIVariable();
if ( var != null ) {
ICType type = null;
try {
type = getType();
}
catch( DebugException e ) {
// ignore and use default type
}
if ( type != null && type.isArray() ) {
int[] dims = type.getArrayDimensions();
if ( dims.length > 0 && dims[0] > 0 )
fValue = CValueFactory.createArrayValue( getVariable(), var, 0, dims[0] - 1 );
}
else {
try {
ICDIValue cdiValue = var.getValue();
if ( cdiValue != null )
ICDIValue cdiValue = var.getValue();
if ( cdiValue != null ) {
ICDIType cdiType = cdiValue.getType();
if ( cdiValue instanceof ICDIArrayValue && cdiType != null ) {
ICType type = new CType( cdiType );
if ( type.isArray() ) {
int[] dims = type.getArrayDimensions();
if ( dims.length > 0 && dims[0] > 0 )
fValue = CValueFactory.createIndexedValue( getVariable(), (ICDIArrayValue)cdiValue, 0, dims[0] );
}
}
else {
fValue = CValueFactory.createValue( getVariable(), cdiValue );
}
}
catch( CDIException e ) {
requestFailed( e.getMessage(), e );
}
}
catch( CDIException e ) {
requestFailed( e.getMessage(), e );
}
}
}
@ -452,7 +452,7 @@ public class CVariable extends AbstractCVariable implements ICDIEventListener {
*/
public String getReferenceTypeName() throws DebugException {
ICType type = getType();
return ( type != null ) ? type.getName() : null;
return ( type != null ) ? type.getName() : ""; //$NON-NLS-1$
}
/*

View file

@ -35,3 +35,6 @@ CVariable.2=Variable does not support value modification.
CVariable.3=Variable does not support value modification.
CVariable.4=Qualified name is not available.
CVariable.5=Type is not available.
CIndexedValue.0=Index out of bounds.
CIndexedValue.1=Index out of bounds.
CIndexedValue.2=Specified range out of bounds.