* corelow.c (core_xfer_partial): Pass writebuf to
[deliverable/binutils-gdb.git] / gdb / eval.c
index 1a3d72a547834021172a9043a2e40990f3dd6515..0fb320e4474c9faa074f5d05e77b27046e5e44c8 100644 (file)
@@ -1,14 +1,14 @@
 /* Evaluate expressions for GDB.
 
-   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
-   1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006
+   Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1995,
+   1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2005, 2006, 2007
    Free Software Foundation, Inc.
 
    This file is part of GDB.
 
    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
-   the Free Software Foundation; either version 2 of the License, or
+   the Free Software Foundation; either version 3 of the License, or
    (at your option) any later version.
 
    This program is distributed in the hope that it will be useful,
@@ -17,9 +17,7 @@
    GNU General Public License for more details.
 
    You should have received a copy of the GNU General Public License
-   along with this program; if not, write to the Free Software
-   Foundation, Inc., 51 Franklin Street, Fifth Floor,
-   Boston, MA 02110-1301, USA.  */
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include "defs.h"
 #include "gdb_string.h"
@@ -37,6 +35,9 @@
 #include "block.h"
 #include "parser-defs.h"
 #include "cp-support.h"
+#include "ui-out.h"
+#include "exceptions.h"
+#include "regcache.h"
 
 #include "gdb_assert.h"
 
@@ -469,8 +470,26 @@ evaluate_subexp_standard (struct type *expect_type,
         value_rtti_target_type () if we are dealing with a pointer
         or reference to a base class and print object is on. */
 
-       return value_of_variable (exp->elts[pc + 2].symbol,
-                                 exp->elts[pc + 1].block);
+      {
+       volatile struct gdb_exception except;
+       struct value *ret = NULL;
+
+       TRY_CATCH (except, RETURN_MASK_ERROR)
+         {
+           ret = value_of_variable (exp->elts[pc + 2].symbol,
+                                    exp->elts[pc + 1].block);
+         }
+
+       if (except.reason < 0)
+         {
+           if (noside == EVAL_AVOID_SIDE_EFFECTS)
+             ret = value_zero (SYMBOL_TYPE (exp->elts[pc + 2].symbol), not_lval);
+           else
+             throw_exception (except);
+         }
+
+       return ret;
+      }
 
     case OP_LAST:
       (*pos) += 2;
@@ -479,12 +498,21 @@ evaluate_subexp_standard (struct type *expect_type,
 
     case OP_REGISTER:
       {
-       int regno = longest_to_int (exp->elts[pc + 1].longconst);
-       struct value *val = value_of_register (regno, get_selected_frame (NULL));
-       (*pos) += 2;
+       const char *name = &exp->elts[pc + 2].string;
+       int regno;
+       struct value *val;
+
+       (*pos) += 3 + BYTES_TO_EXP_ELEM (exp->elts[pc + 1].longconst + 1);
+       regno = frame_map_name_to_regnum (deprecated_safe_get_selected_frame (),
+                                         name, strlen (name));
+       if (regno == -1)
+         error (_("Register $%s not available."), name);
+       if (noside == EVAL_AVOID_SIDE_EFFECTS)
+         val = value_zero (register_type (current_gdbarch, regno), not_lval);
+       else
+         val = value_of_register (regno, get_selected_frame (NULL));
        if (val == NULL)
-         error (_("Value of register %s not available."),
-                frame_map_regnum_to_name (get_selected_frame (NULL), regno));
+         error (_("Value of register %s not available."), name);
        else
          return val;
       }
@@ -997,14 +1025,6 @@ evaluate_subexp_standard (struct type *expect_type,
       argvec = (struct value **) alloca (sizeof (struct value *) * (nargs + 3));
       if (op == STRUCTOP_MEMBER || op == STRUCTOP_MPTR)
        {
-         /* 1997-08-01 Currently we do not support function invocation
-            via pointers-to-methods with HP aCC. Pointer does not point
-            to the function, but possibly to some thunk. */
-         if (deprecated_hp_som_som_object_present)
-           {
-             error (_("Not implemented: function invocation through pointer to method with HP aCC"));
-           }
-
          nargs++;
          /* First, evaluate the structure into arg2 */
          pc2 = (*pos)++;
@@ -1390,14 +1410,6 @@ evaluate_subexp_standard (struct type *expect_type,
       switch (TYPE_CODE (type))
        {
        case TYPE_CODE_METHODPTR:
-         if (deprecated_hp_som_som_object_present)
-           {
-             /* With HP aCC, pointers to methods do not point to the
-                function code.  */
-             /* 1997-08-19 */
-             error (_("Pointers to methods not supported with HP aCC"));
-           }
-
          if (noside == EVAL_AVOID_SIDE_EFFECTS)
            return value_zero (TYPE_TARGET_TYPE (type), not_lval);
          else
@@ -1413,14 +1425,6 @@ evaluate_subexp_standard (struct type *expect_type,
                             arg1);
 
          mem_offset = value_as_long (arg2);
-         if (deprecated_hp_som_som_object_present)
-           {
-             /* HP aCC generates offsets that have bit #29 set; turn it off to get
-                a real offset to the member. */
-             if (!mem_offset)  /* no bias -> really null */
-               error (_("Attempted dereference of null pointer-to-member"));
-             mem_offset &= ~0x20000000;
-           }
 
          arg3 = value_from_pointer (lookup_pointer_type (TYPE_TARGET_TYPE (type)),
                                     value_as_long (arg1) + mem_offset);
@@ -1444,24 +1448,6 @@ evaluate_subexp_standard (struct type *expect_type,
       arg1 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
       arg2 = evaluate_subexp (value_type (arg1), exp, pos, noside);
 
-      /* Do special stuff for HP aCC pointers to members */
-      if (deprecated_hp_som_som_object_present)
-       {
-         /* 1997-08-19 Can't assign HP aCC pointers to methods. No details of
-            the implementation yet; but the pointer appears to point to a code
-            sequence (thunk) in memory -- in any case it is *not* the address
-            of the function as it would be in a naive implementation. */
-         if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_METHODPTR)
-           error (_("Assignment to pointers to methods not implemented with HP aCC"));
-
-         /* HP aCC pointers to data members require a constant bias.  */
-         if (TYPE_CODE (value_type (arg1)) == TYPE_CODE_MEMBERPTR)
-           {
-             unsigned int *ptr = (unsigned int *) value_contents (arg2);       /* forces evaluation */
-             *ptr |= 0x20000000;       /* set 29th bit */
-           }
-       }
-
       if (noside == EVAL_SKIP || noside == EVAL_AVOID_SIDE_EFFECTS)
        return arg1;
       if (binop_user_defined_p (op, arg1, arg2))
@@ -1953,13 +1939,6 @@ evaluate_subexp_standard (struct type *expect_type,
       else
        {
          struct value *retvalp = evaluate_subexp_for_address (exp, pos, noside);
-         /* If HP aCC object, use bias for pointers to members */
-         if (deprecated_hp_som_som_object_present
-             && TYPE_CODE (value_type (retvalp)) == TYPE_CODE_MEMBERPTR)
-           {
-             unsigned int *ptr = (unsigned int *) value_contents (retvalp);    /* forces evaluation */
-             *ptr |= 0x20000000;       /* set 29th bit */
-           }
          return retvalp;
        }
 
This page took 0.036628 seconds and 4 git commands to generate.