]>
Commit | Line | Data |
---|---|---|
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 <[email protected]> |
06c4d4dc | 5 | |
197e01b6 | 6 | Copyright (C) 2001, 2005 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 |
30 | struct fn_field; |
31 | struct type; | |
e933e538 AC |
32 | struct value; |
33 | ||
c5f5341b JB |
34 | /* The functions here that attempt to determine what sort of thing a |
35 | mangled name refers to may well be revised in the future. It would | |
36 | certainly be cleaner to carry this information explicitly in GDB's | |
37 | data structures than to derive it from the mangled name. */ | |
38 | ||
39 | ||
015a42b4 JB |
40 | /* Kinds of constructors. All these values are guaranteed to be |
41 | non-zero. */ | |
42 | enum ctor_kinds { | |
43 | ||
44 | /* Initialize a complete object, including virtual bases, using | |
45 | memory provided by caller. */ | |
46 | complete_object_ctor = 1, | |
47 | ||
48 | /* Initialize a base object of some larger object. */ | |
49 | base_object_ctor, | |
50 | ||
51 | /* An allocating complete-object constructor. */ | |
52 | complete_object_allocating_ctor | |
53 | }; | |
54 | ||
c5f5341b JB |
55 | /* Return non-zero iff NAME is the mangled name of a constructor. |
56 | Actually, return an `enum ctor_kind' value describing what *kind* | |
57 | of constructor it is. */ | |
58 | extern enum ctor_kinds is_constructor_name (const char *name); | |
59 | ||
015a42b4 JB |
60 | |
61 | /* Kinds of destructors. All these values are guaranteed to be | |
62 | non-zero. */ | |
63 | enum dtor_kinds { | |
64 | ||
65 | /* A destructor which finalizes the entire object, and then calls | |
66 | `delete' on its storage. */ | |
67 | deleting_dtor = 1, | |
68 | ||
69 | /* A destructor which finalizes the entire object, but does not call | |
70 | `delete'. */ | |
71 | complete_object_dtor, | |
72 | ||
73 | /* A destructor which finalizes a subobject of some larger object. */ | |
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. */ | |
80 | extern enum dtor_kinds is_destructor_name (const char *name); | |
81 | ||
82 | ||
83 | /* Return non-zero iff NAME is the mangled name of a vtable. */ | |
84 | extern 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. */ | |
89 | extern 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 AC |
108 | extern struct value *value_virtual_fn_field (struct value **valuep, |
109 | struct fn_field *f, int j, | |
110 | struct type *type, int offset); | |
c5f5341b JB |
111 | |
112 | ||
113 | /* Try to find the run-time type of VALUE, using C++ run-time type | |
114 | information. Return the run-time type, or zero if we can't figure | |
115 | it out. | |
116 | ||
117 | If we do find the run-time type: | |
118 | - Set *FULL to non-zero if VALUE already contains the complete | |
119 | run-time object, not just some embedded base class of the object. | |
120 | - Set *TOP and *USING_ENC to indicate where the enclosing object | |
121 | starts relative to VALUE: | |
122 | - If *USING_ENC is zero, then *TOP is the offset from the start | |
123 | of the complete object to the start of the embedded subobject | |
124 | VALUE represents. In other words, the enclosing object starts | |
125 | at VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + | |
13c3b5f5 | 126 | value_embedded_offset (VALUE) + *TOP |
c5f5341b JB |
127 | - If *USING_ENC is non-zero, then *TOP is the offset from the |
128 | address of the complete object to the enclosing object stored | |
129 | in VALUE. In other words, the enclosing object starts at | |
130 | VALUE_ADDR (VALUE) + VALUE_OFFSET (VALUE) + *TOP. | |
131 | If VALUE's type and enclosing type are the same, then these two | |
132 | cases are equivalent. | |
133 | ||
134 | FULL, TOP, and USING_ENC can each be zero, in which case we don't | |
135 | provide the corresponding piece of information. */ | |
136 | extern struct type *value_rtti_type (struct value *value, | |
137 | int *full, int *top, int *using_enc); | |
138 | ||
1514d34e DJ |
139 | /* Compute the offset of the baseclass which is |
140 | the INDEXth baseclass of class TYPE, | |
141 | for value at VALADDR (in host) at ADDRESS (in target). | |
142 | The result is the offset of the baseclass value relative | |
143 | to (the address of)(ARG) + OFFSET. | |
015a42b4 | 144 | |
1514d34e DJ |
145 | -1 is returned on error. */ |
146 | ||
06c4d4dc AC |
147 | extern int baseclass_offset (struct type *type, int index, |
148 | const bfd_byte *valaddr, CORE_ADDR address); | |
1514d34e | 149 | |
015a42b4 JB |
150 | struct cp_abi_ops |
151 | { | |
152 | const char *shortname; | |
153 | const char *longname; | |
154 | const char *doc; | |
155 | ||
c5f5341b | 156 | /* ABI-specific implementations for the functions declared above. */ |
015a42b4 | 157 | enum ctor_kinds (*is_constructor_name) (const char *name); |
015a42b4 | 158 | enum dtor_kinds (*is_destructor_name) (const char *name); |
015a42b4 | 159 | int (*is_vtable_name) (const char *name); |
015a42b4 | 160 | int (*is_operator_name) (const char *name); |
e933e538 AC |
161 | struct value *(*virtual_fn_field) (struct value **arg1p, struct fn_field * f, |
162 | int j, struct type * type, int offset); | |
163 | struct type *(*rtti_type) (struct value *v, int *full, int *top, | |
015a42b4 | 164 | int *using_enc); |
06c4d4dc AC |
165 | int (*baseclass_offset) (struct type *type, int index, |
166 | const bfd_byte *valaddr, CORE_ADDR address); | |
015a42b4 JB |
167 | }; |
168 | ||
169 | ||
fe1f4a5e DJ |
170 | extern int register_cp_abi (struct cp_abi_ops *abi); |
171 | extern void set_cp_abi_as_auto_default (const char *short_name); | |
015a42b4 JB |
172 | |
173 | #endif | |
174 |