mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-07-24 09:25:31 +02:00
Removed the gdb-specific variable parsing.
This commit is contained in:
parent
d74d9d5a46
commit
21564c5259
13 changed files with 51 additions and 282 deletions
|
@ -1,3 +1,15 @@
|
|||
2003-03-18 Mikhail Khodjaiants
|
||||
Removed the gdb-specific variable parsing.
|
||||
* ICValue.java
|
||||
* CArrayPartition.java
|
||||
* CArrayPartitionValue.java
|
||||
* CModificationVariable.java
|
||||
* CStackFrame.java
|
||||
* CValue.java
|
||||
* CVariable.java
|
||||
* CArrayEntryVariable.java: removed
|
||||
* CLocalVariable.java: removed
|
||||
|
||||
2003-03-17 Mikhail Khodjaiants
|
||||
Replace range by start index and length in 'Display As Array' action.
|
||||
* ICDIVariableManager.java
|
||||
|
|
|
@ -18,24 +18,6 @@ import org.eclipse.debug.core.model.IValue;
|
|||
*/
|
||||
public interface ICValue extends IValue
|
||||
{
|
||||
static final public int TYPE_UNKNOWN = -1;
|
||||
static final public int TYPE_SIMPLE = 0;
|
||||
static final public int TYPE_ARRAY = 1;
|
||||
static final public int TYPE_STRUCTURE = 2;
|
||||
static final public int TYPE_STRING = 3;
|
||||
static final public int TYPE_POINTER = 4;
|
||||
static final public int TYPE_ARRAY_PARTITION = 5;
|
||||
static final public int TYPE_ARRAY_ENTRY = 7;
|
||||
static final public int TYPE_CHAR = 8;
|
||||
static final public int TYPE_KEYWORD = 9;
|
||||
|
||||
/**
|
||||
* Returns the type of this value.
|
||||
*
|
||||
* @return the type of this value
|
||||
*/
|
||||
int getType();
|
||||
|
||||
/**
|
||||
* Returns the underlying CDI value for this value.
|
||||
*/
|
||||
|
|
|
@ -1,63 +0,0 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
|
||||
/**
|
||||
*
|
||||
* An entry in an array.
|
||||
*
|
||||
* @since Sep 9, 2002
|
||||
*/
|
||||
public class CArrayEntryVariable extends CModificationVariable
|
||||
{
|
||||
/**
|
||||
* The index of the variable entry.
|
||||
*/
|
||||
private int fIndex;
|
||||
|
||||
/**
|
||||
* Constructor for CArrayEntryVariable.
|
||||
* @param target
|
||||
*/
|
||||
public CArrayEntryVariable( CDebugElement parent, ICDIVariable cdiVariable, int index )
|
||||
{
|
||||
super( parent, cdiVariable );
|
||||
fIndex = index;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IVariable#getName()
|
||||
*/
|
||||
public String getName() throws DebugException
|
||||
{
|
||||
return "[" + getIndex() + "]";
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.debug.core.model.IVariable#getReferenceTypeName()
|
||||
*/
|
||||
public String getReferenceTypeName() throws DebugException
|
||||
{
|
||||
return stripBrackets( super.getReferenceTypeName() );
|
||||
}
|
||||
|
||||
protected int getIndex()
|
||||
{
|
||||
return fIndex;
|
||||
}
|
||||
|
||||
protected String stripBrackets( String typeName )
|
||||
{
|
||||
int index = typeName.lastIndexOf( '[' );
|
||||
if ( index < 0 )
|
||||
return typeName;
|
||||
return typeName.substring( 0, index );
|
||||
}
|
||||
}
|
|
@ -96,7 +96,7 @@ public class CArrayPartition extends CVariable
|
|||
return fArrayPartitionValue;
|
||||
}
|
||||
|
||||
static public List splitArray( CDebugTarget target, List cdiVars, int start, int end )
|
||||
static public List splitArray( CDebugElement parent, List cdiVars, int start, int end )
|
||||
{
|
||||
ArrayList children = new ArrayList();
|
||||
int perSlot = 1;
|
||||
|
@ -115,11 +115,11 @@ public class CArrayPartition extends CVariable
|
|||
CVariable var = null;
|
||||
if ( perSlot == 1 )
|
||||
{
|
||||
var = new CArrayEntryVariable( target, (ICDIVariable)cdiVars.get( start ), start );
|
||||
var = new CModificationVariable( parent, (ICDIVariable)cdiVars.get( start ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
var = new CArrayPartition( target, cdiVars.subList( start, start + perSlot ), start, start + perSlot - 1 );
|
||||
var = new CArrayPartition( parent, cdiVars.subList( start, start + perSlot ), start, start + perSlot - 1 );
|
||||
}
|
||||
children.add( var );
|
||||
start += perSlot;
|
||||
|
|
|
@ -101,7 +101,7 @@ public class CArrayPartitionValue extends CDebugElement implements ICValue
|
|||
fVariables = new ArrayList( getEnd() - getStart() + 1 );
|
||||
for ( int i = getStart(); i <= getEnd(); ++i )
|
||||
{
|
||||
fVariables.add( new CArrayEntryVariable( (CDebugTarget)getDebugTarget(), (ICDIVariable)fCDIVariables.get( i - getStart() ), i ) );
|
||||
fVariables.add( new CModificationVariable( this, (ICDIVariable)fCDIVariables.get( i - getStart() ) ) );
|
||||
}
|
||||
}
|
||||
return (IVariable[])fVariables.toArray( new IVariable[fVariables.size()] );
|
||||
|
|
|
@ -1,26 +0,0 @@
|
|||
/*
|
||||
*(c) Copyright QNX Software Systems Ltd. 2002.
|
||||
* All Rights Reserved.
|
||||
*
|
||||
*/
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.model.ICDIVariable;
|
||||
|
||||
/**
|
||||
*
|
||||
* Enter type comment.
|
||||
*
|
||||
* @since Aug 9, 2002
|
||||
*/
|
||||
public class CLocalVariable extends CModificationVariable
|
||||
{
|
||||
/**
|
||||
* Constructor for CLocalVariable.
|
||||
* @param target
|
||||
*/
|
||||
public CLocalVariable( CDebugElement parent, ICDIVariable cdiVariable )
|
||||
{
|
||||
super( parent, cdiVariable );
|
||||
}
|
||||
}
|
|
@ -6,13 +6,9 @@
|
|||
|
||||
package org.eclipse.cdt.debug.internal.core.model;
|
||||
|
||||
import java.text.MessageFormat;
|
||||
|
||||
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.model.ICValue;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
|
||||
|
@ -22,7 +18,7 @@ import org.eclipse.debug.core.model.IValue;
|
|||
*
|
||||
* @since Aug 9, 2002
|
||||
*/
|
||||
public abstract class CModificationVariable extends CVariable
|
||||
public class CModificationVariable extends CVariable
|
||||
{
|
||||
/**
|
||||
* Constructor for CModificationVariable.
|
||||
|
@ -109,6 +105,7 @@ public abstract class CModificationVariable extends CVariable
|
|||
|
||||
private String processExpression( String oldExpression ) throws DebugException
|
||||
{
|
||||
/*
|
||||
CValue value = (CValue)getValue();
|
||||
if ( value == null )
|
||||
{
|
||||
|
@ -126,6 +123,7 @@ public abstract class CModificationVariable extends CVariable
|
|||
}
|
||||
return Short.toString( (short)chars[0] );
|
||||
}
|
||||
*/
|
||||
return oldExpression;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -107,7 +107,7 @@ public class CStackFrame extends CDebugElement
|
|||
Iterator it = vars.iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
fVariables.add( new CLocalVariable( this, (ICDIVariable)it.next() ) );
|
||||
fVariables.add( new CModificationVariable( this, (ICDIVariable)it.next() ) );
|
||||
}
|
||||
}
|
||||
else if ( refreshVariables() )
|
||||
|
@ -128,7 +128,7 @@ public class CStackFrame extends CDebugElement
|
|||
int index = 0;
|
||||
while( index < fVariables.size() )
|
||||
{
|
||||
CLocalVariable local = (CLocalVariable)fVariables.get( index );
|
||||
CVariable local = (CVariable)fVariables.get( index );
|
||||
ICDIVariable var = findVariable( locals, local.getOriginalCDIVariable() );
|
||||
if ( var != null )
|
||||
{
|
||||
|
@ -146,7 +146,7 @@ public class CStackFrame extends CDebugElement
|
|||
Iterator newOnes = locals.iterator();
|
||||
while( newOnes.hasNext() )
|
||||
{
|
||||
fVariables.add( new CLocalVariable( this, (ICDIVariable)newOnes.next() ) );
|
||||
fVariables.add( new CModificationVariable( this, (ICDIVariable)newOnes.next() ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -683,8 +683,8 @@ public class CStackFrame extends CDebugElement
|
|||
}
|
||||
for ( int i = 0; i < vars.length; ++i )
|
||||
{
|
||||
if ( vars[i] instanceof CLocalVariable &&
|
||||
((CLocalVariable)vars[i]).getOriginalCDIVariable() instanceof ICDIArgument )
|
||||
if ( vars[i] instanceof CVariable &&
|
||||
((CVariable)vars[i]).getOriginalCDIVariable() instanceof ICDIArgument )
|
||||
{
|
||||
list.add( vars[i] );
|
||||
}
|
||||
|
|
|
@ -47,11 +47,6 @@ public class CValue extends CDebugElement implements ICValue
|
|||
*/
|
||||
private List fVariables = Collections.EMPTY_LIST;
|
||||
|
||||
/**
|
||||
* Type (simple, array, structure or string) of this value.
|
||||
*/
|
||||
private int fType = TYPE_UNKNOWN;
|
||||
|
||||
/**
|
||||
* Constructor for CValue.
|
||||
* @param target
|
||||
|
@ -127,18 +122,16 @@ public class CValue extends CDebugElement implements ICValue
|
|||
if ( fVariables.size() == 0 )
|
||||
{
|
||||
List vars = getCDIVariables();
|
||||
if ( getType() == ICValue.TYPE_ARRAY )
|
||||
{
|
||||
if ( vars.size() > 0 )
|
||||
fVariables = CArrayPartition.splitArray( (CDebugTarget)getDebugTarget(), vars, 0, vars.size() - 1 );
|
||||
}
|
||||
|
||||
if ( vars.size() > 1 )
|
||||
fVariables = CArrayPartition.splitArray( this, vars, 0, vars.size() - 1 );
|
||||
else
|
||||
{
|
||||
fVariables = new ArrayList( vars.size() );
|
||||
Iterator it = vars.iterator();
|
||||
while( it.hasNext() )
|
||||
{
|
||||
fVariables.add( new CLocalVariable( this, (ICDIVariable)it.next() ) );
|
||||
fVariables.add( new CModificationVariable( this, (ICDIVariable)it.next() ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -196,46 +189,6 @@ public class CValue extends CDebugElement implements ICValue
|
|||
return Arrays.asList( vars );
|
||||
}
|
||||
|
||||
protected void calculateType( String stringValue )
|
||||
{
|
||||
if ( fType == TYPE_UNKNOWN && stringValue != null )
|
||||
{
|
||||
stringValue = stringValue.trim();
|
||||
if ( stringValue.length() == 0 )
|
||||
{
|
||||
fType = TYPE_KEYWORD;
|
||||
}
|
||||
else if ( stringValue.charAt( stringValue.length() - 1 ) == '\'' )
|
||||
{
|
||||
fType = TYPE_CHAR;
|
||||
}
|
||||
else if ( stringValue.charAt( 0 ) == '[' )
|
||||
{
|
||||
fType = TYPE_ARRAY;
|
||||
}
|
||||
else if ( stringValue.charAt( 0 ) == '{' )
|
||||
{
|
||||
fType = TYPE_STRUCTURE;
|
||||
}
|
||||
else if ( stringValue.startsWith( "0x" ) )
|
||||
{
|
||||
fType = TYPE_POINTER;
|
||||
}
|
||||
else
|
||||
{
|
||||
fType = TYPE_SIMPLE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
* @see org.eclipse.cdt.debug.core.ICValue#getType()
|
||||
*/
|
||||
public int getType()
|
||||
{
|
||||
return fType;
|
||||
}
|
||||
|
||||
protected int getNumberOfChildren() throws DebugException
|
||||
{
|
||||
int result = 0;
|
||||
|
@ -256,11 +209,6 @@ public class CValue extends CDebugElement implements ICValue
|
|||
if ( cdiValue != null )
|
||||
{
|
||||
result = cdiValue.trim();
|
||||
calculateType( result );
|
||||
if ( getType() == TYPE_CHAR )
|
||||
{
|
||||
result = getCharValue( result );
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
@ -286,38 +234,7 @@ public class CValue extends CDebugElement implements ICValue
|
|||
((CVariable)it.next()).dispose();
|
||||
}
|
||||
}
|
||||
|
||||
private String getCharValue( String value )
|
||||
{
|
||||
String result = "";
|
||||
int index = value.indexOf( ' ' );
|
||||
if ( index > 0 )
|
||||
{
|
||||
char resultChar = '.';
|
||||
try
|
||||
{
|
||||
short shortValue = Short.parseShort( value.substring( 0, index ), 10 );
|
||||
if ( shortValue >= 0 )
|
||||
{
|
||||
resultChar = (char)shortValue;
|
||||
if ( Character.isISOControl( resultChar ) )
|
||||
{
|
||||
resultChar = '.';
|
||||
}
|
||||
}
|
||||
}
|
||||
catch( NumberFormatException e )
|
||||
{
|
||||
}
|
||||
result = String.valueOf( resultChar );
|
||||
}
|
||||
else
|
||||
{
|
||||
result = value;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
protected CVariable getParentVariable()
|
||||
{
|
||||
return fParent;
|
||||
|
|
|
@ -126,11 +126,12 @@ public abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
public boolean hasValueChanged() throws DebugException
|
||||
{
|
||||
// ??
|
||||
if ( isPointer() )
|
||||
return false;
|
||||
IValue value = getValue();
|
||||
if ( value != null )
|
||||
{
|
||||
if ( value instanceof CValue && ((CValue)getValue()).getType() == ICValue.TYPE_POINTER )
|
||||
return false;
|
||||
return ( value.hasVariables() ) ? false : fChanged;
|
||||
}
|
||||
return false;
|
||||
|
@ -270,7 +271,7 @@ public abstract class CVariable extends CDebugElement
|
|||
if ( getValue() != null && getValue() instanceof ICValue )
|
||||
{
|
||||
((ICValue)getValue()).setChanged( changed );
|
||||
if ( !getValue().hasVariables() || ((ICValue)getValue()).getType() == ICValue.TYPE_POINTER )
|
||||
if ( !hasChildren() )
|
||||
{
|
||||
fChanged = changed;
|
||||
}
|
||||
|
@ -303,12 +304,6 @@ public abstract class CVariable extends CDebugElement
|
|||
try
|
||||
{
|
||||
setChanged( true );
|
||||
if ( getValue() != null &&
|
||||
((CValue)getValue()).getType() == ICValue.TYPE_CHAR &&
|
||||
getParent() instanceof CValue )
|
||||
{
|
||||
updateParentVariable( (CValue)getParent() );
|
||||
}
|
||||
getParent().fireChangeEvent( DebugEvent.CONTENT );
|
||||
}
|
||||
catch( DebugException e )
|
||||
|
@ -611,7 +606,7 @@ public abstract class CVariable extends CDebugElement
|
|||
*/
|
||||
public boolean isEditable()
|
||||
{
|
||||
if ( fEditable == null )
|
||||
if ( fEditable == null && getCDIVariable() != null )
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -624,4 +619,9 @@ public abstract class CVariable extends CDebugElement
|
|||
}
|
||||
return ( fEditable != null ) ? fEditable.booleanValue() : false;
|
||||
}
|
||||
|
||||
protected boolean isPointer()
|
||||
{
|
||||
return isEditable() && hasChildren();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,3 +1,8 @@
|
|||
2003-03-18 Mikhail Khodjaiants
|
||||
Removed the gdb-specific variable parsing.
|
||||
* VariableFormatActionDelegate.java
|
||||
* CDTDebugModelPresentation.java
|
||||
|
||||
2003-03-17 Mikhail Khodjaiants
|
||||
Replace range by start index and length in 'Display As Array' action.
|
||||
* CastToArrayActionDelegate.java
|
||||
|
|
|
@ -25,7 +25,7 @@ import org.eclipse.cdt.debug.core.model.ICDebugTargetType;
|
|||
import org.eclipse.cdt.debug.core.model.ICFunctionBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICLineBreakpoint;
|
||||
import org.eclipse.cdt.debug.core.model.ICSharedLibrary;
|
||||
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||
import org.eclipse.cdt.debug.core.model.ICWatchpoint;
|
||||
import org.eclipse.cdt.debug.core.model.IDummyStackFrame;
|
||||
import org.eclipse.cdt.debug.core.model.IExecFileInfo;
|
||||
|
@ -489,29 +489,9 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
}
|
||||
label += var.getName();
|
||||
IValue value = var.getValue();
|
||||
if ( value != null && value.getValueString() != null )
|
||||
if ( value != null && value.getValueString() != null && value.getValueString().trim().length() > 0 )
|
||||
{
|
||||
if ( value instanceof ICValue )
|
||||
{
|
||||
switch( ((ICValue)value).getType() )
|
||||
{
|
||||
case ICValue.TYPE_ARRAY:
|
||||
label += value.getValueString();
|
||||
break;
|
||||
case ICValue.TYPE_STRUCTURE:
|
||||
break;
|
||||
case ICValue.TYPE_KEYWORD:
|
||||
break;
|
||||
default:
|
||||
label += "= " + value.getValueString();
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
label += "= " + value.getValueString();
|
||||
}
|
||||
label += "= " + value.getValueString();
|
||||
}
|
||||
}
|
||||
return label;
|
||||
|
@ -787,24 +767,11 @@ public class CDTDebugModelPresentation extends LabelProvider
|
|||
|
||||
protected Image getVariableImage( IVariable element ) throws DebugException
|
||||
{
|
||||
if ( element != null )
|
||||
if ( element instanceof ICVariable )
|
||||
{
|
||||
IValue value = element.getValue();
|
||||
if ( value instanceof ICValue )
|
||||
return getValueTypeImage( (ICValue)value );
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
protected Image getValueTypeImage( ICValue element )
|
||||
{
|
||||
if ( element != null )
|
||||
{
|
||||
if ( element.getType() == ICValue.TYPE_ARRAY ||
|
||||
element.getType() == ICValue.TYPE_STRUCTURE ||
|
||||
element.getType() == ICValue.TYPE_KEYWORD )
|
||||
if ( !((ICVariable)element).isEditable() )
|
||||
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_AGGREGATE, 0 ) );
|
||||
else if ( element.getType() == ICValue.TYPE_POINTER )
|
||||
else if ( ((ICVariable)element).hasChildren() )
|
||||
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_POINTER, 0 ) );
|
||||
else
|
||||
return fDebugImageRegistry.get( new CImageDescriptor( CDebugImages.DESC_OBJS_VARIABLE_SIMPLE, 0 ) );
|
||||
|
|
|
@ -6,12 +6,10 @@
|
|||
package org.eclipse.cdt.debug.internal.ui.actions;
|
||||
|
||||
import org.eclipse.cdt.debug.core.cdi.ICDIFormat;
|
||||
import org.eclipse.cdt.debug.core.model.ICValue;
|
||||
import org.eclipse.cdt.debug.core.model.ICVariable;
|
||||
import org.eclipse.cdt.debug.ui.CDebugUIPlugin;
|
||||
import org.eclipse.core.runtime.MultiStatus;
|
||||
import org.eclipse.debug.core.DebugException;
|
||||
import org.eclipse.debug.core.model.IValue;
|
||||
import org.eclipse.jface.action.IAction;
|
||||
import org.eclipse.jface.viewers.ISelection;
|
||||
import org.eclipse.jface.viewers.IStructuredSelection;
|
||||
|
@ -114,28 +112,7 @@ public class VariableFormatActionDelegate implements IObjectActionDelegate
|
|||
|
||||
private boolean enablesFor( ICVariable var )
|
||||
{
|
||||
boolean enabled = false;
|
||||
try
|
||||
{
|
||||
IValue value = var.getValue();
|
||||
if ( value != null && value instanceof ICValue )
|
||||
{
|
||||
switch( ((ICValue)value).getType() )
|
||||
{
|
||||
// case ICValue.TYPE_ARRAY:
|
||||
case ICValue.TYPE_SIMPLE:
|
||||
case ICValue.TYPE_POINTER:
|
||||
case ICValue.TYPE_CHAR:
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch( DebugException e )
|
||||
{
|
||||
}
|
||||
return enabled;
|
||||
return var.isEditable();
|
||||
}
|
||||
|
||||
private void setVariable( ICVariable var )
|
||||
|
|
Loading…
Add table
Reference in a new issue