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

Create a special type of ICDIVariable (ErrorVariable) if request to gdb fails.

This commit is contained in:
Mikhail Khodjaiants 2003-07-22 22:32:40 +00:00
parent 6a09808529
commit 52e1267d4a
3 changed files with 143 additions and 15 deletions

View file

@ -1,3 +1,8 @@
2003-07-22 Mikhail Khodjaiants
Create a special type of ICDIVariable (ErrorVariable) if request to gdb fails.
* CVariable.java
* CValue.java
2003-07-22 Mikhail Khodjaiants
Use the 'getReferencedProjects' method of 'CSourceLocator' to obtain the list of referenced projects.
Use the correct tag for additional source locations.

View file

@ -27,6 +27,7 @@ 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.model.ICDebugElementErrorStatus;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.debug.core.DebugException;
@ -133,19 +134,29 @@ public class CValue extends CDebugElement implements ICValue
return Collections.EMPTY_LIST;
if ( fVariables.size() == 0 )
{
List vars = getCDIVariables();
if ( vars.size() > 1 )
fVariables = CArrayPartition.splitArray( this, vars, 0, vars.size() - 1 );
else
try
{
fVariables = new ArrayList( vars.size() );
Iterator it = vars.iterator();
while( it.hasNext() )
List vars = getCDIVariables();
if ( vars.size() > 1 )
fVariables = CArrayPartition.splitArray( this, vars, 0, vars.size() - 1 );
else
{
fVariables.add( new CModificationVariable( this, (ICDIVariable)it.next() ) );
fVariables = new ArrayList( vars.size() );
Iterator it = vars.iterator();
while( it.hasNext() )
{
fVariables.add( new CModificationVariable( this, (ICDIVariable)it.next() ) );
}
}
}
catch( DebugException e )
{
fVariables = new ArrayList( 1 );
CModificationVariable var = new CModificationVariable( this, new CVariable.ErrorVariable( null, e ) );
var.setStatus( ICDebugElementErrorStatus.ERROR, e.getMessage() );
fVariables.add( var );
}
}
return fVariables;
}
@ -192,8 +203,7 @@ public class CValue extends CDebugElement implements ICValue
}
catch( CDIException e )
{
vars = new ICDIVariable[0];
infoMessage( e );
requestFailed( "not available: ", e );
}
return Arrays.asList( vars );
}

View file

@ -5,6 +5,7 @@
*/
package org.eclipse.cdt.debug.internal.core.model;
import java.text.MessageFormat;
import java.util.LinkedList;
import org.eclipse.cdt.debug.core.CDebugCorePlugin;
@ -19,9 +20,12 @@ import org.eclipse.cdt.debug.core.cdi.event.ICDIEventListener;
import org.eclipse.cdt.debug.core.cdi.model.ICDIArgumentObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIStackFrame;
import org.eclipse.cdt.debug.core.cdi.model.ICDITarget;
import org.eclipse.cdt.debug.core.cdi.model.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIType;
import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus;
import org.eclipse.cdt.debug.core.model.ICType;
import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICVariable;
@ -47,6 +51,106 @@ public abstract class CVariable extends CDebugElement
ICastToType,
ICastToArray
{
/**
* The instance of this class is created when the 'getCDIVariable' call throws an exception.
*
* @since Jul 22, 2003
*/
public static class ErrorVariable implements ICDIVariable
{
private ICDIVariableObject fVariableObject;
private Exception fException;
public ErrorVariable( ICDIVariableObject varObject, Exception e )
{
fVariableObject = varObject;
fException = e;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getStackFrame()
*/
public ICDIStackFrame getStackFrame() throws CDIException
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariableObject#getName()
*/
public String getName()
{
return ( fVariableObject != null ) ? fVariableObject.getName() : "";
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getTypeName()
*/
public String getTypeName() throws CDIException
{
// TODO When the 'getType' method is moved to 'ICDIVariableObject'
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getType()
*/
public ICDIType getType() throws CDIException
{
// TODO When the 'getType' method is moved to 'ICDIVariableObject'
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#getValue()
*/
public ICDIValue getValue() throws CDIException
{
return null;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#isEditable()
*/
public boolean isEditable() throws CDIException
{
return false;
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(java.lang.String)
*/
public void setValue( String expression ) throws CDIException
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setValue(org.eclipse.cdt.debug.core.cdi.model.ICDIValue)
*/
public void setValue( ICDIValue value ) throws CDIException
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIVariable#setFormat(int)
*/
public void setFormat( int format ) throws CDIException
{
}
/* (non-Javadoc)
* @see org.eclipse.cdt.debug.core.cdi.model.ICDIObject#getTarget()
*/
public ICDITarget getTarget()
{
return ( fVariableObject != null ) ? fVariableObject.getTarget() : null;
}
public Exception getException()
{
return fException;
}
}
class InternalVariable
{
private ICDIVariableObject fCDIVariableObject;
@ -67,10 +171,19 @@ public abstract class CVariable extends CDebugElement
{
if ( fCDIVariable == null )
{
if ( getCDIVariableObject() instanceof ICDIArgumentObject )
fCDIVariable = getCDISession().getVariableManager().createArgument( (ICDIArgumentObject)getCDIVariableObject() );
else if ( getCDIVariableObject() instanceof ICDIVariableObject )
fCDIVariable = getCDISession().getVariableManager().createVariable( getCDIVariableObject() );
try
{
if ( getCDIVariableObject() instanceof ICDIArgumentObject )
fCDIVariable = getCDISession().getVariableManager().createArgument( (ICDIArgumentObject)getCDIVariableObject() );
else if ( getCDIVariableObject() instanceof ICDIVariableObject )
fCDIVariable = getCDISession().getVariableManager().createVariable( getCDIVariableObject() );
}
catch( CDIException e )
{
fCDIVariable = new ErrorVariable( getCDIVariableObject(), e );
setStatus( ICDebugElementErrorStatus.ERROR,
MessageFormat.format( "not available: {0}", new String[] { e.getMessage() } ) );
}
}
return fCDIVariable;
}