* gdbint.texinfo (Formatting): Mention some formatting guidelines
[deliverable/binutils-gdb.git] / gdb / valprint.c
index 6ddbed83ebf291a9a85af13d736e9c43cb070e6d..b6b96d4ec4f239be11372c4d1df795529cb683c3 100644 (file)
@@ -514,6 +514,47 @@ val_print_type_code_flags (struct type *type, const gdb_byte *valaddr,
        }
     }
   fputs_filtered ("]", stream);
+
+/* Print a scalar of data of type TYPE, pointed to in GDB by VALADDR,
+   according to OPTIONS and SIZE on STREAM.  Format i is not supported
+   at this level.
+
+   This is how the elements of an array or structure are printed
+   with a format.  */
+}
+
+void
+val_print_scalar_formatted (struct type *type,
+                           const gdb_byte *valaddr, int embedded_offset,
+                           const struct value *val,
+                           const struct value_print_options *options,
+                           int size,
+                           struct ui_file *stream)
+{
+  gdb_assert (val != NULL);
+  gdb_assert (valaddr == value_contents_for_printing_const (val));
+
+  /* If we get here with a string format, try again without it.  Go
+     all the way back to the language printers, which may call us
+     again.  */
+  if (options->format == 's')
+    {
+      struct value_print_options opts = *options;
+      opts.format = 0;
+      opts.deref_ref = 0;
+      val_print (type, valaddr, embedded_offset, 0, stream, 0, val, &opts,
+                current_language);
+      return;
+    }
+
+  /* A scalar object that does not have all bits available can't be
+     printed, because all bits contribute to its representation.  */
+  if (!value_bits_valid (val, TARGET_CHAR_BIT * embedded_offset,
+                             TARGET_CHAR_BIT * TYPE_LENGTH (type)))
+    val_print_optimized_out (stream);
+  else
+    print_scalar_formatted (valaddr + embedded_offset, type,
+                           options, size, stream);
 }
 
 /* Print a number according to FORMAT which is one of d,u,x,o,b,h,w,g.
This page took 0.024327 seconds and 4 git commands to generate.