2002-08-21 Andrew Cagney <ac131313@redhat.com>
[deliverable/binutils-gdb.git] / gdb / ax-gdb.c
index 2e2d0f23d54c0b6dad96a451a646128d934ecca3..368b9df12a1d92eb30bec3ea7c42cce6014a7359 100644 (file)
@@ -1,5 +1,5 @@
 /* GDB-specific functions for operating on agent expressions
-   Copyright 1998, 2000 Free Software Foundation, Inc.
+   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -353,7 +353,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
 {
   /* Do we need to sign-extend this?  */
   if (!TYPE_UNSIGNED (type))
-    ax_ext (ax, type->length * TARGET_CHAR_BIT);
+    ax_ext (ax, TYPE_LENGTH (type) * TARGET_CHAR_BIT);
 }
 
 
@@ -363,7 +363,7 @@ gen_sign_extend (struct agent_expr *ax, struct type *type)
 static void
 gen_extend (struct agent_expr *ax, struct type *type)
 {
-  int bits = type->length * TARGET_CHAR_BIT;
+  int bits = TYPE_LENGTH (type) * TARGET_CHAR_BIT;
   /* I just had to.  */
   ((TYPE_UNSIGNED (type) ? ax_zero_ext : ax_ext) (ax, bits));
 }
@@ -381,7 +381,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
       ax_trace_quick (ax, TYPE_LENGTH (type));
     }
 
-  switch (type->code)
+  switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
     case TYPE_CODE_ENUM:
@@ -389,7 +389,7 @@ gen_fetch (struct agent_expr *ax, struct type *type)
     case TYPE_CODE_CHAR:
       /* It's a scalar value, so we know how to dereference it.  How
          many bytes long is it?  */
