* breakpoint.c:
[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 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
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
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
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
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
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. */
108 extern struct value *value_virtual_fn_field (struct value **valuep,
109 struct fn_field *f, int j,
110 struct type *type, int offset);
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) +
126 value_embedded_offset (VALUE) + *TOP
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
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.
144
145 -1 is returned on error. */
146
147 extern int baseclass_offset (struct type *type, int index,
148 const bfd_byte *valaddr, CORE_ADDR address);
149
150 struct cp_abi_ops
151 {
152 const char *shortname;
153 const char *longname;
154 const char *doc;
155
156 /* ABI-specific implementations for the functions declared above. */
157 enum ctor_kinds (*is_constructor_name) (const char *name);
158 enum dtor_kinds (*is_destructor_name) (const char *name);
159 int (*is_vtable_name) (const char *name);
160 int (*is_operator_name) (const char *name);
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,
164 int *using_enc);
165 int (*baseclass_offset) (struct type *type, int index,
166 const bfd_byte *valaddr, CORE_ADDR address);
167 };
168
169
170 extern int register_cp_abi (struct cp_abi_ops *abi);
171 extern void set_cp_abi_as_auto_default (const char *short_name);
172
173 #endif
174
This page took 0.04623 seconds and 5 git commands to generate.