1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-07-26 18:35:32 +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 2003-07-22 Mikhail Khodjaiants
Use the 'getReferencedProjects' method of 'CSourceLocator' to obtain the list of referenced projects. Use the 'getReferencedProjects' method of 'CSourceLocator' to obtain the list of referenced projects.
Use the correct tag for additional source locations. 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.ICDIPointerValue;
import org.eclipse.cdt.debug.core.cdi.model.type.ICDIReferenceValue; 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.ICDIShortValue;
import org.eclipse.cdt.debug.core.model.ICDebugElementErrorStatus;
import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator; import org.eclipse.cdt.debug.core.model.ICExpressionEvaluator;
import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.debug.core.DebugException; import org.eclipse.debug.core.DebugException;
@ -132,6 +133,8 @@ public class CValue extends CDebugElement implements ICValue
if ( !isAllocated() || !hasVariables() ) if ( !isAllocated() || !hasVariables() )
return Collections.EMPTY_LIST; return Collections.EMPTY_LIST;
if ( fVariables.size() == 0 ) if ( fVariables.size() == 0 )
{
try
{ {
List vars = getCDIVariables(); List vars = getCDIVariables();
@ -147,6 +150,14 @@ public class CValue extends CDebugElement implements ICValue
} }
} }
} }
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; return fVariables;
} }
@ -192,8 +203,7 @@ public class CValue extends CDebugElement implements ICValue
} }
catch( CDIException e ) catch( CDIException e )
{ {
vars = new ICDIVariable[0]; requestFailed( "not available: ", e );
infoMessage( e );
} }
return Arrays.asList( vars ); return Arrays.asList( vars );
} }

View file

@ -5,6 +5,7 @@
*/ */
package org.eclipse.cdt.debug.internal.core.model; package org.eclipse.cdt.debug.internal.core.model;
import java.text.MessageFormat;
import java.util.LinkedList; import java.util.LinkedList;
import org.eclipse.cdt.debug.core.CDebugCorePlugin; 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.ICDIArgumentObject;
import org.eclipse.cdt.debug.core.cdi.model.ICDIObject; 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.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.ICDIValue;
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable; 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.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.ICType;
import org.eclipse.cdt.debug.core.model.ICValue; import org.eclipse.cdt.debug.core.model.ICValue;
import org.eclipse.cdt.debug.core.model.ICVariable; import org.eclipse.cdt.debug.core.model.ICVariable;
@ -47,6 +51,106 @@ public abstract class CVariable extends CDebugElement
ICastToType, ICastToType,
ICastToArray 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 class InternalVariable
{ {
private ICDIVariableObject fCDIVariableObject; private ICDIVariableObject fCDIVariableObject;
@ -66,12 +170,21 @@ public abstract class CVariable extends CDebugElement
protected synchronized ICDIVariable getCDIVariable() throws CDIException protected synchronized ICDIVariable getCDIVariable() throws CDIException
{ {
if ( fCDIVariable == null ) if ( fCDIVariable == null )
{
try
{ {
if ( getCDIVariableObject() instanceof ICDIArgumentObject ) if ( getCDIVariableObject() instanceof ICDIArgumentObject )
fCDIVariable = getCDISession().getVariableManager().createArgument( (ICDIArgumentObject)getCDIVariableObject() ); fCDIVariable = getCDISession().getVariableManager().createArgument( (ICDIArgumentObject)getCDIVariableObject() );
else if ( getCDIVariableObject() instanceof ICDIVariableObject ) else if ( getCDIVariableObject() instanceof ICDIVariableObject )
fCDIVariable = getCDISession().getVariableManager().createVariable( getCDIVariableObject() ); 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; return fCDIVariable;
} }