arc: Fix ARI warning for printf(%p)
[deliverable/binutils-gdb.git] / gdb / dwarf2expr.c
index 214b371e569f083bdf9cf98a3cca120e299a4f58..7eb1982e5a580759bd11473d613b36b9d615e555 100644 (file)
@@ -1,7 +1,6 @@
 /* DWARF 2 Expression Evaluator.
 
-   Copyright (C) 2001-2003, 2005, 2007-2012 Free Software Foundation,
-   Inc.
+   Copyright (C) 2001-2016 Free Software Foundation, Inc.
 
    Contributed by Daniel Berlin (dan@dberlin.org)
 
@@ -27,7 +26,7 @@
 #include "gdbcore.h"
 #include "dwarf2.h"
 #include "dwarf2expr.h"
-#include "gdb_assert.h"
+#include "dwarf2loc.h"
 
 /* Local prototypes.  */
 
@@ -66,8 +65,9 @@ dwarf_gdbarch_types_init (struct gdbarch *gdbarch)
 static struct type *
 dwarf_expr_address_type (struct dwarf_expr_context *ctx)
 {
-  struct dwarf_gdbarch_types *types = gdbarch_data (ctx->gdbarch,
-                                                   dwarf_arch_cookie);
+  struct dwarf_gdbarch_types *types
+    = (struct dwarf_gdbarch_types *) gdbarch_data (ctx->gdbarch,
+                                                  dwarf_arch_cookie);
   int ndx;
 
   if (ctx->addr_size == 2)
@@ -96,11 +96,10 @@ new_dwarf_expr_context (void)
 {
   struct dwarf_expr_context *retval;
 
-  retval = xcalloc (1, sizeof (struct dwarf_expr_context));
+  retval = XCNEW (struct dwarf_expr_context);
   retval->stack_len = 0;
   retval->stack_allocated = 10;
-  retval->stack = xmalloc (retval->stack_allocated
-                          * sizeof (struct dwarf_stack_value));
+  retval->stack = XNEWVEC (struct dwarf_stack_value, retval->stack_allocated);
   retval->num_pieces = 0;
   retval->pieces = 0;
   retval->max_recursion_depth = 0x100;
@@ -122,7 +121,7 @@ free_dwarf_expr_context (struct dwarf_expr_context *ctx)
 static void
 free_dwarf_expr_context_cleanup (void *arg)
 {
-  free_dwarf_expr_context (arg);
+  free_dwarf_expr_context ((struct dwarf_expr_context *) arg);
 }
 
 /* Return a cleanup that calls free_dwarf_expr_context.  */
@@ -143,8 +142,7 @@ dwarf_expr_grow_stack (struct dwarf_expr_context *ctx, size_t need)
     {
       size_t newlen = ctx->stack_len + need + 10;
 
-      ctx->stack = xrealloc (ctx->stack,
-                            newlen * sizeof (struct dwarf_stack_value));
+      ctx->stack = XRESIZEVEC (struct dwarf_stack_value, ctx->stack, newlen);
       ctx->stack_allocated = newlen;
     }
 }
@@ -273,7 +271,7 @@ dwarf_expr_fetch_address (struct dwarf_expr_context *ctx, int n)
      for those architectures which require it.  */
   if (gdbarch_integer_to_address_p (ctx->gdbarch))
     {
-      gdb_byte *buf = alloca (ctx->addr_size);
+      gdb_byte *buf = (gdb_byte *) alloca (ctx->addr_size);
       struct type *int_type = get_unsigned_type (ctx->gdbarch,
                                                 value_type (result_val));
 
@@ -312,9 +310,8 @@ add_piece (struct dwarf_expr_context *ctx, ULONGEST size, ULONGEST offset)
 
   ctx->num_pieces++;
 
-  ctx->pieces = xrealloc (ctx->pieces,
-                         (ctx->num_pieces
-                          * sizeof (struct dwarf_expr_piece)));
+  ctx->pieces
+    = XRESIZEVEC (struct dwarf_expr_piece, ctx->pieces, ctx->num_pieces);
 
   p = &ctx->pieces[ctx->num_pieces - 1];
   p->location = ctx->location;
@@ -342,7 +339,7 @@ add_piece (struct dwarf_expr_context *ctx, ULONGEST size, ULONGEST offset)
     }
   else if (p->location == DWARF_VALUE_IMPLICIT_POINTER)
     {
-      p->v.ptr.die.cu_off = ctx->len;
+      p->v.ptr.die.sect_off = ctx->len;
       p->v.ptr.offset = value_as_long (dwarf_expr_fetch (ctx, 0));
     }
   else if (p->location == DWARF_VALUE_REGISTER)
@@ -615,7 +612,7 @@ dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
        return 0;
     }
 
