* ada-valprint.c (ada_val_print_1) [TYPE_CODE_REF]: Ignore deref_ref
authorJoel Brobecker <brobecker@gnat.com>
Tue, 1 Jan 2008 11:39:07 +0000 (11:39 +0000)
committerJoel Brobecker <brobecker@gnat.com>
Tue, 1 Jan 2008 11:39:07 +0000 (11:39 +0000)
        and always print the dereferenced value.

gdb/ChangeLog
gdb/ada-valprint.c

index 73d984ed654484de425f9303351954b78376b210..55b2fe29c154ea73d1b9652c17dab30359b343e5 100644 (file)
@@ -1,3 +1,8 @@
+2008-01-01  Joel Brobecker  <brobecker@adacore.com>
+
+       * ada-valprint.c (ada_val_print_1) [TYPE_CODE_REF]: Ignore deref_ref
+       and always print the dereferenced value.
+
 2008-01-01  Joel Brobecker  <brobecker@adacore.com>
 
        * ada-lang.c (ada_evaluate_subexp, case BINOP_SUB): Add handling
index b96baf08954af0f8cefe4fdd3e6c1e465a0949b7..d2def87ae2ab175fa11f7cd660a9a8163277f415 100644 (file)
@@ -855,32 +855,35 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
       return len;
 
     case TYPE_CODE_REF:
+      /* For references, the debugger is expected to print the value as
+         an address if DEREF_REF is null.  But printing an address in place
+         of the object value would be confusing to an Ada programmer.
+         So, for Ada values, we print the actual dereferenced value
+         regardless.  */
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      /* De-reference the reference */
-      if (deref_ref)
-       {
-         if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
-           {
-             LONGEST deref_val_int = (LONGEST)
-               unpack_pointer (lookup_pointer_type (builtin_type_void),
-                               valaddr);
-             if (deref_val_int != 0)
-               {
-                 struct value *deref_val =
-                   ada_value_ind (value_from_longest
-                                  (lookup_pointer_type (elttype),
-                                   deref_val_int));
-                 val_print (value_type (deref_val),
-                            value_contents (deref_val), 0,
-                            VALUE_ADDRESS (deref_val), stream, format,
-                            deref_ref, recurse + 1, pretty);
-               }
-             else
-               fputs_filtered ("(null)", stream);
-           }
-         else
-           fputs_filtered ("???", stream);
-       }
+      
+      if (TYPE_CODE (elttype) != TYPE_CODE_UNDEF)
+        {
+          LONGEST deref_val_int = (LONGEST)
+            unpack_pointer (lookup_pointer_type (builtin_type_void),
+                            valaddr);
+          if (deref_val_int != 0)
+            {
+              struct value *deref_val =
+                ada_value_ind (value_from_longest
+                               (lookup_pointer_type (elttype),
+                                deref_val_int));
+              val_print (value_type (deref_val),
+                         value_contents (deref_val), 0,
+                         VALUE_ADDRESS (deref_val), stream, format,
+                         deref_ref, recurse + 1, pretty);
+            }
+          else
+            fputs_filtered ("(null)", stream);
+        }
+      else
+        fputs_filtered ("???", stream);
+
       break;
     }
   gdb_flush (stream);