ChangeLog:
[deliverable/binutils-gdb.git] / gdb / ada-valprint.c
index 2548a5fe026e83c7a80bf0b146d976db5afe7e6f..648cd3605e76f68a79e04951ea48f70667791e4e 100644 (file)
@@ -1,23 +1,22 @@
 /* Support for printing Ada values for GDB, the GNU debugger.
 
-   Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1997, 2001,
-   2002, 2003, 2004, 2005 Free Software Foundation, Inc.
+   Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1997, 2001, 2002,
+   2003, 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
 
-This file is part of GDB.
+   This file is part of GDB.
 
-This program is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 3 of the License, or
+   (at your option) any later version.
 
-This program is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with this program; if not, write to the Free Software
-Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.  */
+   You should have received a copy of the GNU General Public License
+   along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
 
 #include <ctype.h>
 #include "defs.h"
@@ -247,7 +246,7 @@ val_print_packed_array_elements (struct type *type, const gdb_byte *valaddr,
 static struct type *
 printable_val_type (struct type *type, const gdb_byte *valaddr)
 {
-  return ada_to_fixed_type (ada_aligned_type (type), valaddr, 0, NULL);
+  return ada_to_fixed_type (ada_aligned_type (type), valaddr, 0, NULL, 1);
 }
 
 /* Print the character C on STREAM as part of the contents of a literal
@@ -265,7 +264,7 @@ ada_emit_char (int c, struct ui_file *stream, int quoter, int type_len)
   if (isascii (c) && isprint (c))
     {
       if (c == quoter && c == '"')
-       fprintf_filtered (stream, "[\"%c\"]", quoter);
+       fprintf_filtered (stream, "\"\"");
       else
        fprintf_filtered (stream, "%c", c);
     }
@@ -419,7 +418,8 @@ ada_print_scalar (struct type *type, LONGEST val, struct ui_file *stream)
     case TYPE_CODE_SET:
     case TYPE_CODE_STRING:
     case TYPE_CODE_ERROR:
-    case TYPE_CODE_MEMBER:
+    case TYPE_CODE_MEMBERPTR:
+    case TYPE_CODE_METHODPTR:
     case TYPE_CODE_METHOD:
     case TYPE_CODE_REF:
       warning (_("internal error: unhandled type in ada_print_scalar"));
@@ -726,9 +726,9 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
               fprintf_filtered (stream, "(");
               type_print (type, "", stream, -1);
               fprintf_filtered (stream, ") ");
-              deprecated_print_address_numeric 
-               (extract_typed_address (valaddr, builtin_type_void_data_ptr),
-                 1, stream);
+             fputs_filtered (paddress (extract_typed_address
+                                       (valaddr, builtin_type_void_data_ptr)),
+                             stream);
             }
          else
            {
@@ -773,6 +773,13 @@ ada_val_print_1 (struct type *type, const gdb_byte *valaddr0,
        }
       break;
 
+    case TYPE_CODE_FLAGS:
+      if (format)
+         print_scalar_formatted (valaddr, type, format, 0, stream);
+      else
+       val_print_type_code_flags (type, valaddr, stream);
+      break;
+
     case TYPE_CODE_FLT:
       if (format)
        return c_val_print (type, valaddr0, embedded_offset, address, stream,
@@ -848,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);
@@ -907,7 +917,7 @@ ada_value_print (struct value *val0, struct ui_file *stream, int format,
   const gdb_byte *valaddr = value_contents (val0);
   CORE_ADDR address = VALUE_ADDRESS (val0) + value_offset (val0);
   struct type *type =
-    ada_to_fixed_type (value_type (val0), valaddr, address, NULL);
+    ada_to_fixed_type (value_type (val0), valaddr, address, NULL, 1);
   struct value *val =
     value_from_contents_and_address (type, valaddr, address);
 
This page took 0.031262 seconds and 4 git commands to generate.