Support structure offsets that are 512K or larger.
[deliverable/binutils-gdb.git] / gdb / cp-valprint.c
index 624976b0c05f66e620a05b1d4483a372c03e4972..7b0c19a3bb798d4843c459b0e45e1ed2f45a4e1f 100644 (file)
@@ -1,6 +1,6 @@
 /* Support for printing C++ values for GDB, the GNU debugger.
 
-   Copyright (C) 1986-2015 Free Software Foundation, Inc.
+   Copyright (C) 1986-2016 Free Software Foundation, Inc.
 
    This file is part of GDB.
 
@@ -80,7 +80,7 @@ static void cp_print_static_field (struct type *, struct value *,
                                   const struct value_print_options *);
 
 static void cp_print_value (struct type *, struct type *,
-                           const gdb_byte *, int,
+                           const gdb_byte *, LONGEST,
                            CORE_ADDR, struct ui_file *,
                            int, const struct value *,
                            const struct value_print_options *,
@@ -88,7 +88,7 @@ static void cp_print_value (struct type *, struct type *,
 
 
 /* GCC versions after 2.4.5 use this.  */
-const char vtbl_ptr_name[] = "__vtbl_ptr_type";
+EXPORTED_CONST char vtbl_ptr_name[] = "__vtbl_ptr_type";
 
 /* Return truth value for assertion that TYPE is of the type
    "pointer to virtual function".  */
@@ -96,9 +96,9 @@ const char vtbl_ptr_name[] = "__vtbl_ptr_type";
 int
 cp_is_vtbl_ptr_type (struct type *type)
 {
-  const char *typename = type_name_no_tag (type);
+  const char *type_name = type_name_no_tag (type);
 
-  return (typename != NULL && !strcmp (typename, vtbl_ptr_name));
+  return (type_name != NULL && !strcmp (type_name, vtbl_ptr_name));
 }
 
 /* Return truth value for the assertion that TYPE is of the type
@@ -154,7 +154,7 @@ cp_is_vtbl_member (struct type *type)
 
 void
 cp_print_value_fields (struct type *type, struct type *real_type,
-                      const gdb_byte *valaddr, int offset,
+                      const gdb_byte *valaddr, LONGEST offset,
                       CORE_ADDR address, struct ui_file *stream,
                       int recurse, const struct value *val,
                       const struct value_print_options *options,
@@ -165,7 +165,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
   int fields_seen = 0;
   static int last_set_recurse = -1;
 
-  CHECK_TYPEDEF (type);
+  type = check_typedef (type);
   
   if (recurse == 0)
     {
@@ -313,18 +313,21 @@ cp_print_value_fields (struct type *type, struct type *real_type,
                }
              else if (field_is_static (&TYPE_FIELD (type, i)))
                {
-                 volatile struct gdb_exception ex;
                  struct value *v = NULL;
 
-                 TRY_CATCH (ex, RETURN_MASK_ERROR)
+                 TRY
                    {
                      v = value_static_field (type, i);
                    }
 
-                 if (ex.reason < 0)
-                   fprintf_filtered (stream,
-                                     _("<error reading variable: %s>"),
-                                     ex.message);
+                 CATCH (ex, RETURN_MASK_ERROR)
+                   {
+                     fprintf_filtered (stream,
+                                       _("<error reading variable: %s>"),
+                                       ex.message);
+                   }
+                 END_CATCH
+
                  cp_print_static_field (TYPE_FIELD_TYPE (type, i),
                                         v, stream, recurse + 1,
                                         options);
@@ -414,7 +417,7 @@ cp_print_value_fields (struct type *type, struct type *real_type,
 
 void
 cp_print_value_fields_rtti (struct type *type,
-                           const gdb_byte *valaddr, int offset,
+                           const gdb_byte *valaddr, LONGEST offset,
                            CORE_ADDR address,
                            struct ui_file *stream, int recurse,
                            const struct value *val,
@@ -431,7 +434,8 @@ cp_print_value_fields_rtti (struct type *type,
                                     TARGET_CHAR_BIT * TYPE_LENGTH (type)))
     {
       struct value *value;
-      int full, top, using_enc;
+      int full, using_enc;
+      LONGEST top;
 
       /* Ugh, we have to convert back to a value here.  */
       value = value_from_contents_and_address (type, valaddr + offset,
@@ -456,7 +460,7 @@ cp_print_value_fields_rtti (struct type *type,
 
 static void
 cp_print_value (struct type *type, struct type *real_type,
-               const gdb_byte *valaddr, int offset,
+               const gdb_byte *valaddr, LONGEST offset,
                CORE_ADDR address, struct ui_file *stream,
                int recurse, const struct value *val,
                const struct value_print_options *options,
@@ -466,7 +470,7 @@ cp_print_value (struct type *type, struct type *real_type,
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
   struct obstack tmp_obstack = dont_print_vb_obstack;
   int i, n_baseclasses = TYPE_N_BASECLASSES (type);
-  int thisoffset;
+  LONGEST thisoffset;
   struct type *thistype;
 
   if (dont_print_vb == 0)
@@ -480,13 +484,12 @@ cp_print_value (struct type *type, struct type *real_type,
 
   for (i = 0; i < n_baseclasses; i++)
     {
-      int boffset = 0;
-      int skip;
+      LONGEST boffset = 0;
+      int skip = 0;
       struct type *baseclass = check_typedef (TYPE_BASECLASS (type, i));
       const char *basename = TYPE_NAME (baseclass);
       const gdb_byte *base_valaddr = NULL;
       const struct value *base_val = NULL;
-      volatile struct gdb_exception ex;
 
       if (BASETYPE_VIA_VIRTUAL (type, i))
        {
@@ -506,18 +509,21 @@ cp_print_value (struct type *type, struct type *real_type,
       thisoffset = offset;
       thistype = real_type;
 
-      TRY_CATCH (ex, RETURN_MASK_ERROR)
+      TRY
        {
          boffset = baseclass_offset (type, i, valaddr, offset, address, val);
        }
-      if (ex.reason < 0 && ex.error == NOT_AVAILABLE_ERROR)
-       skip = -1;
-      else if (ex.reason < 0)
-       skip = 1;
-      else
-       {
-         skip = 0;
+      CATCH (ex, RETURN_MASK_ERROR)
+       {
+         if (ex.error == NOT_AVAILABLE_ERROR)
+           skip = -1;
+         else
+           skip = 1;
+       }
+      END_CATCH
 
+      if (skip == 0)
+       {
          if (BASETYPE_VIA_VIRTUAL (type, i))
            {
              /* The virtual base class pointer might have been
@@ -530,7 +536,7 @@ cp_print_value (struct type *type, struct type *real_type,
                  gdb_byte *buf;
                  struct cleanup *back_to;
 
-                 buf = xmalloc (TYPE_LENGTH (baseclass));
+                 buf = (gdb_byte *) xmalloc (TYPE_LENGTH (baseclass));
                  back_to = make_cleanup (xfree, buf);
 
                  if (target_read_memory (address + boffset, buf,
@@ -664,7 +670,7 @@ cp_print_static_field (struct type *type,
       addr = value_address (val);
       obstack_grow (&dont_print_statmem_obstack, (char *) &addr,
                    sizeof (CORE_ADDR));
-      CHECK_TYPEDEF (type);
+      type = check_typedef (type);
       cp_print_value_fields (type, value_enclosing_type (val),
                             value_contents_for_printing (val),
                             value_embedded_offset (val), addr,
This page took 0.035109 seconds and 4 git commands to generate.