]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blobdiff - gdb/m2-valprint.c
[binutils, ARM, 4/16] BF insns infrastructure with array of relocs in struct arm_it
[thirdparty/binutils-gdb.git] / gdb / m2-valprint.c
index 015af3b0aa4273a9aa2df0d2d163d89f3b96be07..74f89ee45fb33f70ec54b07b70000aba5b7883ca 100644 (file)
@@ -1,7 +1,6 @@
 /* Support for printing Modula 2 values for GDB, the GNU debugger.
 
-   Copyright (C) 1986, 1988-1989, 1991-1992, 1996, 1998, 2000, 2005-2012
-   Free Software Foundation, Inc.
+   Copyright (C) 1986-2019 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -38,7 +37,7 @@ static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
                         int embedded_offset, CORE_ADDR address,
                         struct ui_file *stream, int recurse,
-                        const struct value *val,
+                        struct value *val,
                         const struct value_print_options *options,
                         int len);
 
@@ -82,7 +81,7 @@ m2_print_long_set (struct type *type, const gdb_byte *valaddr,
   struct type *target;
   int bitval;
 
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
 
   fprintf_filtered (stream, "{");
   len = TYPE_NFIELDS (type);
@@ -163,13 +162,11 @@ m2_print_unbounded_array (struct type *type, const gdb_byte *valaddr,
                          struct ui_file *stream, int recurse,
                          const struct value_print_options *options)
 {
-  struct type *content_type;
   CORE_ADDR addr;
   LONGEST len;
   struct value *val;
 
-  CHECK_TYPEDEF (type);
-  content_type = TYPE_TARGET_TYPE (TYPE_FIELD_TYPE (type, 0));
+  type = check_typedef (type);
 
   addr = unpack_pointer (TYPE_FIELD_TYPE (type, 0),
                         (TYPE_FIELD_BITPOS (type, 0) / 8) +
@@ -195,6 +192,7 @@ print_unpacked_pointer (struct type *type,
 {
   struct gdbarch *gdbarch = get_type_arch (type);
   struct type *elttype = check_typedef (TYPE_TARGET_TYPE (type));
+  int want_space = 0;
 
   if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
     {
@@ -205,7 +203,10 @@ print_unpacked_pointer (struct type *type,
     }
 
   if (options->addressprint && options->format != 's')
-    fputs_filtered (paddress (gdbarch, address), stream);
+    {
+      fputs_filtered (paddress (gdbarch, address), stream);
+      want_space = 1;
+    }
 
   /* For a pointer to char or unsigned char, also print the string
      pointed to, unless pointer is null.  */
@@ -214,8 +215,12 @@ print_unpacked_pointer (struct type *type,
       && TYPE_CODE (elttype) == TYPE_CODE_INT
       && (options->format == 0 || options->format == 's')
       && addr != 0)
-    return val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
-                            stream, options);
+    {
+      if (want_space)
+       fputs_filtered (" ", stream);
+      return val_print_string (TYPE_TARGET_TYPE (type), NULL, addr, -1,
+                              stream, options);
+    }
   
   return 0;
 }
@@ -257,20 +262,18 @@ static void
 m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
                         int embedded_offset, CORE_ADDR address,
                         struct ui_file *stream, int recurse,
