daily update
[deliverable/binutils-gdb.git] / gdb / dwarf2loc.c
index d9580c658889aa11143f60558565d8ee5df9e612..0c4d834f6484db1b239b55f7dc4b384423f1ef51 100644 (file)
@@ -422,7 +422,7 @@ insert_bits (unsigned int datum,
 {
   unsigned int mask;
 
-  gdb_assert (dest_offset_bits >= 0 && dest_offset_bits + nbits <= 8);
+  gdb_assert (dest_offset_bits + nbits <= 8);
 
   mask = (1 << nbits) - 1;
   if (bits_big_endian)
@@ -603,10 +603,10 @@ read_pieced_value (struct value *v)
          break;
 
        case DWARF_VALUE_MEMORY:
-         if (p->v.mem.in_stack_memory)
-           read_stack (p->v.mem.addr + source_offset, buffer, this_size);
-         else
-           read_memory (p->v.mem.addr + source_offset, buffer, this_size);
+         read_value_memory (v, offset,
+                            p->v.mem.in_stack_memory,
+                            p->v.mem.addr + source_offset,
+                            buffer, this_size);
          break;
 
        case DWARF_VALUE_STACK:
@@ -976,6 +976,7 @@ indirect_pieced_value (struct value *value)
   frame = get_selected_frame (_("No frame selected."));
   byte_offset = value_as_address (value);
 
+  gdb_assert (piece);
   baton = dwarf2_fetch_die_location_block (piece->v.ptr.die, c->per_cu,
                                           get_frame_address_in_block_wrapper,
                                           frame);
@@ -1159,7 +1160,7 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
        case DWARF_VALUE_LITERAL:
          {
            bfd_byte *contents;
-           const bfd_byte *data;
+           const bfd_byte *ldata;
            size_t n = ctx->len;
 
            if (byte_offset + TYPE_LENGTH (type) > n)
@@ -1168,12 +1169,12 @@ dwarf2_evaluate_loc_desc_full (struct type *type, struct frame_info *frame,
            retval = allocate_value (type);
            contents = value_contents_raw (retval);
 
-           data = ctx->data + byte_offset;
+           ldata = ctx->data + byte_offset;
            n -= byte_offset;
 
            if (n > TYPE_LENGTH (type))
              n = TYPE_LENGTH (type);
-           memcpy (contents, data, n);
+           memcpy (contents, ldata, n);
          }
          break;
 
@@ -1334,8 +1335,15 @@ dwarf2_loc_desc_needs_frame (const gdb_byte *data, unsigned short size,
 static void
 unimplemented (unsigned int op)
 {
-  error (_("DWARF operator %s cannot be translated to an agent expression"),
-        dwarf_stack_op_name (op, 1));
+  const char *name = dwarf_stack_op_name (op);
+
+  if (name)
+    error (_("DWARF operator %s cannot be translated to an agent expression"),
+          name);
+  else
+    error (_("Unknown DWARF operator 0x%02x cannot be translated "
+            "to an agent expression"),
+          op);
 }
 
 /* A helper function to convert a DWARF register to an arch register.
@@ -1419,11 +1427,11 @@ get_ax_pc (void *baton)
    example, if the expression cannot be compiled, or if the expression
    is invalid.  */
 
-static void
-compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
-                    struct gdbarch *arch, unsigned int addr_size,
-                    const gdb_byte *op_ptr, const gdb_byte *op_end,
-                    struct dwarf2_per_cu_data *per_cu)
+void
+dwarf2_compile_expr_to_ax (struct agent_expr *expr, struct axs_value *loc,
+                          struct gdbarch *arch, unsigned int addr_size,
+                          const gdb_byte *op_ptr, const gdb_byte *op_end,
+                          struct dwarf2_per_cu_data *per_cu)
 {
   struct cleanup *cleanups;
   int i, *offsets;
@@ -1710,8 +1718,8 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
                                     &datastart, &datalen);
 
            op_ptr = read_sleb128 (op_ptr, op_end, &offset);
-           compile_dwarf_to_ax (expr, loc, arch, addr_size, datastart,
-                                datastart + datalen, per_cu);
+           dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size, datastart,
+                                      datastart + datalen, per_cu);
 
            if (offset != 0)
              {
@@ -1733,7 +1741,7 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
 
        case DW_OP_pick:
          offset = *op_ptr++;
-         unimplemented (op);
+         ax_pick (expr, offset);
          break;
          
        case DW_OP_swap:
@@ -1741,31 +1749,11 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
          break;
 
        case DW_OP_over:
-         /* We can't directly support DW_OP_over, but GCC emits it as
-            part of a sequence to implement signed modulus.  As a
-            hack, we recognize this sequence.  Note that if GCC ever
-            generates a branch to the middle of this sequence, then
-            we will die somehow.  */
-         if (op_end - op_ptr >= 4
-             && op_ptr[0] == DW_OP_over
-             && op_ptr[1] == DW_OP_div
-             && op_ptr[2] == DW_OP_mul
-             && op_ptr[3] == DW_OP_minus)
-           {
-             /* Sign extend the operands.  */
-             ax_ext (expr, addr_size_bits);
-             ax_simple (expr, aop_swap);
-             ax_ext (expr, addr_size_bits);
-             ax_simple (expr, aop_swap);
-             ax_simple (expr, aop_rem_signed);
-             op_ptr += 4;
-           }
-         else
-           unimplemented (op);
+         ax_pick (expr, 1);
          break;
 
        case DW_OP_rot:
-         unimplemented (op);
+         ax_simple (expr, aop_rot);
          break;
 
        case DW_OP_deref:
@@ -1793,8 +1781,10 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
                ax_simple (expr, aop_ref64);
                break;
              default:
+               /* Note that dwarf_stack_op_name will never return
+                  NULL here.  */
                error (_("Unsupported size %d in %s"),
-                      size, dwarf_stack_op_name (op, 1));
+                      size, dwarf_stack_op_name (op));
              }
          }
          break;
