2004-09-12 Andrew Cagney <cagney@gnu.org>
[deliverable/binutils-gdb.git] / gdb / dwarf2loc.c
index cdbeb10acf43eef6557822c49be23169406e1a54..c281642ced82a93fc64b1aebaaf489ba11608933 100644 (file)
@@ -205,7 +205,7 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
                          unsigned char *data, unsigned short size,
                          struct objfile *objfile)
 {
-  CORE_ADDR result;
+  struct gdbarch *arch = get_frame_arch (frame);
   struct value *retval;
   struct dwarf_expr_baton baton;
   struct dwarf_expr_context *ctx;
@@ -228,21 +228,30 @@ dwarf2_evaluate_loc_desc (struct symbol *var, struct frame_info *frame,
   ctx->get_tls_address = dwarf_expr_tls_address;
 
   dwarf_expr_eval (ctx, data, size);
-  result = dwarf_expr_fetch (ctx, 0);
-
-  if (ctx->in_reg)
+  if (ctx->num_pieces > 0)
+    {
+      /* We haven't implemented splicing together pieces from
+         arbitrary sources yet.  */
+      error ("The value of variable '%s' is distributed across several\n"
+             "locations, and GDB cannot access its value.\n",
+             SYMBOL_NATURAL_NAME (var));
+    }
+  else if (ctx->in_reg)
     {
-      int regnum = DWARF2_REG_TO_REGNUM (result);
-      retval = value_from_register (SYMBOL_TYPE (var), regnum, frame);
+      CORE_ADDR dwarf_regnum = dwarf_expr_fetch (ctx, 0);
+      int gdb_regnum = DWARF2_REG_TO_REGNUM (dwarf_regnum);
+      retval = value_from_register (SYMBOL_TYPE (var), gdb_regnum, frame);
     }
   else
     {
+      CORE_ADDR address = dwarf_expr_fetch (ctx, 0);
+
       retval = allocate_value (SYMBOL_TYPE (var));
       VALUE_BFD_SECTION (retval) = SYMBOL_BFD_SECTION (var);
 
       VALUE_LVAL (retval) = lval_memory;
       VALUE_LAZY (retval) = 1;
-      VALUE_ADDRESS (retval) = result;
+      VALUE_ADDRESS (retval) = address;
     }
 
   free_dwarf_expr_context (ctx);
@@ -322,6 +331,17 @@ dwarf2_loc_desc_needs_frame (unsigned char *data, unsigned short size)
 
   in_reg = ctx->in_reg;
 
+  if (ctx->num_pieces > 0)
+    {
+      int i;
+
+      /* If the location has several pieces, and any of them are in
+         registers, then we will need a frame to fetch them from.  */
+      for (i = 0; i < ctx->num_pieces; i++)
+        if (ctx->pieces[i].in_reg)
+          in_reg = 1;
+    }
+
   free_dwarf_expr_context (ctx);
 
   return baton.needs_frame || in_reg;
This page took 0.023918 seconds and 4 git commands to generate.