2007-07-01 H.J. Lu <hongjiu.lu@intel.com>
[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
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;
52f729a7 34struct frame_info;
e933e538 35
c5f5341b
JB
36/* The functions here that attempt to determine what sort of thing a
37 mangled name refers to may well be revised in the future. It would
38 certainly be cleaner to carry this information explicitly in GDB's
39 data structures than to derive it from the mangled name. */
40
41
015a42b4
JB
42/* Kinds of constructors. All these values are guaranteed to be
43 non-zero. */
44enum ctor_kinds {
45
46 /* Initialize a complete object, including virtual bases, using
47 memory provided by caller. */
48 complete_object_ctor = 1,
49
50 /* Initialize a base object of some larger object. */
51 base_object_ctor,
52
53 /* An allocating complete-object constructor. */
54 complete_object_allocating_ctor
55};
56
c5f5341b
JB
57/* Return non-zero iff NAME is the mangled name of a constructor.
58 Actually, return an `enum ctor_kind' value describing what *kind*
59 of constructor it is. */
60extern enum ctor_kinds is_constructor_name (const char *name);
61
015a42b4
JB
62
63/* Kinds of destructors. All these values are guaranteed to be
64 non-zero. */
65enum dtor_kinds {
66
67 /* A destructor which finalizes the entire object, and then calls
68 `delete' on its storage. */
69 deleting_dtor = 1,
70
71 /* A destructor which finalizes the entire object, but does not call
72 `delete'. */
73 complete_object_dtor,
74
75 /* A destructor which finalizes a subobject of some larger object. */
76 base_object_dtor
77};
78
c5f5341b
JB
79/* Return non-zero iff NAME is the mangled name of a destructor.
80 Actually, return an `enum dtor_kind' value describing what *kind*
81 of destructor it is. */
82extern enum dtor_kinds is_destructor_name (const char *name);
83
84
85/* Return non-zero iff NAME is the mangled name of a vtable. */
86extern int is_vtable_name (const char *name);
87
88
89/* Return non-zero iff NAME is the un-mangled name of an operator,
90 perhaps scoped within some class. */
91extern int is_operator_name (const char *name);
92
93
94/* Return an object's virtual function as a value.
95
96 VALUEP is a pointer to a pointer to a value, holding the object
97 whose virtual function we want to invoke. If the ABI requires a
98 virtual function's caller to adjust the `this' pointer by an amount
99 retrieved from the vtable before invoking the function (i.e., we're
100 not using "vtable thunks" to do the adjustment automatically), then
101 this function may set *VALUEP to point to a new object with an
102 appropriately tweaked address.
103
104 The J'th element of the overload set F is the virtual function of
105 *VALUEP we want to invoke.
106
107 TYPE is the base type of *VALUEP whose method we're invoking ---
108 this is the type containing F. OFFSET is the offset of that base
109 type within *VALUEP. */
e933e538
AC
110extern struct value *value_virtual_fn_field (struct value **valuep,
111 struct fn_field *f, int j,
112 struct type *type, 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,
139 int *full, int *top, int *using_enc);
140
1514d34e
DJ
141/* Compute the offset of the baseclass which is
142 the INDEXth baseclass of class TYPE,
143 for value at VALADDR (in host) at ADDRESS (in target).
144 The result is the offset of the baseclass value relative
145 to (the address of)(ARG) + OFFSET.
015a42b4 146
1514d34e
DJ
147 -1 is returned on error. */
148
06c4d4dc
AC
149extern int baseclass_offset (struct type *type, int index,
150 const bfd_byte *valaddr, CORE_ADDR address);
1514d34e 151
0d5de010
DJ
152/* Describe the target of a pointer to method. CONTENTS is the byte
153 pattern representing the pointer to method. TYPE is the pointer to
154 method type. STREAM is the stream to print it to. */
155void cplus_print_method_ptr (const gdb_byte *contents, struct type *type,
156 struct ui_file *stream);
157
158/* Return the size of a pointer to member function for the current
159 architecture. */
160int cplus_method_ptr_size (void);
161
162/* Return the method which should be called by applying METHOD_PTR
163 to *THIS_P, and adjust *THIS_P if necessary. */
164struct value *cplus_method_ptr_to_value (struct value **this_p,
165 struct value *method_ptr);
166
167/* Create the byte pattern in CONTENTS representing a pointer to
168 member function at ADDRESS (if IS_VIRTUAL is 0) or with virtual
169 table offset ADDRESS (if IS_VIRTUAL is 1). This is the opposite
170 of cplus_method_ptr_to_value. */
171void cplus_make_method_ptr (gdb_byte *CONTENTS, CORE_ADDR address,
172 int is_virtual);
173
b18be20d
DJ
174/* Determine if we are currently in a C++ thunk. If so, get the address
175 of the routine we are thunking to and continue to there instead. */
176
52f729a7 177CORE_ADDR cplus_skip_trampoline (struct frame_info *frame, CORE_ADDR stop_pc);
b18be20d 178
015a42b4
JB
179struct cp_abi_ops
180{
181 const char *shortname;
182 const char *longname;
183 const char *doc;
184
c5f5341b 185 /* ABI-specific implementations for the functions declared above. */
015a42b4 186 enum ctor_kinds (*is_constructor_name) (const char *name);
015a42b4 187 enum dtor_kinds (*is_destructor_name) (const char *name);
015a42b4 188 int (*is_vtable_name) (const char *name);
015a42b4 189 int (*is_operator_name) (const char *name);
e933e538
AC
190 struct value *(*virtual_fn_field) (struct value **arg1p, struct fn_field * f,
191 int j, struct type * type, int offset);
192 struct type *(*rtti_type) (struct value *v, int *full, int *top,
015a42b4 193 int *using_enc);
06c4d4dc
AC
194 int (*baseclass_offset) (struct type *type, int index,
195 const bfd_byte *valaddr, CORE_ADDR address);
0d5de010
DJ
196 void (*print_method_ptr) (const gdb_byte *contents, struct type *type,
197 struct ui_file *stream);
198 int (*method_ptr_size) (void);
199 void (*make_method_ptr) (gdb_byte *, CORE_ADDR, int);
200 struct value * (*method_ptr_to_value) (struct value **, struct value *);
52f729a7 201 CORE_ADDR (*skip_trampoline) (struct frame_info *, CORE_ADDR);
015a42b4
JB
202};
203
204
fe1f4a5e
DJ
205extern int register_cp_abi (struct cp_abi_ops *abi);
206extern void set_cp_abi_as_auto_default (const char *short_name);
015a42b4
JB
207
208#endif
209
This page took 0.410855 seconds and 4 git commands to generate.