2011-07-22 Phil Muldoon <pmuldoon@redhat.com>
[deliverable/binutils-gdb.git] / gdb / f-valprint.c
index 94a70a15e0dadb32d42f67cf68c94f17194d9e38..66b425d78c956b851b1ae9de106a5ce2d862169b 100644 (file)
@@ -242,12 +242,9 @@ Type node corrupt! F77 arrays cannot have %d subscripts (%d Max)"),
 }
 \f
 
-/* Print data of type TYPE located at VALADDR (within GDB), which came from
-   the inferior at address ADDRESS, onto stdio stream STREAM according to
-   OPTIONS.  The data at VALADDR is in target byte order.
-
-   If the data are a string pointer, returns the number of string characters
-   printed.  */
+/* See val_print for a description of the various parameters of this
+   function; they are identical.  The semantics of the return value is
+   also identical to val_print.  */
 
 int
 f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
@@ -274,17 +271,30 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_ARRAY:
-      fprintf_filtered (stream, "(");
-      f77_print_array (type, valaddr, embedded_offset,
-                      address, stream, recurse, original_value, options);
-      fprintf_filtered (stream, ")");
+      if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_CHAR)
+       {
+         fprintf_filtered (stream, "(");
+         f77_print_array (type, valaddr, embedded_offset,
+                          address, stream, recurse, original_value, options);
+         fprintf_filtered (stream, ")");
+       }
+      else
+       {
+         struct type *ch_type = TYPE_TARGET_TYPE (type);
+
+         f77_get_dynamic_length_of_aggregate (type);
+         LA_PRINT_STRING (stream, ch_type,
+                          valaddr + embedded_offset,
+                          TYPE_LENGTH (type) / TYPE_LENGTH (ch_type),
+                          NULL, 0, options);
+       }
       break;
 
     case TYPE_CODE_PTR:
       if (options->format && options->format != 's')
        {
-         print_scalar_formatted (valaddr + embedded_offset,
-                                 type, options, 0, stream);
+         val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                     original_value, options, 0, stream);
          break;
        }
       else
@@ -352,8 +362,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
     case TYPE_CODE_FUNC:
       if (options->format)
        {
-         print_scalar_formatted (valaddr + embedded_offset,
-                                 type, options, 0, stream);
+         val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                     original_value, options, 0, stream);
          break;
        }
       /* FIXME, we should consider, at least for ANSI C language, eliminating
@@ -366,14 +376,15 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
       break;
 
     case TYPE_CODE_INT:
+    case TYPE_CODE_CHAR:
       if (options->format || options->output_format)
        {
          struct value_print_options opts = *options;
 
          opts.format = (options->format ? options->format
                         : options->output_format);
-         print_scalar_formatted (valaddr + embedded_offset,
-                                 type, &opts, 0, stream);
+         val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                     original_value, options, 0, stream);
        }
       else
        {
@@ -382,7 +393,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
             Since we don't know whether the value is really intended to
             be used as an integer or a character, print the character
             equivalent as well.  */
-         if (TYPE_LENGTH (type) == 1)
+         if (TYPE_LENGTH (type) == 1 || TYPE_CODE (type) == TYPE_CODE_CHAR)
            {
              LONGEST c;
 
@@ -395,16 +406,16 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
     case TYPE_CODE_FLAGS:
       if (options->format)
-       print_scalar_formatted (valaddr + embedded_offset,
-                               type, options, 0, stream);
+       val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                   original_value, options, 0, stream);
       else
        val_print_type_code_flags (type, valaddr + embedded_offset, stream);
       break;
 
     case TYPE_CODE_FLT:
       if (options->format)
-       print_scalar_formatted (valaddr + embedded_offset,
-                               type, options, 0, stream);
+       val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                   original_value, options, 0, stream);
       else
        print_floating (valaddr + embedded_offset, type, stream);
       break;
@@ -429,8 +440,8 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 
          opts.format = (options->format ? options->format
                         : options->output_format);
-         print_scalar_formatted (valaddr + embedded_offset,
-                                 type, &opts, 0, stream);
+         val_print_scalar_formatted (type, valaddr, embedded_offset,
+                                     original_value, &opts, 0, stream);
        }
       else
        {
This page took 0.024897 seconds and 4 git commands to generate.