* f-typeprint.c (f_type_print_base): Handle TYPE_CODE_REF.
authorRichard Henderson <rth@redhat.com>
Tue, 14 Oct 2003 06:51:14 +0000 (06:51 +0000)
committerRichard Henderson <rth@redhat.com>
Tue, 14 Oct 2003 06:51:14 +0000 (06:51 +0000)
        * f-valprint.c (f_val_print): Likewise.  Tweak TYPE_CODE_PTR to
        match c_val_print a bit closer.

gdb/ChangeLog
gdb/f-typeprint.c
gdb/f-valprint.c

index 1a77033..e6a8d3d 100644 (file)
@@ -1,3 +1,9 @@
+2003-10-13  Richard Henderson  <rth@redhat.com>
+
+       * f-typeprint.c (f_type_print_base): Handle TYPE_CODE_REF.
+       * f-valprint.c (f_val_print): Likewise.  Tweak TYPE_CODE_PTR to
+       match c_val_print a bit closer.
+
 2003-10-13  Kevin Buettner  <kevinb@redhat.com>
 
        * frv-tdep.c (max_instrs_per_bundle, frv_instr_size): New constants.
index 3a153a3..9e148fb 100644 (file)
@@ -329,6 +329,11 @@ f_type_print_base (struct type *type, struct ui_file *stream, int show,
       f_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
       break;
 
+    case TYPE_CODE_REF:
+      fprintf_filtered (stream, "REF TO -> ( ");
+      f_type_print_base (TYPE_TARGET_TYPE (type), stream, 0, level);
+      break;
+
     case TYPE_CODE_VOID:
       fprintf_filtered (stream, "VOID");
       break;
index 7fdcabd..805590f 100644 (file)
@@ -384,11 +384,7 @@ f_val_print (struct type *type, char *valaddr, int embedded_offset,
                       deref_ref, recurse, pretty);
       fprintf_filtered (stream, ")");
       break;
-#if 0
-      /* Array of unspecified length: treat like pointer to first elt.  */
-      valaddr = (char *) &address;
-      /* FALL THROUGH */
-#endif
+
     case TYPE_CODE_PTR:
       if (format && format != 's')
        {
@@ -409,7 +405,7 @@ f_val_print (struct type *type, char *valaddr, int embedded_offset,
            }
 
          if (addressprint && format != 's')
-           fprintf_filtered (stream, "0x%s", paddr_nz (addr));
+           print_address_numeric (addr, 1, stream);
 
          /* For a pointer to char or unsigned char, also print the string
             pointed to, unless pointer is null.  */
@@ -419,9 +415,47 @@ f_val_print (struct type *type, char *valaddr, int embedded_offset,
              && addr != 0)
            i = val_print_string (addr, -1, TYPE_LENGTH (elttype), stream);
 
-         /* Return number of characters printed, plus one for the
-            terminating null if we have "reached the end".  */
-         return (i + (print_max && i != print_max));
+         /* Return number of characters printed, including the terminating
+            '\0' if we reached the end.  val_print_string takes care including
+            the terminating '\0' if necessary.  */
+         return i;
+       }
+      break;
+
+    case TYPE_CODE_REF:
+      elttype = check_typedef (TYPE_TARGET_TYPE (type));
+      if (addressprint)
+       {
+         CORE_ADDR addr
+           = extract_typed_address (valaddr + embedded_offset, type);
+         fprintf_filtered (stream, "@");
+         print_address_numeric (addr, 1, stream);
+         if (deref_ref)
+           fputs_filtered (": ", stream);
+       }
+      /* De-reference the reference.  */
+      if (deref_ref)
+       {
+         if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
+           {
+             struct value *deref_val =
+             value_at
+             (TYPE_TARGET_TYPE (type),
+              unpack_pointer (lookup_pointer_type (builtin_type_void),
+                              valaddr + embedded_offset),
+              NULL);
+             val_print (VALUE_TYPE (deref_val),
+                        VALUE_CONTENTS (deref_val),
+                        0,
+                        VALUE_ADDRESS (deref_val),
+                        stream,
+                        format,
+                        deref_ref,
+                        recurse,
+                        pretty);
+           }
+         else
+           fputs_filtered ("???", stream);
        }
       break;