15796c8dcSSimon Schubert /* Abstraction of GNU v2 abi. 25796c8dcSSimon Schubert 3*cf7f2e2dSJohn Marino Copyright (C) 2001, 2002, 2003, 2005, 2007, 2008, 2009, 2010 45796c8dcSSimon Schubert Free Software Foundation, Inc. 55796c8dcSSimon Schubert 65796c8dcSSimon Schubert Contributed by Daniel Berlin <dberlin@redhat.com> 75796c8dcSSimon Schubert 85796c8dcSSimon Schubert This file is part of GDB. 95796c8dcSSimon Schubert 105796c8dcSSimon Schubert This program is free software; you can redistribute it and/or modify 115796c8dcSSimon Schubert it under the terms of the GNU General Public License as published by 125796c8dcSSimon Schubert the Free Software Foundation; either version 3 of the License, or 135796c8dcSSimon Schubert (at your option) any later version. 145796c8dcSSimon Schubert 155796c8dcSSimon Schubert This program is distributed in the hope that it will be useful, 165796c8dcSSimon Schubert but WITHOUT ANY WARRANTY; without even the implied warranty of 175796c8dcSSimon Schubert MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 185796c8dcSSimon Schubert GNU General Public License for more details. 195796c8dcSSimon Schubert 205796c8dcSSimon Schubert You should have received a copy of the GNU General Public License 215796c8dcSSimon Schubert along with this program. If not, see <http://www.gnu.org/licenses/>. */ 225796c8dcSSimon Schubert 235796c8dcSSimon Schubert #include "defs.h" 245796c8dcSSimon Schubert #include "gdb_string.h" 255796c8dcSSimon Schubert #include "symtab.h" 265796c8dcSSimon Schubert #include "gdbtypes.h" 275796c8dcSSimon Schubert #include "value.h" 285796c8dcSSimon Schubert #include "demangle.h" 295796c8dcSSimon Schubert #include "cp-abi.h" 305796c8dcSSimon Schubert #include "cp-support.h" 315796c8dcSSimon Schubert 325796c8dcSSimon Schubert #include <ctype.h> 335796c8dcSSimon Schubert 345796c8dcSSimon Schubert struct cp_abi_ops gnu_v2_abi_ops; 355796c8dcSSimon Schubert 365796c8dcSSimon Schubert static int vb_match (struct type *, int, struct type *); 375796c8dcSSimon Schubert 385796c8dcSSimon Schubert static enum dtor_kinds 395796c8dcSSimon Schubert gnuv2_is_destructor_name (const char *name) 405796c8dcSSimon Schubert { 415796c8dcSSimon Schubert if ((name[0] == '_' && is_cplus_marker (name[1]) && name[2] == '_') 425796c8dcSSimon Schubert || strncmp (name, "__dt__", 6) == 0) 435796c8dcSSimon Schubert return complete_object_dtor; 445796c8dcSSimon Schubert else 455796c8dcSSimon Schubert return 0; 465796c8dcSSimon Schubert } 475796c8dcSSimon Schubert 485796c8dcSSimon Schubert static enum ctor_kinds 495796c8dcSSimon Schubert gnuv2_is_constructor_name (const char *name) 505796c8dcSSimon Schubert { 515796c8dcSSimon Schubert if ((name[0] == '_' && name[1] == '_' 525796c8dcSSimon Schubert && (isdigit (name[2]) || strchr ("Qt", name[2]))) 535796c8dcSSimon Schubert || strncmp (name, "__ct__", 6) == 0) 545796c8dcSSimon Schubert return complete_object_ctor; 555796c8dcSSimon Schubert else 565796c8dcSSimon Schubert return 0; 575796c8dcSSimon Schubert } 585796c8dcSSimon Schubert 595796c8dcSSimon Schubert static int 605796c8dcSSimon Schubert gnuv2_is_vtable_name (const char *name) 615796c8dcSSimon Schubert { 625796c8dcSSimon Schubert return (((name)[0] == '_' 635796c8dcSSimon Schubert && (((name)[1] == 'V' && (name)[2] == 'T') 645796c8dcSSimon Schubert || ((name)[1] == 'v' && (name)[2] == 't')) 655796c8dcSSimon Schubert && is_cplus_marker ((name)[3])) || 665796c8dcSSimon Schubert ((name)[0] == '_' && (name)[1] == '_' 675796c8dcSSimon Schubert && (name)[2] == 'v' && (name)[3] == 't' && (name)[4] == '_')); 685796c8dcSSimon Schubert } 695796c8dcSSimon Schubert 705796c8dcSSimon Schubert static int 715796c8dcSSimon Schubert gnuv2_is_operator_name (const char *name) 725796c8dcSSimon Schubert { 735796c8dcSSimon Schubert return strncmp (name, "operator", 8) == 0; 745796c8dcSSimon Schubert } 755796c8dcSSimon Schubert 765796c8dcSSimon Schubert 775796c8dcSSimon Schubert /* Return a virtual function as a value. 785796c8dcSSimon Schubert ARG1 is the object which provides the virtual function 795796c8dcSSimon Schubert table pointer. *ARG1P is side-effected in calling this function. 805796c8dcSSimon Schubert F is the list of member functions which contains the desired virtual 815796c8dcSSimon Schubert function. 825796c8dcSSimon Schubert J is an index into F which provides the desired virtual function. 835796c8dcSSimon Schubert 845796c8dcSSimon Schubert TYPE is the type in which F is located. */ 855796c8dcSSimon Schubert static struct value * 865796c8dcSSimon Schubert gnuv2_virtual_fn_field (struct value **arg1p, struct fn_field * f, int j, 875796c8dcSSimon Schubert struct type * type, int offset) 885796c8dcSSimon Schubert { 895796c8dcSSimon Schubert struct value *arg1 = *arg1p; 905796c8dcSSimon Schubert struct type *type1 = check_typedef (value_type (arg1)); 915796c8dcSSimon Schubert struct type *entry_type; 925796c8dcSSimon Schubert /* First, get the virtual function table pointer. That comes 935796c8dcSSimon Schubert with a strange type, so cast it to type `pointer to long' (which 945796c8dcSSimon Schubert should serve just fine as a function type). Then, index into 955796c8dcSSimon Schubert the table, and convert final value to appropriate function type. */ 965796c8dcSSimon Schubert struct value *entry; 975796c8dcSSimon Schubert struct value *vfn; 985796c8dcSSimon Schubert struct value *vtbl; 995796c8dcSSimon Schubert LONGEST vi = (LONGEST) TYPE_FN_FIELD_VOFFSET (f, j); 1005796c8dcSSimon Schubert struct type *fcontext = TYPE_FN_FIELD_FCONTEXT (f, j); 1015796c8dcSSimon Schubert struct type *context; 1025796c8dcSSimon Schubert struct type *context_vptr_basetype; 1035796c8dcSSimon Schubert int context_vptr_fieldno; 1045796c8dcSSimon Schubert 1055796c8dcSSimon Schubert if (fcontext == NULL) 1065796c8dcSSimon Schubert /* We don't have an fcontext (e.g. the program was compiled with 1075796c8dcSSimon Schubert g++ version 1). Try to get the vtbl from the TYPE_VPTR_BASETYPE. 1085796c8dcSSimon Schubert This won't work right for multiple inheritance, but at least we 1095796c8dcSSimon Schubert should do as well as GDB 3.x did. */ 1105796c8dcSSimon Schubert fcontext = TYPE_VPTR_BASETYPE (type); 1115796c8dcSSimon Schubert context = lookup_pointer_type (fcontext); 1125796c8dcSSimon Schubert /* Now context is a pointer to the basetype containing the vtbl. */ 1135796c8dcSSimon Schubert if (TYPE_TARGET_TYPE (context) != type1) 1145796c8dcSSimon Schubert { 1155796c8dcSSimon Schubert struct value *tmp = value_cast (context, value_addr (arg1)); 116*cf7f2e2dSJohn Marino 1175796c8dcSSimon Schubert arg1 = value_ind (tmp); 1185796c8dcSSimon Schubert type1 = check_typedef (value_type (arg1)); 1195796c8dcSSimon Schubert } 1205796c8dcSSimon Schubert 1215796c8dcSSimon Schubert context = type1; 1225796c8dcSSimon Schubert /* Now context is the basetype containing the vtbl. */ 1235796c8dcSSimon Schubert 1245796c8dcSSimon Schubert /* This type may have been defined before its virtual function table 1255796c8dcSSimon Schubert was. If so, fill in the virtual function table entry for the 1265796c8dcSSimon Schubert type now. */ 1275796c8dcSSimon Schubert context_vptr_fieldno = get_vptr_fieldno (context, &context_vptr_basetype); 1285796c8dcSSimon Schubert /* FIXME: What to do if vptr_fieldno is still -1? */ 1295796c8dcSSimon Schubert 1305796c8dcSSimon Schubert /* The virtual function table is now an array of structures 1315796c8dcSSimon Schubert which have the form { int16 offset, delta; void *pfn; }. */ 1325796c8dcSSimon Schubert vtbl = value_primitive_field (arg1, 0, context_vptr_fieldno, 1335796c8dcSSimon Schubert context_vptr_basetype); 1345796c8dcSSimon Schubert 1355796c8dcSSimon Schubert /* With older versions of g++, the vtbl field pointed to an array 1365796c8dcSSimon Schubert of structures. Nowadays it points directly to the structure. */ 1375796c8dcSSimon Schubert if (TYPE_CODE (value_type (vtbl)) == TYPE_CODE_PTR 1385796c8dcSSimon Schubert && TYPE_CODE (TYPE_TARGET_TYPE (value_type (vtbl))) == TYPE_CODE_ARRAY) 1395796c8dcSSimon Schubert { 1405796c8dcSSimon Schubert /* Handle the case where the vtbl field points to an 1415796c8dcSSimon Schubert array of structures. */ 1425796c8dcSSimon Schubert vtbl = value_ind (vtbl); 1435796c8dcSSimon Schubert 1445796c8dcSSimon Schubert /* Index into the virtual function table. This is hard-coded because 1455796c8dcSSimon Schubert looking up a field is not cheap, and it may be important to save 1465796c8dcSSimon Schubert time, e.g. if the user has set a conditional breakpoint calling 1475796c8dcSSimon Schubert a virtual function. */ 1485796c8dcSSimon Schubert entry = value_subscript (vtbl, vi); 1495796c8dcSSimon Schubert } 1505796c8dcSSimon Schubert else 1515796c8dcSSimon Schubert { 1525796c8dcSSimon Schubert /* Handle the case where the vtbl field points directly to a structure. */ 1535796c8dcSSimon Schubert vtbl = value_ptradd (vtbl, vi); 1545796c8dcSSimon Schubert entry = value_ind (vtbl); 1555796c8dcSSimon Schubert } 1565796c8dcSSimon Schubert 1575796c8dcSSimon Schubert entry_type = check_typedef (value_type (entry)); 1585796c8dcSSimon Schubert 1595796c8dcSSimon Schubert if (TYPE_CODE (entry_type) == TYPE_CODE_STRUCT) 1605796c8dcSSimon Schubert { 1615796c8dcSSimon Schubert /* Move the `this' pointer according to the virtual function table. */ 1625796c8dcSSimon Schubert set_value_offset (arg1, value_offset (arg1) + value_as_long (value_field (entry, 0))); 1635796c8dcSSimon Schubert 1645796c8dcSSimon Schubert if (!value_lazy (arg1)) 1655796c8dcSSimon Schubert { 1665796c8dcSSimon Schubert set_value_lazy (arg1, 1); 1675796c8dcSSimon Schubert value_fetch_lazy (arg1); 1685796c8dcSSimon Schubert } 1695796c8dcSSimon Schubert 1705796c8dcSSimon Schubert vfn = value_field (entry, 2); 1715796c8dcSSimon Schubert } 1725796c8dcSSimon Schubert else if (TYPE_CODE (entry_type) == TYPE_CODE_PTR) 1735796c8dcSSimon Schubert vfn = entry; 1745796c8dcSSimon Schubert else 1755796c8dcSSimon Schubert error (_("I'm confused: virtual function table has bad type")); 1765796c8dcSSimon Schubert /* Reinstantiate the function pointer with the correct type. */ 1775796c8dcSSimon Schubert deprecated_set_value_type (vfn, lookup_pointer_type (TYPE_FN_FIELD_TYPE (f, j))); 1785796c8dcSSimon Schubert 1795796c8dcSSimon Schubert *arg1p = arg1; 1805796c8dcSSimon Schubert return vfn; 1815796c8dcSSimon Schubert } 1825796c8dcSSimon Schubert 1835796c8dcSSimon Schubert 1845796c8dcSSimon Schubert static struct type * 1855796c8dcSSimon Schubert gnuv2_value_rtti_type (struct value *v, int *full, int *top, int *using_enc) 1865796c8dcSSimon Schubert { 1875796c8dcSSimon Schubert struct type *known_type; 1885796c8dcSSimon Schubert struct type *rtti_type; 1895796c8dcSSimon Schubert CORE_ADDR vtbl; 1905796c8dcSSimon Schubert struct minimal_symbol *minsym; 1915796c8dcSSimon Schubert char *demangled_name, *p; 1925796c8dcSSimon Schubert struct type *btype; 1935796c8dcSSimon Schubert struct type *known_type_vptr_basetype; 1945796c8dcSSimon Schubert int known_type_vptr_fieldno; 1955796c8dcSSimon Schubert 1965796c8dcSSimon Schubert if (full) 1975796c8dcSSimon Schubert *full = 0; 1985796c8dcSSimon Schubert if (top) 1995796c8dcSSimon Schubert *top = -1; 2005796c8dcSSimon Schubert if (using_enc) 2015796c8dcSSimon Schubert *using_enc = 0; 2025796c8dcSSimon Schubert 2035796c8dcSSimon Schubert /* Get declared type */ 2045796c8dcSSimon Schubert known_type = value_type (v); 2055796c8dcSSimon Schubert CHECK_TYPEDEF (known_type); 2065796c8dcSSimon Schubert /* RTTI works only or class objects */ 2075796c8dcSSimon Schubert if (TYPE_CODE (known_type) != TYPE_CODE_CLASS) 2085796c8dcSSimon Schubert return NULL; 2095796c8dcSSimon Schubert 2105796c8dcSSimon Schubert /* Plan on this changing in the future as i get around to setting 2115796c8dcSSimon Schubert the vtables properly for G++ compiled stuff. Also, I'll be using 2125796c8dcSSimon Schubert the type info functions, which are always right. Deal with it 2135796c8dcSSimon Schubert until then. */ 2145796c8dcSSimon Schubert 2155796c8dcSSimon Schubert /* Try to get the vptr basetype, fieldno. */ 2165796c8dcSSimon Schubert known_type_vptr_fieldno = get_vptr_fieldno (known_type, 2175796c8dcSSimon Schubert &known_type_vptr_basetype); 2185796c8dcSSimon Schubert 2195796c8dcSSimon Schubert /* If we can't find it, give up. */ 2205796c8dcSSimon Schubert if (known_type_vptr_fieldno < 0) 2215796c8dcSSimon Schubert return NULL; 2225796c8dcSSimon Schubert 2235796c8dcSSimon Schubert /* Make sure our basetype and known type match, otherwise, cast 2245796c8dcSSimon Schubert so we can get at the vtable properly. 2255796c8dcSSimon Schubert */ 2265796c8dcSSimon Schubert btype = known_type_vptr_basetype; 2275796c8dcSSimon Schubert CHECK_TYPEDEF (btype); 2285796c8dcSSimon Schubert if (btype != known_type ) 2295796c8dcSSimon Schubert { 2305796c8dcSSimon Schubert v = value_cast (btype, v); 2315796c8dcSSimon Schubert if (using_enc) 2325796c8dcSSimon Schubert *using_enc=1; 2335796c8dcSSimon Schubert } 2345796c8dcSSimon Schubert /* 2355796c8dcSSimon Schubert We can't use value_ind here, because it would want to use RTTI, and 2365796c8dcSSimon Schubert we'd waste a bunch of time figuring out we already know the type. 2375796c8dcSSimon Schubert Besides, we don't care about the type, just the actual pointer 2385796c8dcSSimon Schubert */ 2395796c8dcSSimon Schubert if (value_address (value_field (v, known_type_vptr_fieldno)) == 0) 2405796c8dcSSimon Schubert return NULL; 2415796c8dcSSimon Schubert 2425796c8dcSSimon Schubert vtbl = value_as_address (value_field (v, known_type_vptr_fieldno)); 2435796c8dcSSimon Schubert 2445796c8dcSSimon Schubert /* Try to find a symbol that is the vtable */ 2455796c8dcSSimon Schubert minsym=lookup_minimal_symbol_by_pc(vtbl); 2465796c8dcSSimon Schubert if (minsym==NULL 2475796c8dcSSimon Schubert || (demangled_name=SYMBOL_LINKAGE_NAME (minsym))==NULL 2485796c8dcSSimon Schubert || !is_vtable_name (demangled_name)) 2495796c8dcSSimon Schubert return NULL; 2505796c8dcSSimon Schubert 2515796c8dcSSimon Schubert /* If we just skip the prefix, we get screwed by namespaces */ 2525796c8dcSSimon Schubert demangled_name=cplus_demangle(demangled_name,DMGL_PARAMS|DMGL_ANSI); 2535796c8dcSSimon Schubert p = strchr (demangled_name, ' '); 2545796c8dcSSimon Schubert if (p) 2555796c8dcSSimon Schubert *p = '\0'; 2565796c8dcSSimon Schubert 2575796c8dcSSimon Schubert /* Lookup the type for the name */ 2585796c8dcSSimon Schubert /* FIXME: chastain/2003-11-26: block=NULL is bogus. See pr gdb/1465. */ 2595796c8dcSSimon Schubert rtti_type = cp_lookup_rtti_type (demangled_name, NULL); 2605796c8dcSSimon Schubert if (rtti_type == NULL) 2615796c8dcSSimon Schubert return NULL; 2625796c8dcSSimon Schubert 2635796c8dcSSimon Schubert if (TYPE_N_BASECLASSES(rtti_type) > 1 && full && (*full) != 1) 2645796c8dcSSimon Schubert { 2655796c8dcSSimon Schubert if (top) 2665796c8dcSSimon Schubert *top=TYPE_BASECLASS_BITPOS(rtti_type,TYPE_VPTR_FIELDNO(rtti_type))/8; 2675796c8dcSSimon Schubert if (top && ((*top) >0)) 2685796c8dcSSimon Schubert { 2695796c8dcSSimon Schubert if (TYPE_LENGTH(rtti_type) > TYPE_LENGTH(known_type)) 2705796c8dcSSimon Schubert { 2715796c8dcSSimon Schubert if (full) 2725796c8dcSSimon Schubert *full=0; 2735796c8dcSSimon Schubert } 2745796c8dcSSimon Schubert else 2755796c8dcSSimon Schubert { 2765796c8dcSSimon Schubert if (full) 2775796c8dcSSimon Schubert *full=1; 2785796c8dcSSimon Schubert } 2795796c8dcSSimon Schubert } 2805796c8dcSSimon Schubert } 2815796c8dcSSimon Schubert else 2825796c8dcSSimon Schubert { 2835796c8dcSSimon Schubert if (full) 2845796c8dcSSimon Schubert *full=1; 2855796c8dcSSimon Schubert } 2865796c8dcSSimon Schubert 2875796c8dcSSimon Schubert return rtti_type; 2885796c8dcSSimon Schubert } 2895796c8dcSSimon Schubert 2905796c8dcSSimon Schubert /* Return true if the INDEXth field of TYPE is a virtual baseclass 2915796c8dcSSimon Schubert pointer which is for the base class whose type is BASECLASS. */ 2925796c8dcSSimon Schubert 2935796c8dcSSimon Schubert static int 2945796c8dcSSimon Schubert vb_match (struct type *type, int index, struct type *basetype) 2955796c8dcSSimon Schubert { 2965796c8dcSSimon Schubert struct type *fieldtype; 2975796c8dcSSimon Schubert char *name = TYPE_FIELD_NAME (type, index); 2985796c8dcSSimon Schubert char *field_class_name = NULL; 2995796c8dcSSimon Schubert 3005796c8dcSSimon Schubert if (*name != '_') 3015796c8dcSSimon Schubert return 0; 3025796c8dcSSimon Schubert /* gcc 2.4 uses _vb$. */ 3035796c8dcSSimon Schubert if (name[1] == 'v' && name[2] == 'b' && is_cplus_marker (name[3])) 3045796c8dcSSimon Schubert field_class_name = name + 4; 3055796c8dcSSimon Schubert /* gcc 2.5 will use __vb_. */ 3065796c8dcSSimon Schubert if (name[1] == '_' && name[2] == 'v' && name[3] == 'b' && name[4] == '_') 3075796c8dcSSimon Schubert field_class_name = name + 5; 3085796c8dcSSimon Schubert 3095796c8dcSSimon Schubert if (field_class_name == NULL) 3105796c8dcSSimon Schubert /* This field is not a virtual base class pointer. */ 3115796c8dcSSimon Schubert return 0; 3125796c8dcSSimon Schubert 3135796c8dcSSimon Schubert /* It's a virtual baseclass pointer, now we just need to find out whether 3145796c8dcSSimon Schubert it is for this baseclass. */ 3155796c8dcSSimon Schubert fieldtype = TYPE_FIELD_TYPE (type, index); 3165796c8dcSSimon Schubert if (fieldtype == NULL 3175796c8dcSSimon Schubert || TYPE_CODE (fieldtype) != TYPE_CODE_PTR) 3185796c8dcSSimon Schubert /* "Can't happen". */ 3195796c8dcSSimon Schubert return 0; 3205796c8dcSSimon Schubert 3215796c8dcSSimon Schubert /* What we check for is that either the types are equal (needed for 3225796c8dcSSimon Schubert nameless types) or have the same name. This is ugly, and a more 3235796c8dcSSimon Schubert elegant solution should be devised (which would probably just push 3245796c8dcSSimon Schubert the ugliness into symbol reading unless we change the stabs format). */ 3255796c8dcSSimon Schubert if (TYPE_TARGET_TYPE (fieldtype) == basetype) 3265796c8dcSSimon Schubert return 1; 3275796c8dcSSimon Schubert 3285796c8dcSSimon Schubert if (TYPE_NAME (basetype) != NULL 3295796c8dcSSimon Schubert && TYPE_NAME (TYPE_TARGET_TYPE (fieldtype)) != NULL 3305796c8dcSSimon Schubert && strcmp (TYPE_NAME (basetype), 3315796c8dcSSimon Schubert TYPE_NAME (TYPE_TARGET_TYPE (fieldtype))) == 0) 3325796c8dcSSimon Schubert return 1; 3335796c8dcSSimon Schubert return 0; 3345796c8dcSSimon Schubert } 3355796c8dcSSimon Schubert 3365796c8dcSSimon Schubert /* Compute the offset of the baseclass which is 3375796c8dcSSimon Schubert the INDEXth baseclass of class TYPE, 3385796c8dcSSimon Schubert for value at VALADDR (in host) at ADDRESS (in target). 3395796c8dcSSimon Schubert The result is the offset of the baseclass value relative 3405796c8dcSSimon Schubert to (the address of)(ARG) + OFFSET. 3415796c8dcSSimon Schubert 3425796c8dcSSimon Schubert -1 is returned on error. */ 3435796c8dcSSimon Schubert 344*cf7f2e2dSJohn Marino static int 3455796c8dcSSimon Schubert gnuv2_baseclass_offset (struct type *type, int index, 3465796c8dcSSimon Schubert const bfd_byte *valaddr, CORE_ADDR address) 3475796c8dcSSimon Schubert { 3485796c8dcSSimon Schubert struct type *basetype = TYPE_BASECLASS (type, index); 3495796c8dcSSimon Schubert 3505796c8dcSSimon Schubert if (BASETYPE_VIA_VIRTUAL (type, index)) 3515796c8dcSSimon Schubert { 3525796c8dcSSimon Schubert /* Must hunt for the pointer to this virtual baseclass. */ 3535796c8dcSSimon Schubert int i, len = TYPE_NFIELDS (type); 3545796c8dcSSimon Schubert int n_baseclasses = TYPE_N_BASECLASSES (type); 3555796c8dcSSimon Schubert 3565796c8dcSSimon Schubert /* First look for the virtual baseclass pointer 3575796c8dcSSimon Schubert in the fields. */ 3585796c8dcSSimon Schubert for (i = n_baseclasses; i < len; i++) 3595796c8dcSSimon Schubert { 3605796c8dcSSimon Schubert if (vb_match (type, i, basetype)) 3615796c8dcSSimon Schubert { 3625796c8dcSSimon Schubert CORE_ADDR addr 3635796c8dcSSimon Schubert = unpack_pointer (TYPE_FIELD_TYPE (type, i), 3645796c8dcSSimon Schubert valaddr + (TYPE_FIELD_BITPOS (type, i) / 8)); 3655796c8dcSSimon Schubert 3665796c8dcSSimon Schubert return addr - (LONGEST) address; 3675796c8dcSSimon Schubert } 3685796c8dcSSimon Schubert } 3695796c8dcSSimon Schubert /* Not in the fields, so try looking through the baseclasses. */ 3705796c8dcSSimon Schubert for (i = index + 1; i < n_baseclasses; i++) 3715796c8dcSSimon Schubert { 3725796c8dcSSimon Schubert int boffset = 3735796c8dcSSimon Schubert baseclass_offset (type, i, valaddr, address); 374*cf7f2e2dSJohn Marino 3755796c8dcSSimon Schubert if (boffset) 3765796c8dcSSimon Schubert return boffset; 3775796c8dcSSimon Schubert } 3785796c8dcSSimon Schubert /* Not found. */ 3795796c8dcSSimon Schubert return -1; 3805796c8dcSSimon Schubert } 3815796c8dcSSimon Schubert 3825796c8dcSSimon Schubert /* Baseclass is easily computed. */ 3835796c8dcSSimon Schubert return TYPE_BASECLASS_BITPOS (type, index) / 8; 3845796c8dcSSimon Schubert } 3855796c8dcSSimon Schubert 3865796c8dcSSimon Schubert static void 3875796c8dcSSimon Schubert init_gnuv2_ops (void) 3885796c8dcSSimon Schubert { 3895796c8dcSSimon Schubert gnu_v2_abi_ops.shortname = "gnu-v2"; 3905796c8dcSSimon Schubert gnu_v2_abi_ops.longname = "GNU G++ Version 2 ABI"; 3915796c8dcSSimon Schubert gnu_v2_abi_ops.doc = "G++ Version 2 ABI"; 3925796c8dcSSimon Schubert gnu_v2_abi_ops.is_destructor_name = gnuv2_is_destructor_name; 3935796c8dcSSimon Schubert gnu_v2_abi_ops.is_constructor_name = gnuv2_is_constructor_name; 3945796c8dcSSimon Schubert gnu_v2_abi_ops.is_vtable_name = gnuv2_is_vtable_name; 3955796c8dcSSimon Schubert gnu_v2_abi_ops.is_operator_name = gnuv2_is_operator_name; 3965796c8dcSSimon Schubert gnu_v2_abi_ops.virtual_fn_field = gnuv2_virtual_fn_field; 3975796c8dcSSimon Schubert gnu_v2_abi_ops.rtti_type = gnuv2_value_rtti_type; 3985796c8dcSSimon Schubert gnu_v2_abi_ops.baseclass_offset = gnuv2_baseclass_offset; 3995796c8dcSSimon Schubert } 4005796c8dcSSimon Schubert 4015796c8dcSSimon Schubert extern initialize_file_ftype _initialize_gnu_v2_abi; /* -Wmissing-prototypes */ 4025796c8dcSSimon Schubert 4035796c8dcSSimon Schubert void 4045796c8dcSSimon Schubert _initialize_gnu_v2_abi (void) 4055796c8dcSSimon Schubert { 4065796c8dcSSimon Schubert init_gnuv2_ops (); 4075796c8dcSSimon Schubert register_cp_abi (&gnu_v2_abi_ops); 4085796c8dcSSimon Schubert set_cp_abi_as_auto_default (gnu_v2_abi_ops.shortname); 4095796c8dcSSimon Schubert } 410