mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-06-07 01:36:01 +02:00
Implementation of variable expansion.
This commit is contained in:
parent
c4ec584fc4
commit
4907b4f35a
2 changed files with 60 additions and 12 deletions
|
@ -16,6 +16,7 @@ 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.debug.core.DebugEvent;
|
import org.eclipse.debug.core.DebugEvent;
|
||||||
import org.eclipse.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
|
import org.eclipse.debug.core.model.IDebugTarget;
|
||||||
import org.eclipse.debug.core.model.IValue;
|
import org.eclipse.debug.core.model.IValue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -33,18 +34,18 @@ public class CLocalVariable extends CModificationVariable
|
||||||
private ICDIVariable fCDIVariable;
|
private ICDIVariable fCDIVariable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The stack frame this variable is contained in.
|
* The parent object this variable is contained in.
|
||||||
*/
|
*/
|
||||||
private CStackFrame fStackFrame;
|
private CDebugElement fParent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CLocalVariable.
|
* Constructor for CLocalVariable.
|
||||||
* @param target
|
* @param target
|
||||||
*/
|
*/
|
||||||
public CLocalVariable( CStackFrame stackFrame, ICDIVariable cdiVariable )
|
public CLocalVariable( CDebugElement parent, ICDIVariable cdiVariable )
|
||||||
{
|
{
|
||||||
super( (CDebugTarget)stackFrame.getDebugTarget() );
|
super( (CDebugTarget)parent.getDebugTarget() );
|
||||||
fStackFrame = stackFrame;
|
fParent = parent;
|
||||||
fCDIVariable = cdiVariable;
|
fCDIVariable = cdiVariable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -68,8 +69,8 @@ public class CLocalVariable extends CModificationVariable
|
||||||
*/
|
*/
|
||||||
protected ICDIValue retrieveValue() throws DebugException, CDIException
|
protected ICDIValue retrieveValue() throws DebugException, CDIException
|
||||||
{
|
{
|
||||||
return ( getStackFrame().isSuspended() ) ?
|
return ( ((IDebugTarget)getParent().getDebugTarget()).isSuspended() ) ?
|
||||||
getCDIVariable().getValue() : getLastKnownValue();
|
getCDIVariable().getValue() : getLastKnownValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -126,9 +127,9 @@ public class CLocalVariable extends CModificationVariable
|
||||||
*
|
*
|
||||||
* @return the stack frame
|
* @return the stack frame
|
||||||
*/
|
*/
|
||||||
protected CStackFrame getStackFrame()
|
protected CDebugElement getParent()
|
||||||
{
|
{
|
||||||
return fStackFrame;
|
return fParent;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -160,7 +161,7 @@ public class CLocalVariable extends CModificationVariable
|
||||||
if ( !getValue().hasVariables() )
|
if ( !getValue().hasVariables() )
|
||||||
{
|
{
|
||||||
setChanged( true );
|
setChanged( true );
|
||||||
getStackFrame().fireChangeEvent( DebugEvent.CONTENT );
|
getParent().fireChangeEvent( DebugEvent.CONTENT );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch( DebugException e )
|
catch( DebugException e )
|
||||||
|
|
|
@ -6,8 +6,15 @@
|
||||||
|
|
||||||
package org.eclipse.cdt.debug.internal.core.model;
|
package org.eclipse.cdt.debug.internal.core.model;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
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.CDIException;
|
||||||
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.debug.core.DebugException;
|
import org.eclipse.debug.core.DebugException;
|
||||||
import org.eclipse.debug.core.model.IValue;
|
import org.eclipse.debug.core.model.IValue;
|
||||||
import org.eclipse.debug.core.model.IVariable;
|
import org.eclipse.debug.core.model.IVariable;
|
||||||
|
@ -25,6 +32,11 @@ public class CValue extends CDebugElement implements IValue
|
||||||
*/
|
*/
|
||||||
private ICDIValue fValue;
|
private ICDIValue fValue;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* List of child variables.
|
||||||
|
*/
|
||||||
|
private List fVariables = Collections.EMPTY_LIST;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor for CValue.
|
* Constructor for CValue.
|
||||||
* @param target
|
* @param target
|
||||||
|
@ -69,7 +81,7 @@ public class CValue extends CDebugElement implements IValue
|
||||||
*/
|
*/
|
||||||
public boolean isAllocated() throws DebugException
|
public boolean isAllocated() throws DebugException
|
||||||
{
|
{
|
||||||
return false;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -77,7 +89,25 @@ public class CValue extends CDebugElement implements IValue
|
||||||
*/
|
*/
|
||||||
public IVariable[] getVariables() throws DebugException
|
public IVariable[] getVariables() throws DebugException
|
||||||
{
|
{
|
||||||
return null;
|
List list = getVariables0();
|
||||||
|
return (IVariable[])list.toArray( new IVariable[list.size()] );
|
||||||
|
}
|
||||||
|
|
||||||
|
protected synchronized List getVariables0() throws DebugException
|
||||||
|
{
|
||||||
|
if ( !isAllocated() )
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
if ( fVariables.size() == 0 )
|
||||||
|
{
|
||||||
|
List vars = getCDIVariables();
|
||||||
|
fVariables = new ArrayList( vars.size() );
|
||||||
|
Iterator it = vars.iterator();
|
||||||
|
while( it.hasNext() )
|
||||||
|
{
|
||||||
|
fVariables.add( new CLocalVariable( this, (ICDIVariable)it.next() ) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return fVariables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
|
@ -114,4 +144,21 @@ public class CValue extends CDebugElement implements IValue
|
||||||
{
|
{
|
||||||
return fValue;
|
return fValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected List getCDIVariables() throws DebugException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ICDIValue value = getUnderlyingValue();
|
||||||
|
if ( value != null )
|
||||||
|
{
|
||||||
|
return Arrays.asList( value.getVariables() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch( CDIException e )
|
||||||
|
{
|
||||||
|
targetRequestFailed( "Operation failed. Reason: ", e );
|
||||||
|
}
|
||||||
|
return Collections.EMPTY_LIST;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue