Uniquefy gdb.threads/attach-into-signal.exp
[deliverable/binutils-gdb.git] / gdb / dwarf2expr.c
index 80c6e173a31706077afea61e61d80a107d99a9dd..071b83fa7042a4bd5ac7c4cd14af4a7b2ab10c65 100644 (file)
@@ -1,7 +1,6 @@
 /* DWARF 2 Expression Evaluator.
 
-   Copyright (C) 2001-2003, 2005, 2007-2012 Free Software Foundation,
-   Inc.
+   Copyright (C) 2001-2015 Free Software Foundation, Inc.
 
    Contributed by Daniel Berlin (dan@dberlin.org)
 
@@ -27,7 +26,6 @@
 #include "gdbcore.h"
 #include "dwarf2.h"
 #include "dwarf2expr.h"
-#include "gdb_assert.h"
 
 /* Local prototypes.  */
 
@@ -342,7 +340,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)
@@ -373,7 +371,7 @@ dwarf_expr_eval (struct dwarf_expr_context *ctx, const gdb_byte *addr,
 
 const gdb_byte *
 safe_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end,
-                  unsigned long long *r)
+                  uint64_t *r)
 {
   buf = gdb_read_uleb128 (buf, buf_end, r);
   if (buf == NULL)
@@ -385,7 +383,7 @@ safe_read_uleb128 (const gdb_byte *buf, const gdb_byte *buf_end,
 
 const gdb_byte *
 safe_read_sleb128 (const gdb_byte *buf, const gdb_byte *buf_end,
-                  long long *r)
+                  int64_t *r)
 {
   buf = gdb_read_sleb128 (buf, buf_end, r);
   if (buf == NULL)
@@ -465,7 +463,7 @@ dwarf_get_base_type (struct dwarf_expr_context *ctx, cu_offset die, int size)
 int
 dwarf_block_to_dwarf_reg (const gdb_byte *buf, const gdb_byte *buf_end)
 {
-  unsigned long long dwarf_reg;
+  uint64_t dwarf_reg;
 
   if (buf_end <= buf)
     return -1;
@@ -509,8 +507,8 @@ int
 dwarf_block_to_dwarf_reg_deref (const gdb_byte *buf, const gdb_byte *buf_end,
                                CORE_ADDR *deref_size_return)
 {
-  unsigned long long dwarf_reg;
-  long long offset;
+  uint64_t dwarf_reg;
+  int64_t offset;
 
   if (buf_end <= buf)
     return -1;
@@ -568,7 +566,7 @@ int
 dwarf_block_to_fb_offset (const gdb_byte *buf, const gdb_byte *buf_end,
                          CORE_ADDR *fb_offset_return)
 {
-  long long fb_offset;
+  int64_t fb_offset;
 
   if (buf_end <= buf)
     return 0;
@@ -595,8 +593,8 @@ int
 dwarf_block_to_sp_offset (struct gdbarch *gdbarch, const gdb_byte *buf,
                          const gdb_byte *buf_end, CORE_ADDR *sp_offset_return)
 {
-  unsigned long long dwarf_reg;
-  long long sp_offset;
+  uint64_t dwarf_reg;
+  int64_t sp_offset;
 
   if (buf_end <= buf)
     return 0;
@@ -665,8 +663,8 @@ execute_stack_op (struct dwarf_expr_context *ctx,
         This is just an optimization, so it's always ok to punt
         and leave this as 0.  */
       int in_stack_memory = 0;
-      unsigned long long uoffset, reg;
-      long long offset;
+      uint64_t uoffset, reg;
+      int64_t offset;
       struct value *result_val = NULL;
 
       /* The DWARF expression might have a bug causing an infinite
@@ -725,6 +723,12 @@ execute_stack_op (struct dwarf_expr_context *ctx,
          break;
 
        case DW_OP_GNU_addr_index:
+         op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
+         result = (ctx->funcs->get_addr_index) (ctx->baton, uoffset);
+         result += ctx->offset;
+         result_val = value_from_ulongest (address_type, result);
+         break;
+       case DW_OP_GNU_const_index:
          op_ptr = safe_read_uleb128 (op_ptr, op_end, &uoffset);
          result = (ctx->funcs->get_addr_index) (ctx->baton, uoffset);
          result_val = value_from_ulongest (address_type, result);
@@ -839,7 +843,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 
        case DW_OP_implicit_value:
          {
-           unsigned long long len;
+           uint64_t len;
 
            op_ptr = safe_read_uleb128 (op_ptr, op_end, &len);
            if (op_ptr + len > op_end)
@@ -860,13 +864,13 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 
        case DW_OP_GNU_implicit_pointer:
          {
-           long long len;
+           int64_t len;
 
            if (ctx->ref_addr_size == -1)
              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;
@@ -916,7 +920,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);
          }
@@ -925,7 +930,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);
          }
@@ -950,8 +955,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"));
@@ -1291,7 +1297,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 
         case DW_OP_piece:
           {
-            unsigned long long size;
+            uint64_t size;
 
             /* Record the piece.  */
             op_ptr = safe_read_uleb128 (op_ptr, op_end, &size);
@@ -1308,7 +1314,7 @@ execute_stack_op (struct dwarf_expr_context *ctx,
 
        case DW_OP_bit_piece:
          {
-           unsigned long long size, offset;
+           uint64_t size, offset;
 
             /* Record the piece.  */
            op_ptr = safe_read_uleb128 (op_ptr, op_end, &size);
@@ -1354,34 +1360,36 @@ execute_stack_op (struct dwarf_expr_context *ctx,
        
        case DW_OP_GNU_entry_value:
          {
-           unsigned long long len;
-           int dwarf_reg;
+           uint64_t len;
            CORE_ADDR deref_size;
+           union call_site_parameter_u kind_u;
 
            op_ptr = safe_read_uleb128 (op_ptr, op_end, &len);
            if (op_ptr + len > op_end)
              error (_("DW_OP_GNU_entry_value: too few bytes available."));
 
-           dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len);
-           if (dwarf_reg != -1)
+           kind_u.dwarf_reg = dwarf_block_to_dwarf_reg (op_ptr, op_ptr + len);
+           if (kind_u.dwarf_reg != -1)
              {
                op_ptr += len;
-               ctx->funcs->push_dwarf_reg_entry_value (ctx, dwarf_reg,
-                                                       0 /* unused */,
+               ctx->funcs->push_dwarf_reg_entry_value (ctx,
+                                                 CALL_SITE_PARAMETER_DWARF_REG,
+                                                       kind_u,
                                                        -1 /* deref_size */);
                goto no_push;
              }
 
-           dwarf_reg = dwarf_block_to_dwarf_reg_deref (op_ptr, op_ptr + len,
-                                                       &deref_size);
-           if (dwarf_reg != -1)
+           kind_u.dwarf_reg = dwarf_block_to_dwarf_reg_deref (op_ptr,
+                                                              op_ptr + len,
+                                                              &deref_size);
+           if (kind_u.dwarf_reg != -1)
              {
                if (deref_size == -1)
                  deref_size = ctx->addr_size;
                op_ptr += len;
-               ctx->funcs->push_dwarf_reg_entry_value (ctx, dwarf_reg,
-                                                       0 /* unused */,
-                                                       deref_size);
+               ctx->funcs->push_dwarf_reg_entry_value (ctx,
+                                                 CALL_SITE_PARAMETER_DWARF_REG,
+                                                       kind_u, deref_size);
                goto no_push;
              }
 
@@ -1390,6 +1398,20 @@ execute_stack_op (struct dwarf_expr_context *ctx,
                     "or for DW_OP_breg*(0)+DW_OP_deref*"));
          }
 
+       case DW_OP_GNU_parameter_ref:
+         {
+           union call_site_parameter_u kind_u;
+
+           kind_u.param_offset.cu_off = extract_unsigned_integer (op_ptr, 4,
+                                                                  byte_order);
+           op_ptr += 4;
+           ctx->funcs->push_dwarf_reg_entry_value (ctx,
+                                              CALL_SITE_PARAMETER_PARAM_OFFSET,
+                                                   kind_u,
+                                                   -1 /* deref_size */);
+         }
+         goto no_push;
+
        case DW_OP_GNU_const_type:
          {
            cu_offset type_die;
@@ -1418,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;
 
@@ -1458,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);
        }
@@ -1533,7 +1558,8 @@ ctx_no_get_base_type (struct dwarf_expr_context *ctx, cu_offset die)
 
 void
 ctx_no_push_dwarf_reg_entry_value (struct dwarf_expr_context *ctx,
-                                  int dwarf_reg, CORE_ADDR fb_offset,
+                                  enum call_site_parameter_kind kind,
+                                  union call_site_parameter_u kind_u,
                                   int deref_size)
 {
   internal_error (__FILE__, __LINE__,
This page took 0.028193 seconds and 4 git commands to generate.