1 /* Abstraction of various C++ ABI's we support, and the info we need
4 Copyright 2001 Free Software Foundation, Inc.
6 This file is part of GDB.
8 This program is free software; you can redistribute it and/or
10 it under the terms of the GNU General Public License as published
12 the Free Software Foundation; either version 2 of the License, or
13 (at your option) any later version.
15 This program is distributed in the hope that it will be useful,
16 but WITHOUT ANY WARRANTY; without even the implied warranty of
17 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 GNU General Public License for more details.
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330,
23 Boston, MA 02111-1307, USA. */
30 /* The functions here that attempt to determine what sort of thing a
31 mangled name refers to may well be revised in the future. It would
32 certainly be cleaner to carry this information explicitly in GDB's
33 data structures than to derive it from the mangled name. */
36 /* Kinds of constructors. All these values are guaranteed to be
40 /* Initialize a complete object, including virtual bases, using
41 memory provided by caller. */
42 complete_object_ctor = 1,
44 /* Initialize a base object of some larger object. */
47 /* An allocating complete-object constructor. */
48 complete_object_allocating_ctor
51 /* Return non-zero iff NAME is the mangled name of a constructor.
52 Actually, return an `enum ctor_kind' value describing what *kind*
53 of constructor it is. */
54 extern enum ctor_kinds is_constructor_name (const char *name);
57 /* Kinds of destructors. All these values are guaranteed to be
61 /* A destructor which finalizes the entire object, and then calls
62 `delete' on its storage. */
65 /* A destructor which finalizes the entire object, but does not call
69 /* A destructor which finalizes a subobject of some larger object. */
73 /* Return non-zero iff NAME is the mangled name of a destructor.
74 Actually, return an `enum dtor_kind' value describing what *kind*
75 of destructor it is. */
76 extern enum dtor_kinds is_destructor_name (const char *name);
79 /* Return non-zero iff NAME is the mangled name of a vtable. */
80 extern int is_vtable_name (const char *name);
83 /* Return non-zero iff NAME is the un-mangled name of an operator,
84 perhaps scoped within some class. */
85 extern int is_operator_name (const char *name);
88 /* Return an object's virtual function as a value.
90 VALUEP is a pointer to a pointer to a value, holding the object
91 whose virtual function we want to invoke. If the ABI requires a
92 virtual function's caller to adjust the `this' pointer by an amount
93 retrieved from the vtable before invoking the function (i.e., we're
94 not using "vtable thunks" to do the adjustment automatically), then
95 this function may set *VALUEP to point to a new object with an
96 appropriately tweaked address.
98 The J'th element of the overload set F is the virtual function of
99 *VALUEP we want to invoke.
101 TYPE is the base type of *VALUEP whose method we're invoking ---
102 this is the type containing F. OFFSET is the offset of that base
103 type within *VALUEP. */
104 extern struct value *value_virtual_fn_field (struct value **valuep,
105 struct fn_field *f, int j,
106 struct type *type, int offset);
109 /* Try to find the run-time type of VALUE, using C++ run-time type
110 information. Return the run-time type, or zero if we can't figure
113 If we do find the run-time type:
114 - Set *FULL to non-zero if VALUE already contains the complete
115 run-time object, not just some embedded base class of the object.
116 - Set *TOP and *USING_ENC to indicate where the enclosing object
117 starts relative to VALUE:
118 - If *USING_ENC is zero, then *TOP is the offset from the start
119 of the complete object to the start of the embedded subobject
120 VALUE represents. In other words, the enclosing object starts
121 at VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) +
122 VALUE_EMBEDDED_OFFSET (VALUE) + *TOP
123 - If *USING_ENC is non-zero, then *TOP is the offset from the
124 address of the complete object to the enclosing object stored
125 in VALUE. In other words, the enclosing object starts at
126 VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + *TOP.
127 If VALUE's type and enclosing type are the same, then these two
128 cases are equivalent.
130 FULL, TOP, and USING_ENC can each be zero, in which case we don't
131 provide the corresponding piece of information. */
132 extern struct type *value_rtti_type (struct value *value,
133 int *full, int *top, int *using_enc);
135 /* Compute the offset of the baseclass which is
136 the INDEXth baseclass of class TYPE,
137 for value at VALADDR (in host) at ADDRESS (in target).
138 The result is the offset of the baseclass value relative
139 to (the address of)(ARG) + OFFSET.
141 -1 is returned on error. */
143 extern int baseclass_offset (struct type *type, int index, char *valaddr,
148 const char *shortname;
149 const char *longname;
152 /* ABI-specific implementations for the functions declared above. */
153 enum ctor_kinds (*is_constructor_name) (const char *name);
154 enum dtor_kinds (*is_destructor_name) (const char *name);
155 int (*is_vtable_name) (const char *name);
156 int (*is_operator_name) (const char *name);
157 struct value *(*virtual_fn_field) (struct value **arg1p, struct fn_field * f,
158 int j, struct type * type, int offset);
159 struct type *(*rtti_type) (struct value *v, int *full, int *top,
161 int (*baseclass_offset) (struct type *type, int index, char *valaddr,
166 extern struct cp_abi_ops *cp_abis;
167 extern int num_cp_abis;
168 extern struct cp_abi_ops current_cp_abi;
169 extern int register_cp_abi (struct cp_abi_ops abi);
170 extern int switch_to_cp_abi (const char *short_name);