* gdb.base/attach.exp (do_attach_tests): Don't forget to kill second
[deliverable/binutils-gdb.git] / gdb / eval.c
index 914a552070405c6c48ce7c829dc59e172694fedf..b690a78da09e6807e5628b1dc22ff365c1839a29 100644 (file)
@@ -35,9 +35,7 @@
 #include "infcall.h"
 #include "objc-lang.h"
 #include "block.h"
-
-/* Defined in symtab.c */
-extern int hp_som_som_object_present;
+#include "parser-defs.h"
 
 /* This is defined in valops.c */
 extern int overload_resolution;
@@ -67,10 +65,11 @@ static LONGEST init_array_element (struct value *, struct value *,
                                   LONGEST, LONGEST);
 
 static struct value *
-evaluate_subexp (struct type *expect_type, register struct expression *exp,
-                register int *pos, enum noside noside)
+evaluate_subexp (struct type *expect_type, struct expression *exp,
+                int *pos, enum noside noside)
 {
-  return (*exp->language_defn->evaluate_exp) (expect_type, exp, pos, noside);
+  return (*exp->language_defn->la_exp_desc->evaluate_exp) 
+    (expect_type, exp, pos, noside);
 }
 \f
 /* Parse the string EXP as a C expression, evaluate it,
@@ -80,8 +79,8 @@ CORE_ADDR
 parse_and_eval_address (char *exp)
 {
   struct expression *expr = parse_expression (exp);
-  register CORE_ADDR addr;
-  register struct cleanup *old_chain =
+  CORE_ADDR addr;
+  struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
 
   addr = value_as_address (evaluate_expression (expr));
@@ -96,8 +95,8 @@ CORE_ADDR
 parse_and_eval_address_1 (char **expptr)
 {
   struct expression *expr = parse_exp_1 (expptr, (struct block *) 0, 0);
-  register CORE_ADDR addr;
-  register struct cleanup *old_chain =
+  CORE_ADDR addr;
+  struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
 
   addr = value_as_address (evaluate_expression (expr));
@@ -111,8 +110,8 @@ LONGEST
 parse_and_eval_long (char *exp)
 {
   struct expression *expr = parse_expression (exp);
-  register LONGEST retval;
-  register struct cleanup *old_chain =
+  LONGEST retval;
+  struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
 
   retval = value_as_long (evaluate_expression (expr));
@@ -125,7 +124,7 @@ parse_and_eval (char *exp)
 {
   struct expression *expr = parse_expression (exp);
   struct value *val;
-  register struct cleanup *old_chain =
+  struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
 
   val = evaluate_expression (expr);
@@ -142,7 +141,7 @@ parse_to_comma_and_eval (char **expp)
 {
   struct expression *expr = parse_exp_1 (expp, (struct block *) 0, 1);
   struct value *val;
-  register struct cleanup *old_chain =
+  struct cleanup *old_chain =
     make_cleanup (free_current_contents, &expr);
 
   val = evaluate_expression (expr);
@@ -176,7 +175,7 @@ evaluate_type (struct expression *exp)
    returning the label.  Otherwise, does nothing and returns NULL. */
 
 static char *
