* NEWS: Mention pointer to member improvements.
[deliverable/binutils-gdb.git] / gdb / cp-abi.h
1 /* Abstraction of various C++ ABI's we support, and the info we need
2 to get from them.
3
4 Contributed by Daniel Berlin <dberlin@redhat.com>
5
6 Copyright (C) 2001, 2005, 2006 Free Software Foundation, Inc.
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
24 Foundation, Inc., 51 Franklin Street, Fifth Floor,
25 Boston, MA 02110-1301, USA. */
26
27 #ifndef CP_ABI_H_
28 #define CP_ABI_H_ 1
29
30 struct fn_field;
31 struct type;
32 struct value;
33 struct ui_file;
34
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
41 /* Kinds of constructors. All these values are guaranteed to be
42 non-zero. */
43 enum 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
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);
60
61
62 /* Kinds of destructors. All these values are guaranteed to be
63 non-zero. */
64 enum 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
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);
82
83
84 /* Return non-zero iff NAME is the mangled name of a vtable. */
85 extern 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. */
90 extern 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. */
109 extern struct value *value_virtual_fn_field (struct value **valuep,
110 struct fn_field *f, int j,
111 struct type *type, int offset);
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) +
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.
134
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);
139
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.
145
146 -1 is returned on error. */
147
148 extern int baseclass_offset (struct type *type, int index,
149 const bfd_byte *valaddr, CORE_ADDR address);
150
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);
156
157 /* Return the size of a pointer to member function for the current
158 architecture. */
159 int 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. */
163 struct 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. */
170 void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
171 int is_virtual);
172
173 struct cp_abi_ops
174 {
175 const char *shortname;
176 const char *longname;
177 const char *doc;
178
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,
187 int *using_enc);
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 *);
195 };
196
197
198 extern int register_cp_abi (struct cp_abi_ops *abi);
199 extern void set_cp_abi_as_auto_default (const char *short_name);
200
201 #endif
202
This page took 0.063507 seconds and 5 git commands to generate.