@@ -1946,7 +1936,8 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
          break;
 
        case DW_OP_call_frame_cfa:
-         unimplemented (op);
+         dwarf2_compile_cfa_to_ax (expr, loc, arch, expr->scope, per_cu);
+         loc->kind = axs_lvalue_memory;
          break;
 
        case DW_OP_GNU_push_tls_address:
@@ -2060,9 +2051,9 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
            /* DW_OP_call_ref is currently not supported.  */
            gdb_assert (block.per_cu == per_cu);
 
-           compile_dwarf_to_ax (expr, loc, arch, addr_size,
-                                block.data, block.data + block.size,
-                                per_cu);
+           dwarf2_compile_expr_to_ax (expr, loc, arch, addr_size,
+                                      block.data, block.data + block.size,
+                                      per_cu);
          }
          break;
 
@@ -2070,7 +2061,7 @@ compile_dwarf_to_ax (struct agent_expr *expr, struct axs_value *loc,
          unimplemented (op);
 
        default:
-         error (_("Unhandled dwarf expression opcode 0x%x"), op);
+         unimplemented (op);
        }
     }
 
@@ -2295,7 +2286,7 @@ disassemble_dwarf_expression (struct ui_file *stream,
       LONGEST l;
       const char *name;
 
-      name = dwarf_stack_op_name (op, 0);
+      name = dwarf_stack_op_name (op);
 
       if (!name)
        error (_("Unrecognized DWARF opcode 0x%02x at %ld"),
@@ -2440,27 +2431,23 @@ disassemble_dwarf_expression (struct ui_file *stream,
        case DW_OP_breg29:
        case DW_OP_breg30:
        case DW_OP_breg31:
-         data = read_sleb128 (data, end, &ul);
-         fprintf_filtered (stream, " %s [$%s]", pulongest (ul),
+         data = read_sleb128 (data, end, &l);
+         fprintf_filtered (stream, " %s [$%s]", plongest (l),
                            gdbarch_register_name (arch, op - DW_OP_breg0));
          break;
 
        case DW_OP_bregx:
-         {
-           ULONGEST offset;
-
-           data = read_uleb128 (data, end, &ul);
-           data = read_sleb128 (data, end, &offset);
-           fprintf_filtered (stream, " register %s [$%s] offset %s",
-                             pulongest (ul),
-                             gdbarch_register_name (arch, (int) ul),
-                             pulongest (offset));
-         }
+         data = read_uleb128 (data, end, &ul);
+         data = read_sleb128 (data, end, &l);
+         fprintf_filtered (stream, " register %s [$%s] offset %s",
+                           pulongest (ul),
+                           gdbarch_register_name (arch, (int) ul),
+                           plongest (l));
          break;
 
        case DW_OP_fbreg:
-         data = read_sleb128 (data, end, &ul);
-         fprintf_filtered (stream, " %s", pulongest (ul));
+         data = read_sleb128 (data, end, &l);
+         fprintf_filtered (stream, " %s", plongest (l));
          break;
 
        case DW_OP_xderef_size:
@@ -2664,9 +2651,9 @@ locexpr_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
   if (dlbaton->data == NULL || dlbaton->size == 0)
     value->optimized_out = 1;
   else
-    compile_dwarf_to_ax (ax, value, gdbarch, addr_size,
-                        dlbaton->data, dlbaton->data + dlbaton->size,
-                        dlbaton->per_cu);
+    dwarf2_compile_expr_to_ax (ax, value, gdbarch, addr_size,
+                              dlbaton->data, dlbaton->data + dlbaton->size,
+                              dlbaton->per_cu);
 }
 
 /* The set of location functions used with the DWARF-2 expression
@@ -2817,8 +2804,8 @@ loclist_tracepoint_var_ref (struct symbol *symbol, struct gdbarch *gdbarch,
   if (data == NULL || size == 0)
     value->optimized_out = 1;
   else
-    compile_dwarf_to_ax (ax, value, gdbarch, addr_size, data, data + size,
-                        dlbaton->per_cu);
+    dwarf2_compile_expr_to_ax (ax, value, gdbarch, addr_size, data, data + size,
+                              dlbaton->per_cu);
 }
 
 /* The set of location functions used with the DWARF-2 expression
This page took 0.033789 seconds and 4 git commands to generate.