1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-06-05 16:56:04 +02:00

New implementation of the variable types.

This commit is contained in:
Mikhail Khodjaiants 2004-08-04 21:06:56 +00:00
parent aed28a3861
commit 172c988cf8
37 changed files with 1606 additions and 1898 deletions

View file

@ -1,3 +1,33 @@
2004-08-04 Mikhail Khodjaiants
New implementation of the variable types.
* CDIDebugModel.java
* CVariableFormat.java: new
* ICastToArray.java
* ICastToType.java
* ICGlobalVariable.java
* ICType.java
* ICValue.java
* ICVariable.java
* IFormatSupport.java: new
* CGlobalVariableManager.java
* CoreModelMessages.properties
* AbstractCValue.java: new
* AbstractCVariable.java: new
* CArrayPartition.java
* CArrayPartitionValue.java
* CDebugTarget.java
* CExpression.java
* CGlobalVariable.java
* CRegister.java
* CRegisterGroup.java
* CStackFrame.java
* CType.java
* CValue.java
* CValueFactory.java
* CVariable.java
* CVariableFactory.java: new
* CModificationVariable: deleted
2004-07-23 Mikhail Khodjaiants
Marked the expression creation methods as deprecated in CDebugModel.
* CDebugModel.java

View file

@ -12,7 +12,6 @@ package org.eclipse.cdt.debug.core;
import java.text.MessageFormat;
import java.util.HashMap;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
@ -39,7 +38,7 @@ import org.eclipse.cdt.debug.internal.core.breakpoints.CWatchpoint;
import org.eclipse.cdt.debug.internal.core.model.CCoreFileDebugTarget;
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.CGlobalVariable;
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.IResource;
@ -543,8 +542,7 @@ public class CDIDebugModel {
ICDIVariableObject vo = null;
try {
vo = ((CDebugTarget)target).getCDISession().getVariableManager().getGlobalVariableObject( info.getPath().lastSegment(), null, info.getName() );
ICDIVariable cdiVariable = ((CDebugTarget)target).getCDISession().getVariableManager().createVariable( vo );
return new CGlobalVariable( (CDebugTarget)target, cdiVariable );
return CVariableFactory.createGlobalVariable( (CDebugTarget)target, 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$

View file

@ -0,0 +1,50 @@
/**********************************************************************
* 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.core.model;
/**
* Defines the variable format types.
*/
public class CVariableFormat {
private final String fName;
private CVariableFormat( String name ) {
this.fName = name;
}
public String toString() {
return this.fName;
}
public static CVariableFormat getFormat( int code ) {
switch( code ) {
case 0:
return NATURAL;
case 1:
return DECIMAL;
case 2:
return BINARY;
case 3:
return OCTAL;
case 4:
return HEXADECIMAL;
default:
return NATURAL;
}
}
public static final CVariableFormat NATURAL = new CVariableFormat( "natural" ); //$NON-NLS-1$
public static final CVariableFormat DECIMAL = new CVariableFormat( "decimal" ); //$NON-NLS-1$
public static final CVariableFormat BINARY = new CVariableFormat( "binary" ); //$NON-NLS-1$
public static final CVariableFormat OCTAL = new CVariableFormat( "octal" ); //$NON-NLS-1$
public static final CVariableFormat HEXADECIMAL = new CVariableFormat( "hexadecimal" ); //$NON-NLS-1$
}

View file

@ -14,5 +14,4 @@ package org.eclipse.cdt.debug.core.model;
* Represents a global C/C++ variable.
*/
public interface ICGlobalVariable extends ICVariable {
public void dispose();
}

View file

@ -8,33 +8,75 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.IAdaptable;
/**
* Enter type comment.
*
* @since Jun 10, 2003
* Represents a type of a varibale.
* Used by the UI responsible components for variable rendering.
*/
public interface ICType extends IAdaptable
{
public interface ICType {
/**
* Returns the name of this type.
*
* @return the name of this type
*/
String getName();
/**
* Returns whether this is an array type.
*
* @return whether this is an array type
*/
boolean isArray();
/**
* Returns the array dimensions for array types,
* otherwise returns an empty array.
*
* @return the array dimensions
*/
int[] getArrayDimensions();
/**
* Returns whether this is a structure or a class type.
*
* @return whether this is a structure or a class type
*/
boolean isStructure();
/**
* Returns whether this is a character type.
*
* @return whether this is a character type
*/
boolean isCharacter();
/**
* Returns whether this is a floating point type.
*
* @return whether this is a floating point type
*/
boolean isFloatingPointType();
/**
* Returns whether this is a pointer type.
*
* @return whether this is a pointer type
*/
boolean isPointer();
/**
* Returns whether this is a reference type.
*
* @return whether this is a reference type
*/
boolean isReference();
void dispose();
}
/**
* Returns whether this is an unsigned type.
*
* @return whether this is an unsigned type
*/
boolean isUnsigned();
}

View file

@ -8,20 +8,14 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.model.IValue;
/**
*
* Extends the IValue interface by C/C++ specific functionality.
*
* @since Sep 9, 2002
* Extends the IValue interface by C/C++ specific functionality.
*/
public interface ICValue extends IValue
{
String evaluateAsExpression();
public interface ICValue extends IValue, ICDebugElement {
void dispose();
}
String evaluateAsExpression();
}

View file

@ -11,31 +11,48 @@
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValueModification;
import org.eclipse.debug.core.model.IVariable;
/**
*
* Enter type comment.
*
* @since Dec 15, 2002
* C/C++ specific extension <code>IVariable</code>.
*/
public interface ICVariable extends IVariable
{
int getFormat();
void setFormat( int format ) throws DebugException;
ICType getType() throws DebugException;
boolean isEditable();
boolean hasChildren();
public interface ICVariable extends IVariable, ICDebugElement, IFormatSupport, ICastToArray, IValueModification {
/**
* Returns the type of this variable.
*
* @return the type of this variable
* @throws DebugException
*/
ICType getType() throws DebugException;
/**
* Returns whether this variable is enabled.
*
* @return whether this variable is enabled
*/
boolean isEnabled();
/**
* Sets the enabled state of this action.
*
* @param enabled <code>true</code> to enable, and <code>false</code> to disable
* @throws DebugException
*/
void setEnabled( boolean enabled ) throws DebugException;
/**
* Returns whether this variable supports enable/disable operation.
*
* @return whether this variable supports enable/disable operation
*/
boolean canEnableDisable();
/**
* Returns whether this variable is an argument.
*
* @return whether this variable is an argument
*/
boolean isArgument();
}
}

View file

@ -8,19 +8,29 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.debug.core.DebugException;
/**
* Enter type comment.
*
* @since Mar 10, 2003
* Provides the ability to present a variable as an array of the same type.
*/
public interface ICastToArray extends ICastToType
{
boolean supportsCastToArray();
public interface ICastToArray extends ICastToType {
/**
* Returns whether this element can be currently casted to array.
*
* @return whether this element can be currently casted to array
*/
boolean canCastToArray();
/**
* Performs the casting. The element is transformed to the array of the same type.
*
* @param startIndex the index of the first element of the array. 0 means that
* the original element is the first member of the array.
* @param length tha array size
* @throws DebugException
*/
void castToArray( int startIndex, int length ) throws DebugException;
}
}

View file

@ -8,26 +8,49 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.core.model;
import org.eclipse.core.runtime.IAdaptable;
import org.eclipse.debug.core.DebugException;
/**
* Enter type comment.
*
* @since Mar 7, 2003
* Provides the ability to cast a variable to the given type.
*/
public interface ICastToType extends IAdaptable
{
boolean supportsCasting();
public interface ICastToType extends IAdaptable {
/**
* Returns whether this element can currently be casted.
*
* @return whether this element can currently be casted
*/
boolean canCast();
/**
* Returns the string presentation of the current type.
*
* @return the string presentation of the current type
*/
String getCurrentType();
/**
* Performs the casting to the given type.
*
* @param type a type to cast to.
* @throws DebugException
*/
void cast( String type ) throws DebugException;
void restoreDefault() throws DebugException;
/**
* Restores the original type.
*
* @throws DebugException
*/
void restoreOriginal() throws DebugException;
/**
* Returns whether this element is casted.
*
* @return whether this element is casted
*/
boolean isCasted();
}
}

View file

@ -0,0 +1,41 @@
/**********************************************************************
* 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.core.model;
import org.eclipse.debug.core.DebugException;
/**
* Provides the ability to set and get the format of a variable.
*/
public interface IFormatSupport {
/**
* Returns whether this variable supports formatting operations.
*
* @return whether this variable supports formatting operations
*/
boolean supportsFormatting();
/**
* Returns the current format of this variable.
*
* @return the current format of this variable
*/
CVariableFormat getFormat();
/**
* Sets the current format of this variable to <code>format</code>.
*
* @param format the new format type
* @throws DebugException if this method fails.
*/
void changeFormat( CVariableFormat format ) throws DebugException;
}

View file

@ -86,7 +86,8 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
fGlobals.removeAll( Arrays.asList( globals ) );
}
for ( int i = 0; i < globals.length; ++i ) {
globals[i].dispose();
if ( globals[i] instanceof CVariable )
((CVariable)globals[i]).dispose();
}
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
}
@ -101,7 +102,8 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
fGlobals.clear();
}
for ( int i = 0; i < globals.length; ++i ) {
((CVariable)globals[i]).dispose();
if ( globals[i] instanceof CVariable )
((CVariable)globals[i]).dispose();
}
getDebugTarget().fireChangeEvent( DebugEvent.CONTENT );
}
@ -109,7 +111,7 @@ public class CGlobalVariableManager implements ICGlobalVariableManager {
public void dispose() {
Iterator it = fGlobals.iterator();
while( it.hasNext() ) {
((ICGlobalVariable)it.next()).dispose();
((CVariable)it.next()).dispose();
}
fGlobals.clear();
}

View file

@ -0,0 +1,28 @@
/**********************************************************************
* 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.model.ICValue;
/**
* The abstract super class for the C/C++ value types.
*/
public abstract class AbstractCValue extends CDebugElement implements ICValue {
/**
* Constructor for AbstractCValue.
*/
public AbstractCValue( CDebugTarget target ) {
super( target );
}
abstract public void dispose();
}

View file

@ -0,0 +1,37 @@
/**********************************************************************
* 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.model.ICVariable;
import org.eclipse.debug.core.DebugException;
/**
* The super class for all variable types.
*/
public abstract class AbstractCVariable extends CDebugElement implements ICVariable {
/**
* Constructor for AbstractCVariable.
*/
public AbstractCVariable( CDebugTarget target ) {
super( target );
}
/**
* Returns the text presentation of this variable as an expression.
*
* @return the text presentation of this variable as an expression
* @throws DebugException
*/
public abstract String getExpressionString() throws DebugException;
public abstract void dispose();
}

View file

@ -1,75 +1,119 @@
/*******************************************************************************
* Copyright (c) 2000, 2004 QNX Software Systems and others.
* All rights reserved. This program and the accompanying materials
/**********************************************************************
* 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;
* 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.event.ICDIEvent;
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.ICDIVariableObject;
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.DebugException;
import org.eclipse.debug.core.model.IValue;
/**
*
* A sub-range of an array.
*
* @since Sep 9, 2002
*/
public class CArrayPartition extends CVariable
{
public class CArrayPartition extends AbstractCVariable {
static final protected int SLOT_SIZE = 100;
private int fStart;
private int fEnd;
private ICDIVariableObject fCDIVariableObject;
private ICDIVariable fCDIVariable;
private ICType fType = null;
private String fQualifiedName = null;
/**
* Cache of value.
* Cached value.
*/
private CArrayPartitionValue fArrayPartitionValue = null;
/**
* Constructor for CArrayPartition.
* @param target
/**
* Constructor for CArrayPartition.
*/
public CArrayPartition( CDebugElement parent, ICDIVariable cdiVariable, int start, int end )
{
super( parent, null );
private CArrayPartition( CDebugElement parent, ICDIVariable cdiVariable, int start, int end ) {
super( (CDebugTarget)parent.getDebugTarget() );
fStart = start;
fEnd = end;
fCDIVariable = cdiVariable;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.CVariable#retrieveValue()
* @see org.eclipse.cdt.debug.core.model.ICVariable#getType()
*/
protected ICDIValue retrieveValue() throws DebugException, CDIException
{
return null;
public ICType getType() throws DebugException {
if ( fType == null ) {
try {
ICDIVariableObject 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
{
public String getName() throws DebugException {
StringBuffer name = new StringBuffer();
name.append( '[' );
name.append( fStart );
@ -82,63 +126,160 @@ public class CArrayPartition extends CVariable
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException
{
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.cdi.event.ICDIEventListener#handleDebugEvents(ICDIEvent)
* @see org.eclipse.cdt.debug.core.model.IFormatSupport#changeFormat(org.eclipse.cdt.debug.core.model.CVariableFormat)
*/
public void handleDebugEvents( ICDIEvent[] events )
{
public void changeFormat( CVariableFormat format ) throws DebugException {
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#getValue()
* @see org.eclipse.cdt.debug.core.model.ICastToArray#canCastToArray()
*/
public IValue getValue() throws DebugException
{
if ( fArrayPartitionValue == null )
{
fArrayPartitionValue = new CArrayPartitionValue( this, fCDIVariable, getStart(), getEnd() );
}
return fArrayPartitionValue;
public boolean canCastToArray() {
return false;
}
static public List splitArray( CDebugElement parent, ICDIVariable cdiVariable, int start, int end ) throws DebugException
{
/* (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 ICDIVariableObject getVariableObject() throws CDIException {
if ( fCDIVariableObject == null ) {
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 )
{
while( len > perSlot * SLOT_SIZE ) {
perSlot *= SLOT_SIZE;
}
if ( perSlot == 1 )
{
try
{
if ( perSlot == 1 ) {
try {
ICDIValue value = cdiVariable.getValue();
if ( value instanceof ICDIArrayValue )
{
if ( value instanceof ICDIArrayValue ) {
ICDIVariable[] cdiVars = ((ICDIArrayValue)value).getVariables( start, len );
for ( int i = 0; i < cdiVars.length; ++i )
children.add( new CModificationVariable( parent, cdiVars[i] ) );
for( int i = 0; i < cdiVars.length; ++i )
children.add( CVariableFactory.createVariable( parent, cdiVars[i] ) );
}
}
catch( CDIException e )
{
children.add( new CModificationVariable( parent, new CVariable.ErrorVariable( null, e ) ) );
catch( CDIException e ) {
// children.add( CVariableFactory.createVariableWithError( parent, e.getMessage() ) );
}
}
else
{
else {
int pos = start;
while( pos <= end )
{
if ( pos + perSlot > end )
{
while( pos <= end ) {
if ( pos + perSlot > end ) {
perSlot = end - pos + 1;
}
children.add( new CArrayPartition( parent, cdiVariable, pos, pos + perSlot - 1 ) );
@ -147,82 +288,35 @@ public class CArrayPartition extends CVariable
}
return children;
}
protected int getStart()
{
return fStart;
}
protected int getEnd()
{
return fEnd;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable()
* @see org.eclipse.cdt.debug.internal.core.model.AbstractCVariable#getExpressionString()
*/
public boolean canEnableDisable()
{
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#getType()
*/
public ICType getType() throws DebugException
{
if ( fType == null )
{
try
{
ICDIVariableObject 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#hasChildren()
*/
public boolean hasChildren()
{
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.CVariable#getQualifiedName()
*/
protected String getQualifiedName() throws DebugException
{
if ( fQualifiedName == null )
{
try
{
if ( getVariableObject() != null )
{
public String getExpressionString() throws DebugException {
if ( fQualifiedName == null ) {
try {
if ( getVariableObject() != null ) {
fQualifiedName = getVariableObject().getQualifiedName();
}
}
catch( CDIException e )
{
catch( CDIException e ) {
requestFailed( CoreModelMessages.getString( "CArrayPartition.1" ), e ); //$NON-NLS-1$
}
}
return fQualifiedName;
}
private ICDIVariableObject getVariableObject() throws CDIException
{
if ( fCDIVariableObject == null )
{
fCDIVariableObject = getCDISession().getVariableManager().getVariableObjectAsArray( fCDIVariable, getStart(), getEnd() - getStart() + 1 );
/* (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;
}
return fCDIVariableObject;
}
}

View file

@ -8,27 +8,21 @@
* 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.ICExpressionEvaluator;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
/**
*
* The value for an array partition.
*
* @since Sep 9, 2002
* A value for an array partition.
*/
public class CArrayPartitionValue extends CDebugElement implements ICValue
{
public class CArrayPartitionValue extends AbstractCValue {
/**
* The underlying CDI variable.
*/
@ -37,7 +31,7 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue
/**
* Parent variable.
*/
private CVariable fParent = null;
private AbstractCVariable fParent = null;
/**
* List of child variables.
@ -50,10 +44,8 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue
/**
* Constructor for CArrayPartitionValue.
* @param target
*/
public CArrayPartitionValue( CVariable parent, ICDIVariable cdiVariable, int start, int end )
{
public CArrayPartitionValue( AbstractCVariable parent, ICDIVariable cdiVariable, int start, int end ) {
super( (CDebugTarget)parent.getDebugTarget() );
fCDIVariable = cdiVariable;
fParent = parent;
@ -61,115 +53,108 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue
fEnd = end;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException
{
return null;
public String getReferenceTypeName() throws DebugException {
return ( getParentVariable() != null ) ? getParentVariable().getReferenceTypeName() : null;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#getValueString()
*/
public String getValueString() throws DebugException
{
return null;
public String getValueString() throws DebugException {
return ""; //$NON-NLS-1$
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#isAllocated()
*/
public boolean isAllocated() throws DebugException
{
public boolean isAllocated() throws DebugException {
return true;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#getVariables()
*/
public IVariable[] getVariables() throws DebugException
{
public IVariable[] getVariables() throws DebugException {
List list = getVariables0();
return (IVariable[])list.toArray( new IVariable[list.size()] );
}
protected synchronized List getVariables0() throws DebugException
{
protected synchronized List getVariables0() throws DebugException {
if ( !isAllocated() || !hasVariables() )
return Collections.EMPTY_LIST;
if ( fVariables.size() == 0 )
{
if ( fVariables.size() == 0 ) {
fVariables = CArrayPartition.splitArray( this, getCDIVariable(), getStart(), getEnd() );
}
return fVariables;
}
/* (non-Javadoc)
/*
* (non-Javadoc)
*
* @see org.eclipse.debug.core.model.IValue#hasVariables()
*/
public boolean hasVariables() throws DebugException
{
public boolean hasVariables() throws DebugException {
return true;
}
protected int getStart()
{
protected int getStart() {
return fStart;
}
protected int getEnd()
{
protected int getEnd() {
return fEnd;
}
public void setChanged( boolean changed ) throws DebugException
{
public void setChanged( boolean changed ) throws DebugException {
Iterator it = fVariables.iterator();
while( it.hasNext() )
{
while( it.hasNext() ) {
((CVariable)it.next()).setChanged( changed );
}
}
/* (non-Javadoc)
/*
* (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;
if ( ee != null && ee.canEvaluate() )
{
try
{
String valueString = null;
if ( ee != null && ee.canEvaluate() ) {
try {
if ( getParentVariable() != null )
valueString = ee.evaluateExpressionToString( getParentVariable().getQualifiedName() );
valueString = ee.evaluateExpressionToString( getParentVariable().getExpressionString() );
}
catch( DebugException e )
{
catch( DebugException e ) {
valueString = e.getMessage();
}
}
return valueString;
}
public CVariable getParentVariable()
{
public AbstractCVariable getParentVariable() {
return fParent;
}
protected ICDIVariable getCDIVariable()
{
protected ICDIVariable getCDIVariable() {
return fCDIVariable;
}
public void dispose()
{
public void dispose() {
Iterator it = fVariables.iterator();
while( it.hasNext() )
{
((CVariable)it.next()).dispose();
while( it.hasNext() ) {
((AbstractCVariable)it.next()).dispose();
}
}
}
}

View file

@ -34,7 +34,6 @@ import org.eclipse.cdt.debug.core.cdi.ICDIBreakpointHit;
import org.eclipse.cdt.debug.core.cdi.ICDIConfiguration;
import org.eclipse.cdt.debug.core.cdi.ICDIEndSteppingRange;
import org.eclipse.cdt.debug.core.cdi.ICDIErrorInfo;
import org.eclipse.cdt.debug.core.cdi.ICDIExpressionManager;
import org.eclipse.cdt.debug.core.cdi.ICDILocation;
import org.eclipse.cdt.debug.core.cdi.ICDISession;
import org.eclipse.cdt.debug.core.cdi.ICDISessionObject;
@ -1294,14 +1293,8 @@ public class CDebugTarget extends CDebugElement implements ICDebugTarget, ICDIEv
* @see org.eclipse.debug.core.IExpressionListener#expressionRemoved(org.eclipse.debug.core.model.IExpression)
*/
public void expressionRemoved( IExpression expression ) {
if ( expression != null && expression.getDebugTarget().equals( this ) && expression instanceof CExpression ) {
ICDIExpressionManager em = getCDISession().getExpressionManager();
try {
em.destroyExpression( ((CExpression)expression).getCDIExpression() );
}
catch( CDIException e ) {
// do nothing
}
if ( expression instanceof CExpression && expression.getDebugTarget().equals( this ) ) {
((CExpression)expression).dispose();
}
}

View file

@ -12,139 +12,88 @@ 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.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.CVariableFormat;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IExpression;
import org.eclipse.debug.core.model.IValue;
/**
*
* Enter type comment.
*
* @since Sep 17, 2002
* Represents an expression in the CDI model.
*/
public class CExpression extends CModificationVariable
implements IExpression
{
public class CExpression extends CVariable implements IExpression {
/**
* Constructor for CExpression.
* @param target
* @param cdiExpression
*/
public CExpression( CDebugTarget target, ICDIExpression cdiExpression )
{
public CExpression( CDebugTarget target, ICDIExpression cdiExpression ) {
super( target, cdiExpression );
fFormat = CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT );
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
}
/**
* Constructor for CExpression.
* @param target
* @param cdiExpression
*/
public CExpression( CDebugTarget target, ICDIVariableObject cdiVariableObject )
{
public CExpression( CDebugTarget target, ICDIVariableObject cdiVariableObject ) {
super( target, cdiVariableObject );
fFormat = CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT );
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_EXPRESSION_FORMAT ) ) );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IExpression#getExpressionText()
*/
public String getExpressionText()
{
try
{
public String getExpressionText() {
try {
return getName();
}
catch( DebugException e )
{
catch( DebugException e ) {
}
return null;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IExpression#getValue()
* @see org.eclipse.debug.core.model.IVariable#getValue()
*/
public IValue getValue()
{
try
{
public IValue getValue() {
try {
return super.getValue();
}
catch( DebugException e )
{
catch( DebugException e ) {
}
return null;
}
public void dispose()
{
super.dispose();
try {
ICDIExpression cdiExpression = getCDIExpression();
if ( cdiExpression != null ) {
getCDISession().getExpressionManager().destroyExpression( cdiExpression );
}
}
catch( CDIException e ) {
DebugPlugin.log( e );
}
}
protected ICDIExpression getCDIExpression() throws CDIException
{
ICDIVariable var = getCDIVariable();
return ( var instanceof ICDIExpression ) ? (ICDIExpression)var : null;
}
/**
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(ICDIEvent)
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(org.eclipse.cdt.debug.core.cdi.event.ICDIEvent[])
*/
public void handleDebugEvents( ICDIEvent[] events )
{
for (int i = 0; i < events.length; i++)
{
public void handleDebugEvents( ICDIEvent[] events ) {
for( int i = 0; i < events.length; i++ ) {
ICDIEvent event = events[i];
if ( event instanceof ICDIResumedEvent )
{
if ( event.getSource() instanceof ICDITarget && getCDITarget().equals( event.getSource() ) )
{
try
{
setChanged( false );
}
catch( DebugException e )
{
CDebugCorePlugin.log( e );
}
if ( event instanceof ICDIResumedEvent ) {
if ( event.getSource() instanceof ICDITarget && getCDITarget().equals( event.getSource() ) ) {
setChanged( false );
}
break;
}
}
super.handleDebugEvents(events);
super.handleDebugEvents( events );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#isEnabled()
*/
public boolean isEnabled()
{
public boolean isEnabled() {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#canEnableDisable()
*/
public boolean canEnableDisable()
{
public boolean canEnableDisable() {
return false;
}
}
}

View file

@ -7,116 +7,29 @@
*
* Contributors:
* QNX Software Systems - Initial API and implementation
***********************************************************************/
***********************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
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.ICDIObject;
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.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.ICGlobalVariable;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
/**
*
* Enter type comment.
*
* @since: Oct 2, 2002
* Represents a global variable.
*/
public class CGlobalVariable extends CModificationVariable implements ICGlobalVariable
{
public class CGlobalVariable extends CVariable implements ICGlobalVariable {
/**
* Constructor for CGlobalVariable.
* @param parent
* @param cdiVariable
*/
public CGlobalVariable( CDebugElement parent, ICDIVariable cdiVariable )
{
super( parent, cdiVariable );
protected CGlobalVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) {
super( parent, cdiVariableObject );
}
/**
* Returns the current value of this variable. The value
* is cached.
*
* @see org.eclipse.debug.core.model.IVariable#getValue()
* Constructor for CGlobalVariable.
*/
public IValue getValue() throws DebugException
{
if ( !isEnabled() )
return fDisabledValue;
if ( fValue == null )
{
ICDIValue cdiValue = getCurrentValue();
if ( cdiValue instanceof ICDIArrayValue )
{
ICDIVariable var = null;
try
{
var = getCDIVariable();
}
catch( CDIException e )
{
requestFailed( "", e ); //$NON-NLS-1$
}
int[] dims = getType().getArrayDimensions();
if ( dims.length > 0 && dims[0] > 0 )
fValue = CValueFactory.createArrayValue( this, var, 0, dims.length - 1 );
}
else
fValue = CValueFactory.createGlobalValue( this, getCurrentValue() );
}
return fValue;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener#handleDebugEvents(ICDIEvent)
*/
public void handleDebugEvents( ICDIEvent[] events )
{
super.handleDebugEvents( events );
for (int i = 0; i < events.length; i++)
{
ICDIEvent event = events[i];
ICDIObject source = event.getSource();
if (source == null)
continue;
if ( source.getTarget().equals( getCDITarget() ) )
{
if ( event instanceof ICDIResumedEvent )
{
try
{
setChanged( false );
}
catch( DebugException e )
{
CDebugCorePlugin.log( e );
}
}
}
}
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.model.CVariable#dispose()
*/
public void dispose() {
if ( getShadow() != null )
getShadow().dispose();
try {
getCDISession().getVariableManager().destroyVariable( getCDIVariable() );
}
catch( CDIException e ) {
}
super.dispose();
protected CGlobalVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject, String message ) {
super( parent, cdiVariableObject, message );
}
/* (non-Javadoc)
@ -125,4 +38,4 @@ public class CGlobalVariable extends CModificationVariable implements ICGlobalVa
public boolean canEnableDisable() {
return true;
}
}
}

View file

@ -1,115 +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 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.ICDIVariableObject;
import org.eclipse.cdt.debug.core.model.CDebugElementState;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IValue;
import org.eclipse.debug.core.model.IValueModification;
/**
*
* Common functionality for variables that support value modification
*
* @since Aug 9, 2002
*/
public class CModificationVariable extends CVariable
{
/**
* Constructor for CModificationVariable.
* @param parent
* @param cdiVariable
*/
public CModificationVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject )
{
super( parent, cdiVariableObject );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValueModification#supportsValueModification()
*/
public boolean supportsValueModification()
{
CDebugTarget target = (CDebugTarget)getDebugTarget().getAdapter( CDebugTarget.class );
return ( target != null && CDebugElementState.SUSPENDED.equals( target.getState() ) && isEditable() );
}
/**
* @see IValueModification#verifyValue(String)
*/
public boolean verifyValue( String expression )
{
return true;
}
/**
* @see IValueModification#verifyValue(IValue)
*/
public boolean verifyValue( IValue value )
{
return value.getDebugTarget().equals( getDebugTarget() );
}
/**
* @see IValueModification#setValue(String)
*/
public final void setValue( String expression ) throws DebugException
{
String newExpression = processExpression( expression );
ICDIVariable cdiVariable = null;
try
{
cdiVariable = getCDIVariable();
if ( cdiVariable != null )
cdiVariable.setValue( newExpression );
else
requestFailed( CoreModelMessages.getString( "CModificationVariable.0" ), null ); //$NON-NLS-1$
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
/**
* Set this variable's value to the given value
*/
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.internal.core.CModificationVariable#setValue(ICDIValue)
*/
protected void setValue( ICDIValue value ) throws DebugException
{
ICDIVariable cdiVariable = null;
try
{
cdiVariable = getCDIVariable();
if ( cdiVariable != null )
cdiVariable.setValue( value );
else
requestFailed( CoreModelMessages.getString( "CModificationVariable.1" ), null ); //$NON-NLS-1$
}
catch( CDIException e )
{
targetRequestFailed( e.getMessage(), null );
}
}
private String processExpression( String oldExpression ) throws DebugException
{
return oldExpression;
}
}

View file

@ -13,70 +13,44 @@ 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.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IRegister;
import org.eclipse.debug.core.model.IRegisterGroup;
import org.eclipse.debug.core.model.IValue;
/**
*
* Enter type comment.
*
* @since Sep 16, 2002
* Represents a register in the CDI model.
*/
public class CRegister extends CGlobalVariable implements IRegister
{
public static class ErrorRegister extends ErrorVariable implements ICDIRegister
{
public ErrorRegister( ICDIVariableObject varObject, Exception e )
{
super( varObject, e );
}
public class CRegister extends CGlobalVariable implements IRegister {
/**
* Constructor for CRegister.
*/
protected CRegister( CRegisterGroup parent, ICDIRegister cdiRegister ) {
super( parent, cdiRegister );
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
}
/**
* Constructor for CRegister.
* @param parent
* @param cdiVariable
*/
public CRegister( CRegisterGroup parent, ICDIRegister cdiRegister )
{
super( parent, cdiRegister );
fFormat = CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT );
protected CRegister( CRegisterGroup parent, ICDIRegisterObject registerObject, String message ) {
super( parent, registerObject, message );
setFormat( CVariableFormat.getFormat( CDebugCorePlugin.getDefault().getPluginPreferences().getInt( ICDebugConstants.PREF_DEFAULT_REGISTER_FORMAT ) ) );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IRegister#getRegisterGroup()
*/
public IRegisterGroup getRegisterGroup() throws DebugException
{
public IRegisterGroup getRegisterGroup() throws DebugException {
return (IRegisterGroup)getParent();
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IVariable#hasValueChanged()
*/
public boolean hasValueChanged() throws DebugException
{
try {
IValue value = getValue();
if ( value != null )
{
return ( value.hasVariables() ) ? false : fChanged;
}
}
catch( DebugException e ) {
// ignore to prevent logging.
}
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICVariable#isEnabled()
*/
public boolean isEnabled()
{
public boolean isEnabled() {
return true;
}
}
}

View file

@ -14,12 +14,11 @@ import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegister;
import org.eclipse.cdt.debug.core.cdi.model.ICDIRegisterObject;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.DebugPlugin;
import org.eclipse.debug.core.model.IRegister;
import org.eclipse.debug.core.model.IRegisterGroup;
/**
* Represents a group of registers of a debug target.
* Represents a group of registers.
*/
public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
@ -39,32 +38,31 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
fRegisters = new IRegister[regObjects.length];
}
/*
* (non-Javadoc)
*
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IRegisterGroup#getName()
*/
public String getName() throws DebugException {
return fName;
}
/*
* (non-Javadoc)
*
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IRegisterGroup#getRegisters()
*/
public IRegister[] getRegisters() throws DebugException {
for ( int i = 0; i < fRegisters.length; ++i ) {
if ( fRegisters[i] == null ) {
fRegisters[i] = new CRegister( this, getCDIRegister( fRegisterObjects[i] ) );
try {
fRegisters[i] = new CRegister( this, getCDIRegister( fRegisterObjects[i] ) );
}
catch( DebugException e ) {
fRegisters[i] = new CRegister( this, fRegisterObjects[i], e.getMessage() );
}
}
}
return fRegisters;
}
/*
* (non-Javadoc)
*
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IRegisterGroup#hasRegisters()
*/
public boolean hasRegisters() throws DebugException {
@ -81,23 +79,20 @@ public class CRegisterGroup extends CDebugElement implements IRegisterGroup {
}
private ICDIRegister getCDIRegister( ICDIRegisterObject ro ) throws DebugException {
ICDIRegister register = null;
try {
return ((CDebugTarget)getDebugTarget()).getCDISession().getRegisterManager().createRegister( ro );
register = ((CDebugTarget)getDebugTarget()).getCDISession().getRegisterManager().createRegister( ro );
}
catch( CDIException e ) {
return new CRegister.ErrorRegister( ro, e );
requestFailed( e.getMessage(), null );
}
return register;
}
public void resetChangeFlags() {
for ( int i = 0; i < fRegisters.length; ++i ) {
if ( fRegisters[i] != null ) {
try {
((CRegister)fRegisters[i]).setChanged( false );
}
catch( DebugException e ) {
DebugPlugin.log( e );
}
((CRegister)fRegisters[i]).setChanged( false );
}
}
}

View file

@ -16,7 +16,6 @@ import java.util.ArrayList;
import java.util.Arrays;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
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;
@ -109,7 +108,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
fVariables = new ArrayList( vars.size() );
Iterator it = vars.iterator();
while( it.hasNext() ) {
fVariables.add( new CModificationVariable( this, (ICDIVariableObject)it.next() ) );
fVariables.add( CVariableFactory.createVariable( this, (ICDIVariableObject)it.next() ) );
}
}
else if ( refreshVariables() ) {
@ -140,7 +139,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
// add any new locals
Iterator newOnes = locals.iterator();
while( newOnes.hasNext() ) {
fVariables.add( new CModificationVariable( this, (ICDIVariableObject)newOnes.next() ) );
fVariables.add( CVariableFactory.createVariable( this, (ICDIVariableObject)newOnes.next() ) );
}
}
@ -582,14 +581,9 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
private void preserveVariables() {
if ( fVariables == null )
return;
try {
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
((CVariable)it.next()).setChanged( false );
}
}
catch( DebugException e ) {
CDebugCorePlugin.log( e );
Iterator it = fVariables.iterator();
while( it.hasNext() ) {
((CVariable)it.next()).setChanged( false );
}
}
@ -597,7 +591,7 @@ public class CStackFrame extends CDebugElement implements ICStackFrame, IRestart
Iterator it = list.iterator();
while( it.hasNext() ) {
ICDIVariableObject newVarObject = (ICDIVariableObject)it.next();
if ( var.sameVariableObject( newVarObject ) )
if ( var.sameVariable( newVarObject ) )
return newVarObject;
}
return null;

View file

@ -8,13 +8,13 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIArrayType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDICharType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDerivedType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatingPointType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntegralType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIStructType;
@ -22,61 +22,46 @@ import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.model.ICType;
/**
* Enter type comment.
*
* @since Jun 10, 2003
* The CDI-based implementation of <code>ICType</code>.
*/
public class CType implements ICType
{
public class CType implements ICType {
/**
* The underlying CDI type.
*/
private ICDIType fCDIType;
public CType( ICDIType cdiType )
{
/**
* Constructor for CType.
*/
public CType( ICDIType cdiType ) {
setCDIType( cdiType );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#getName()
* @see org.eclipse.cdt.debug.core.model.ICType#getName()
*/
public String getName()
{
public String getName() {
return ( fCDIType != null ) ? fCDIType.getTypeName() : null;
}
/* (non-Javadoc)
* @see org.eclipse.core.runtime.IAdaptable#getAdapter(java.lang.Class)
*/
public Object getAdapter( Class adapter )
{
if ( ICType.class.equals( adapter ) )
return this;
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#dispose()
*/
public void dispose()
{
public void dispose() {
fCDIType = null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#getArrayDimensions()
* @see org.eclipse.cdt.debug.core.model.ICType#getArrayDimensions()
*/
public int[] getArrayDimensions()
{
public int[] getArrayDimensions() {
int length = 0;
ICDIType type = getCDIType();
while( type instanceof ICDIArrayType )
{
while( type instanceof ICDIArrayType ) {
++length;
type = ( type instanceof ICDIDerivedType ) ? ((ICDIDerivedType)type).getComponentType() : null;
}
int[] dims = new int[length];
type = getCDIType();
for ( int i = length; i > 0; --i )
{
for( int i = length; i > 0; --i ) {
dims[i - 1] = ((ICDIArrayType)type).getDimension();
type = ((ICDIDerivedType)type).getComponentType();
}
@ -84,69 +69,64 @@ public class CType implements ICType
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#isArray()
* @see org.eclipse.cdt.debug.core.model.ICType#isArray()
*/
public boolean isArray()
{
public boolean isArray() {
return ( getCDIType() instanceof ICDIArrayType );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#isCharacter()
* @see org.eclipse.cdt.debug.core.model.ICType#isCharacter()
*/
public boolean isCharacter()
{
public boolean isCharacter() {
return ( getCDIType() instanceof ICDICharType );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#isFloatingPointType()
* @see org.eclipse.cdt.debug.core.model.ICType#isFloatingPointType()
*/
public boolean isFloatingPointType()
{
public boolean isFloatingPointType() {
return ( getCDIType() instanceof ICDIFloatingPointType );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#isPointer()
* @see org.eclipse.cdt.debug.core.model.ICType#isPointer()
*/
public boolean isPointer()
{
public boolean isPointer() {
return ( getCDIType() instanceof ICDIPointerType );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICType#isReference()
*/
public boolean isReference()
{
public boolean isReference() {
return ( getCDIType() instanceof ICDIReferenceType );
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.type.ICType#isStructure()
* @see org.eclipse.cdt.debug.core.model.ICType#isStructure()
*/
public boolean isStructure()
{
public boolean isStructure() {
return ( getCDIType() instanceof ICDIStructType );
}
protected ICDIType getCDIType()
{
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.model.ICType#isUnsigned()
*/
public boolean isUnsigned() {
ICDIType cdiType = getCDIType();
return ( cdiType instanceof ICDIIntegralType ) ? ((ICDIIntegralType)cdiType).isUnsigned() : false;
}
protected ICDIType getCDIType() {
return fCDIType;
}
protected void setCDIType( ICDIType type )
{
protected void setCDIType( ICDIType type ) {
fCDIType = type;
}
protected boolean hasChildren()
{
ICDIType type = getCDIType();
if ( type instanceof ICDIStructType || type instanceof ICDIArrayType ||
type instanceof ICDIPointerType || type instanceof ICDIReferenceType )
return true;
return false;
protected boolean isAggregate() {
return ( isArray() || isStructure() || isPointer() || isReference() );
}
}
}

View file

@ -8,7 +8,6 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.debug.internal.core.model;
import java.math.BigInteger;
@ -18,34 +17,30 @@ import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.CDIException;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
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.ICDICharValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIDoubleValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIFloatValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIIntegralType;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongLongValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDILongValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIPointerValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue;
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.model.CVariableFormat;
import org.eclipse.cdt.debug.core.model.ICDebugElementStatus;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.debug.core.DebugException;
import org.eclipse.debug.core.model.IVariable;
/**
*
* The value of a variable.
*
* @since Aug 9, 2002
* Represents the value of a variable in the CDI model.
*/
public class CValue extends CDebugElement implements ICValue
{
public class CValue extends AbstractCValue {
/**
* Parent variable.
*/
@ -68,37 +63,40 @@ public class CValue extends CDebugElement implements ICValue
/**
* Constructor for CValue.
* @param target
*/
public CValue( CVariable parent, ICDIValue cdiValue )
{
protected CValue( CVariable parent, ICDIValue cdiValue ) {
super( (CDebugTarget)parent.getDebugTarget() );
fParent = parent;
fCDIValue = cdiValue;
}
/**
* Constructor for CValue.
*/
protected CValue( CVariable parent, String message ) {
super( (CDebugTarget)parent.getDebugTarget() );
fParent = parent;
setStatus( ICDebugElementStatus.ERROR, message );
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#getReferenceTypeName()
*/
public String getReferenceTypeName() throws DebugException
{
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
{
if ( fValueString == null && getUnderlyingValue() != null )
{
try
{
public String getValueString() throws DebugException {
if ( fValueString == null && getUnderlyingValue() != null ) {
try {
fValueString = processUnderlyingValue( getUnderlyingValue() );
resetStatus();
}
catch( CDIException e )
{
fValueString = e.getMessage();
catch( CDIException e ) {
setStatus( ICDebugElementStatus.ERROR, e.getMessage() );
}
}
return fValueString;
@ -107,42 +105,33 @@ public class CValue extends CDebugElement implements ICValue
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#isAllocated()
*/
public boolean isAllocated() throws DebugException
{
public boolean isAllocated() throws DebugException {
return true;
}
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#getVariables()
*/
public IVariable[] getVariables() throws DebugException
{
public IVariable[] getVariables() throws DebugException {
List list = getVariables0();
return (IVariable[])list.toArray( new IVariable[list.size()] );
}
protected synchronized List getVariables0() throws DebugException
{
protected synchronized List getVariables0() throws DebugException {
if ( !isAllocated() || !hasVariables() )
return Collections.EMPTY_LIST;
if ( fVariables.size() == 0 )
{
try
{
List vars = getCDIVariables();
if ( fVariables.size() == 0 ) {
try {
List vars = getCDIVariables();
fVariables = new ArrayList( vars.size() );
Iterator it = vars.iterator();
while( it.hasNext() )
{
fVariables.add( new CModificationVariable( this, (ICDIVariable)it.next() ) );
while( it.hasNext() ) {
fVariables.add( CVariableFactory.createVariable( this, (ICDIVariable)it.next() ) );
}
resetStatus();
}
catch( DebugException e )
{
fVariables = new ArrayList( 1 );
CModificationVariable var = new CModificationVariable( this, new CVariable.ErrorVariable( null, e ) );
var.setStatus( ICDebugElementStatus.ERROR, e.getMessage() );
fVariables.add( var );
catch( DebugException e ) {
setStatus( ICDebugElementStatus.ERROR, e.getMessage() );
}
}
return fVariables;
@ -151,81 +140,65 @@ public class CValue extends CDebugElement implements ICValue
/* (non-Javadoc)
* @see org.eclipse.debug.core.model.IValue#hasVariables()
*/
public boolean hasVariables() throws DebugException
{
try
{
public boolean hasVariables() throws DebugException {
try {
ICDIValue value = getUnderlyingValue();
if ( value != null )
return value.getChildrenNumber() > 0;
}
catch( CDIException e )
{
catch( CDIException e ) {
targetRequestFailed( e.getMessage(), null );
}
return false;
}
public ICDIValue getUnderlyingValue()
{
public ICDIValue getUnderlyingValue() {
return fCDIValue;
}
protected List getCDIVariables() throws DebugException
{
protected List getCDIVariables() throws DebugException {
ICDIVariable[] vars = null;
try
{
try {
ICDIValue value = getUnderlyingValue();
if ( value != null )
{
if ( value != null ) {
vars = value.getVariables();
// Quick fix.
// Quick fix.
// getVariables should return an empty array instead of null.
if ( vars == null )
{
if ( vars == null ) {
vars = new ICDIVariable[0];
}
}
}
catch( CDIException e )
{
requestFailed( CoreModelMessages.getString( "CValue.0" ), e ); //$NON-NLS-1$
catch( CDIException e ) {
requestFailed( e.getMessage(), e ); //$NON-NLS-1$
}
return Arrays.asList( vars );
}
public synchronized void setChanged( boolean changed ) throws DebugException
{
if ( changed )
{
public synchronized void setChanged( boolean changed ) /*throws DebugException*/ {
if ( changed ) {
fValueString = null;
resetStatus();
}
Iterator it = fVariables.iterator();
while( it.hasNext() )
{
while( it.hasNext() ) {
((CVariable)it.next()).setChanged( changed );
}
}
public void dispose()
{
public void dispose() {
Iterator it = fVariables.iterator();
while( it.hasNext() )
{
((CVariable)it.next()).dispose();
while( it.hasNext() ) {
((AbstractCVariable)it.next()).dispose();
}
}
public CVariable getParentVariable()
{
public CVariable getParentVariable() {
return fParent;
}
private String processUnderlyingValue( ICDIValue cdiValue ) throws CDIException
{
if ( cdiValue != null )
{
private String processUnderlyingValue( ICDIValue cdiValue ) throws CDIException {
if ( cdiValue != null ) {
if ( cdiValue instanceof ICDICharValue )
return getCharValueString( (ICDICharValue)cdiValue );
else if ( cdiValue instanceof ICDIShortValue )
@ -252,259 +225,200 @@ public class CValue extends CDebugElement implements ICValue
return null;
}
private String getCharValueString( ICDICharValue value ) throws CDIException
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
{
byte byteValue = (byte)value.byteValue();
return ( ( Character.isISOControl( (char)byteValue ) &&
byteValue != '\b' &&
byteValue != '\t' &&
byteValue != '\n' &&
byteValue != '\f' &&
byteValue != '\r' ) || byteValue < 0 ) ? "" : new String( new byte[] { '\'', byteValue, '\'' } ); //$NON-NLS-1$
}
case ICDIFormat.DECIMAL:
{
return ( isUnsigned() ) ? Integer.toString( value.shortValue() ) :
Integer.toString( (byte)value.byteValue() );
}
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = ( isUnsigned() ) ? Integer.toHexString( value.shortValue() ) : Integer.toHexString( (byte)value.byteValue() );
sb.append( ( stringValue.length() > 2 ) ? stringValue.substring( stringValue.length() - 2 ) : stringValue );
return sb.toString();
}
private String getCharValueString( ICDICharValue value ) throws CDIException {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) ) {
byte byteValue = (byte)value.byteValue();
return ((Character.isISOControl( (char)byteValue ) && byteValue != '\b' && byteValue != '\t' && byteValue != '\n' && byteValue != '\f' && byteValue != '\r') || byteValue < 0) ? "" : new String( new byte[]{ '\'', byteValue, '\'' } ); //$NON-NLS-1$
}
else if ( CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Integer.toString( value.shortValue() ) : Integer.toString( (byte)value.byteValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = (isUnsigned()) ? Integer.toHexString( value.shortValue() ) : Integer.toHexString( (byte)value.byteValue() );
sb.append( (stringValue.length() > 2) ? stringValue.substring( stringValue.length() - 2 ) : stringValue );
return sb.toString();
}
return null;
}
private String getShortValueString( ICDIShortValue value ) throws CDIException
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
case ICDIFormat.DECIMAL:
return ( isUnsigned() ) ? Integer.toString( value.intValue() ) : Short.toString( value.shortValue() );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Integer.toHexString( ( isUnsigned() ) ? value.intValue() : value.shortValue() );
sb.append( ( stringValue.length() > 4 ) ? stringValue.substring( stringValue.length() - 4 ) : stringValue );
return sb.toString();
}
private String getShortValueString( ICDIShortValue value ) throws CDIException {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Integer.toString( value.intValue() ) : Short.toString( value.shortValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Integer.toHexString( (isUnsigned()) ? value.intValue() : value.shortValue() );
sb.append( (stringValue.length() > 4) ? stringValue.substring( stringValue.length() - 4 ) : stringValue );
return sb.toString();
}
return null;
}
private String getIntValueString( ICDIIntValue value ) throws CDIException
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
case ICDIFormat.DECIMAL:
return ( isUnsigned() ) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = ( isUnsigned() ) ? Long.toHexString( value.longValue() ) : Integer.toHexString( value.intValue() );
sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
private String getIntValueString( ICDIIntValue value ) throws CDIException {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = (isUnsigned()) ? Long.toHexString( value.longValue() ) : Integer.toHexString( value.intValue() );
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
return null;
}
private String getLongValueString( ICDILongValue value ) throws CDIException
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
case ICDIFormat.DECIMAL:
return ( isUnsigned() ) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( ( isUnsigned() ) ? value.longValue() : value.intValue() );
sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
private String getLongValueString( ICDILongValue value ) throws CDIException {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( (isUnsigned()) ? value.longValue() : value.intValue() );
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
return null;
}
private String getLongLongValueString( ICDILongLongValue value ) throws CDIException
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
case ICDIFormat.DECIMAL:
{
if ( isUnsigned() )
{
BigInteger bigValue = new BigInteger( value.getValueString() );
return bigValue.toString();
}
return Long.toString( value.longValue() );
private String getLongLongValueString( ICDILongLongValue value ) throws CDIException {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
if ( isUnsigned() ) {
BigInteger bigValue = new BigInteger( value.getValueString() );
return bigValue.toString();
}
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
if ( isUnsigned() )
{
BigInteger bigValue = new BigInteger( value.getValueString() );
sb.append( bigValue.toString( 16 ) );
}
else
sb.append( Long.toHexString( value.longValue() ) );
return sb.toString();
return Long.toString( value.longValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
if ( isUnsigned() ) {
BigInteger bigValue = new BigInteger( value.getValueString() );
sb.append( bigValue.toString( 16 ) );
}
else
sb.append( Long.toHexString( value.longValue() ) );
return sb.toString();
}
return null;
}
private String getFloatValueString( ICDIFloatValue value ) throws CDIException
{
private String getFloatValueString( ICDIFloatValue value ) throws CDIException {
float floatValue = value.floatValue();
Float flt = new Float( floatValue );
if ( flt.isNaN() || flt.isInfinite() )
return ""; //$NON-NLS-1$
long longValue = flt.longValue();
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
return Float.toString( floatValue );
case ICDIFormat.DECIMAL:
return Long.toString( longValue );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) ) {
return Float.toString( floatValue );
}
else if ( CVariableFormat.DECIMAL.equals( format ) ) {
return Long.toString( longValue );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
return null;
}
private String getDoubleValueString( ICDIDoubleValue value ) throws CDIException
{
private String getDoubleValueString( ICDIDoubleValue value ) throws CDIException {
double doubleValue = value.doubleValue();
Double dbl = new Double( doubleValue );
if ( dbl.isNaN() || dbl.isInfinite() )
return ""; //$NON-NLS-1$
long longValue = dbl.longValue();
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
return dbl.toString();
case ICDIFormat.DECIMAL:
return Long.toString( longValue );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( ( stringValue.length() > 16 ) ? stringValue.substring( stringValue.length() - 16 ) : stringValue );
return sb.toString();
}
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) ) {
return dbl.toString();
}
else if ( CVariableFormat.DECIMAL.equals( format ) ) {
return Long.toString( longValue );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( (stringValue.length() > 16) ? stringValue.substring( stringValue.length() - 16 ) : stringValue );
return sb.toString();
}
return null;
}
private String getPointerValueString( ICDIPointerValue value ) throws CDIException
{
private String getPointerValueString( ICDIPointerValue value ) throws CDIException {
long longValue = value.pointerValue();
switch( getParentVariable().getFormat() )
{
case ICDIFormat.DECIMAL:
return Long.toString( longValue );
case ICDIFormat.NATURAL:
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.DECIMAL.equals( format ) ) {
return Long.toString( longValue );
}
else if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
return null;
}
private String getReferenceValueString( ICDIReferenceValue value ) throws CDIException
{
private String getReferenceValueString( ICDIReferenceValue value ) throws CDIException {
long longValue = value.referenceValue();
switch( getParentVariable().getFormat() )
{
case ICDIFormat.DECIMAL:
return Long.toString( longValue );
case ICDIFormat.NATURAL:
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.DECIMAL.equals( format ) ) {
return Long.toString( longValue );
}
else if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Long.toHexString( longValue );
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
return null;
}
private String getWCharValueString( ICDIWCharValue value ) throws CDIException
{
if ( getParentVariable() != null )
{
private String getWCharValueString( ICDIWCharValue value ) throws CDIException {
if ( getParentVariable() != null ) {
int size = getParentVariable().sizeof();
if ( size == 2 )
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
case ICDIFormat.DECIMAL:
return ( isUnsigned() ) ? Integer.toString( value.intValue() ) : Short.toString( value.shortValue() );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Integer.toHexString( ( isUnsigned() ) ? value.intValue() : value.shortValue() );
sb.append( ( stringValue.length() > 4 ) ? stringValue.substring( stringValue.length() - 4 ) : stringValue );
return sb.toString();
}
if ( size == 2 ) {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Integer.toString( value.intValue() ) : Short.toString( value.shortValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = Integer.toHexString( (isUnsigned()) ? value.intValue() : value.shortValue() );
sb.append( (stringValue.length() > 4) ? stringValue.substring( stringValue.length() - 4 ) : stringValue );
return sb.toString();
}
}
if ( size == 4 )
{
switch( getParentVariable().getFormat() )
{
case ICDIFormat.NATURAL:
case ICDIFormat.DECIMAL:
return ( isUnsigned() ) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
case ICDIFormat.HEXADECIMAL:
{
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = ( isUnsigned() ) ? Long.toHexString( value.longValue() ) : Integer.toHexString( value.intValue() );
sb.append( ( stringValue.length() > 8 ) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
if ( size == 4 ) {
CVariableFormat format = getParentVariable().getFormat();
if ( CVariableFormat.NATURAL.equals( format ) || CVariableFormat.DECIMAL.equals( format ) ) {
return (isUnsigned()) ? Long.toString( value.longValue() ) : Integer.toString( value.intValue() );
}
else if ( CVariableFormat.HEXADECIMAL.equals( format ) ) {
StringBuffer sb = new StringBuffer( "0x" ); //$NON-NLS-1$
String stringValue = (isUnsigned()) ? Long.toHexString( value.longValue() ) : Integer.toHexString( value.intValue() );
sb.append( (stringValue.length() > 8) ? stringValue.substring( stringValue.length() - 8 ) : stringValue );
return sb.toString();
}
}
}
return value.getValueString();
}
private boolean isUnsigned()
{
private boolean isUnsigned() {
boolean result = false;
try
{
if ( getParentVariable().getCDIVariable() != null )
result = ( getParentVariable().getCDIVariable().getType() instanceof ICDIIntegralType ) ?
((ICDIIntegralType)getParentVariable().getCDIVariable().getType()).isUnsigned() : false;
try {
ICType type = getParentVariable().getType();
result = type.isUnsigned();
}
catch( CDIException e )
{
catch( DebugException e ) {
}
return result;
}
@ -512,32 +426,29 @@ public class CValue extends CDebugElement implements ICValue
/* (non-Javadoc)
* @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;
if ( ee != null && ee.canEvaluate() )
{
try
{
String valueString = null;
if ( ee != null && ee.canEvaluate() ) {
try {
if ( getParentVariable() != null )
valueString = ee.evaluateExpressionToString( getParentVariable().getQualifiedName() );
valueString = ee.evaluateExpressionToString( getParentVariable().getExpressionString() );
}
catch( DebugException e )
{
catch( DebugException e ) {
valueString = e.getMessage();
}
}
return valueString;
}
protected void reset() throws DebugException
{
/**
* Invalidates the string cache.
*/
protected void reset() {
fValueString = null;
Iterator it = fVariables.iterator();
while( it.hasNext() )
{
((CVariable)it.next()).reset();
while( it.hasNext() ) {
((CVariable)it.next()).resetValue();
}
}
}
}

View file

@ -8,37 +8,34 @@
* Contributors:
* QNX Software Systems - Initial API and implementation
*******************************************************************************/
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.ICDIFloatingPointValue;
import org.eclipse.debug.core.DebugException;
import org.eclipse.cdt.debug.core.model.ICValue;
/**
*
* Generates values for variable and expressions.
*
* @since Sep 9, 2002
* The value factory for variable and expressions.
*/
public class CValueFactory
{
static public CValue createValue( CVariable parent, ICDIValue cdiValue ) throws DebugException
{
public class CValueFactory {
static public CValue createValue( CVariable parent, ICDIValue cdiValue ) {
if ( cdiValue instanceof ICDIFloatingPointValue ) {
return new CFloatingPointValue( parent, cdiValue );
}
return new CValue( parent, cdiValue );
}
static public CArrayPartitionValue createArrayValue( CVariable parent, ICDIVariable cdiVariable, int start, int end ) throws DebugException
{
static public CArrayPartitionValue createArrayValue( AbstractCVariable parent, ICDIVariable cdiVariable, int start, int end ) {
return new CArrayPartitionValue( parent, cdiVariable, start, end );
}
static public CValue createGlobalValue( CVariable parent, ICDIValue cdiValue ) throws DebugException
{
static public CValue createGlobalValue( CVariable parent, ICDIValue cdiValue ) {
return new CGlobalValue( parent, cdiValue );
}
}
static public ICValue createValueWithError( CVariable parent, String message ) {
return new CValue( parent, message );
}
}

View file

@ -0,0 +1,31 @@
/**********************************************************************
* 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.model.ICDIVariableObject;
/**
* Provides factory methods for the variable types.
*/
public class CVariableFactory {
public static CVariable createVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) {
return new CVariable( parent, cdiVariableObject );
}
public static CVariable createVariableWithError( CDebugElement parent, ICDIVariableObject cdiVariableObject, String message ) {
return new CVariable( parent, cdiVariableObject, message );
}
public static CGlobalVariable createGlobalVariable( CDebugElement parent, ICDIVariableObject cdiVariableObject ) {
return new CGlobalVariable( parent, cdiVariableObject );
}
}

View file

@ -23,7 +23,7 @@ CThread.3=Suspend failed.
CThread.4=Step failed.
CThread.5=Step failed.
CThread.6=Step failed.
CValue.0=not available:
CValue.0=not available: {0}
CVariable.0=not available: {0}
CVariable.1=not available: {0}
CVariable.2=Variable does not support value modification.

View file

@ -1,3 +1,14 @@
2004-08-04 Mikhail Khodjaiants
New implementation of the variable types.
* CDTDebugModelPresentation.java
* CastToArrayActionDelegate.java
* CastToTypeActionDelegate.java
* DecVariableFormatActionDelegate.java
* HexVariableFormatActionDelegate.java
* NaturalVariableFormatActionDelegate.java
* RestoreDefaultTypeActionDelegate.java
* VariableFormatActionDelegate.java
2004-07-30 Mikhail Khodjaiants
Display the error message in the variable's label if the value of variable can not be retrieved.
* CDebugUIMessages.properties

View file

@ -478,6 +478,16 @@ public class CDTDebugModelPresentation extends LabelProvider implements IDebugMo
if ( valueString.length() > 0 ) {
result.append( " = " ).append( valueString ); //$NON-NLS-1$
}
if ( isShowVariableTypeNames() ) {
String type = null;
try {
type = value.getReferenceTypeName();
}
catch( DebugException e ) {
}
if ( !isEmpty( type ) )
result.insert( 0, type + ' ' );
}
}
}
if ( !expression.isEnabled() ) {

View file

@ -280,7 +280,7 @@ public class CastToArrayActionDelegate extends ActionDelegate implements IObject
if ( selection instanceof IStructuredSelection ) {
Object element = ((IStructuredSelection)selection).getFirstElement();
if ( element instanceof ICastToArray ) {
boolean enabled = ((ICastToArray)element).supportsCastToArray();
boolean enabled = ((ICastToArray)element).canCastToArray();
action.setEnabled( enabled );
if ( enabled ) {
setCastToArray( (ICastToArray)element );

View file

@ -129,7 +129,7 @@ public class CastToTypeActionDelegate extends ActionDelegate implements IObjectA
if ( selection instanceof IStructuredSelection ) {
Object element = ((IStructuredSelection)selection).getFirstElement();
if ( element instanceof ICastToType ) {
boolean enabled = ((ICastToType)element).supportsCasting();
boolean enabled = ((ICastToType)element).canCast();
action.setEnabled( enabled );
if ( enabled ) {
setCastToType( (ICastToType)element );

View file

@ -10,23 +10,17 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
/**
*
* Enter type comment.
*
* @since Dec 16, 2002
* The delegate of the "Decimal Format" action.
*/
public class DecVariableFormatActionDelegate extends VariableFormatActionDelegate
{
public class DecVariableFormatActionDelegate extends VariableFormatActionDelegate {
/**
* Constructor for DecVariableFormatActionDelegate.
* @param format
*/
public DecVariableFormatActionDelegate()
{
super( ICDIFormat.DECIMAL );
public DecVariableFormatActionDelegate() {
super( CVariableFormat.DECIMAL );
}
}
}

View file

@ -10,22 +10,17 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
/**
*
* Enter type comment.
*
* @since Dec 16, 2002
* The delegate of the "Hexadecimal Format" action.
*/
public class HexVariableFormatActionDelegate extends VariableFormatActionDelegate
{
public class HexVariableFormatActionDelegate extends VariableFormatActionDelegate {
/**
* Constructor for HexVariableFormatActionDelegate.
* @param format
*/
public HexVariableFormatActionDelegate()
{
super( ICDIFormat.HEXADECIMAL );
public HexVariableFormatActionDelegate() {
super( CVariableFormat.HEXADECIMAL );
}
}
}

View file

@ -10,23 +10,17 @@
*******************************************************************************/
package org.eclipse.cdt.debug.internal.ui.actions;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
/**
*
* Enter type comment.
*
* @since Dec 16, 2002
* The delegate of the "Natural Format" action.
*/
public class NaturalVariableFormatActionDelegate extends VariableFormatActionDelegate
{
public class NaturalVariableFormatActionDelegate extends VariableFormatActionDelegate {
/**
* Constructor for NaturalVariableFormatActionDelegate.
* @param format
*/
public NaturalVariableFormatActionDelegate()
{
super( ICDIFormat.NATURAL );
public NaturalVariableFormatActionDelegate() {
super( CVariableFormat.NATURAL );
}
}
}

View file

@ -110,6 +110,6 @@ public class RestoreDefaultTypeActionDelegate extends ActionDelegate implements
}
protected void doAction( ICastToType castToType ) throws DebugException {
castToType.restoreDefault();
castToType.restoreOriginal();
}
}

View file

@ -13,7 +13,7 @@ package org.eclipse.cdt.debug.internal.ui.actions;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
import org.eclipse.cdt.debug.core.model.CVariableFormat;
import org.eclipse.cdt.debug.core.model.ICVariable;
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
import org.eclipse.core.runtime.MultiStatus;
@ -28,18 +28,18 @@ import org.eclipse.ui.IWorkbenchPart;
import org.eclipse.ui.IWorkbenchWindow;
/**
* The delegate of the "Format" action.
* The superclass of the all format action delegates.
*/
public class VariableFormatActionDelegate implements IObjectActionDelegate {
public abstract class VariableFormatActionDelegate implements IObjectActionDelegate {
private int fFormat = ICDIFormat.NATURAL;
private CVariableFormat fFormat = CVariableFormat.NATURAL;
private ICVariable[] fVariables = null;
/**
* Constructor for VariableFormatActionDelegate.
*/
public VariableFormatActionDelegate( int format ) {
public VariableFormatActionDelegate( CVariableFormat format ) {
fFormat = format;
}
@ -91,7 +91,7 @@ public class VariableFormatActionDelegate implements IObjectActionDelegate {
Object o = i.next();
if ( o instanceof ICVariable ) {
ICVariable var = (ICVariable)o;
boolean enabled = var.isEditable();
boolean enabled = var.supportsFormatting();
action.setEnabled( enabled );
if ( enabled ) {
action.setChecked( var.getFormat() == fFormat );
@ -109,7 +109,7 @@ public class VariableFormatActionDelegate implements IObjectActionDelegate {
protected void doAction( ICVariable[] vars ) throws DebugException {
for( int i = 0; i < vars.length; i++ ) {
vars[i].setFormat( fFormat );
vars[i].changeFormat( fFormat );
}
}