2011-05-18 Pedro Alves <pedro@codesourcery.com>
[deliverable/binutils-gdb.git] / gdb / valprint.c
index b32d6fca5e57f6ababcc9847fcdbcaca14890062..9bf19f4b469bc31912b9ece503f2badd5e793491 100644 (file)
@@ -260,7 +260,7 @@ scalar_type_p (struct type *type)
 static int
 valprint_check_validity (struct ui_file *stream,
                         struct type *type,
-                        int offset,
+                        int embedded_offset,
                         const struct value *val)
 {
   CHECK_TYPEDEF (type);
@@ -269,19 +269,25 @@ valprint_check_validity (struct ui_file *stream,
       && TYPE_CODE (type) != TYPE_CODE_STRUCT
       && TYPE_CODE (type) != TYPE_CODE_ARRAY)
     {
-      if (! value_bits_valid (val, TARGET_CHAR_BIT * offset,
-                             TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+      if (!value_bits_valid (val, TARGET_CHAR_BIT * embedded_offset,
+                            TARGET_CHAR_BIT * TYPE_LENGTH (type)))
        {
          val_print_optimized_out (stream);
          return 0;
        }
 
-      if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * offset,
+      if (value_bits_synthetic_pointer (val, TARGET_CHAR_BIT * embedded_offset,
                                        TARGET_CHAR_BIT * TYPE_LENGTH (type)))
        {
          fputs_filtered (_("<synthetic pointer>"), stream);
          return 0;
        }
+
+      if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
+       {
+         val_print_unavailable (stream);
+         return 0;
+       }
     }
 
   return 1;
@@ -293,6 +299,18 @@ val_print_optimized_out (struct ui_file *stream)
   fprintf_filtered (stream, _("<optimized out>"));
 }
 
+void
+val_print_unavailable (struct ui_file *stream)
+{
+  fprintf_filtered (stream, _("<unavailable>"));
+}
+
+void
+val_print_invalid_address (struct ui_file *stream)
+{
+  fprintf_filtered (stream, _("<invalid address>"));
+}
+
 /* Print using the given LANGUAGE the data of type TYPE located at
    VALADDR + EMBEDDED_OFFSET (within GDB), which came from the
    inferior at address ADDRESS + EMBEDDED_OFFSET, onto stdio stream
@@ -560,6 +578,8 @@ val_print_scalar_formatted (struct type *type,
   if (!value_bits_valid (val, TARGET_CHAR_BIT * embedded_offset,
                              TARGET_CHAR_BIT * TYPE_LENGTH (type)))
     val_print_optimized_out (stream);
+  else if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
+    val_print_unavailable (stream);
   else
     print_scalar_formatted (valaddr + embedded_offset, type,
                            options, size, stream);
@@ -1227,13 +1247,21 @@ val_print_array_elements (struct type *type,
 
       rep1 = i + 1;
       reps = 1;
-      while (rep1 < len
-            && memcmp (valaddr + embedded_offset + i * eltlen,
-                       valaddr + embedded_offset + rep1 * eltlen,
-                       eltlen) == 0)
+      /* Only check for reps if repeat_count_threshold is not set to
+        UINT_MAX (unlimited).  */
+      if (options->repeat_count_threshold < UINT_MAX)
        {
-         ++reps;
-         ++rep1;
+         while (rep1 < len
+                && value_available_contents_eq (val,
+                                                embedded_offset + i * eltlen,
+                                                val,
+                                                (embedded_offset
+                                                 + rep1 * eltlen),
+                                                eltlen))
+           {
+             ++reps;
+             ++rep1;
+           }
        }
 
       if (reps > options->repeat_count_threshold)
This page took 0.024175 seconds and 4 git commands to generate.