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