Explicitly include <array> for std::array<>.
[deliverable/binutils-gdb.git] / gdb / cp-valprint.c
index 57d5d02a37c3fc92be42e3d7fe5c8e1f51b3d1ac..af70421fd774a07b8b33ee5a6c148c8e3f3515b8 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing C++ values for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2016 Free Software Foundation, Inc.
+   Copyright (C) 1986-2017 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -35,6 +35,7 @@
 #include "language.h"
 #include "extension.h"
 #include "typeprint.h"
+#include "byte-vector.h"
 
 /* Controls printing of vtbl's.  */
 static void
@@ -490,7 +491,6 @@ cp_print_value (struct type *type, struct type *real_type,
       int skip = 0;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
       const char *basename = TYPE_NAME (baseclass);
-      const gdb_byte *base_valaddr = NULL;
       struct value *base_val = NULL;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
@@ -535,34 +535,26 @@ cp_print_value (struct type *type, struct type *real_type,
              if ((boffset + offset) < 0
                  || (boffset + offset) >= TYPE_LENGTH (real_type))
                {
-                 gdb_byte *buf;
-                 struct cleanup *back_to;
+                 gdb::byte_vector buf (TYPE_LENGTH (baseclass));
 
-                 buf = (gdb_byte *) xmalloc (TYPE_LENGTH (baseclass));
-                 back_to = make_cleanup (xfree, buf);
-
-                 if (target_read_memory (address + boffset, buf,
+                 if (target_read_memory (address + boffset, buf.data (),
                                          TYPE_LENGTH (baseclass)) != 0)
                    skip = 1;
                  base_val = value_from_contents_and_address (baseclass,
-                                                             buf,
+                                                             buf.data (),
                                                              address + boffset);
                  baseclass = value_type (base_val);
                  thisoffset = 0;
                  boffset = 0;
                  thistype = baseclass;
-                 base_valaddr = value_contents_for_printing_const (base_val);
-                 do_cleanups (back_to);
                }
              else
                {
-                 base_valaddr = valaddr;
                  base_val = val;
                }
            }
          else
            {
-             base_valaddr = valaddr;
              base_val = val;
            }
        }
@@ -591,7 +583,7 @@ cp_print_value (struct type *type, struct type *real_type,
             baseclass if possible.  */
          if (!options->raw)
            result
-             = apply_ext_lang_val_pretty_printer (baseclass, base_valaddr,
+             = apply_ext_lang_val_pretty_printer (baseclass,
                                                   thisoffset + boffset,
                                                   value_address (base_val),
                                                   stream, recurse,
@@ -763,7 +755,7 @@ cp_find_class_member (struct type **self_p, int *fieldno,
 
 void
 cp_print_class_member (const gdb_byte *valaddr, struct type *type,
-                      struct ui_file *stream, char *prefix)
+                      struct ui_file *stream, const char *prefix)
 {
   enum bfd_endian byte_order = gdbarch_byte_order (get_type_arch (type));
 
This page took 0.024678 seconds and 4 git commands to generate.