2007-06-13 Markus Deuling <deuling@de.ibm.com>
[deliverable/binutils-gdb.git] / gdb / c-valprint.c
index 0a4255eebd5b4a8c59545df87fd06fd0500f9a62..ad5e4d16edac22a5ac577d2ddcb3d94c0baa281b 100644 (file)
@@ -1,8 +1,8 @@
 /* Support for printing C values for GDB, the GNU debugger.
 
-   Copyright 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996,
-   1997, 1998, 1999, 2000, 2001, 2003, 2005 Free Software Foundation,
-   Inc.
+   Copyright (C) 1986, 1988, 1989, 1991, 1992, 1993, 1994, 1995, 1996, 1997,
+   1998, 1999, 2000, 2001, 2003, 2005, 2006, 2007
+   Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -18,8 +18,8 @@
 
    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., 59 Temple Place - Suite 330,
-   Boston, MA 02111-1307, USA.  */
+   Foundation, Inc., 51 Franklin Street, Fifth Floor,
+   Boston, MA 02110-1301, USA.  */
 
 #include "defs.h"
 #include "gdb_string.h"
@@ -70,7 +70,7 @@ print_function_pointer_address (CORE_ADDR address, struct ui_file *stream)
    The PRETTY parameter controls prettyprinting.  */
 
 int
-c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
+c_val_print (struct type *type, const gdb_byte *valaddr, int embedded_offset,
             CORE_ADDR address, struct ui_file *stream, int format,
             int deref_ref, int recurse, enum val_prettyprint pretty)
 {
@@ -96,7 +96,7 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
            }
          /* For an array of chars, print with string syntax.  */
          if (eltlen == 1 &&
-             ((TYPE_CODE (elttype) == TYPE_CODE_INT)
+             ((TYPE_CODE (elttype) == TYPE_CODE_INT && TYPE_NOSIGN (elttype))
               || ((current_language->la_language == language_m2)
                   && (TYPE_CODE (elttype) == TYPE_CODE_CHAR)))
              && (format == 0 || format == 's'))
@@ -142,6 +142,21 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
       addr = address;
       goto print_unpacked_pointer;
 
+    case TYPE_CODE_MEMBERPTR:
+      if (format)
+       {
+         print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+         break;
+       }
+      cp_print_class_member (valaddr + embedded_offset,
+                            TYPE_DOMAIN_TYPE (type),
+                            stream, "&");
+      break;
+
+    case TYPE_CODE_METHODPTR:
+      cplus_print_method_ptr (valaddr + embedded_offset, type, stream);
+      break;
+
     case TYPE_CODE_PTR:
       if (format && format != 's')
        {
@@ -159,17 +174,6 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
          break;
        }
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (TYPE_CODE (elttype) == TYPE_CODE_METHOD)
-       {
-         cp_print_class_method (valaddr + embedded_offset, type, stream);
-       }
-      else if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
-       {
-         cp_print_class_member (valaddr + embedded_offset,
-                                TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)),
-                                stream, "&");
-       }
-      else
        {
          addr = unpack_pointer (type, valaddr + embedded_offset);
        print_unpacked_pointer:
@@ -250,19 +254,8 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
        }
       break;
 
-    case TYPE_CODE_MEMBER:
-      error (_("not implemented: member type in c_val_print"));
-      break;
-
     case TYPE_CODE_REF:
       elttype = check_typedef (TYPE_TARGET_TYPE (type));
-      if (TYPE_CODE (elttype) == TYPE_CODE_MEMBER)
-       {
-         cp_print_class_member (valaddr + embedded_offset,
-                                TYPE_DOMAIN_TYPE (elttype),
-                                stream, "");
-         break;
-       }
       if (addressprint)
        {
          CORE_ADDR addr
@@ -343,7 +336,15 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
        }
       break;
 
+    case TYPE_CODE_FLAGS:
+      if (format)
+         print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
+      else
+       val_print_type_code_flags (type, valaddr + embedded_offset, stream);
+      break;
+
     case TYPE_CODE_FUNC:
+    case TYPE_CODE_METHOD:
       if (format)
        {
          print_scalar_formatted (valaddr + embedded_offset, type, format, 0, stream);
@@ -435,14 +436,6 @@ c_val_print (struct type *type, const bfd_byte *valaddr, int embedded_offset,
        }
       break;
 
-    case TYPE_CODE_METHOD:
-      {
-       struct value *v = value_at (type, address);
-       cp_print_class_method (value_contents (value_addr (v)),
-                              lookup_pointer_type (type), stream);
-       break;
-      }
-
     case TYPE_CODE_VOID:
       fprintf_filtered (stream, "void");
       break;
@@ -563,6 +556,9 @@ c_value_print (struct value *val, struct ui_file *stream, int format,
        }
     }
 
+  if (!value_initialized (val))
+    fprintf_filtered (stream, " [uninitialized] ");
+
   if (objectprint && (TYPE_CODE (type) == TYPE_CODE_CLASS))
     {
       /* Attempt to determine real type of object */
This page took 0.026286 seconds and 4 git commands to generate.