cdt/cdt_6_0_x/org.eclipse.cdt.dsf/src/org/eclipse/cdt/dsf/debug/service/IExpressions.java
changeset 129 723898599d35
parent 105 fbceb3d6fb44
equal deleted inserted replaced
127:b32168b846ac 129:723898599d35
     9  *     Wind River Systems - initial API and implementation
     9  *     Wind River Systems - initial API and implementation
    10  *     Ericsson           - Update for GDB/MI
    10  *     Ericsson           - Update for GDB/MI
    11  *******************************************************************************/
    11  *******************************************************************************/
    12 package org.eclipse.cdt.dsf.debug.service;
    12 package org.eclipse.cdt.dsf.debug.service;
    13 
    13 
       
    14 import java.math.BigInteger;
    14 import java.util.Map;
    15 import java.util.Map;
    15 
    16 
       
    17 import org.eclipse.cdt.core.IAddress;
    16 import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
    18 import org.eclipse.cdt.dsf.concurrent.DataRequestMonitor;
    17 import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
    19 import org.eclipse.cdt.dsf.concurrent.RequestMonitor;
    18 import org.eclipse.cdt.dsf.datamodel.IDMContext;
    20 import org.eclipse.cdt.dsf.datamodel.IDMContext;
    19 import org.eclipse.cdt.dsf.datamodel.IDMData;
    21 import org.eclipse.cdt.dsf.datamodel.IDMData;
    20 import org.eclipse.cdt.dsf.datamodel.IDMEvent;
    22 import org.eclipse.cdt.dsf.datamodel.IDMEvent;
    38          * expression string is the same as the string that is sent to the debug engine to be
    40          * expression string is the same as the string that is sent to the debug engine to be
    39          * evaluated in context of a stack frame, thread, or a symbol context.   
    41          * evaluated in context of a stack frame, thread, or a symbol context.   
    40          */
    42          */
    41         String getExpression();
    43         String getExpression();
    42     }
    44     }
    43     
    45 
       
    46 
    44     /**
    47     /**
    45      * The address and size of an expression.
    48      * The address and size of an expression.
    46      */
    49      */
    47     public interface IExpressionDMAddress {
    50     public interface IExpressionDMAddress {
    48     	Object getAddress();
    51         
       
    52         /**
       
    53          * Returns the address of the expression.
       
    54          */
       
    55     	IAddress getAddress();
       
    56     	
       
    57     	/**
       
    58     	 * Returns the size of the address.
       
    59     	 */
    49     	int getSize();
    60     	int getSize();
    50     }
    61     }
       
    62  
       
    63     /**
       
    64      * A representation of an expression location that does not correspond to 
       
    65      * an address.  
       
    66      * 
       
    67      * @since 2.1
       
    68      */
       
    69     public interface IExpressionDMLocation extends IExpressionDMAddress {
       
    70         
       
    71         /**
       
    72          * A constant that can be returned by {@link IExpressionDMAddress#getAddress()}
       
    73          * to represent an invalid address.  Implementations of 
       
    74          * <code>IExpressionDMLocation</code> can return this constant if no  
       
    75          * valid address can be returned for a given expression location.  
       
    76          */
       
    77         public static final IAddress INVALID_ADDRESS = new IAddress() {
       
    78             public IAddress add(BigInteger offset) { return this; }
       
    79             public IAddress add(long offset) { return this; }
       
    80             public BigInteger getMaxOffset() { return BigInteger.ZERO; }
       
    81             public BigInteger distanceTo(IAddress other) { return BigInteger.ZERO; }
       
    82             public BigInteger getValue() { return BigInteger.ZERO; }
       
    83             public boolean isZero() { return false; }
       
    84             public boolean isMax() { return false; }
       
    85             public String toString(int radix) { return "INVALID"; }
       
    86             public String toHexAddressString() { return toString(); }
       
    87             public String toBinaryAddressString()  { return toString(); }
       
    88             public int getCharsNum() { return 0; }
       
    89             public int getSize() { return 0; }
       
    90             public int compareTo(Object o) { return 0; }
       
    91         };
       
    92         
       
    93         /**
       
    94          * Returns a string representation of the expression location.
       
    95          */
       
    96     	public String getLocation();
       
    97     }
       
    98 
       
    99     
    51     
   100     
    52     /**
   101     /**
    53      * This is the model data interface that corresponds to IExpressionDMContext.
   102      * This is the model data interface that corresponds to IExpressionDMContext.
    54      */
   103      */
    55     public interface IExpressionDMData extends IDMData {
   104     public interface IExpressionDMData extends IDMData {
   137     void getExpressionData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMData> rm);
   186     void getExpressionData(IExpressionDMContext dmc, DataRequestMonitor<IExpressionDMData> rm);
   138 
   187 
   139     /**
   188     /**
   140      * Retrieves the address and size of an expression given by the expression context(<tt>dmc</tt>).
   189      * Retrieves the address and size of an expression given by the expression context(<tt>dmc</tt>).
   141      * Non-lvalues do not have an addresses (e.g., "x + 5").  When the expression
   190      * Non-lvalues do not have an addresses (e.g., "x + 5").  When the expression
   142 -    * has no address, the data request monitor will contain null.
   191 -    * has no address, the request monitor will have an error with code 
       
   192      * <code>IDsfStatusConstants.REQUEST_FAILED</code> and the data request
       
   193      * monitor will contain null.
   143      * 
   194      * 
   144      * @param dmc
   195      * @param dmc
   145      *            The ExpressionDMC for the expression
   196      *            The ExpressionDMC for the expression
   146      * @param rm
   197      * @param rm
   147      *            The data request monitor that will contain the requested data
   198      *            The data request monitor that will contain the requested data
   155      * @param ctx: Context in which to evaluate the expression.  This context could include the
   206      * @param ctx: Context in which to evaluate the expression.  This context could include the
   156      * PC location, stack frame, thread, or just a symbol context.
   207      * PC location, stack frame, thread, or just a symbol context.
   157      *                
   208      *                
   158      * @param expression: The expression to evaluate.
   209      * @param expression: The expression to evaluate.
   159      * 
   210      * 
   160      * @return  An expression data model context object that must be passed to 
   211      * @return  An expression data model context object that must be passed to the appropriate
   161      * getModelData() to obtain the value of the expression. 
   212      *          data retrieval routine to obtain the value of the expression.
   162      */
   213      */
   163     IExpressionDMContext createExpression(IDMContext ctx, String expression);
   214     IExpressionDMContext createExpression(IDMContext ctx, String expression);
   164 
   215 
   165     /**
   216     /**
   166      * Retrieves the sub-expressions of the given expression.  Sub-expressions are fields of a struct, union,
   217      * Retrieves the sub-expressions of the given expression.  Sub-expressions are fields of a struct, union,
   167      * or class, the enumerators of an enumeration, and the element of an array.
   218      * or class, the enumerators of an enumeration, and the element of an array.
       
   219      * <br> 
       
   220      * Note: Clients may call this method on any valid expression context, and before calling any other
       
   221      * method to evaluate the expression value.  It is up to the implementation to internally evaluate the 
       
   222      * expression if needed, in order to calculate sub expressions.    
   168      * 
   223      * 
   169      * @param exprCtx: The data model context representing an expression.
   224      * @param exprCtx: The data model context representing an expression.
   170      * 
   225      * 
   171      * @param rm: Request completion monitor containing an array of all sub-expressions   
   226      * @param rm: Request completion monitor containing an array of all sub-expressions   
   172      */
   227      */
   174 
   229 
   175     /**
   230     /**
   176      * Retrieves a particular range of sub-expressions of the given expression.  
   231      * Retrieves a particular range of sub-expressions of the given expression.  
   177      * Sub-expressions are fields of a struct, union, or class, the enumerators 
   232      * Sub-expressions are fields of a struct, union, or class, the enumerators 
   178      * of an enumeration, and the element of an array.
   233      * of an enumeration, and the element of an array.
       
   234      * <br> 
       
   235      * Note: Clients may call this method on any valid expression context, and before calling any other
       
   236      * method to evaluate the expression value.  It is up to the implementation to internally evaluate the 
       
   237      * expression if needed, in order to calculate sub expressions.    
   179      * 
   238      * 
   180      * @param exprCtx: The data model context representing an expression.
   239      * @param exprCtx: The data model context representing an expression.
   181      *        startIndex: Index of the first sub-expression to retrieve
   240      *        startIndex: Index of the first sub-expression to retrieve
   182      *        length: Total number of sub-expressions to retrieve
   241      *        length: Total number of sub-expressions to retrieve
   183      * 
   242      * 
   188     		DataRequestMonitor<IExpressionDMContext[]> rm);
   247     		DataRequestMonitor<IExpressionDMContext[]> rm);
   189     
   248     
   190     /**
   249     /**
   191      * Retrieves the number of sub-expressions of the given expression.  Sub-expressions are fields of a struct, union,
   250      * Retrieves the number of sub-expressions of the given expression.  Sub-expressions are fields of a struct, union,
   192      * or class, the enumerators of an enumeration, and the element of an array.
   251      * or class, the enumerators of an enumeration, and the element of an array.
       
   252      * <br> 
       
   253      * Note: Clients may call this method on any valid expression context, and before calling any other
       
   254      * method to evaluate the expression value.  It is up to the implementation to internally evaluate the 
       
   255      * expression if needed, in order to calculate sub expressions.    
   193      * 
   256      * 
   194      * @param exprCtx: The data model context representing an expression.
   257      * @param exprCtx: The data model context representing an expression.
   195      * 
   258      * 
   196      * @param rm: Request completion monitor containing the number of sub-expressions
   259      * @param rm: Request completion monitor containing the number of sub-expressions
   197      *            of the specified expression
   260      *            of the specified expression
   199     void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor<Integer> rm);
   262     void getSubExpressionCount(IExpressionDMContext exprCtx, DataRequestMonitor<Integer> rm);
   200 
   263 
   201     /**
   264     /**
   202      * For object oriented languages, this method returns the expressions representing base types of
   265      * For object oriented languages, this method returns the expressions representing base types of
   203      * the given expression type.
   266      * the given expression type.
       
   267      * <br> 
       
   268      * Note: Clients may call this method on any valid expression context, and before calling any other
       
   269      * method to evaluate the expression value.  It is up to the implementation to internally evaluate the 
       
   270      * expression if needed, in order to calculate sub expressions.    
   204      * 
   271      * 
   205      * @param exprContext: The data model context representing an expression.
   272      * @param exprContext: The data model context representing an expression.
   206      * 
   273      * 
   207      * @param rm: Request completion monitor.
   274      * @param rm: Request completion monitor.
   208      */
   275      */