-  if (gdbarch_dwarf2_reg_to_regnum (gdbarch, dwarf_reg)
+  if (dwarf_reg_to_regnum (gdbarch, dwarf_reg)
       != gdbarch_sp_regnum (gdbarch))
     return 0;
 
@@ -656,7 +653,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 
   while (op_ptr < op_end)
     {
-      enum dwarf_location_atom op = *op_ptr++;
+      enum dwarf_location_atom op = (enum dwarf_location_atom) *op_ptr++;
       ULONGEST result;
       /* Assume the value is not in stack memory.
         Code that knows otherwise sets this to 1.
@@ -872,7 +869,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
              error (_("DWARF-2 expression error: DW_OP_GNU_implicit_pointer "
                       "is not allowed in frame context"));
 
-           /* The referred-to DIE of cu_offset kind.  */
+           /* The referred-to DIE of sect_offset kind.  */
            ctx->len = extract_unsigned_integer (op_ptr, ctx->ref_addr_size,
                                                 byte_order);
            op_ptr += ctx->ref_addr_size;
@@ -922,7 +919,8 @@ execute_stack_op (struct dwarf_expr_context *ctx,
        case DW_OP_breg31:
          {
            op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
-           result = (ctx->funcs->read_reg) (ctx->baton, op - DW_OP_breg0);
+           result = (ctx->funcs->read_addr_from_reg) (ctx->baton,
+                                                      op - DW_OP_breg0);
            result += offset;
            result_val = value_from_ulongest (address_type, result);
          }
@@ -931,7 +929,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
          {
            op_ptr = safe_read_uleb128 (op_ptr, op_end, &reg);
            op_ptr = safe_read_sleb128 (op_ptr, op_end, &offset);
-           result = (ctx->funcs->read_reg) (ctx->baton, reg);
+           result = (ctx->funcs->read_addr_from_reg) (ctx->baton, reg);
            result += offset;
            result_val = value_from_ulongest (address_type, result);
          }
@@ -956,8 +954,9 @@ execute_stack_op (struct dwarf_expr_context *ctx,
            if (ctx->location == DWARF_VALUE_MEMORY)
              result = dwarf_expr_fetch_address (ctx, 0);
            else if (ctx->location == DWARF_VALUE_REGISTER)
-             result = (ctx->funcs->read_reg) (ctx->baton,
-                                    value_as_long (dwarf_expr_fetch (ctx, 0)));
+             result = (ctx->funcs->read_addr_from_reg)
+                         (ctx->baton,
+                          value_as_long (dwarf_expr_fetch (ctx, 0)));
            else
              error (_("Not implemented: computing frame "
                       "base using explicit value operator"));
@@ -1026,7 +1025,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
        case DW_OP_GNU_deref_type:
          {
            int addr_size = (op == DW_OP_deref ? ctx->addr_size : *op_ptr++);
-           gdb_byte *buf = alloca (addr_size);
+           gdb_byte *buf = (gdb_byte *) alloca (addr_size);
            CORE_ADDR addr = dwarf_expr_fetch_address (ctx, 0);
            struct type *type;
 
@@ -1052,7 +1051,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
                ULONGEST result =
                  extract_unsigned_integer (buf, addr_size, byte_order);
 
-               buf = alloca (TYPE_LENGTH (type));
+               buf = (gdb_byte *) alloca (TYPE_LENGTH (type));
                store_unsigned_integer (buf, TYPE_LENGTH (type),
                                        byte_order, result);
              }
@@ -1258,6 +1257,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
          break;
 
        case DW_OP_GNU_push_tls_address:
+       case DW_OP_form_tls_address:
          /* Variable is at a constant offset in the thread-local
          storage block into the objfile for the current thread and
          the dynamic linker module containing this expression.  Here
@@ -1440,10 +1440,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
            type_die.cu_off = uoffset;
 
            type = dwarf_get_base_type (ctx, type_die, 0);
-           result = (ctx->funcs->read_reg) (ctx->baton, reg);
-           result_val = value_from_ulongest (address_type, result);
-           result_val = value_from_contents (type,
-                                             value_contents_all (result_val));
+           result_val = ctx->funcs->get_reg_value (ctx->baton, type, reg);
          }
          break;
 
@@ -1480,6 +1477,12 @@ execute_stack_op (struct dwarf_expr_context *ctx,
          }
          break;
 
+       case DW_OP_push_object_address:
+         /* Return the address of the object we are currently observing.  */
+         result = (ctx->funcs->get_object_address) (ctx->baton);
+         result_val = value_from_ulongest (address_type, result);
+         break;
+
        default:
          error (_("Unhandled dwarf expression opcode 0x%x"), op);
        }
@@ -1531,7 +1534,7 @@ ctx_no_get_frame_pc (void *baton)
 CORE_ADDR
 ctx_no_get_tls_address (void *baton, CORE_ADDR offset)
 {
-  error (_("%s is invalid in this context"), "DW_OP_GNU_push_tls_address");
+  error (_("%s is invalid in this context"), "DW_OP_form_tls_address");
 }
 
 /* Stub dwarf_expr_context_funcs.dwarf_call implementation.  */
This page took 0.029585 seconds and 4 git commands to generate.