* alpha-tdep.c (alpha_push_dummy_call): Transmography from
[deliverable/binutils-gdb.git] / gdb / dwarf2expr.c
index 35e76f3cd40bb09ccdc51d40154f56f8d978ebb1..aa391ebd6a5e0b698ee7e808351fdb16daaeec2d 100644 (file)
@@ -39,8 +39,9 @@ new_dwarf_expr_context (void)
 {
   struct dwarf_expr_context *retval;
   retval = xcalloc (1, sizeof (struct dwarf_expr_context));
-  retval->stack_len = 10;
-  retval->stack = xmalloc (10 * sizeof (CORE_ADDR));
+  retval->stack_len = 0;
+  retval->stack_allocated = 10;
+  retval->stack = xmalloc (retval->stack_allocated * sizeof (CORE_ADDR));
   return retval;
 }
 
@@ -61,12 +62,10 @@ dwarf_expr_grow_stack (struct dwarf_expr_context *ctx, size_t need)
 {
   if (ctx->stack_len + need > ctx->stack_allocated)
     {
-      size_t templen = ctx->stack_len * 2;
-      while (templen < (ctx->stack_len + need))
-          templen *= 2;
+      size_t newlen = ctx->stack_len + need + 10;
       ctx->stack = xrealloc (ctx->stack,
-                            templen * sizeof (CORE_ADDR));
-      ctx->stack_allocated = templen;
+                            newlen * sizeof (CORE_ADDR));
+      ctx->stack_allocated = newlen;
     }
 }
 
@@ -179,7 +178,9 @@ dwarf2_read_address (unsigned char *buf, unsigned char *buf_end, int *bytes_read
     error ("dwarf2_read_address: Corrupted DWARF expression.");
 
   *bytes_read = TARGET_ADDR_BIT / TARGET_CHAR_BIT;
-  result = extract_address (buf, TARGET_ADDR_BIT / TARGET_CHAR_BIT);
+  /* NOTE: cagney/2003-05-22: This extract is assuming that a DWARF 2
+     address is always unsigned.  That may or may not be true.  */
+  result = extract_unsigned_integer (buf, TARGET_ADDR_BIT / TARGET_CHAR_BIT);
   return result;
 }
 
@@ -228,6 +229,8 @@ static void
 execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
                  unsigned char *op_end)
 {
+  ctx->in_reg = 0;
+
   while (op_ptr < op_end)
     {
       enum dwarf_location_atom op = *op_ptr++;
@@ -236,8 +239,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
       LONGEST offset;
       int bytes_read;
 
-      ctx->in_reg = 0;
-
       switch (op)
        {
        case DW_OP_lit0:
@@ -355,10 +356,9 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
        case DW_OP_reg29:
        case DW_OP_reg30:
        case DW_OP_reg31:
-         /* NOTE: in the presence of DW_OP_piece this check is incorrect.  */
-         if (op_ptr != op_end)
+         if (op_ptr != op_end && *op_ptr != DW_OP_piece)
            error ("DWARF-2 expression error: DW_OP_reg operations must be "
-                  "used alone.");
+                  "used either alone or in conjuction with DW_OP_piece.");
 
          result = op - DW_OP_reg0;
          ctx->in_reg = 1;
@@ -367,9 +367,9 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
 
        case DW_OP_regx:
          op_ptr = read_uleb128 (op_ptr, op_end, &reg);
-         if (op_ptr != op_end)
+         if (op_ptr != op_end && *op_ptr != DW_OP_piece)
            error ("DWARF-2 expression error: DW_OP_reg operations must be "
-                  "used alone.");
+                  "used either alone or in conjuction with DW_OP_piece.");
 
          result = reg;
          ctx->in_reg = 1;
This page took 0.024689 seconds and 4 git commands to generate.