]> git.ipfire.org Git - thirdparty/binutils-gdb.git/blame - gdb/cp-abi.h
Copyright updates for 2007.
[thirdparty/binutils-gdb.git] / gdb / cp-abi.h
CommitLineData
015a42b4
JB
1/* Abstraction of various C++ ABI's we support, and the info we need
2 to get from them.
06c4d4dc 3
015a42b4 4 Contributed by Daniel Berlin <dberlin@redhat.com>
06c4d4dc 5
6aba47ca 6 Copyright (C) 2001, 2005, 2006, 2007 Free Software Foundation, Inc.
015a42b4
JB
7
8 This file is part of GDB.
9
10 This program is free software; you can redistribute it and/or
11 modify
12 it under the terms of the GNU General Public License as published
13 by
14 the Free Software Foundation; either version 2 of the License, or
15 (at your option) any later version.
16
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.
21
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
197e01b6
EZ
24 Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 Boston, MA 02110-1301, USA. */
015a42b4
JB
26
27#ifndef CP_ABI_H_
28#define CP_ABI_H_ 1
29
da3331ec
AC
30struct fn_field;
31struct type;
e933e538 32struct value;
0d5de010 33struct ui_file;
e933e538 34
c5f5341b
JB
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. */
39
40
015a42b4
JB
41/* Kinds of constructors. All these values are guaranteed to be
42 non-zero. */
43enum ctor_kinds {
44
45 /* Initialize a complete object, including virtual bases, using
46 memory provided by caller. */
47 complete_object_ctor = 1,
48
49 /* Initialize a base object of some larger object. */
50 base_object_ctor,
51
52 /* An allocating complete-object constructor. */
53 complete_object_allocating_ctor
54};
55
c5f5341b
JB
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. */
59extern enum ctor_kinds is_constructor_name (const char *name);
60
015a42b4
JB
61
62/* Kinds of destructors. All these values are guaranteed to be
63 non-zero. */
64enum dtor_kinds {
65
66 /* A destructor which finalizes the entire object, and then calls
67 `delete' on its storage. */
68 deleting_dtor = 1,
69
70 /* A destructor which finalizes the entire object, but does not call
71 `delete'. */
72 complete_object_dtor,
73
74 /* A destructor which finalizes a subobject of some larger object. */
75 base_object_dtor
76};
77
c5f5341b
JB
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. */
81extern enum dtor_kinds is_destructor_name (const char *name);
82
83
84/* Return non-zero iff NAME is the mangled name of a vtable. */
85extern int is_vtable_name (const char *name);
86
87
88/* Return non-zero iff NAME is the un-mangled name of an operator,
89 perhaps scoped within some class. */
90extern int is_operator_name (const char *name);
91
92
93/* Return an object's virtual function as a value.
94
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.
102
103 The J'th element of the overload set F is the virtual function of
104 *VALUEP we want to invoke.
105
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. */
e933e538
AC
109extern struct value *value_virtual_fn_field (struct value **valuep,
110 struct fn_field *f, int j,
111 struct type *type, int offset);
c5f5341b
JB
112
113
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
116 it out.
117
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) +
13c3b5f5 127 value_embedded_offset (VALUE) + *TOP
c5f5341b
JB
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.
134
135 FULL, TOP, and USING_ENC can each be zero, in which case we don't
136 provide the corresponding piece of information. */
137extern struct type *value_rtti_type (struct value *value,
138 int *full, int *top, int *using_enc);
139
1514d34e
DJ
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.
015a42b4 145
1514d34e
DJ
146 -1 is returned on error. */
147
06c4d4dc
AC
148extern int baseclass_offset (struct type *type, int index,
149 const bfd_byte *valaddr, CORE_ADDR address);
1514d34e 150
0d5de010
DJ
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. */
154void cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
155 struct ui_file *stream);
156
157/* Return the size of a pointer to member function for the current
158 architecture. */
159int cplus_method_ptr_size (void);
160
161/* Return the method which should be called by applying METHOD_PTR
162 to *THIS_P, and adjust *THIS_P if necessary. */
163struct value *cplus_method_ptr_to_value (struct value **this_p,
164 struct value *method_ptr);
165
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. */
170void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
171 int is_virtual);
172
015a42b4
JB
173struct cp_abi_ops
174{
175 const char *shortname;
176 const char *longname;
177 const char *doc;
178
c5f5341b 179 /* ABI-specific implementations for the functions declared above. */
015a42b4 180 enum ctor_kinds (*is_constructor_name) (const char *name);
015a42b4 181 enum dtor_kinds (*is_destructor_name) (const char *name);
015a42b4 182 int (*is_vtable_name) (const char *name);
015a42b4 183 int (*is_operator_name) (const char *name);
e933e538
AC
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,
015a42b4 187 int *using_enc);
06c4d4dc
AC
188 int (*baseclass_offset) (struct type *type, int index,
189 const bfd_byte *valaddr, CORE_ADDR address);
0d5de010
DJ
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 *);
015a42b4
JB
195};
196
197
fe1f4a5e
DJ
198extern int register_cp_abi (struct cp_abi_ops *abi);
199extern void set_cp_abi_as_auto_default (const char *short_name);
015a42b4
JB
200
201#endif
202