1 /* Abstraction of various C++ ABI's we support, and the info we need
4 Contributed by Daniel Berlin <dberlin@redhat.com>
6 Copyright (C) 2001, 2005, 2006, 2007 Free Software Foundation, Inc.
8 This file is part of GDB.
10 This program is free software; you can redistribute it and/or
12 it under the terms of the GNU General Public License as published
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
17 This program is distributed in the hope that it will be useful,
18 but WITHOUT ANY WARRANTY; without even the implied warranty of
19 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 GNU General Public License for more details.
22 You should have received a copy of the GNU General Public License
23 along with this program; if not, write to the Free Software
24 Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 Boston, MA 02110-1301, USA. */
35 /* The functions here that attempt to determine what sort of thing a
36 mangled name refers to may well be revised in the future. It would
37 certainly be cleaner to carry this information explicitly in GDB's
38 data structures than to derive it from the mangled name. */
41 /* Kinds of constructors. All these values are guaranteed to be
45 /* Initialize a complete object, including virtual bases, using
46 memory provided by caller. */
47 complete_object_ctor = 1,
49 /* Initialize a base object of some larger object. */
52 /* An allocating complete-object constructor. */
53 complete_object_allocating_ctor
56 /* Return non-zero iff NAME is the mangled name of a constructor.
57 Actually, return an `enum ctor_kind' value describing what *kind*
58 of constructor it is. */
59 extern enum ctor_kinds is_constructor_name (const char *name);
62 /* Kinds of destructors. All these values are guaranteed to be
66 /* A destructor which finalizes the entire object, and then calls
67 `delete' on its storage. */
70 /* A destructor which finalizes the entire object, but does not call
74 /* A destructor which finalizes a subobject of some larger object. */
78 /* Return non-zero iff NAME is the mangled name of a destructor.
79 Actually, return an `enum dtor_kind' value describing what *kind*
80 of destructor it is. */
81 extern enum dtor_kinds is_destructor_name (const char *name);
84 /* Return non-zero iff NAME is the mangled name of a vtable. */
85 extern int is_vtable_name (const char *name);
88 /* Return non-zero iff NAME is the un-mangled name of an operator,
89 perhaps scoped within some class. */
90 extern int is_operator_name (const char *name);
93 /* Return an object's virtual function as a value.
95 VALUEP is a pointer to a pointer to a value, holding the object
96 whose virtual function we want to invoke. If the ABI requires a
97 virtual function's caller to adjust the `this' pointer by an amount
98 retrieved from the vtable before invoking the function (i.e., we're
99 not using "vtable thunks" to do the adjustment automatically), then
100 this function may set *VALUEP to point to a new object with an
101 appropriately tweaked address.
103 The J'th element of the overload set F is the virtual function of
104 *VALUEP we want to invoke.
106 TYPE is the base type of *VALUEP whose method we're invoking ---
107 this is the type containing F. OFFSET is the offset of that base
108 type within *VALUEP. */
109 extern struct value *value_virtual_fn_field (struct value **valuep,
110 struct fn_field *f, int j,
111 struct type *type, int offset);
114 /* Try to find the run-time type of VALUE, using C++ run-time type
115 information. Return the run-time type, or zero if we can't figure
118 If we do find the run-time type:
119 - Set *FULL to non-zero if VALUE already contains the complete
120 run-time object, not just some embedded base class of the object.
121 - Set *TOP and *USING_ENC to indicate where the enclosing object
122 starts relative to VALUE:
123 - If *USING_ENC is zero, then *TOP is the offset from the start
124 of the complete object to the start of the embedded subobject
125 VALUE represents. In other words, the enclosing object starts
126 at VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) +
127 value_embedded_offset (VALUE) + *TOP
128 - If *USING_ENC is non-zero, then *TOP is the offset from the
129 address of the complete object to the enclosing object stored
130 in VALUE. In other words, the enclosing object starts at
131 VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + *TOP.
132 If VALUE's type and enclosing type are the same, then these two
133 cases are equivalent.
135 FULL, TOP, and USING_ENC can each be zero, in which case we don't
136 provide the corresponding piece of information. */
137 extern struct type *value_rtti_type (struct value *value,
138 int *full, int *top, int *using_enc);
140 /* Compute the offset of the baseclass which is
141 the INDEXth baseclass of class TYPE,
142 for value at VALADDR (in host) at ADDRESS (in target).
143 The result is the offset of the baseclass value relative
144 to (the address of)(ARG) + OFFSET.
146 -1 is returned on error. */
148 extern int baseclass_offset (struct type *type, int index,
149 const bfd_byte *valaddr, CORE_ADDR address);
151 /* Describe the target of a pointer to method. CONTENTS is the byte
152 pattern representing the pointer to method. TYPE is the pointer to
153 method type. STREAM is the stream to print it to. */
154 void cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
155 struct ui_file *stream);
157 /* Return the size of a pointer to member function for the current
159 int cplus_method_ptr_size (void);
161 /* Return the method which should be called by applying METHOD_PTR
162 to *THIS_P, and adjust *THIS_P if necessary. */
163 struct value *cplus_method_ptr_to_value (struct value **this_p,
164 struct value *method_ptr);
166 /* Create the byte pattern in CONTENTS representing a pointer to
167 member function at ADDRESS (if IS_VIRTUAL is 0) or with virtual
168 table offset ADDRESS (if IS_VIRTUAL is 1). This is the opposite
169 of cplus_method_ptr_to_value. */
170 void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
175 const char *shortname;
176 const char *longname;
179 /* ABI-specific implementations for the functions declared above. */
180 enum ctor_kinds (*is_constructor_name) (const char *name);
181 enum dtor_kinds (*is_destructor_name) (const char *name);
182 int (*is_vtable_name) (const char *name);
183 int (*is_operator_name) (const char *name);
184 struct value *(*virtual_fn_field) (struct value **arg1p, struct fn_field * f,
185 int j, struct type * type, int offset);
186 struct type *(*rtti_type) (struct value *v, int *full, int *top,
188 int (*baseclass_offset) (struct type *type, int index,
189 const bfd_byte *valaddr, CORE_ADDR address);
190 void (*print_method_ptr) (const gdb_byte *contents, struct type *type,
191 struct ui_file *stream);
192 int (*method_ptr_size) (void);
193 void (*make_method_ptr) (gdb_byte *, CORE_ADDR, int);
194 struct value * (*method_ptr_to_value) (struct value **, struct value *);
198 extern int register_cp_abi (struct cp_abi_ops *abi);
199 extern void set_cp_abi_as_auto_default (const char *short_name);