Include string.h in common-defs.h
[deliverable/binutils-gdb.git] / gdb / cp-valprint.c
index 0871848ec77dade795036c459179586a3b95e74f..e38a2be305abb454bdc6fa4dbf420832c489c792 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing C++ values for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2013 Free Software Foundation, Inc.
+   Copyright (C) 1986-2014 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
 #include "gdbcmd.h"
 #include "demangle.h"
 #include "annotate.h"
-#include "gdb_string.h"
 #include "c-lang.h"
 #include "target.h"
 #include "cp-abi.h"
 #include "valprint.h"
 #include "cp-support.h"
 #include "language.h"
-#include "python/python.h"
+#include "extension.h"
 #include "exceptions.h"
 #include "typeprint.h"
 
@@ -208,8 +207,8 @@ cp_print_value_fields (struct type *type, struct type *real_type,
     fprintf_filtered (stream, "<No data fields>");
   else
     {
-      int statmem_obstack_initial_size = 0;
-      int stat_array_obstack_initial_size = 0;
+      size_t statmem_obstack_initial_size = 0;
+      size_t stat_array_obstack_initial_size = 0;
       struct type *vptr_basetype = NULL;
       int vptr_fieldno;
 
@@ -239,7 +238,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
            fprintf_filtered (stream, ", ");
          else if (n_baseclasses > 0)
            {
-             if (options->pretty)
+             if (options->prettyformat)
                {
                  fprintf_filtered (stream, "\n");
                  print_spaces_filtered (2 + 2 * recurse, stream);
@@ -250,7 +249,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
            }
          fields_seen = 1;
 
-         if (options->pretty)
+         if (options->prettyformat)
            {
              fprintf_filtered (stream, "\n");
              print_spaces_filtered (2 + 2 * recurse, stream);
@@ -298,7 +297,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
                                          TYPE_FIELD_BITPOS (type, i),
                                          TYPE_FIELD_BITSIZE (type, i)))
                {
-                 val_print_optimized_out (stream);
+                 val_print_optimized_out (val, stream);
                }
              else
                {
@@ -333,12 +332,9 @@ cp_print_value_fields (struct type *type, struct type *real_type,
                    fprintf_filtered (stream,
                                      _("<error reading variable: %s>"),
                                      ex.message);
-                 else if (v == NULL)
-                   val_print_optimized_out (stream);
-                 else
-                   cp_print_static_field (TYPE_FIELD_TYPE (type, i),
-                                          v, stream, recurse + 1,
-                                          options);
+                 cp_print_static_field (TYPE_FIELD_TYPE (type, i),
+                                        v, stream, recurse + 1,
+                                        options);
                }
              else if (i == vptr_fieldno && type == vptr_basetype)
                {
@@ -373,7 +369,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
       if (dont_print_statmem == 0)
        {
-         int obstack_final_size =
+         size_t obstack_final_size =
            obstack_object_size (&dont_print_statmem_obstack);
 
          if (obstack_final_size > statmem_obstack_initial_size)
@@ -390,7 +386,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
          if (last_set_recurse != recurse)
            {
-             int obstack_final_size =
+             size_t obstack_final_size =
                obstack_object_size (&dont_print_stat_array_obstack);
              
              if (obstack_final_size > stat_array_obstack_initial_size)
@@ -407,7 +403,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
            }
        }
 
-      if (options->pretty)
+      if (options->prettyformat)
        {
          fprintf_filtered (stream, "\n");
          print_spaces_filtered (2 * recurse, stream);
@@ -446,6 +442,7 @@ cp_print_value_fields_rtti (struct type *type,
       /* Ugh, we have to convert back to a value here.  */
       value = value_from_contents_and_address (type, valaddr + offset,
                                               address + offset);
+      type = value_type (value);
       /* We don't actually care about most of the result here -- just
         the type.  We already have the correct offset, due to how
         val_print was initially called.  */
@@ -548,6 +545,7 @@ cp_print_value (struct type *type, struct type *real_type,
                  base_val = value_from_contents_and_address (baseclass,
                                                              buf,
                                                              address + boffset);
+                 baseclass = value_type (base_val);
                  thisoffset = 0;
                  boffset = 0;
                  thistype = baseclass;
@@ -568,7 +566,7 @@ cp_print_value (struct type *type, struct type *real_type,
        }
 
       /* Now do the printing.  */
-      if (options->pretty)
+      if (options->prettyformat)
        {
          fprintf_filtered (stream, "\n");
          print_spaces_filtered (2 * recurse, stream);
@@ -587,17 +585,17 @@ cp_print_value (struct type *type, struct type *real_type,
        {
          int result = 0;
 
-         /* Attempt to run the Python pretty-printers on the
+         /* Attempt to run an extension language pretty-printer on the
             baseclass if possible.  */
          if (!options->raw)
-           result = apply_val_pretty_printer (baseclass, base_valaddr,
-                                              thisoffset + boffset,
-                                              value_address (base_val),
-                                              stream, recurse, base_val,
-                                              options, current_language);
+           result
+             = apply_ext_lang_val_pretty_printer (baseclass, base_valaddr,
+                                                  thisoffset + boffset,
+                                                  value_address (base_val),
+                                                  stream, recurse,
+                                                  base_val, options,
+                                                  current_language);
 
-
-                 
          if (!result)
            cp_print_value_fields (baseclass, thistype, base_valaddr,
                                   thisoffset + boffset,
@@ -640,7 +638,13 @@ cp_print_static_field (struct type *type,
                       const struct value_print_options *options)
 {
   struct value_print_options opts;
-  
+
+  if (value_entirely_optimized_out (val))
+    {
+      val_print_optimized_out (val, stream);
+      return;
+    }
+
   if (TYPE_CODE (type) == TYPE_CODE_STRUCT)
     {
       CORE_ADDR *first_dont_print;
This page took 0.043505 seconds and 4 git commands to generate.