198944Sobrien/* Abstraction of various C++ ABI's we support, and the info we need 298944Sobrien to get from them. 398944Sobrien Contributed by Daniel Berlin <dberlin@redhat.com> 498944Sobrien Copyright 2001 Free Software Foundation, Inc. 598944Sobrien 698944Sobrien This file is part of GDB. 798944Sobrien 898944Sobrien This program is free software; you can redistribute it and/or 998944Sobrien modify 1098944Sobrien it under the terms of the GNU General Public License as published 1198944Sobrien by 1298944Sobrien the Free Software Foundation; either version 2 of the License, or 1398944Sobrien (at your option) any later version. 1498944Sobrien 1598944Sobrien This program is distributed in the hope that it will be useful, 1698944Sobrien but WITHOUT ANY WARRANTY; without even the implied warranty of 1798944Sobrien MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 1898944Sobrien GNU General Public License for more details. 1998944Sobrien 2098944Sobrien You should have received a copy of the GNU General Public License 2198944Sobrien along with this program; if not, write to the Free Software 2298944Sobrien Foundation, Inc., 59 Temple Place - Suite 330, 2398944Sobrien Boston, MA 02111-1307, USA. */ 2498944Sobrien 2598944Sobrien#ifndef CP_ABI_H_ 2698944Sobrien#define CP_ABI_H_ 1 2798944Sobrien 28130803Smarcelstruct fn_field; 29130803Smarcelstruct type; 3098944Sobrienstruct value; 3198944Sobrien 3298944Sobrien/* The functions here that attempt to determine what sort of thing a 3398944Sobrien mangled name refers to may well be revised in the future. It would 3498944Sobrien certainly be cleaner to carry this information explicitly in GDB's 3598944Sobrien data structures than to derive it from the mangled name. */ 3698944Sobrien 3798944Sobrien 3898944Sobrien/* Kinds of constructors. All these values are guaranteed to be 3998944Sobrien non-zero. */ 4098944Sobrienenum ctor_kinds { 4198944Sobrien 4298944Sobrien /* Initialize a complete object, including virtual bases, using 4398944Sobrien memory provided by caller. */ 4498944Sobrien complete_object_ctor = 1, 4598944Sobrien 4698944Sobrien /* Initialize a base object of some larger object. */ 4798944Sobrien base_object_ctor, 4898944Sobrien 4998944Sobrien /* An allocating complete-object constructor. */ 5098944Sobrien complete_object_allocating_ctor 5198944Sobrien}; 5298944Sobrien 5398944Sobrien/* Return non-zero iff NAME is the mangled name of a constructor. 5498944Sobrien Actually, return an `enum ctor_kind' value describing what *kind* 5598944Sobrien of constructor it is. */ 5698944Sobrienextern enum ctor_kinds is_constructor_name (const char *name); 5798944Sobrien 5898944Sobrien 5998944Sobrien/* Kinds of destructors. All these values are guaranteed to be 6098944Sobrien non-zero. */ 6198944Sobrienenum dtor_kinds { 6298944Sobrien 6398944Sobrien /* A destructor which finalizes the entire object, and then calls 6498944Sobrien `delete' on its storage. */ 6598944Sobrien deleting_dtor = 1, 6698944Sobrien 6798944Sobrien /* A destructor which finalizes the entire object, but does not call 6898944Sobrien `delete'. */ 6998944Sobrien complete_object_dtor, 7098944Sobrien 7198944Sobrien /* A destructor which finalizes a subobject of some larger object. */ 7298944Sobrien base_object_dtor 7398944Sobrien}; 7498944Sobrien 7598944Sobrien/* Return non-zero iff NAME is the mangled name of a destructor. 7698944Sobrien Actually, return an `enum dtor_kind' value describing what *kind* 7798944Sobrien of destructor it is. */ 7898944Sobrienextern enum dtor_kinds is_destructor_name (const char *name); 7998944Sobrien 8098944Sobrien 8198944Sobrien/* Return non-zero iff NAME is the mangled name of a vtable. */ 8298944Sobrienextern int is_vtable_name (const char *name); 8398944Sobrien 8498944Sobrien 8598944Sobrien/* Return non-zero iff NAME is the un-mangled name of an operator, 8698944Sobrien perhaps scoped within some class. */ 8798944Sobrienextern int is_operator_name (const char *name); 8898944Sobrien 8998944Sobrien 9098944Sobrien/* Return an object's virtual function as a value. 9198944Sobrien 9298944Sobrien VALUEP is a pointer to a pointer to a value, holding the object 9398944Sobrien whose virtual function we want to invoke. If the ABI requires a 9498944Sobrien virtual function's caller to adjust the `this' pointer by an amount 9598944Sobrien retrieved from the vtable before invoking the function (i.e., we're 9698944Sobrien not using "vtable thunks" to do the adjustment automatically), then 9798944Sobrien this function may set *VALUEP to point to a new object with an 9898944Sobrien appropriately tweaked address. 9998944Sobrien 10098944Sobrien The J'th element of the overload set F is the virtual function of 10198944Sobrien *VALUEP we want to invoke. 10298944Sobrien 10398944Sobrien TYPE is the base type of *VALUEP whose method we're invoking --- 10498944Sobrien this is the type containing F. OFFSET is the offset of that base 10598944Sobrien type within *VALUEP. */ 10698944Sobrienextern struct value *value_virtual_fn_field (struct value **valuep, 10798944Sobrien struct fn_field *f, int j, 10898944Sobrien struct type *type, int offset); 10998944Sobrien 11098944Sobrien 11198944Sobrien/* Try to find the run-time type of VALUE, using C++ run-time type 11298944Sobrien information. Return the run-time type, or zero if we can't figure 11398944Sobrien it out. 11498944Sobrien 11598944Sobrien If we do find the run-time type: 11698944Sobrien - Set *FULL to non-zero if VALUE already contains the complete 11798944Sobrien run-time object, not just some embedded base class of the object. 11898944Sobrien - Set *TOP and *USING_ENC to indicate where the enclosing object 11998944Sobrien starts relative to VALUE: 12098944Sobrien - If *USING_ENC is zero, then *TOP is the offset from the start 12198944Sobrien of the complete object to the start of the embedded subobject 12298944Sobrien VALUE represents. In other words, the enclosing object starts 12398944Sobrien at VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + 12498944Sobrien VALUE_EMBEDDED_OFFSET (VALUE) + *TOP 12598944Sobrien - If *USING_ENC is non-zero, then *TOP is the offset from the 12698944Sobrien address of the complete object to the enclosing object stored 12798944Sobrien in VALUE. In other words, the enclosing object starts at 12898944Sobrien VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + *TOP. 12998944Sobrien If VALUE's type and enclosing type are the same, then these two 13098944Sobrien cases are equivalent. 13198944Sobrien 13298944Sobrien FULL, TOP, and USING_ENC can each be zero, in which case we don't 13398944Sobrien provide the corresponding piece of information. */ 13498944Sobrienextern struct type *value_rtti_type (struct value *value, 13598944Sobrien int *full, int *top, int *using_enc); 13698944Sobrien 13798944Sobrien/* Compute the offset of the baseclass which is 13898944Sobrien the INDEXth baseclass of class TYPE, 13998944Sobrien for value at VALADDR (in host) at ADDRESS (in target). 14098944Sobrien The result is the offset of the baseclass value relative 14198944Sobrien to (the address of)(ARG) + OFFSET. 14298944Sobrien 14398944Sobrien -1 is returned on error. */ 14498944Sobrien 14598944Sobrienextern int baseclass_offset (struct type *type, int index, char *valaddr, 14698944Sobrien CORE_ADDR address); 14798944Sobrien 14898944Sobrienstruct cp_abi_ops 14998944Sobrien{ 15098944Sobrien const char *shortname; 15198944Sobrien const char *longname; 15298944Sobrien const char *doc; 15398944Sobrien 15498944Sobrien /* ABI-specific implementations for the functions declared above. */ 15598944Sobrien enum ctor_kinds (*is_constructor_name) (const char *name); 15698944Sobrien enum dtor_kinds (*is_destructor_name) (const char *name); 15798944Sobrien int (*is_vtable_name) (const char *name); 15898944Sobrien int (*is_operator_name) (const char *name); 15998944Sobrien struct value *(*virtual_fn_field) (struct value **arg1p, struct fn_field * f, 16098944Sobrien int j, struct type * type, int offset); 16198944Sobrien struct type *(*rtti_type) (struct value *v, int *full, int *top, 16298944Sobrien int *using_enc); 16398944Sobrien int (*baseclass_offset) (struct type *type, int index, char *valaddr, 16498944Sobrien CORE_ADDR address); 16598944Sobrien}; 16698944Sobrien 16798944Sobrien 168130803Smarcelextern int register_cp_abi (struct cp_abi_ops *abi); 169130803Smarcelextern void set_cp_abi_as_auto_default (const char *short_name); 17098944Sobrien 17198944Sobrien#endif 17298944Sobrien 173