Remove trailing spaces and tabulations from pascal language
[deliverable/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
7b6bb8da 6 Copyright (C) 2001, 2005, 2006, 2007, 2008, 2009, 2010, 2011
0fb0cc75 7 Free Software Foundation, Inc.
015a42b4
JB
8
9 This file is part of GDB.
10
a9762ec7
JB
11 This program is free software; you can redistribute it and/or modify
12 it under the terms of the GNU General Public License as published by
13 the Free Software Foundation; either version 3 of the License, or
015a42b4
JB
14 (at your option) any later version.
15
16 This program is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 GNU General Public License for more details.
20
21 You should have received a copy of the GNU General Public License
a9762ec7 22 along with this program. If not, see <http://www.gnu.org/licenses/>. */
015a42b4
JB
23
24#ifndef CP_ABI_H_
25#define CP_ABI_H_ 1
26
da3331ec
AC
27struct fn_field;
28struct type;
e933e538 29struct value;
0d5de010 30struct ui_file;
52f729a7 31struct frame_info;
e933e538 32
c5f5341b
JB
33/* The functions here that attempt to determine what sort of thing a
34 mangled name refers to may well be revised in the future. It would
35 certainly be cleaner to carry this information explicitly in GDB's
36 data structures than to derive it from the mangled name. */
37
38
015a42b4
JB
39/* Kinds of constructors. All these values are guaranteed to be
40 non-zero. */
41enum ctor_kinds {
42
43 /* Initialize a complete object, including virtual bases, using
44 memory provided by caller. */
45 complete_object_ctor = 1,
46
47 /* Initialize a base object of some larger object. */
48 base_object_ctor,
49
50 /* An allocating complete-object constructor. */
51 complete_object_allocating_ctor
52};
53
c5f5341b
JB
54/* Return non-zero iff NAME is the mangled name of a constructor.
55 Actually, return an `enum ctor_kind' value describing what *kind*
56 of constructor it is. */
57extern enum ctor_kinds is_constructor_name (const char *name);
58
015a42b4
JB
59
60/* Kinds of destructors. All these values are guaranteed to be
61 non-zero. */
62enum dtor_kinds {
63
64 /* A destructor which finalizes the entire object, and then calls
65 `delete' on its storage. */
66 deleting_dtor = 1,
67
68 /* A destructor which finalizes the entire object, but does not call
69 `delete'. */
70 complete_object_dtor,
71
aff410f1
MS
72 /* A destructor which finalizes a subobject of some larger
73 object. */
015a42b4
JB
74 base_object_dtor
75};
76
c5f5341b
JB
77/* Return non-zero iff NAME is the mangled name of a destructor.
78 Actually, return an `enum dtor_kind' value describing what *kind*
79 of destructor it is. */
80extern enum dtor_kinds is_destructor_name (const char *name);
81
82
83/* Return non-zero iff NAME is the mangled name of a vtable. */
84extern int is_vtable_name (const char *name);
85
86
87/* Return non-zero iff NAME is the un-mangled name of an operator,
88 perhaps scoped within some class. */
89extern int is_operator_name (const char *name);
90
91
92/* Return an object's virtual function as a value.
93
94 VALUEP is a pointer to a pointer to a value, holding the object
95 whose virtual function we want to invoke. If the ABI requires a
96 virtual function's caller to adjust the `this' pointer by an amount
97 retrieved from the vtable before invoking the function (i.e., we're
98 not using "vtable thunks" to do the adjustment automatically), then
99 this function may set *VALUEP to point to a new object with an
100 appropriately tweaked address.
101
102 The J'th element of the overload set F is the virtual function of
103 *VALUEP we want to invoke.
104
105 TYPE is the base type of *VALUEP whose method we're invoking ---
106 this is the type containing F. OFFSET is the offset of that base
107 type within *VALUEP. */
e933e538 108extern struct value *value_virtual_fn_field (struct value **valuep,
aff410f1
MS
109 struct fn_field *f,
110 int j,
111 struct type *type,
112 int offset);
c5f5341b
JB
113
114
115/* Try to find the run-time type of VALUE, using C++ run-time type
116 information. Return the run-time type, or zero if we can't figure
117 it out.
118
119 If we do find the run-time type:
120 - Set *FULL to non-zero if VALUE already contains the complete
121 run-time object, not just some embedded base class of the object.
122 - Set *TOP and *USING_ENC to indicate where the enclosing object
123 starts relative to VALUE:
124 - If *USING_ENC is zero, then *TOP is the offset from the start
125 of the complete object to the start of the embedded subobject
126 VALUE represents. In other words, the enclosing object starts
127 at VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) +
13c3b5f5 128 value_embedded_offset (VALUE) + *TOP
c5f5341b
JB
129 - If *USING_ENC is non-zero, then *TOP is the offset from the
130 address of the complete object to the enclosing object stored
131 in VALUE. In other words, the enclosing object starts at
132 VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + *TOP.
133 If VALUE's type and enclosing type are the same, then these two
134 cases are equivalent.
135
136 FULL, TOP, and USING_ENC can each be zero, in which case we don't
137 provide the corresponding piece of information. */
138extern struct type *value_rtti_type (struct value *value,
aff410f1
MS
139 int *full, int *top,
140 int *using_enc);
c5f5341b 141
8af8e3bc
PA
142/* Compute the offset of the baseclass which is the INDEXth baseclass
143 of class TYPE, for value at VALADDR (in host) at ADDRESS (in
144 target), offset by EMBEDDED_OFFSET. VALADDR points to the raw
145 contents of VAL. The result is the offset of the baseclass value
146 relative to (the address of)(ARG) + OFFSET. */
147
148extern int baseclass_offset (struct type *type,
149 int index, const gdb_byte *valaddr,
150 int embedded_offset,
151 CORE_ADDR address,
152 const struct value *val);
153
0d5de010
DJ
154/* Describe the target of a pointer to method. CONTENTS is the byte
155 pattern representing the pointer to method. TYPE is the pointer to
156 method type. STREAM is the stream to print it to. */
aff410f1
MS
157void cplus_print_method_ptr (const gdb_byte *contents,
158 struct type *type,
0d5de010
DJ
159 struct ui_file *stream);
160
aff410f1
MS
161/* Return the size of a pointer to member function of type
162 TO_TYPE. */
ad4820ab 163int cplus_method_ptr_size (struct type *to_type);
0d5de010 164
aff410f1
MS
165/* Return the method which should be called by applying METHOD_PTR to
166 *THIS_P, and adjust *THIS_P if necessary. */
0d5de010
DJ
167struct value *cplus_method_ptr_to_value (struct value **this_p,
168 struct value *method_ptr);
169
aff410f1
MS
170/* Create the byte pattern in CONTENTS representing a pointer of type
171 TYPE to member function at ADDRESS (if IS_VIRTUAL is 0) or with
172 virtual table offset ADDRESS (if IS_VIRTUAL is 1). This is the
173 opposite of cplus_method_ptr_to_value. */
ad4820ab
UW
174void cplus_make_method_ptr (struct type *type, gdb_byte *CONTENTS,
175 CORE_ADDR address, int is_virtual);
0d5de010 176
aff410f1
MS
177/* Determine if we are currently in a C++ thunk. If so, get the
178 address of the routine we are thunking to and continue to there
179 instead. */
b18be20d 180
aff410f1
MS
181CORE_ADDR cplus_skip_trampoline (struct frame_info *frame,
182 CORE_ADDR stop_pc);
b18be20d 183
aff410f1
MS
184/* Return non-zero if an argument of type TYPE should be passed by
185 reference instead of value. */
41f1b697
DJ
186extern int cp_pass_by_reference (struct type *type);
187
015a42b4
JB
188struct cp_abi_ops
189{
190 const char *shortname;
191 const char *longname;
192 const char *doc;
193
aff410f1
MS
194 /* ABI-specific implementations for the functions declared
195 above. */
015a42b4 196 enum ctor_kinds (*is_constructor_name) (const char *name);
015a42b4 197 enum dtor_kinds (*is_destructor_name) (const char *name);
015a42b4 198 int (*is_vtable_name) (const char *name);
015a42b4 199 int (*is_operator_name) (const char *name);
aff410f1
MS
200 struct value *(*virtual_fn_field) (struct value **arg1p,
201 struct fn_field * f,
202 int j, struct type * type,
203 int offset);
204 struct type *(*rtti_type) (struct value *v, int *full,
205 int *top, int *using_enc);
06c4d4dc 206 int (*baseclass_offset) (struct type *type, int index,
8af8e3bc
PA
207 const bfd_byte *valaddr, int embedded_offset,
208 CORE_ADDR address, const struct value *val);
aff410f1
MS
209 void (*print_method_ptr) (const gdb_byte *contents,
210 struct type *type,
0d5de010 211 struct ui_file *stream);
ad4820ab 212 int (*method_ptr_size) (struct type *);
aff410f1
MS
213 void (*make_method_ptr) (struct type *, gdb_byte *,
214 CORE_ADDR, int);
215 struct value * (*method_ptr_to_value) (struct value **,
216 struct value *);
52f729a7 217 CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
41f1b697 218 int (*pass_by_reference) (struct type *type);
015a42b4
JB
219};
220
221
fe1f4a5e
DJ
222extern int register_cp_abi (struct cp_abi_ops *abi);
223extern void set_cp_abi_as_auto_default (const char *short_name);
015a42b4
JB
224
225#endif
226
This page took 0.633307 seconds and 4 git commands to generate.