gdb
[deliverable/binutils-gdb.git] / gdb / gnu-v3-abi.c
index c2c348a6103e0be0f052d227d2e111cd0fcf8666..ece910b4b4cabd2ceea1a038d1aec57b7958549a 100644 (file)
@@ -1,7 +1,7 @@
 /* Abstraction of GNU v3 abi.
    Contributed by Jim Blandy <jimb@redhat.com>
 
-   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008
+   Copyright (C) 2001, 2002, 2003, 2005, 2006, 2007, 2008, 2009
    Free Software Foundation, Inc.
 
    This file is part of GDB.
@@ -187,6 +187,16 @@ build_gdb_vtable_type (struct gdbarch *arch)
 }
 
 
+/* Return the ptrdiff_t type used in the vtable type.  */
+static struct type *
+vtable_ptrdiff_type (struct gdbarch *gdbarch)
+{
+  struct type *vtable_type = gdbarch_data (gdbarch, vtable_type_gdbarch_data);
+
+  /* The "offset_to_top" field has the appropriate (ptrdiff_t) type.  */
+  return TYPE_FIELD_TYPE (vtable_type, vtable_field_offset_to_top);
+}
+
 /* Return the offset from the start of the imaginary `struct
    gdb_gnu_v3_abi_vtable' object to the vtable's "address point"
    (i.e., where objects' virtual table pointers point).  */
@@ -259,8 +269,7 @@ gnuv3_rtti_type (struct value *value,
   
   /* Find the linker symbol for this vtable.  */
   vtable_symbol
-    = lookup_minimal_symbol_by_pc (VALUE_ADDRESS (vtable)
-                                   + value_offset (vtable)
+    = lookup_minimal_symbol_by_pc (value_address (vtable)
                                    + value_embedded_offset (vtable));
   if (! vtable_symbol)
     return NULL;
@@ -450,7 +459,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
      start of whichever baseclass it resides in, as a sanity measure - iff
      we have debugging information for that baseclass.  */
 
-  vbasetype = TYPE_VPTR_BASETYPE (type);
+  vbasetype = check_typedef (TYPE_VPTR_BASETYPE (type));
   vbasetype_vptr_fieldno = get_vptr_fieldno (vbasetype, NULL);
 
   if (vbasetype_vptr_fieldno >= 0
@@ -472,7 +481,7 @@ gnuv3_baseclass_offset (struct type *type, int index, const bfd_byte *valaddr,
    which has virtual table index VOFFSET.  The method has an associated
    "this" adjustment of ADJUSTMENT bytes.  */
 
-const char *
+static const char *
 gnuv3_find_method_in (struct type *domain, CORE_ADDR voffset,
                      LONGEST adjustment)
 {
@@ -531,7 +540,7 @@ gnuv3_decode_method_ptr (struct gdbarch *gdbarch,
                         LONGEST *adjustment_p)
 {
   struct type *funcptr_type = builtin_type (gdbarch)->builtin_func_ptr;
-  struct type *offset_type = builtin_type (gdbarch)->builtin_long;
+  struct type *offset_type = vtable_ptrdiff_type (gdbarch);
   CORE_ADDR ptr_value;
   LONGEST voffset, adjustment;
   int vbit;
@@ -595,7 +604,7 @@ gnuv3_print_method_ptr (const gdb_byte *contents,
       /* It's a virtual table offset, maybe in this class.  Search
         for a field with the correct vtable offset.  First convert it
         to an index, as used in TYPE_FN_FIELD_VOFFSET.  */
-      voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
+      voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch));
 
       physname = gnuv3_find_method_in (domain, voffset, adjustment);
 
@@ -722,7 +731,7 @@ gnuv3_method_ptr_to_value (struct value **this_p, struct value *method_ptr)
   if (vbit)
     {
       LONGEST voffset;
-      voffset = ptr_value / TYPE_LENGTH (builtin_type (gdbarch)->builtin_long);
+      voffset = ptr_value / TYPE_LENGTH (vtable_ptrdiff_type (gdbarch));
       return gnuv3_get_virtual_fn (gdbarch, value_ind (*this_p),
                                   method_type, voffset);
     }
This page took 0.02551 seconds and 4 git commands to generate.