-get_label (register struct expression *exp, int *pos)
+get_label (struct expression *exp, int *pos)
 {
   if (exp->elts[*pos].opcode == OP_LABELED)
     {
@@ -195,8 +194,8 @@ get_label (register struct expression *exp, int *pos)
 
 static struct value *
 evaluate_struct_tuple (struct value *struct_val,
-                      register struct expression *exp,
-                      register int *pos, enum noside noside, int nargs)
+                      struct expression *exp,
+                      int *pos, enum noside noside, int nargs)
 {
   struct type *struct_type = check_typedef (VALUE_TYPE (struct_val));
   struct type *substruct_type = struct_type;
@@ -225,7 +224,7 @@ evaluate_struct_tuple (struct value *struct_val,
                   fieldno++)
                {
                  char *field_name = TYPE_FIELD_NAME (struct_type, fieldno);
-                 if (field_name != NULL && STREQ (field_name, label))
+                 if (field_name != NULL && DEPRECATED_STREQ (field_name, label))
                    {
                      variantno = -1;
                      subfieldno = fieldno;
@@ -253,7 +252,7 @@ evaluate_struct_tuple (struct value *struct_val,
                                 subfieldno < TYPE_NFIELDS (substruct_type);
                                   subfieldno++)
                                {
-                                 if (STREQ (TYPE_FIELD_NAME (substruct_type,
+                                 if (DEPRECATED_STREQ (TYPE_FIELD_NAME (substruct_type,
                                                              subfieldno),
                                             label))
                                    {
@@ -338,7 +337,7 @@ evaluate_struct_tuple (struct value *struct_val,
 
 static LONGEST
 init_array_element (struct value *array, struct value *element,
-                   register struct expression *exp, register int *pos,
+                   struct expression *exp, int *pos,
                    enum noside noside, LONGEST low_bound, LONGEST high_bound)
 {
   LONGEST index;
@@ -379,12 +378,12 @@ init_array_element (struct value *array, struct value *element,
 
 struct value *
 evaluate_subexp_standard (struct type *expect_type,
-                         register struct expression *exp, register int *pos,
+                         struct expression *exp, int *pos,
                          enum noside noside)
 {
   enum exp_opcode op;
   int tem, tem2, tem3;
-  register int pc, pc2 = 0, oldpos;
+  int pc, pc2 = 0, oldpos;
   struct value *arg1 = NULL;
   struct value *arg2 = NULL;
   struct value *arg3;
@@ -406,11 +405,9 @@ evaluate_subexp_standard (struct type *expect_type,
     case OP_SCOPE:
       tem = longest_to_int (exp->elts[pc + 2].longconst);
       (*pos) += 4 + BYTES_TO_EXP_ELEM (tem + 1);
-      arg1 = value_struct_elt_for_reference (exp->elts[pc + 1].type,
-                                            0,
-                                            exp->elts[pc + 1].type,
-                                            &exp->elts[pc + 3].string,
-                                            NULL_TYPE);
+      arg1 = value_aggregate_elt (exp->elts[pc + 1].type,
+                                 &exp->elts[pc + 3].string,
+                                 noside);
       if (arg1 == NULL)
        error ("There is no field named %s", &exp->elts[pc + 3].string);
       return arg1;
@@ -697,10 +694,10 @@ evaluate_subexp_standard (struct type *expect_type,
     case OP_OBJC_MSGCALL:
       {                                /* Objective C message (method) call.  */
 
-       static unsigned long responds_selector = 0;
-       static unsigned long method_selector = 0;
+       static CORE_ADDR responds_selector = 0;
+       static CORE_ADDR method_selector = 0;
 
-       unsigned long selector = 0;
+       CORE_ADDR selector = 0;
 
        int using_gcc = 0;
        int struct_return = 0;
@@ -750,8 +747,19 @@ evaluate_subexp_standard (struct type *expect_type,
           only).  */
        if (gnu_runtime)
          {
+           struct type *type;
+           type = lookup_pointer_type (builtin_type_void);
+           type = lookup_function_type (type);
+           type = lookup_pointer_type (type);
+           type = lookup_function_type (type);
+           type = lookup_pointer_type (type);
+
            msg_send = find_function_in_inferior ("objc_msg_lookup");
            msg_send_stret = find_function_in_inferior ("objc_msg_lookup");
+
+           msg_send = value_from_pointer (type, value_as_address (msg_send));
+           msg_send_stret = value_from_pointer (type, 
+                                       value_as_address (msg_send_stret));
          }
        else
          {
@@ -855,11 +863,11 @@ evaluate_subexp_standard (struct type *expect_type,
                  value_type = expect_type;
              }
 
-           struct_return = using_struct_return (method, funaddr, value_type, using_gcc);
+           struct_return = using_struct_return (value_type, using_gcc);
          }
        else if (expect_type != NULL)
          {
-           struct_return = using_struct_return (NULL, addr, check_typedef (expect_type), using_gcc);
+           struct_return = using_struct_return (check_typedef (expect_type), using_gcc);
          }
        
        /* Found a function symbol.  Now we will substitute its
@@ -936,14 +944,13 @@ evaluate_subexp_standard (struct type *expect_type,
 
        if (gnu_runtime && (method != NULL))
          {
-           ret = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
            /* Function objc_msg_lookup returns a pointer.  */
-           argvec[0] = ret;
-           ret = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
+           VALUE_TYPE (argvec[0]) = lookup_function_type 
+                           (lookup_pointer_type (VALUE_TYPE (argvec[0])));
+           argvec[0] = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
          }
-       else
-         ret = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
 
+       ret = call_function_by_hand (argvec[0], nargs + 2, argvec + 1);
        return ret;
       }
       break;
@@ -962,7 +969,7 @@ evaluate_subexp_standard (struct type *expect_type,
          /* 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 (hp_som_som_object_present)
+         if (deprecated_hp_som_som_object_present)
            {
              error ("Not implemented: function invocation through pointer to method with HP aCC");
            }
@@ -1358,7 +1365,7 @@ evaluate_subexp_standard (struct type *expect_type,
       arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
 
       /* With HP aCC, pointers to methods do not point to the function code */
-      if (hp_som_som_object_present &&
+      if (deprecated_hp_som_som_object_present &&
          (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) &&
       (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
        error ("Pointers to methods not supported with HP aCC");        /* 1997-08-19 */
@@ -1371,7 +1378,7 @@ evaluate_subexp_standard (struct type *expect_type,
       arg2 = evaluate_subexp (NULL_TYPE, exp, pos, noside);
 
       /* With HP aCC, pointers to methods do not point to the function code */
-      if (hp_som_som_object_present &&
+      if (deprecated_hp_som_som_object_present &&
          (TYPE_CODE (VALUE_TYPE (arg2)) == TYPE_CODE_PTR) &&
       (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (arg2))) == TYPE_CODE_METHOD))
        error ("Pointers to methods not supported with HP aCC");        /* 1997-08-19 */
@@ -1381,7 +1388,7 @@ evaluate_subexp_standard (struct type *expect_type,
     handle_pointer_to_member:
       /* HP aCC generates offsets that have bit #29 set; turn it off to get
          a real offset to the member. */
-      if (hp_som_som_object_present)
+      if (deprecated_hp_som_som_object_present)
        {
          if (!mem_offset)      /* no bias -> really null */
            error ("Attempted dereference of null pointer-to-member");
@@ -1421,7 +1428,7 @@ evaluate_subexp_standard (struct type *expect_type,
       arg2 = evaluate_subexp (VALUE_TYPE (arg1), exp, pos, noside);
 
       /* Do special stuff for HP aCC pointers to members */
-      if (hp_som_som_object_present)
+      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
@@ -1924,7 +1931,7 @@ evaluate_subexp_standard (struct type *expect_type,
        {
          struct value *retvalp = evaluate_subexp_for_address (exp, pos, noside);
          /* If HP aCC object, use bias for pointers to members */
-         if (hp_som_som_object_present &&
+         if (deprecated_hp_som_som_object_present &&
              (TYPE_CODE (VALUE_TYPE (retvalp)) == TYPE_CODE_PTR) &&
              (TYPE_CODE (TYPE_TARGET_TYPE (VALUE_TYPE (retvalp))) == TYPE_CODE_MEMBER))
            {
@@ -2063,11 +2070,11 @@ nosideret:
    then only the type of the result need be correct.  */
 
 static struct value *
-evaluate_subexp_for_address (register struct expression *exp, register int *pos,
+evaluate_subexp_for_address (struct expression *exp, int *pos,
                             enum noside noside)
 {
   enum exp_opcode op;
-  register int pc;
+  int pc;
   struct symbol *var;
 
   pc = (*pos);
@@ -2143,11 +2150,11 @@ evaluate_subexp_for_address (register struct expression *exp, register int *pos,
  */
 
 struct value *
-evaluate_subexp_with_coercion (register struct expression *exp,
-                              register int *pos, enum noside noside)
+evaluate_subexp_with_coercion (struct expression *exp,
+                              int *pos, enum noside noside)
 {
-  register enum exp_opcode op;
-  register int pc;
+  enum exp_opcode op;
+  int pc;
   struct value *val;
   struct symbol *var;
 
@@ -2180,10 +2187,10 @@ evaluate_subexp_with_coercion (register struct expression *exp,
    Advance *POS over the subexpression.  */
 
 static struct value *
-evaluate_subexp_for_sizeof (register struct expression *exp, register int *pos)
+evaluate_subexp_for_sizeof (struct expression *exp, int *pos)
 {
   enum exp_opcode op;
-  register int pc;
+  int pc;
   struct type *type;
   struct value *val;
 
This page took 0.063173 seconds and 4 git commands to generate.