GDB (xrefs)

/tmp/gdb-8.1/gdb/cp-support.h
Go to the documentation of this file.
1 /* Helper routines for C++ support in GDB.
2 Copyright (C) 2002-2018 Free Software Foundation, Inc.
3
4 Contributed by MontaVista Software.
5 Namespace support contributed by David Carlton.
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
11 the Free Software Foundation; either version 3 of the License, or
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
20 along with this program. If not, see <http://www.gnu.org/licenses/>. */
21
22 #ifndef CP_SUPPORT_H
23 #define CP_SUPPORT_H
24
25 /* We need this for 'domain_enum', alas... */
26
27 #include "symtab.h"
28 #include "vec.h"
29 #include "gdb_vecs.h"
30 #include "gdb_obstack.h"
31
32 /* Opaque declarations. */
33
34 struct symbol;
35 struct block;
36 struct objfile;
37 struct type;
38 struct demangle_component;
39 struct using_direct;
40
41 /* A string representing the name of the anonymous namespace used in GDB. */
42
43 #define CP_ANONYMOUS_NAMESPACE_STR "(anonymous namespace)"
44
45 /* The length of the string representing the anonymous namespace. */
46
47 #define CP_ANONYMOUS_NAMESPACE_LEN 21
48
49 /* A string representing the start of an operator name. */
50
51 #define CP_OPERATOR_STR "operator"
52
53 /* The length of CP_OPERATOR_STR. */
54
55 #define CP_OPERATOR_LEN 8
56
57 /* The result of parsing a name. */
58
59 struct demangle_parse_info
60 {
61 demangle_parse_info ();
62
63 ~demangle_parse_info ();
64
65 /* The memory used during the parse. */
66 struct demangle_info *info;
67
68 /* The result of the parse. */
69 struct demangle_component *tree;
70
71 /* Any temporary memory used during typedef replacement. */
72 struct obstack obstack;
73 };
74
75
76 /* Functions from cp-support.c. */
77
78 extern std::string cp_canonicalize_string (const char *string);
79
80 extern std::string cp_canonicalize_string_no_typedefs (const char *string);
81
82 typedef const char *(canonicalization_ftype) (struct type *, void *);
83
84 extern std::string cp_canonicalize_string_full (const char *string,
85 canonicalization_ftype *finder,
86 void *data);
87
88 extern char *cp_class_name_from_physname (const char *physname);
89
90 extern char *method_name_from_physname (const char *physname);
91
92 extern unsigned int cp_find_first_component (const char *name);
93
94 extern unsigned int cp_entire_prefix_len (const char *name);
95
96 extern char *cp_func_name (const char *full_name);
97
98 extern gdb::unique_xmalloc_ptr<char> cp_remove_params
99 (const char *demanged_name);
100
101 /* DEMANGLED_NAME is the name of a function, (optionally) including
102 parameters and (optionally) a return type. Return the name of the
103 function without parameters or return type, or NULL if we can not
104 parse the name. If COMPLETION_MODE is true, then tolerate a
105 non-existing or unbalanced parameter list. */
106 extern gdb::unique_xmalloc_ptr<char> cp_remove_params_if_any
107 (const char *demangled_name, bool completion_mode);
108
109 extern struct symbol **make_symbol_overload_list (const char *,
110 const char *);
111
112 extern struct symbol **make_symbol_overload_list_adl (struct type **arg_types,
113 int nargs,
114 const char *func_name);
115
116 extern struct type *cp_lookup_rtti_type (const char *name,
117 struct block *block);
118
119 /* Produce an unsigned hash value from SEARCH_NAME that is compatible
120 with cp_symbol_name_matches. Only the last component in
121 "foo::bar::function()" is considered for hashing purposes (i.e.,
122 the entire prefix is skipped), so that later on looking up for
123 "function" or "bar::function" in all namespaces is possible. */
124 extern unsigned int cp_search_name_hash (const char *search_name);
125
126 /* Implement the "la_get_symbol_name_matcher" language_defn method for
127 C++. */
128 extern symbol_name_matcher_ftype *cp_get_symbol_name_matcher
129 (const lookup_name_info &lookup_name);
130
131 /* Functions/variables from cp-namespace.c. */
132
133 extern int cp_is_in_anonymous (const char *symbol_name);
134
135 extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
136 struct objfile *objfile);
137
138 extern struct block_symbol cp_lookup_symbol_nonlocal
139 (const struct language_defn *langdef,
140 const char *name,
141 const struct block *block,
142 const domain_enum domain);
143
144 extern struct block_symbol
145 cp_lookup_symbol_namespace (const char *the_namespace,
146 const char *name,
147 const struct block *block,
148 const domain_enum domain);
149
150 extern struct block_symbol cp_lookup_symbol_imports_or_template
151 (const char *scope,
152 const char *name,
153 const struct block *block,
154 const domain_enum domain);
155
156 extern struct block_symbol
157 cp_lookup_nested_symbol (struct type *parent_type,
158 const char *nested_name,
159 const struct block *block,
160 const domain_enum domain);
161
162 struct type *cp_lookup_transparent_type (const char *name);
163
164 /* See description in cp-namespace.c. */
165
166 struct type *cp_find_type_baseclass_by_name (struct type *parent_type,
167 const char *name);
168
169 /* Functions from cp-name-parser.y. */
170
171 extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp
172 (const char *demangled_name, const char **errmsg);
173
174 extern gdb::unique_xmalloc_ptr<char> cp_comp_to_string
175 (struct demangle_component *result, int estimated_len);
176
177 extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *,
178 struct demangle_component *,
179 struct demangle_parse_info *);
180
181 /* The list of "maint cplus" commands. */
182
183 extern struct cmd_list_element *maint_cplus_cmd_list;
184
185 /* A wrapper for bfd_demangle. */
186
187 char *gdb_demangle (const char *name, int options);
188
189 /* Like gdb_demangle, but suitable for use as la_sniff_from_mangled_name. */
190
191 int gdb_sniff_from_mangled_name (const char *mangled, char **demangled);
192
193 #endif /* CP_SUPPORT_H */
string
const char * string
Definition: signals.c:50
cp_find_first_component
unsigned int cp_find_first_component(const char *name)
Definition: cp-support.c:970
gdb_obstack.h
cmd_list_element
Definition: cli-decode.h:46
cp_lookup_symbol_imports_or_template
struct block_symbol cp_lookup_symbol_imports_or_template(const char *scope, const char *name, const struct block *block, const domain_enum domain)
Definition: cp-namespace.c:503
cp_canonicalize_string_no_typedefs
std::string cp_canonicalize_string_no_typedefs(const char *string)
Definition: cp-support.c:542
domain_enum
enum domain_enum_tag domain_enum
cp_search_name_hash
unsigned int cp_search_name_hash(const char *search_name)
Definition: cp-support.c:1621
cp_lookup_rtti_type
struct type * cp_lookup_rtti_type(const char *name, struct block *block)
Definition: cp-support.c:1440
demangle_parse_info::tree
struct demangle_component * tree
Definition: cp-support.h:69
symbol_name_matcher_ftype
bool() symbol_name_matcher_ftype(const char *symbol_search_name, const lookup_name_info &lookup_name, completion_match_result *comp_match_res)
Definition: symtab.h:324
method_name_from_physname
char * method_name_from_physname(const char *physname)
Definition: cp-support.c:784
cp_find_type_baseclass_by_name
struct type * cp_find_type_baseclass_by_name(struct type *parent_type, const char *name)
Definition: cp-namespace.c:777
cp_func_name
char * cp_func_name(const char *full_name)
Definition: cp-support.c:816
cp_demangled_name_to_comp
std::unique_ptr< demangle_parse_info > cp_demangled_name_to_comp(const char *demangled_name, const char **errmsg)
Definition: cp-name-parser.c:4266
demangle_parse_info::info
struct demangle_info * info
Definition: cp-support.h:66
language_defn
Definition: language.h:132
cp_remove_params_if_any
gdb::unique_xmalloc_ptr< char > cp_remove_params_if_any(const char *demangled_name, bool completion_mode)
Definition: cp-support.c:900
symtab.h
name
const char *const name
Definition: aarch64-tdep.c:76
cp_canonicalize_string
std::string cp_canonicalize_string(const char *string)
Definition: cp-support.c:552
make_symbol_overload_list
struct symbol ** make_symbol_overload_list(const char *, const char *)
Definition: cp-support.c:1189
gdb::unique_xmalloc_ptr
std::unique_ptr< T, xfree_deleter< T > > unique_xmalloc_ptr
Definition: gdb_unique_ptr.h:48
cp_scan_for_anonymous_namespaces
void cp_scan_for_anonymous_namespaces(const struct symbol *symbol, struct objfile *objfile)
Definition: cp-namespace.c:53
block_symbol
Definition: symtab.h:1133
cp_lookup_symbol_namespace
struct block_symbol cp_lookup_symbol_namespace(const char *the_namespace, const char *name, const struct block *block, const domain_enum domain)
Definition: cp-namespace.c:632
type
Definition: gdbtypes.h:749
demangle_parse_info::obstack
struct obstack obstack
Definition: cp-support.h:72
demangle_parse_info::~demangle_parse_info
~demangle_parse_info()
Definition: cp-name-parser.c:4215
using_direct
Definition: namespace.h:90
cp_is_in_anonymous
int cp_is_in_anonymous(const char *symbol_name)
Definition: cp-namespace.c:114
canonicalization_ftype
const char *() canonicalization_ftype(struct type *, void *)
Definition: cp-support.h:82
cp_comp_to_string
gdb::unique_xmalloc_ptr< char > cp_comp_to_string(struct demangle_component *result, int estimated_len)
Definition: cp-name-parser.c:4195
make_symbol_overload_list_adl
struct symbol ** make_symbol_overload_list_adl(struct type **arg_types, int nargs, const char *func_name)
Definition: cp-support.c:1326
demangle_parse_info
Definition: cp-support.h:59
cp_merge_demangle_parse_infos
void cp_merge_demangle_parse_infos(struct demangle_parse_info *, struct demangle_component *, struct demangle_parse_info *)
Definition: cp-name-parser.c:4241
gdb_sniff_from_mangled_name
int gdb_sniff_from_mangled_name(const char *mangled, char **demangled)
Definition: cp-support.c:1612
block
Definition: block.h:60
demangle_parse_info::demangle_parse_info
demangle_parse_info()
Definition: cp-name-parser.c:4206
objfile
Definition: objfiles.h:286
errmsg
static char errmsg[128]
Definition: procfs.c:269
cp_lookup_nested_symbol
struct block_symbol cp_lookup_nested_symbol(struct type *parent_type, const char *nested_name, const struct block *block, const domain_enum domain)
Definition: cp-namespace.c:913
gdb_vecs.h
cp_remove_params
gdb::unique_xmalloc_ptr< char > cp_remove_params(const char *demanged_name)
Definition: cp-support.c:892
cp_canonicalize_string_full
std::string cp_canonicalize_string_full(const char *string, canonicalization_ftype *finder, void *data)
Definition: cp-support.c:508
cp_class_name_from_physname
char * cp_class_name_from_physname(const char *physname)
Definition: cp-support.c:636
symbol
Definition: symtab.h:1049
demangle_info
Definition: cp-name-parser.c:91
maint_cplus_cmd_list
struct cmd_list_element * maint_cplus_cmd_list
Definition: cp-support.c:67
lookup_name_info
Definition: symtab.h:179
gdb_demangle
char * gdb_demangle(const char *name, int options)
Definition: cp-support.c:1518
cp_lookup_symbol_nonlocal
struct block_symbol cp_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
Definition: cp-namespace.c:737
cp_get_symbol_name_matcher
symbol_name_matcher_ftype * cp_get_symbol_name_matcher(const lookup_name_info &lookup_name)
Definition: cp-support.c:1790
vec.h
cp_entire_prefix_len
unsigned int cp_entire_prefix_len(const char *name)
Definition: cp-support.c:1122
cp_lookup_transparent_type
struct type * cp_lookup_transparent_type(const char *name)
Definition: cp-namespace.c:1009