Commit | Line | Data |
---|---|---|
de17c821 | 1 | /* Helper routines for C++ support in GDB. |
b811d2c2 | 2 | Copyright (C) 2002-2020 Free Software Foundation, Inc. |
de17c821 DJ |
3 | |
4 | Contributed by MontaVista Software. | |
9219021c | 5 | Namespace support contributed by David Carlton. |
de17c821 DJ |
6 | |
7 | This file is part of GDB. | |
8 | ||
9 | This program is free software; you can redistribute it and/or modify | |
10 | it under the terms of the GNU General Public License as published by | |
a9762ec7 | 11 | the Free Software Foundation; either version 3 of the License, or |
de17c821 DJ |
12 | (at your option) any later version. |
13 | ||
14 | This program is distributed in the hope that it will be useful, | |
15 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 | GNU General Public License for more details. | |
18 | ||
19 | You should have received a copy of the GNU General Public License | |
a9762ec7 | 20 | along with this program. If not, see <http://www.gnu.org/licenses/>. */ |
de17c821 | 21 | |
9219021c DC |
22 | #ifndef CP_SUPPORT_H |
23 | #define CP_SUPPORT_H | |
24 | ||
1fcb5155 DC |
25 | /* We need this for 'domain_enum', alas... */ |
26 | ||
27 | #include "symtab.h" | |
268a13a5 | 28 | #include "gdbsupport/gdb_vecs.h" |
3a93a0c2 | 29 | #include "gdb_obstack.h" |
268a13a5 | 30 | #include "gdbsupport/array-view.h" |
0891c3cc | 31 | #include <vector> |
32019081 | 32 | |
9219021c DC |
33 | /* Opaque declarations. */ |
34 | ||
b59661bd | 35 | struct symbol; |
9219021c | 36 | struct block; |
80e649fc | 37 | struct buildsym_compunit; |
4a4b3fed | 38 | struct objfile; |
362ff856 | 39 | struct type; |
fb4c6eba | 40 | struct demangle_component; |
22cee43f | 41 | struct using_direct; |
9219021c | 42 | |
2b1dbab0 KS |
43 | /* A string representing the name of the anonymous namespace used in GDB. */ |
44 | ||
45 | #define CP_ANONYMOUS_NAMESPACE_STR "(anonymous namespace)" | |
46 | ||
47 | /* The length of the string representing the anonymous namespace. */ | |
48 | ||
49 | #define CP_ANONYMOUS_NAMESPACE_LEN 21 | |
50 | ||
8090b426 PA |
51 | /* A string representing the start of an operator name. */ |
52 | ||
53 | #define CP_OPERATOR_STR "operator" | |
54 | ||
55 | /* The length of CP_OPERATOR_STR. */ | |
56 | ||
57 | #define CP_OPERATOR_LEN 8 | |
58 | ||
3a93a0c2 KS |
59 | /* The result of parsing a name. */ |
60 | ||
61 | struct demangle_parse_info | |
62 | { | |
c8b23b3f TT |
63 | demangle_parse_info (); |
64 | ||
65 | ~demangle_parse_info (); | |
66 | ||
3a93a0c2 KS |
67 | /* The memory used during the parse. */ |
68 | struct demangle_info *info; | |
69 | ||
70 | /* The result of the parse. */ | |
71 | struct demangle_component *tree; | |
72 | ||
73 | /* Any temporary memory used during typedef replacement. */ | |
74 | struct obstack obstack; | |
75 | }; | |
76 | ||
9219021c DC |
77 | |
78 | /* Functions from cp-support.c. */ | |
79 | ||
2f408ecb | 80 | extern std::string cp_canonicalize_string (const char *string); |
fb4c6eba | 81 | |
2f408ecb | 82 | extern std::string cp_canonicalize_string_no_typedefs (const char *string); |
3a93a0c2 | 83 | |
2621e0fd TT |
84 | typedef const char *(canonicalization_ftype) (struct type *, void *); |
85 | ||
2f408ecb PA |
86 | extern std::string cp_canonicalize_string_full (const char *string, |
87 | canonicalization_ftype *finder, | |
88 | void *data); | |
2621e0fd | 89 | |
31c27f77 | 90 | extern char *cp_class_name_from_physname (const char *physname); |
de17c821 DJ |
91 | |
92 | extern char *method_name_from_physname (const char *physname); | |
9219021c DC |
93 | |
94 | extern unsigned int cp_find_first_component (const char *name); | |
95 | ||
96 | extern unsigned int cp_entire_prefix_len (const char *name); | |
97 | ||
06d3e5b0 | 98 | extern gdb::unique_xmalloc_ptr<char> cp_func_name (const char *full_name); |
8d577d32 | 99 | |
109483d9 PA |
100 | extern gdb::unique_xmalloc_ptr<char> cp_remove_params |
101 | (const char *demanged_name); | |
3567439c | 102 | |
c62446b1 PA |
103 | /* DEMANGLED_NAME is the name of a function, (optionally) including |
104 | parameters and (optionally) a return type. Return the name of the | |
105 | function without parameters or return type, or NULL if we can not | |
106 | parse the name. If COMPLETION_MODE is true, then tolerate a | |
107 | non-existing or unbalanced parameter list. */ | |
108 | extern gdb::unique_xmalloc_ptr<char> cp_remove_params_if_any | |
109 | (const char *demangled_name, bool completion_mode); | |
110 | ||
0891c3cc PA |
111 | extern std::vector<symbol *> make_symbol_overload_list (const char *, |
112 | const char *); | |
9219021c | 113 | |
0891c3cc PA |
114 | extern void add_symbol_overload_list_adl |
115 | (gdb::array_view<type *> arg_types, | |
116 | const char *func_name, | |
117 | std::vector<symbol *> *overload_list); | |
7322dca9 | 118 | |
362ff856 | 119 | extern struct type *cp_lookup_rtti_type (const char *name, |
582942f4 | 120 | const struct block *block); |
362ff856 | 121 | |
a20714ff PA |
122 | /* Produce an unsigned hash value from SEARCH_NAME that is compatible |
123 | with cp_symbol_name_matches. Only the last component in | |
124 | "foo::bar::function()" is considered for hashing purposes (i.e., | |
125 | the entire prefix is skipped), so that later on looking up for | |
126 | "function" or "bar::function" in all namespaces is possible. */ | |
127 | extern unsigned int cp_search_name_hash (const char *search_name); | |
128 | ||
b5ec771e PA |
129 | /* Implement the "la_get_symbol_name_matcher" language_defn method for |
130 | C++. */ | |
131 | extern symbol_name_matcher_ftype *cp_get_symbol_name_matcher | |
132 | (const lookup_name_info &lookup_name); | |
133 | ||
9219021c DC |
134 | /* Functions/variables from cp-namespace.c. */ |
135 | ||
59da4d04 | 136 | extern int cp_is_in_anonymous (const char *symbol_name); |
9219021c | 137 | |
80e649fc TT |
138 | extern void cp_scan_for_anonymous_namespaces (struct buildsym_compunit *, |
139 | const struct symbol *symbol, | |
a10964d1 | 140 | struct objfile *objfile); |
9219021c | 141 | |
d12307c1 | 142 | extern struct block_symbol cp_lookup_symbol_nonlocal |
f606139a DE |
143 | (const struct language_defn *langdef, |
144 | const char *name, | |
145 | const struct block *block, | |
146 | const domain_enum domain); | |
1fcb5155 | 147 | |
d12307c1 PMR |
148 | extern struct block_symbol |
149 | cp_lookup_symbol_namespace (const char *the_namespace, | |
150 | const char *name, | |
151 | const struct block *block, | |
152 | const domain_enum domain); | |
13387711 | 153 | |
d12307c1 | 154 | extern struct block_symbol cp_lookup_symbol_imports_or_template |
34eaf542 TT |
155 | (const char *scope, |
156 | const char *name, | |
157 | const struct block *block, | |
158 | const domain_enum domain); | |
159 | ||
d12307c1 PMR |
160 | extern struct block_symbol |
161 | cp_lookup_nested_symbol (struct type *parent_type, | |
162 | const char *nested_name, | |
163 | const struct block *block, | |
164 | const domain_enum domain); | |
79c2c32d | 165 | |
b368761e DC |
166 | struct type *cp_lookup_transparent_type (const char *name); |
167 | ||
f7e3ecae KS |
168 | /* See description in cp-namespace.c. */ |
169 | ||
a07e3e18 DE |
170 | struct type *cp_find_type_baseclass_by_name (struct type *parent_type, |
171 | const char *name); | |
f7e3ecae | 172 | |
f88e9fd3 | 173 | /* Functions from cp-name-parser.y. */ |
fb4c6eba | 174 | |
c8b23b3f | 175 | extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp |
3513a6bb | 176 | (const char *demangled_name, std::string *errmsg); |
fb4c6eba | 177 | |
29592bde PA |
178 | extern gdb::unique_xmalloc_ptr<char> cp_comp_to_string |
179 | (struct demangle_component *result, int estimated_len); | |
fb4c6eba | 180 | |
3a93a0c2 KS |
181 | extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *, |
182 | struct demangle_component *, | |
183 | struct demangle_parse_info *); | |
184 | ||
5c4e30ca DC |
185 | /* The list of "maint cplus" commands. */ |
186 | ||
187 | extern struct cmd_list_element *maint_cplus_cmd_list; | |
188 | ||
8de20a37 TT |
189 | /* A wrapper for bfd_demangle. */ |
190 | ||
191 | char *gdb_demangle (const char *name, int options); | |
192 | ||
8b302db8 TT |
193 | /* Like gdb_demangle, but suitable for use as la_sniff_from_mangled_name. */ |
194 | ||
195 | int gdb_sniff_from_mangled_name (const char *mangled, char **demangled); | |
196 | ||
9219021c | 197 | #endif /* CP_SUPPORT_H */ |