2004-06-06 Randolph Chung <tausq@debian.org>
[deliverable/binutils-gdb.git] / gdb / dwarf2expr.c
index 410cd54c6227f198cb5c8a771d0958461dd13553..294afa06c63c6213ad258ede26040e85e9ef682b 100644 (file)
@@ -178,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;
 }
 
@@ -439,18 +441,6 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
            result = dwarf_expr_fetch (ctx, 0);
            if (ctx->in_reg)
              result = (ctx->read_reg) (ctx->baton, result);
-           else
-             {
-               char *buf = alloca (TARGET_ADDR_BIT / TARGET_CHAR_BIT);
-               int bytes_read;
-
-               (ctx->read_mem) (ctx->baton, buf, result,
-                                TARGET_ADDR_BIT / TARGET_CHAR_BIT);
-               result = dwarf2_read_address (buf,
-                                             buf + (TARGET_ADDR_BIT
-                                                    / TARGET_CHAR_BIT),
-                                             &bytes_read);
-             }
            result = result + offset;
            ctx->stack_len = before_stack_len;
            ctx->in_reg = 0;
@@ -572,7 +562,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
            second = dwarf_expr_fetch (ctx, 0);
            dwarf_expr_pop (ctx);
 
-           first = dwarf_expr_fetch (ctx, 1);
+           first = dwarf_expr_fetch (ctx, 0);
            dwarf_expr_pop (ctx);
 
            val1 = value_from_longest (unsigned_address_type (), first);
@@ -585,6 +575,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
                break;
              case DW_OP_div:
                binop = BINOP_DIV;
+                break;
              case DW_OP_minus:
                binop = BINOP_SUB;
                break;
@@ -605,6 +596,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
                break;
              case DW_OP_shr:
                binop = BINOP_RSH;
+                break;
              case DW_OP_shra:
                binop = BINOP_RSH;
                val1 = value_from_longest (signed_address_type (), first);
@@ -639,6 +631,14 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
          break;
 
        case DW_OP_GNU_push_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
+         we return returns the offset from that base.  The top of the
+         stack has the offset from the beginning of the thread
+         control block at which the variable is located.  Nothing
+         should follow this operator, so the top of stack would be
+         returned.  */
          result = dwarf_expr_fetch (ctx, 0);
          dwarf_expr_pop (ctx);
          result = (ctx->get_tls_address) (ctx->baton, result);
@@ -662,7 +662,7 @@ execute_stack_op (struct dwarf_expr_context *ctx, unsigned char *op_ptr,
          goto no_push;
 
        default:
-         error ("Unhandled dwarf expression opcode");
+         error ("Unhandled dwarf expression opcode 0x%x", op);
        }
 
       /* Most things push a result value.  */
This page took 0.026452 seconds and 4 git commands to generate.