* config/m68k/nm-hp300bsd.h: Correctly identify 4.3BSD vs 4.4BSD.
[deliverable/binutils-gdb.git] / gdb / c-valprint.c
index 2d13db2ace2b94d3c4e911945fae03508a741355..be498dfff8aa0dc7d863ee1dc7c7c6717a1959ae 100644 (file)
@@ -32,13 +32,13 @@ extern int vtblprint;               /* Controls printing of vtbl's */
 extern int demangle;           /* whether to print C++ syms raw or src-form */
 
 extern void
-cp_print_class_member PARAMS ((char *, struct type *, FILE *, char *));
+cp_print_class_member PARAMS ((char *, struct type *, GDB_FILE *, char *));
 
 extern void
-cp_print_class_method PARAMS ((char *, struct type *, FILE *));
+cp_print_class_method PARAMS ((char *, struct type *, GDB_FILE *));
 
 extern void
-cp_print_value_fields PARAMS ((struct type *, char *, FILE *, int, int,
+cp_print_value_fields PARAMS ((struct type *, char *, GDB_FILE *, int, int,
                               enum val_prettyprint, struct type **));
 
 extern int
@@ -53,11 +53,11 @@ cp_is_vtbl_member PARAMS ((struct type *));
 /* BEGIN-FIXME:  Hooks into c-typeprint.c */
 
 extern void
-c_type_print_varspec_prefix PARAMS ((struct type *, FILE *, int, int));
+c_type_print_varspec_prefix PARAMS ((struct type *, GDB_FILE *, int, int));
 
 extern void
 cp_type_print_method_args PARAMS ((struct type **, char *, char *, int,
-                                  FILE *));
+                                  GDB_FILE *));
 /* END-FIXME */
 
 
@@ -83,7 +83,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
      struct type *type;
      char *valaddr;
      CORE_ADDR address;
-     FILE *stream;
+     GDB_FILE *stream;
      int format;
      int deref_ref;
      int recurse;
@@ -94,7 +94,6 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
   struct type *elttype;
   unsigned eltlen;
   LONGEST val;
-  unsigned char c;
   CORE_ADDR addr;
 
   switch (TYPE_CODE (type))
@@ -113,11 +112,8 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
          if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT
              && (format == 0 || format == 's'))
            {
-             if (addressprint && format != 's')
-               {
-                 fprintf_filtered (stream, "0x%x ", address);
-               }
              LA_PRINT_STRING (stream, valaddr, len, 0);
+             i = len;
            }
          else
            {
@@ -140,8 +136,8 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
          break;
        }
       /* Array of unspecified length: treat like pointer to first elt.  */
-      valaddr = (char *) &address;
-      /* FALL THROUGH */
+      addr = address;
+      goto print_unpacked_pointer;
 
     case TYPE_CODE_PTR:
       if (format && format != 's')
@@ -162,6 +158,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
       else
        {
          addr = unpack_pointer (type, valaddr);
+       print_unpacked_pointer:
          elttype = TYPE_TARGET_TYPE (type);
 
          if (TYPE_CODE (elttype) == TYPE_CODE_FUNC)
@@ -174,7 +171,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
 
          if (addressprint && format != 's')
            {
-             fprintf_filtered (stream, "0x%x", addr);
+             fprintf_filtered (stream, "0x%lx", (unsigned long)addr);
            }
 
          /* For a pointer to char or unsigned char, also print the string
@@ -203,8 +200,25 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
              if (vtblprint)
                {
                  value vt_val;
+                 struct symbol *wsym = (struct symbol *)NULL;
+                 struct type *wtype;
+                 struct symtab *s;
+                 struct block *block = (struct block *)NULL;
+                 int is_this_fld;
 
-                 vt_val = value_at (TYPE_TARGET_TYPE (type), vt_address);
+
+                 wsym = lookup_symbol (SYMBOL_NAME(msymbol), block, 
+                               VAR_NAMESPACE, &is_this_fld, &s);
+                 if (wsym)
+                   {
+                     wtype = SYMBOL_TYPE(wsym);
+                   }
+                 else
+                   {
+                     wtype = TYPE_TARGET_TYPE(type);
+                   }
+                 vt_val = value_at (wtype, vt_address);
                  val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val),
                             VALUE_ADDRESS (vt_val), stream, format,
                             deref_ref, recurse + 1, pretty);
@@ -288,7 +302,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
          break;
        }
       len = TYPE_NFIELDS (type);
-      val = unpack_long (builtin_type_int, valaddr);
+      val = unpack_long (type, valaddr);
       for (i = 0; i < len; i++)
        {
          QUIT;
@@ -303,11 +317,7 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
        }
       else
        {
-#ifdef LONG_LONG
-         fprintf_filtered (stream, "%lld", val);
-#else
-         fprintf_filtered (stream, "%ld", val);
-#endif
+         print_longest (stream, 'd', 0, val);
        }
       break;
 
@@ -326,6 +336,10 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
       print_address_demangle (address, stream, demangle);
       break;
 
+    case TYPE_CODE_BOOL:
+      /* Do something at least vaguely reasonable, for example if the
+        language is set wrong.  */
+
     case TYPE_CODE_INT:
       format = format ? format : output_format;
       if (format)
@@ -397,6 +411,6 @@ c_val_print (type, valaddr, address, stream, format, deref_ref, recurse,
     default:
       error ("Invalid C/C++ type code %d in symbol table.", TYPE_CODE (type));
     }
-  fflush (stream);
+  gdb_flush (stream);
   return (0);
 }
This page took 0.025189 seconds and 4 git commands to generate.