gdb:
[deliverable/binutils-gdb.git] / gdb / value.c
index b65ba32eb392d4a1daa7fd8e9053aea542d40124..381318b987c36cee05ea58ff09c361b962fa424c 100644 (file)
@@ -747,6 +747,7 @@ release_value (struct value *val)
   if (all_values == val)
     {
       all_values = val->next;
+      val->next = NULL;
       return;
     }
 
@@ -755,6 +756,7 @@ release_value (struct value *val)
       if (v->next == val)
        {
          v->next = val->next;
+         val->next = NULL;
          break;
        }
     }
@@ -824,6 +826,26 @@ value_copy (struct value *arg)
   return val;
 }
 
+/* Return a version of ARG that is non-lvalue.  */
+
+struct value *
+value_non_lval (struct value *arg)
+{
+  if (VALUE_LVAL (arg) != not_lval)
+    {
+      struct type *enc_type = value_enclosing_type (arg);
+      struct value *val = allocate_value (enc_type);
+
+      memcpy (value_contents_all_raw (val), value_contents_all (arg),
+             TYPE_LENGTH (enc_type));
+      val->type = arg->type;
+      set_value_embedded_offset (val, value_embedded_offset (arg));
+      set_value_pointed_to_offset (val, value_pointed_to_offset (arg));
+      return val;
+    }
+   return arg;
+}
+
 void
 set_value_component_location (struct value *component,
                              const struct value *whole)
@@ -1901,21 +1923,11 @@ value_static_field (struct type *type, int fieldno)
            }
        }
       else
-       {
-         /* SYM should never have a SYMBOL_CLASS which will require
-            read_var_value to use the FRAME parameter.  */
-         if (symbol_read_needs_frame (sym))
-           warning (_("static field's value depends on the current "
-                    "frame - bad debug info?"));
-         retval = read_var_value (sym, NULL);
-       }
-      if (retval && VALUE_LVAL (retval) == lval_memory)
-       SET_FIELD_PHYSADDR (TYPE_FIELD (type, fieldno),
-                           value_address (retval));
+       retval = value_of_variable (sym, NULL);
       break;
     }
     default:
-      gdb_assert (0);
+      gdb_assert_not_reached ("unexpected field location kind");
     }
 
   return retval;
@@ -1981,8 +1993,9 @@ value_primitive_field (struct value *arg1, int offset,
        v->bitpos = bitpos % container_bitsize;
       else
        v->bitpos = bitpos % 8;
-      v->offset = value_embedded_offset (arg1)
-       + (bitpos - v->bitpos) / 8;
+      v->offset = (value_embedded_offset (arg1)
+                  + offset
+                  + (bitpos - v->bitpos) / 8);
       v->parent = arg1;
       value_incref (v->parent);
       if (!value_lazy (arg1))
This page took 0.025247 seconds and 4 git commands to generate.