2010-07-02 Ulrich Weigand <uweigand@de.ibm.com>
[binutils-gdb.git] / gdb / valops.c
index 08a64ce02996d52817c4b4eb3db883781b038cc4..7fbad10ce34db9c386e84bdf0b1d87f447be46a6 100644 (file)
@@ -941,11 +941,17 @@ value_fetch_lazy (struct value *val)
       struct value *parent = value_parent (val);
       LONGEST offset = value_offset (val);
       LONGEST num = unpack_bits_as_long (value_type (val),
-                                        value_contents (parent) + offset,
+                                        (value_contents_for_printing (parent)
+                                         + offset),
                                         value_bitpos (val),
                                         value_bitsize (val));
       int length = TYPE_LENGTH (type);
 
+      if (!value_bits_valid (val,
+                            TARGET_CHAR_BIT * offset + value_bitpos (val),
+                            value_bitsize (val)))
+       error (_("value has been optimized out"));
+
       store_signed_integer (value_contents_raw (val), length, byte_order, num);
     }
   else if (VALUE_LVAL (val) == lval_memory)
@@ -1246,6 +1252,7 @@ value_assign (struct value *toval, struct value *fromval)
     {
     case lval_memory:
     case lval_register:
+    case lval_computed:
 
       reinit_frame_cache ();
 
@@ -1845,7 +1852,7 @@ search_struct_field (const char *name, struct value *arg1, int offset,
              {
                v = value_static_field (type, i);
                if (v == 0)
-                 error (_("field %s is nonexistent or has been optimised out"),
+                 error (_("field %s is nonexistent or has been optimized out"),
                         name);
              }
            else
@@ -3277,8 +3284,16 @@ value_maybe_namespace_elt (const struct type *curtype,
   struct value *result;
 
   sym = cp_lookup_symbol_namespace (namespace_name, name,
-                                   get_selected_block (0), 
-                                   VAR_DOMAIN);
+                                   get_selected_block (0), VAR_DOMAIN);
+
+  if (sym == NULL)
+    {
+      char *concatenated_name = alloca (strlen (namespace_name) + 2
+                                       + strlen (name) + 1);
+
+      sprintf (concatenated_name, "%s::%s", namespace_name, name);
+      sym = lookup_static_symbol_aux (concatenated_name, VAR_DOMAIN);
+    }
 
   if (sym == NULL)
     return NULL;