2012-02-24 Luis Machado <lgustavo@codesourcery>
[deliverable/binutils-gdb.git] / gdb / f-valprint.c
index 3280ddcb5d98ff890be0f09184f1c1a370efd311..17f747f5cd0d84c0cd29ab58b5dc75ed9a7c077f 100644 (file)
@@ -1,7 +1,7 @@
 /* Support for printing Fortran values for GDB, the GNU debugger.
 
-   Copyright (C) 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2003, 2005, 2006,
-   2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
+   Copyright (C) 1993-1996, 1998-2000, 2003, 2005-2012 Free Software
+   Foundation, Inc.
 
    Contributed by Motorola.  Adapted from the C definitions by Farooq Butt
    (fmbutt@engage.sps.mot.com), additionally worked over by Stan Shebs.
@@ -41,7 +41,7 @@ static int there_is_a_visible_common_named (char *);
 
 extern void _initialize_f_valprint (void);
 static void info_common_command (char *, int);
-static void list_all_visible_commons (char *);
+static void list_all_visible_commons (const char *);
 static void f77_create_arrayprint_offset_tbl (struct type *,
                                              struct ui_file *);
 static void f77_get_dynamic_length_of_aggregate (struct type *);
@@ -271,10 +271,23 @@ 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:
@@ -333,10 +346,19 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
        {
          if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
            {
-             struct value *deref_val =
-               value_at
-               (TYPE_TARGET_TYPE (type),
-                unpack_pointer (type, valaddr + embedded_offset));
+             struct value *deref_val;
+
+             deref_val = coerce_ref_if_computed (original_value);
+             if (deref_val != NULL)
+               {
+                 /* More complicated computed references are not supported.  */
+                 gdb_assert (embedded_offset == 0);
+               }
+             else
+               deref_val = value_at (TYPE_TARGET_TYPE (type),
+                                     unpack_pointer (type,
+                                                     (valaddr
+                                                      + embedded_offset)));
 
              common_val_print (deref_val, stream, recurse,
                                options, current_language);
@@ -363,6 +385,7 @@ 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;
@@ -379,7 +402,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;
 
@@ -495,7 +518,7 @@ f_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
 }
 
 static void
-list_all_visible_commons (char *funname)
+list_all_visible_commons (const char *funname)
 {
   SAVED_F77_COMMON_PTR tmp;
 
@@ -522,7 +545,7 @@ info_common_command (char *comname, int from_tty)
   SAVED_F77_COMMON_PTR the_common;
   COMMON_ENTRY_PTR entry;
   struct frame_info *fi;
-  char *funname = 0;
+  const char *funname = 0;
   struct symbol *func;
 
   /* We have been told to display the contents of F77 COMMON 
This page took 0.025438 seconds and 4 git commands to generate.