-                        const struct value *val,
+                        struct value *val,
                         const struct value_print_options *options,
                         int len)
 {
-  int eltlen;
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
 
   if (TYPE_LENGTH (type) > 0)
     {
-      eltlen = TYPE_LENGTH (type);
-      if (options->prettyprint_arrays)
+      if (options->prettyformat_arrays)
        print_spaces_filtered (2 + 2 * recurse, stream);
       /* For an array of chars, print with string syntax.  */
-      if (eltlen == 1 &&
+      if (TYPE_LENGTH (type) == 1 &&
          ((TYPE_CODE (type) == TYPE_CODE_INT)
           || ((current_language->la_language == language_m2)
               && (TYPE_CODE (type) == TYPE_CODE_CHAR)))
@@ -279,7 +282,7 @@ m2_print_array_contents (struct type *type, const gdb_byte *valaddr,
       else
        {
          fprintf_filtered (stream, "{");
-         val_print_array_elements (type, valaddr, embedded_offset,
+         val_print_array_elements (type, embedded_offset,
                                    address, stream, recurse, val,
                                    options, 0);
          fprintf_filtered (stream, "}");
@@ -296,39 +299,37 @@ static const struct generic_val_print_decorations m2_decorations =
   " * I",
   "TRUE",
   "FALSE",
-  "void"
+  "void",
+  "{",
+  "}"
 };
 
 /* See val_print for a description of the various parameters of this
    function; they are identical.  */
 
 void
-m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
+m2_val_print (struct type *type, int embedded_offset,
              CORE_ADDR address, struct ui_file *stream, int recurse,
-             const struct value *original_value,
+             struct value *original_value,
              const struct value_print_options *options)
 {
-  struct gdbarch *gdbarch = get_type_arch (type);
-  unsigned int i = 0;  /* Number of characters printed.  */
   unsigned len;
   struct type *elttype;
-  unsigned eltlen;
-  LONGEST val;
   CORE_ADDR addr;
+  const gdb_byte *valaddr = value_contents_for_printing (original_value);
 
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
   switch (TYPE_CODE (type))
     {
     case TYPE_CODE_ARRAY:
       if (TYPE_LENGTH (type) > 0 && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0)
        {
          elttype = check_typedef (TYPE_TARGET_TYPE (type));
-         eltlen = TYPE_LENGTH (elttype);
-         len = TYPE_LENGTH (type) / eltlen;
-         if (options->prettyprint_arrays)
+         len = TYPE_LENGTH (type) / TYPE_LENGTH (elttype);
+         if (options->prettyformat_arrays)
            print_spaces_filtered (2 + 2 * recurse, stream);
          /* For an array of chars, print with string syntax.  */
-         if (eltlen == 1 &&
+         if (TYPE_LENGTH (elttype) == 1 &&
              ((TYPE_CODE (elttype) == TYPE_CODE_INT)
               || ((current_language->la_language == language_m2)
                   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
@@ -351,12 +352,11 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
              LA_PRINT_STRING (stream, TYPE_TARGET_TYPE (type),
                               valaddr + embedded_offset, len, NULL,
                               0, options);
-             i = len;
            }
          else
            {
              fprintf_filtered (stream, "{");
-             val_print_array_elements (type, valaddr, embedded_offset,
+             val_print_array_elements (type, embedded_offset,
                                        address, stream,
                                        recurse, original_value,
                                        options, 0);
@@ -373,7 +373,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
        print_variable_at_address (type, valaddr + embedded_offset,
                                   stream, recurse, options);
       else if (options->format && options->format != 's')
-       val_print_scalar_formatted (type, valaddr, embedded_offset,
+       val_print_scalar_formatted (type, embedded_offset,
                                    original_value, options, 0, stream);
       else
        {
@@ -397,19 +397,17 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
        m2_print_unbounded_array (type, valaddr, embedded_offset,
                                  address, stream, recurse, options);
       else
-       cp_print_value_fields (type, type, valaddr, embedded_offset,
+       cp_print_value_fields (type, type, embedded_offset,
                               address, stream, recurse, original_value,
                               options, NULL, 0);
       break;
 
-    case TYPE_CODE_BITSTRING:
     case TYPE_CODE_SET:
       elttype = TYPE_INDEX_TYPE (type);
-      CHECK_TYPEDEF (elttype);
+      elttype = check_typedef (elttype);
       if (TYPE_STUB (elttype))
        {
          fprintf_filtered (stream, _("<incomplete type>"));
-         gdb_flush (stream);
          break;
        }
       else
@@ -417,13 +415,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
          struct type *range = elttype;
          LONGEST low_bound, high_bound;
          int i;
-         int is_bitstring = TYPE_CODE (type) == TYPE_CODE_BITSTRING;
          int need_comma = 0;
 
-         if (is_bitstring)
-           fputs_filtered ("B'", stream);
-         else
-           fputs_filtered ("{", stream);
+         fputs_filtered ("{", stream);
 
          i = get_discrete_bounds (range, &low_bound, &high_bound);
        maybe_bad_bstring:
@@ -443,9 +437,7 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
                  i = element;
                  goto maybe_bad_bstring;
                }
-             if (is_bitstring)
-               fprintf_filtered (stream, "%d", element);
-             else if (element)
+             if (element)
                {
                  if (need_comma)
                    fputs_filtered (", ", stream);
@@ -469,21 +461,18 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
                }
            }
        done:
-         if (is_bitstring)
-           fputs_filtered ("'", stream);
-         else
-           fputs_filtered ("}", stream);
+         fputs_filtered ("}", stream);
        }
       break;
 
     case TYPE_CODE_RANGE:
       if (TYPE_LENGTH (type) == TYPE_LENGTH (TYPE_TARGET_TYPE (type)))
        {
-         m2_val_print (TYPE_TARGET_TYPE (type), valaddr, embedded_offset,
+         m2_val_print (TYPE_TARGET_TYPE (type), embedded_offset,
                        address, stream, recurse, original_value, options);
          break;
        }
-      /* FIXME: create_range_type does not set the unsigned bit in a
+      /* FIXME: create_static_range_type does not set the unsigned bit in a
          range type (I think it probably should copy it from the target
          type), so we won't print values which are too large to
          fit in a signed integer correctly.  */
@@ -504,10 +493,9 @@ m2_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_BOOL:
     case TYPE_CODE_CHAR:
     default:
-      generic_val_print (type, valaddr, embedded_offset, address,
+      generic_val_print (type, embedded_offset, address,
                         stream, recurse, original_value, options,
                         &m2_decorations);
       break;
     }
-  gdb_flush (stream);
 }