Ada: Reserved word "all" should not need to be spelled in lowercase.
[deliverable/binutils-gdb.git] / gdb / value.c
index d96d285cbdd3ab3a165714498c14d2ea4d10835c..a64e7e117ee64b83905146a0a4250b6650ad549d 100644 (file)
@@ -19,7 +19,7 @@
 
 #include "defs.h"
 #include "arch-utils.h"
-#include "gdb_string.h"
+#include <string.h>
 #include "symtab.h"
 #include "gdbtypes.h"
 #include "value.h"
@@ -768,7 +768,7 @@ allocate_optimized_out_value (struct type *type)
   struct value *retval = allocate_value_lazy (type);
 
   set_value_optimized_out (retval, 1);
-
+  set_value_lazy (retval, 0);
   return retval;
 }
 
@@ -2590,8 +2590,7 @@ unpack_pointer (struct type *type, const gdb_byte *valaddr)
 
 \f
 /* Get the value of the FIELDNO'th field (which must be static) of
-   TYPE.  Return NULL if the field doesn't exist or has been
-   optimized out.  */
+   TYPE.  */
 
 struct value *
 value_static_field (struct type *type, int fieldno)
@@ -2618,7 +2617,7 @@ value_static_field (struct type *type, int fieldno)
                                                               NULL, NULL);
 
          if (!msym)
-           return NULL;
+           return allocate_optimized_out_value (type);
          else
            {
              retval = value_at_lazy (TYPE_FIELD_TYPE (type, fieldno),
@@ -3508,7 +3507,9 @@ value_fetch_lazy (struct value *val)
 
       while (VALUE_LVAL (new_val) == lval_register && value_lazy (new_val))
        {
-         frame = frame_find_by_id (VALUE_FRAME_ID (new_val));
+         struct frame_id frame_id = VALUE_FRAME_ID (new_val);
+
+         frame = frame_find_by_id (frame_id);
          regnum = VALUE_REGNUM (new_val);
 
          gdb_assert (frame != NULL);
@@ -3522,6 +3523,22 @@ value_fetch_lazy (struct value *val)
                                                   regnum, type));
 
          new_val = get_frame_register_value (frame, regnum);
+
+         /* If we get another lazy lval_register value, it means the
+            register is found by reading it from the next frame.
+            get_frame_register_value should never return a value with
+            the frame id pointing to FRAME.  If it does, it means we
+            either have two consecutive frames with the same frame id
+            in the frame chain, or some code is trying to unwind
+            behind get_prev_frame's back (e.g., a frame unwind
+            sniffer trying to unwind), bypassing its validations.  In
+            any case, it should always be an internal error to end up
+            in this situation.  */
+         if (VALUE_LVAL (new_val) == lval_register
+             && value_lazy (new_val)
+             && frame_id_eq (VALUE_FRAME_ID (new_val), frame_id))
+           internal_error (__FILE__, __LINE__,
+                           _("infinite loop while fetching a register"));
        }
 
       /* If it's still lazy (for instance, a saved register on the
@@ -3555,7 +3572,10 @@ value_fetch_lazy (struct value *val)
 
          fprintf_unfiltered (gdb_stdlog, "->");
          if (value_optimized_out (new_val))
-           fprintf_unfiltered (gdb_stdlog, " optimized out");
+           {
+             fprintf_unfiltered (gdb_stdlog, " ");
+             val_print_optimized_out (new_val, gdb_stdlog);
+           }
          else
            {
              int i;
This page took 0.024973 seconds and 4 git commands to generate.