Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
[cdt-patch] Removed the gdb-specific variable parsing (core)

Index: ChangeLog
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/ChangeLog,v
retrieving revision 1.147
diff -u -r1.147 ChangeLog
--- ChangeLog 17 Mar 2003 21:22:07 -0000 1.147
+++ ChangeLog 18 Mar 2003 21:00:29 -0000
@@ -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
Index: src/org/eclipse/cdt/debug/core/model/ICValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/core/model/ICValue.java,v
retrieving revision 1.3
diff -u -r1.3 ICValue.java
--- src/org/eclipse/cdt/debug/core/model/ICValue.java 17 Dec 2002 02:41:32 -0000 1.3
+++ src/org/eclipse/cdt/debug/core/model/ICValue.java 18 Mar 2003 21:00:29 -0000
@@ -18,24 +18,6 @@
  */
 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.
   */
Index: src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java
diff -N src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CArrayEntryVariable.java 7 Mar 2003 19:39:47 -0000 1.5
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -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 );
- }
-}
Index: src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java,v
retrieving revision 1.4
diff -u -r1.4 CArrayPartition.java
--- src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java 2 Oct 2002 19:37:13 -0000 1.4
+++ src/org/eclipse/cdt/debug/internal/core/model/CArrayPartition.java 18 Mar 2003 21:00:30 -0000
@@ -96,7 +96,7 @@
   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 @@
    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;
Index: src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java,v
retrieving revision 1.5
diff -u -r1.5 CArrayPartitionValue.java
--- src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java 4 Dec 2002 21:34:31 -0000 1.5
+++ src/org/eclipse/cdt/debug/internal/core/model/CArrayPartitionValue.java 18 Mar 2003 21:00:30 -0000
@@ -101,7 +101,7 @@
    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()] );
Index: src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java
===================================================================
RCS file: src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java
diff -N src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CLocalVariable.java 10 Mar 2003 23:04:18 -0000 1.7
+++ /dev/null 1 Jan 1970 00:00:00 -0000
@@ -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 );
- }
-}
Index: src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java,v
retrieving revision 1.11
diff -u -r1.11 CModificationVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java 14 Mar 2003 23:12:21 -0000 1.11
+++ src/org/eclipse/cdt/debug/internal/core/model/CModificationVariable.java 18 Mar 2003 21:00:30 -0000
@@ -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 @@
  *
  * @since Aug 9, 2002
  */
-public abstract class CModificationVariable extends CVariable
+public class CModificationVariable extends CVariable
 {
  /**
   * Constructor for CModificationVariable.
@@ -109,6 +105,7 @@
  
  private String processExpression( String oldExpression ) throws DebugException
  {
+/*
   CValue value = (CValue)getValue();
   if ( value == null )
   {
@@ -126,6 +123,7 @@
    }
    return Short.toString( (short)chars[0] );
   }
+*/
   return oldExpression;
  }
 }
Index: src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java,v
retrieving revision 1.17
diff -u -r1.17 CStackFrame.java
--- src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 9 Mar 2003 22:45:33 -0000 1.17
+++ src/org/eclipse/cdt/debug/internal/core/model/CStackFrame.java 18 Mar 2003 21:00:30 -0000
@@ -107,7 +107,7 @@
    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 @@
   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 @@
   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 @@
   }
   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] );
    }
Index: src/org/eclipse/cdt/debug/internal/core/model/CValue.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CValue.java,v
retrieving revision 1.15
diff -u -r1.15 CValue.java
--- src/org/eclipse/cdt/debug/internal/core/model/CValue.java 20 Dec 2002 19:05:27 -0000 1.15
+++ src/org/eclipse/cdt/debug/internal/core/model/CValue.java 18 Mar 2003 21:00:30 -0000
@@ -48,11 +48,6 @@
  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 @@
   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 @@
   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 @@
   if ( cdiValue != null )
   {
    result = cdiValue.trim();
-   calculateType( result );
-   if ( getType() == TYPE_CHAR )
-   {
-    result = getCharValue( result );
-   }
   }
   return result;
  }
@@ -286,38 +234,7 @@
    ((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;
Index: src/org/eclipse/cdt/debug/internal/core/model/CVariable.java
===================================================================
RCS file: /home/tools/org.eclipse.cdt.debug.core/src/org/eclipse/cdt/debug/internal/core/model/CVariable.java,v
retrieving revision 1.21
diff -u -r1.21 CVariable.java
--- src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 17 Mar 2003 21:22:07 -0000 1.21
+++ src/org/eclipse/cdt/debug/internal/core/model/CVariable.java 18 Mar 2003 21:00:30 -0000
@@ -126,11 +126,12 @@
   */
  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 @@
   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 @@
   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 boolean isEditable()
  {
-  if ( fEditable == null )
+  if ( fEditable == null && getCDIVariable() != null )
   {
    try
    {
@@ -623,5 +618,10 @@
    }
   }
   return ( fEditable != null ) ? fEditable.booleanValue() : false;
+ }

+ protected boolean isPointer()
+ {
+  return isEditable() && hasChildren();
  }
 }

Back to the top