Move __SIGRTMIN.
[deliverable/binutils-gdb.git] / gdb / valprint.c
index 8893830ff3d063b5dce9876a61dc0abd7a340483..7e74856c910656c432173c7c4a31b2de188ea173 100644 (file)
@@ -34,6 +34,7 @@
 #include "ada-lang.h"
 #include "gdb_obstack.h"
 #include "charset.h"
+#include "typeprint.h"
 #include <ctype.h>
 
 /* Maximum number of wchars returned from wchar_iterate.  */
@@ -303,6 +304,18 @@ valprint_check_validity (struct ui_file *stream,
 {
   type = check_typedef (type);
 
+  if (type_not_associated (type))
+    {
+      val_print_not_associated (stream);
+      return 0;
+    }
+
+  if (type_not_allocated (type))
+    {
+      val_print_not_allocated (stream);
+      return 0;
+    }
+
   if (TYPE_CODE (type) != TYPE_CODE_UNION
       && TYPE_CODE (type) != TYPE_CODE_STRUCT
       && TYPE_CODE (type) != TYPE_CODE_ARRAY)
@@ -433,6 +446,9 @@ generic_val_print_ptr (struct type *type, const gdb_byte *valaddr,
                       const struct value *original_value,
                       const struct value_print_options *options)
 {
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
   if (options->format && options->format != 's')
     {
       val_print_scalar_formatted (type, valaddr, embedded_offset,
@@ -442,7 +458,8 @@ generic_val_print_ptr (struct type *type, const gdb_byte *valaddr,
     {
       struct type *unresolved_elttype = TYPE_TARGET_TYPE(type);
       struct type *elttype = check_typedef (unresolved_elttype);
-      CORE_ADDR addr = unpack_pointer (type, valaddr + embedded_offset);
+      CORE_ADDR addr = unpack_pointer (type,
+                                      valaddr + embedded_offset * unit_size);
 
       print_unpacked_pointer (type, elttype, addr, stream, options);
     }
@@ -520,6 +537,8 @@ generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
   unsigned int i;
   unsigned int len;
   LONGEST val;
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
 
   if (options->format)
     {
@@ -528,7 +547,7 @@ generic_val_print_enum (struct type *type, const gdb_byte *valaddr,
       return;
     }
   len = TYPE_NFIELDS (type);
-  val = unpack_long (type, valaddr + embedded_offset);
+  val = unpack_long (type, valaddr + embedded_offset * unit_size);
   for (i = 0; i < len; i++)
     {
       QUIT;
@@ -633,6 +652,8 @@ generic_val_print_bool (struct type *type, const gdb_byte *valaddr,
                        const struct generic_val_print_decorations *decorations)
 {
   LONGEST val;
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
 
   if (options->format || options->output_format)
     {
@@ -644,7 +665,7 @@ generic_val_print_bool (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      val = unpack_long (type, valaddr + embedded_offset);
+      val = unpack_long (type, valaddr + embedded_offset * unit_size);
       if (val == 0)
        fputs_filtered (decorations->false_name, stream);
       else if (val == 1)
@@ -662,6 +683,9 @@ generic_val_print_int (struct type *type, const gdb_byte *valaddr,
                       const struct value *original_value,
                       const struct value_print_options *options)
 {
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
   if (options->format || options->output_format)
     {
       struct value_print_options opts = *options;
@@ -672,7 +696,8 @@ generic_val_print_int (struct type *type, const gdb_byte *valaddr,
                                  original_value, &opts, 0, stream);
     }
   else
-    val_print_type_code_int (type, valaddr + embedded_offset, stream);
+    val_print_type_code_int (type, valaddr + embedded_offset * unit_size,
+                            stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_CHAR.  */
@@ -685,6 +710,8 @@ generic_val_print_char (struct type *type, struct type *unresolved_type,
                        const struct value_print_options *options)
 {
   LONGEST val;
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
 
   if (options->format || options->output_format)
     {
@@ -697,7 +724,7 @@ generic_val_print_char (struct type *type, struct type *unresolved_type,
     }
   else
     {
-      val = unpack_long (type, valaddr + embedded_offset);
+      val = unpack_long (type, valaddr + embedded_offset * unit_size);
       if (TYPE_UNSIGNED (type))
        fprintf_filtered (stream, "%u", (unsigned int) val);
       else
@@ -715,6 +742,9 @@ generic_val_print_float (struct type *type, const gdb_byte *valaddr,
                         const struct value *original_value,
                         const struct value_print_options *options)
 {
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
   if (options->format)
     {
       val_print_scalar_formatted (type, valaddr, embedded_offset,
@@ -722,7 +752,7 @@ generic_val_print_float (struct type *type, const gdb_byte *valaddr,
     }
   else
     {
-      print_floating (valaddr + embedded_offset, type, stream);
+      print_floating (valaddr + embedded_offset * unit_size, type, stream);
     }
 }
 
@@ -734,11 +764,15 @@ generic_val_print_decfloat (struct type *type, const gdb_byte *valaddr,
                            const struct value *original_value,
                            const struct value_print_options *options)
 {
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
   if (options->format)
     val_print_scalar_formatted (type, valaddr, embedded_offset, original_value,
                                options, 0, stream);
   else
-    print_decimal_floating (valaddr + embedded_offset, type, stream);
+    print_decimal_floating (valaddr + embedded_offset * unit_size, type,
+                           stream);
 }
 
 /* generic_val_print helper for TYPE_CODE_COMPLEX.  */
@@ -751,22 +785,25 @@ generic_val_print_complex (struct type *type, const gdb_byte *valaddr,
                           const struct generic_val_print_decorations
                             *decorations)
 {
+  struct gdbarch *gdbarch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (gdbarch);
+
   fprintf_filtered (stream, "%s", decorations->complex_prefix);
   if (options->format)
     val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
                                embedded_offset, original_value, options, 0,
                                stream);
   else
-    print_floating (valaddr + embedded_offset, TYPE_TARGET_TYPE (type),
-                   stream);
+    print_floating (valaddr + embedded_offset * unit_size,
+                   TYPE_TARGET_TYPE (type), stream);
   fprintf_filtered (stream, "%s", decorations->complex_infix);
   if (options->format)
     val_print_scalar_formatted (TYPE_TARGET_TYPE (type), valaddr,
                                embedded_offset
-                               + TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
+                               + type_length_units (TYPE_TARGET_TYPE (type)),
                                original_value, options, 0, stream);
   else
-    print_floating (valaddr + embedded_offset
+    print_floating (valaddr + embedded_offset * unit_size
                    + TYPE_LENGTH (TYPE_TARGET_TYPE (type)),
                    TYPE_TARGET_TYPE (type), stream);
   fprintf_filtered (stream, "%s", decorations->complex_suffix);
@@ -1019,6 +1056,18 @@ value_check_printable (struct value *val, struct ui_file *stream,
       return 0;
     }
 
+  if (type_not_associated (value_type (val)))
+    {
+      val_print_not_associated (stream);
+      return 0;
+    }
+
+  if (type_not_allocated (value_type (val)))
+    {
+      val_print_not_allocated (stream);
+      return 0;
+    }
+
   return 1;
 }
 
@@ -1150,6 +1199,9 @@ val_print_scalar_formatted (struct type *type,
                            int size,
                            struct ui_file *stream)
 {
+  struct gdbarch *arch = get_type_arch (type);
+  int unit_size = gdbarch_addressable_memory_unit_size (arch);
+
   gdb_assert (val != NULL);
   gdb_assert (valaddr == value_contents_for_printing_const (val));
 
@@ -1175,7 +1227,7 @@ val_print_scalar_formatted (struct type *type,
   else if (!value_bytes_available (val, embedded_offset, TYPE_LENGTH (type)))
     val_print_unavailable (stream);
   else
-    print_scalar_formatted (valaddr + embedded_offset, type,
+    print_scalar_formatted (valaddr + embedded_offset * unit_size, type,
                            options, size, stream);
 }
 
@@ -1576,7 +1628,7 @@ print_decimal_chars (struct ui_file *stream, const gdb_byte *valaddr,
      as the base 16 number, which is 2 digits per byte.  */
 
   decimal_len = len * 2 * 2;
-  digits = xmalloc (decimal_len);
+  digits = (unsigned char *) xmalloc (decimal_len);
 
   for (i = 0; i < decimal_len; i++)
     {
@@ -1823,7 +1875,7 @@ val_print_array_elements (struct type *type,
   LONGEST low_pos, high_pos;
 
   elttype = TYPE_TARGET_TYPE (type);
-  eltlen = TYPE_LENGTH (check_typedef (elttype));
+  eltlen = type_length_units (check_typedef (elttype));
   index_type = TYPE_INDEX_TYPE (type);
 
   if (get_array_bounds (type, &low_bound, &high_bound))
@@ -2092,7 +2144,7 @@ read_string (CORE_ADDR addr, int len, int width, unsigned int fetchlimit,
   else
     {                          /* Length of string is really 0!  */
       /* We always allocate *buffer.  */
-      *buffer = bufptr = xmalloc (1);
+      *buffer = bufptr = (gdb_byte *) xmalloc (1);
       errcode = 0;
     }
 
@@ -2245,7 +2297,7 @@ generic_emit_char (int c, struct type *type, struct ui_file *stream,
   struct wchar_iterator *iter;
   int need_escape = 0;
 
-  buf = alloca (TYPE_LENGTH (type));
+  buf = (gdb_byte *) alloca (TYPE_LENGTH (type));
   pack_long (buf, type, c);
 
   iter = make_wchar_iterator (buf, TYPE_LENGTH (type),
This page took 0.03357 seconds and 4 git commands to generate.