-      switch (type->length)
+      switch (TYPE_LENGTH (type))
        {
        case 8 / TARGET_CHAR_BIT:
          ax_simple (ax, aop_ref8);
@@ -409,7 +409,8 @@ gen_fetch (struct agent_expr *ax, struct type *type)
             implementing something we should be (this code's fault).
             In any case, it's a bug the user shouldn't see.  */
        default:
-         internal_error ("ax-gdb.c (gen_fetch): strange size");
+         internal_error (__FILE__, __LINE__,
+                         "gen_fetch: strange size");
        }
 
       gen_sign_extend (ax, type);
@@ -420,7 +421,8 @@ gen_fetch (struct agent_expr *ax, struct type *type)
          pointer (other code's fault), or we're not implementing
          something we should be (this code's fault).  In any case,
          it's a bug the user shouldn't see.  */
-      internal_error ("ax-gdb.c (gen_fetch): bad type code");
+      internal_error (__FILE__, __LINE__,
+                     "gen_fetch: bad type code");
     }
 }
 
@@ -452,7 +454,8 @@ gen_left_shift (struct agent_expr *ax, int distance)
 static void
 gen_frame_args_address (struct agent_expr *ax)
 {
-  long frame_reg, frame_offset;
+  int frame_reg;
+  LONGEST frame_offset;
 
   TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset);
   ax_reg (ax, frame_reg);
@@ -465,7 +468,8 @@ gen_frame_args_address (struct agent_expr *ax)
 static void
 gen_frame_locals_address (struct agent_expr *ax)
 {
-  long frame_reg, frame_offset;
+  int frame_reg;
+  LONGEST frame_offset;
 
   TARGET_VIRTUAL_FRAME_POINTER (ax->scope, &frame_reg, &frame_offset);
   ax_reg (ax, frame_reg);
@@ -530,7 +534,8 @@ gen_var_ref (struct agent_expr *ax, struct axs_value *value, struct symbol *var)
       break;
 
     case LOC_CONST_BYTES:
-      internal_error ("ax-gdb.c (gen_var_ref): LOC_CONST_BYTES symbols are not supported");
+      internal_error (__FILE__, __LINE__,
+                     "gen_var_ref: LOC_CONST_BYTES symbols are not supported");
 
       /* Variable at a fixed location in memory.  Easy.  */
     case LOC_STATIC:
@@ -694,7 +699,7 @@ gen_usual_unary (struct agent_expr *ax, struct axs_value *value)
      the stack.  Should we tweak the type?  */
 
   /* Some types require special handling.  */
-  switch (value->type->code)
+  switch (TYPE_CODE (value->type))
     {
       /* Functions get converted to a pointer to the function.  */
     case TYPE_CODE_FUNC:
@@ -869,7 +874,7 @@ gen_cast (struct agent_expr *ax, struct axs_value *value, struct type *type)
   /* Dereference typedefs. */
   type = check_typedef (type);
 
-  switch (type->code)
+  switch (TYPE_CODE (type))
     {
     case TYPE_CODE_PTR:
       /* It's implementation-defined, and I'll bet this is what GCC
@@ -920,9 +925,9 @@ gen_scale (struct agent_expr *ax, enum agent_op op, struct type *type)
 {
   struct type *element = TYPE_TARGET_TYPE (type);
 
-  if (element->length != 1)
+  if (TYPE_LENGTH (element) != 1)
     {
-      ax_const_l (ax, element->length);
+      ax_const_l (ax, TYPE_LENGTH (element));
       ax_simple (ax, op);
     }
 }
@@ -938,8 +943,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
         struct axs_value *value1, struct axs_value *value2, char *name)
 {
   /* Is it INT+PTR?  */
-  if (value1->type->code == TYPE_CODE_INT
-      && value2->type->code == TYPE_CODE_PTR)
+  if (TYPE_CODE (value1->type) == TYPE_CODE_INT
+      && TYPE_CODE (value2->type) == TYPE_CODE_PTR)
     {
       /* Swap the values and proceed normally.  */
       ax_simple (ax, aop_swap);
@@ -950,8 +955,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
     }
 
   /* Is it PTR+INT?  */
-  else if (value1->type->code == TYPE_CODE_PTR
-          && value2->type->code == TYPE_CODE_INT)
+  else if (TYPE_CODE (value1->type) == TYPE_CODE_PTR
+          && TYPE_CODE (value2->type) == TYPE_CODE_INT)
     {
       gen_scale (ax, aop_mul, value1->type);
       ax_simple (ax, aop_add);
@@ -961,8 +966,8 @@ gen_add (struct agent_expr *ax, struct axs_value *value,
 
   /* Must be number + number; the usual binary conversions will have
      brought them both to the same width.  */
-  else if (value1->type->code == TYPE_CODE_INT
-          && value2->type->code == TYPE_CODE_INT)
+  else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
+          && TYPE_CODE (value2->type) == TYPE_CODE_INT)
     {
       ax_simple (ax, aop_add);
       gen_extend (ax, value1->type);   /* Catch overflow.  */
@@ -984,10 +989,10 @@ static void
 gen_sub (struct agent_expr *ax, struct axs_value *value,
         struct axs_value *value1, struct axs_value *value2)
 {
-  if (value1->type->code == TYPE_CODE_PTR)
+  if (TYPE_CODE (value1->type) == TYPE_CODE_PTR)
     {
       /* Is it PTR - INT?  */
-      if (value2->type->code == TYPE_CODE_INT)
+      if (TYPE_CODE (value2->type) == TYPE_CODE_INT)
        {
          gen_scale (ax, aop_mul, value1->type);
          ax_simple (ax, aop_sub);
@@ -998,7 +1003,7 @@ gen_sub (struct agent_expr *ax, struct axs_value *value,
       /* Is it PTR - PTR?  Strictly speaking, the types ought to
          match, but this is what the normal GDB expression evaluator
          tests for.  */
-      else if (value2->type->code == TYPE_CODE_PTR
+      else if (TYPE_CODE (value2->type) == TYPE_CODE_PTR
               && (TYPE_LENGTH (TYPE_TARGET_TYPE (value1->type))
                   == TYPE_LENGTH (TYPE_TARGET_TYPE (value2->type))))
        {
@@ -1013,8 +1018,8 @@ an integer nor a pointer of the same type.");
     }
 
   /* Must be number + number.  */
-  else if (value1->type->code == TYPE_CODE_INT
-          && value2->type->code == TYPE_CODE_INT)
+  else if (TYPE_CODE (value1->type) == TYPE_CODE_INT
+          && TYPE_CODE (value2->type) == TYPE_CODE_INT)
     {
       ax_simple (ax, aop_sub);
       gen_extend (ax, value1->type);   /* Catch overflow.  */
@@ -1039,8 +1044,8 @@ gen_binop (struct agent_expr *ax, struct axs_value *value,
           enum agent_op op_unsigned, int may_carry, char *name)
 {
   /* We only handle INT op INT.  */
-  if ((value1->type->code != TYPE_CODE_INT)
-      || (value2->type->code != TYPE_CODE_INT))
+  if ((TYPE_CODE (value1->type) != TYPE_CODE_INT)
+      || (TYPE_CODE (value2->type) != TYPE_CODE_INT))
     error ("Illegal combination of types in %s.", name);
 
   ax_simple (ax,
@@ -1087,8 +1092,9 @@ gen_deref (struct agent_expr *ax, struct axs_value *value)
 {
   /* The caller should check the type, because several operators use
      this, and we don't know what error message to generate.  */
-  if (value->type->code != TYPE_CODE_PTR)
-    internal_error ("ax-gdb.c (gen_deref): expected a pointer");
+  if (TYPE_CODE (value->type) != TYPE_CODE_PTR)
+    internal_error (__FILE__, __LINE__,
+                   "gen_deref: expected a pointer");
 
   /* We've got an rvalue now, which is a pointer.  We want to yield an
      lvalue, whose address is exactly that pointer.  So we don't
@@ -1096,7 +1102,7 @@ gen_deref (struct agent_expr *ax, struct axs_value *value)
      T" to "T", and mark the value as an lvalue in memory.  Leave it
      to the consumer to actually dereference it.  */
   value->type = check_typedef (TYPE_TARGET_TYPE (value->type));
-  value->kind = ((value->type->code == TYPE_CODE_FUNC)
+  value->kind = ((TYPE_CODE (value->type) == TYPE_CODE_FUNC)
                 ? axs_rvalue : axs_lvalue_memory);
 }
 
@@ -1108,7 +1114,7 @@ gen_address_of (struct agent_expr *ax, struct axs_value *value)
   /* Special case for taking the address of a function.  The ANSI
      standard describes this as a special case, too, so this
      arrangement is not without motivation.  */
-  if (value->type->code == TYPE_CODE_FUNC)
+  if (TYPE_CODE (value->type) == TYPE_CODE_FUNC)
     /* The value's already an rvalue on the stack, so we just need to
        change the type.  */
     value->type = lookup_pointer_type (value->type);
@@ -1143,7 +1149,8 @@ find_field (struct type *type, char *name)
 
   /* Make sure this isn't C++.  */
   if (TYPE_N_BASECLASSES (type) != 0)
-    internal_error ("ax-gdb.c (find_field): derived classes supported");
+    internal_error (__FILE__, __LINE__,
+                   "find_field: derived classes supported");
 
   for (i = 0; i < TYPE_NFIELDS (type); i++)
     {
@@ -1153,11 +1160,12 @@ find_field (struct type *type, char *name)
        return i;
 
       if (this_name[0] == '\0')
-       internal_error ("ax-gdb.c (find_field): anonymous unions not supported");
+       internal_error (__FILE__, __LINE__,
+                       "find_field: anonymous unions not supported");
     }
 
   error ("Couldn't find member named `%s' in struct/union `%s'",
-        name, type->tag_name);
+        name, TYPE_TAG_NAME (type));
 
   return 0;
 }
@@ -1225,7 +1233,8 @@ gen_bitfield_ref (struct agent_expr *ax, struct axs_value *value,
 
   /* Can we fetch the number of bits requested at all?  */
   if ((end - start) > ((1 << num_ops) * 8))
-    internal_error ("ax-gdb.c (gen_bitfield_ref): bitfield too wide");
+    internal_error (__FILE__, __LINE__,
+                   "gen_bitfield_ref: bitfield too wide");
 
   /* Note that we know here that we only need to try each opcode once.
      That may not be true on machines with weird byte sizes.  */
@@ -1294,7 +1303,7 @@ gen_bitfield_ref (struct agent_expr *ax, struct axs_value *value,
             the sign/zero extension will wipe them out.
             - If we're in the interior of the word, then there is no garbage
             on either end, because the ref operators zero-extend.  */
-         if (TARGET_BYTE_ORDER == BIG_ENDIAN)
+         if (TARGET_BYTE_ORDER == BFD_ENDIAN_BIG)
            gen_left_shift (ax, end - (offset + op_size));
          else
            gen_left_shift (ax, offset - start);
@@ -1337,12 +1346,12 @@ gen_struct_ref (struct agent_expr *ax, struct axs_value *value, char *field,
   /* Follow pointers until we reach a non-pointer.  These aren't the C
      semantics, but they're what the normal GDB evaluator does, so we
      should at least be consistent.  */
-  while (value->type->code == TYPE_CODE_PTR)
+  while (TYPE_CODE (value->type) == TYPE_CODE_PTR)
     {
       gen_usual_unary (ax, value);
       gen_deref (ax, value);
     }
-  type = value->type;
+  type = check_typedef (value->type);
 
   /* This must yield a structure or a union.  */
   if (TYPE_CODE (type) != TYPE_CODE_STRUCT
@@ -1401,7 +1410,7 @@ gen_repeat (union exp_element **pc, struct agent_expr *ax,
 
     if (!v)
       error ("Right operand of `@' must be a constant, in agent expressions.");
-    if (v->type->code != TYPE_CODE_INT)
+    if (TYPE_CODE (v->type) != TYPE_CODE_INT)
       error ("Right operand of `@' must be an integer.");
     length = value_as_long (v);
     if (length <= 0)
@@ -1535,7 +1544,8 @@ gen_expr (union exp_element **pc, struct agent_expr *ax,
        default:
          /* We should only list operators in the outer case statement
             that we actually handle in the inner case statement.  */
-         internal_error ("ax-gdb.c (gen_expr): op case sets don't match");
+         internal_error (__FILE__, __LINE__,
+                         "gen_expr: op case sets don't match");
        }
       break;
 
@@ -1610,7 +1620,8 @@ gen_expr (union exp_element **pc, struct agent_expr *ax,
           the given type, and dereference it.  */
        if (value->kind != axs_rvalue)
          /* This would be weird.  */
-         internal_error ("ax-gdb.c (gen_expr): OP_MEMVAL operand isn't an rvalue???");
+         internal_error (__FILE__, __LINE__,
+                         "gen_expr: OP_MEMVAL operand isn't an rvalue???");
        value->type = type;
        value->kind = axs_lvalue_memory;
       }
@@ -1678,7 +1689,8 @@ gen_expr (union exp_element **pc, struct agent_expr *ax,
        else
          /* If this `if' chain doesn't handle it, then the case list
             shouldn't mention it, and we shouldn't be here.  */
-         internal_error ("ax-gdb.c (gen_expr): unhandled struct case");
+         internal_error (__FILE__, __LINE__,
+                         "gen_expr: unhandled struct case");
       }
       break;
 
This page took 0.051529 seconds and 4 git commands to generate.