GDB (xrefs)
Loading...
Searching...
No Matches
cp-support.h
Go to the documentation of this file.
1/* Helper routines for C++ support in GDB.
2 Copyright (C) 2002-2023 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#include "symtab.h"
26#include "gdbsupport/gdb_vecs.h"
27#include "gdbsupport/gdb_obstack.h"
28#include "gdbsupport/array-view.h"
29#include <vector>
30
31/* Opaque declarations. */
32
33struct symbol;
34struct block;
36struct objfile;
37struct type;
38struct demangle_component;
39struct 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
60{
62
64
65 /* The memory used during the parse. */
67
68 /* The result of the parse. */
69 struct demangle_component *tree;
70
71 /* Any temporary memory used during typedef replacement. */
73};
74
75
76/* Functions from cp-support.c. */
77
78extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string
79 (const char *string);
80
81extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_no_typedefs
82 (const char *string);
83
84typedef const char *(canonicalization_ftype) (struct type *, void *);
85
86extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_full
87 (const char *string, canonicalization_ftype *finder, void *data);
88
89extern char *cp_class_name_from_physname (const char *physname);
90
91extern char *method_name_from_physname (const char *physname);
92
93extern unsigned int cp_find_first_component (const char *name);
94
95extern unsigned int cp_entire_prefix_len (const char *name);
96
97extern gdb::unique_xmalloc_ptr<char> cp_func_name (const char *full_name);
98
99extern gdb::unique_xmalloc_ptr<char> cp_remove_params
100 (const char *demangled_name);
101
102/* DEMANGLED_NAME is the name of a function, (optionally) including
103 parameters and (optionally) a return type. Return the name of the
104 function without parameters or return type, or NULL if we can not
105 parse the name. If COMPLETION_MODE is true, then tolerate a
106 non-existing or unbalanced parameter list. */
107extern gdb::unique_xmalloc_ptr<char> cp_remove_params_if_any
108 (const char *demangled_name, bool completion_mode);
109
110extern std::vector<symbol *> make_symbol_overload_list (const char *,
111 const char *);
112
114 (gdb::array_view<type *> arg_types,
115 const char *func_name,
116 std::vector<symbol *> *overload_list);
117
118extern struct type *cp_lookup_rtti_type (const char *name,
119 const struct block *block);
120
121/* Produce an unsigned hash value from SEARCH_NAME that is compatible
122 with cp_symbol_name_matches. Only the last component in
123 "foo::bar::function()" is considered for hashing purposes (i.e.,
124 the entire prefix is skipped), so that later on looking up for
125 "function" or "bar::function" in all namespaces is possible. */
126extern unsigned int cp_search_name_hash (const char *search_name);
127
128/* Implement the "get_symbol_name_matcher" language_defn method for C++. */
130 (const lookup_name_info &lookup_name);
131
132/* Functions/variables from cp-namespace.c. */
133
134extern int cp_is_in_anonymous (const char *symbol_name);
135
137 const struct symbol *symbol,
138 struct objfile *objfile);
139
141 (const struct language_defn *langdef,
142 const char *name,
143 const struct block *block,
144 const domain_enum domain);
145
146extern struct block_symbol
147 cp_lookup_symbol_namespace (const char *the_namespace,
148 const char *name,
149 const struct block *block,
150 const domain_enum domain);
151
153 (const char *scope,
154 const char *name,
155 const struct block *block,
156 const domain_enum domain);
157
158extern struct block_symbol
159 cp_lookup_nested_symbol (struct type *parent_type,
160 const char *nested_name,
161 const struct block *block,
162 const domain_enum domain);
163
164struct type *cp_lookup_transparent_type (const char *name);
165
166/* See description in cp-namespace.c. */
167
168struct type *cp_find_type_baseclass_by_name (struct type *parent_type,
169 const char *name);
170
171/* Functions from cp-name-parser.y. */
172
173extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp
174 (const char *demangled_name, std::string *errmsg);
175
176/* Convert RESULT to a string. ESTIMATED_LEN is used only as a guide
177 to the length of the result. */
178
179extern gdb::unique_xmalloc_ptr<char> cp_comp_to_string
180 (struct demangle_component *result, int estimated_len);
181
183 struct demangle_component *,
184 struct demangle_parse_info *);
185
186/* The list of "maint cplus" commands. */
187
189
190/* Wrappers for bfd and libiberty demangling entry points. Note they
191 all force DMGL_VERBOSE so that callers don't need to. This is so
192 that GDB consistently uses DMGL_VERBOSE throughout -- we want
193 libiberty's demangler to expand standard substitutions to their
194 full template name. */
195
196/* A wrapper for bfd_demangle. */
197
198gdb::unique_xmalloc_ptr<char> gdb_demangle (const char *name, int options);
199
200/* A wrapper for cplus_demangle_print. */
201
202extern char *gdb_cplus_demangle_print (int options,
203 struct demangle_component *tree,
204 int estimated_length,
205 size_t *p_allocated_size);
206
207/* Find an instance of the character C in the string S that is outside
208 of all parenthesis pairs, single-quoted strings, and double-quoted
209 strings. Also, ignore the char within a template name, like a ','
210 within foo<int, int>. */
211
212extern const char *find_toplevel_char (const char *s, char c);
213
214#endif /* CP_SUPPORT_H */
const char *const name
struct block_symbol cp_lookup_symbol_imports_or_template(const char *scope, const char *name, const struct block *block, const domain_enum domain)
std::unique_ptr< demangle_parse_info > cp_demangled_name_to_comp(const char *demangled_name, std::string *errmsg)
std::vector< symbol * > make_symbol_overload_list(const char *, const char *)
gdb::unique_xmalloc_ptr< char > cp_canonicalize_string_full(const char *string, canonicalization_ftype *finder, void *data)
Definition cp-support.c:583
gdb::unique_xmalloc_ptr< char > cp_func_name(const char *full_name)
Definition cp-support.c:883
char * gdb_cplus_demangle_print(int options, struct demangle_component *tree, int estimated_length, size_t *p_allocated_size)
gdb::unique_xmalloc_ptr< char > gdb_demangle(const char *name, int options)
gdb::unique_xmalloc_ptr< char > cp_remove_params(const char *demangled_name)
Definition cp-support.c:959
const char * find_toplevel_char(const char *s, char c)
gdb::unique_xmalloc_ptr< char > cp_comp_to_string(struct demangle_component *result, int estimated_len)
struct type * cp_lookup_transparent_type(const char *name)
gdb::unique_xmalloc_ptr< char > cp_canonicalize_string_no_typedefs(const char *string)
Definition cp-support.c:617
symbol_name_matcher_ftype * cp_get_symbol_name_matcher(const lookup_name_info &lookup_name)
struct type * cp_find_type_baseclass_by_name(struct type *parent_type, const char *name)
struct type * cp_lookup_rtti_type(const char *name, const struct block *block)
char * method_name_from_physname(const char *physname)
Definition cp-support.c:853
void add_symbol_overload_list_adl(gdb::array_view< type * > arg_types, const char *func_name, std::vector< symbol * > *overload_list)
unsigned int cp_find_first_component(const char *name)
unsigned int cp_entire_prefix_len(const char *name)
gdb::unique_xmalloc_ptr< char > cp_canonicalize_string(const char *string)
Definition cp-support.c:627
char * cp_class_name_from_physname(const char *physname)
Definition cp-support.c:706
struct block_symbol cp_lookup_symbol_namespace(const char *the_namespace, const char *name, const struct block *block, const domain_enum domain)
unsigned int cp_search_name_hash(const char *search_name)
struct block_symbol cp_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
const char * canonicalization_ftype(struct type *, void *)
Definition cp-support.h:84
void cp_scan_for_anonymous_namespaces(struct buildsym_compunit *, const struct symbol *symbol, struct objfile *objfile)
gdb::unique_xmalloc_ptr< char > cp_remove_params_if_any(const char *demangled_name, bool completion_mode)
Definition cp-support.c:967
struct block_symbol cp_lookup_nested_symbol(struct type *parent_type, const char *nested_name, const struct block *block, const domain_enum domain)
int cp_is_in_anonymous(const char *symbol_name)
void cp_merge_demangle_parse_infos(struct demangle_parse_info *, struct demangle_component *, struct demangle_parse_info *)
struct cmd_list_element * maint_cplus_cmd_list
Definition cp-support.c:73
Definition block.h:109
struct obstack obstack
Definition cp-support.h:72
struct demangle_component * tree
Definition cp-support.h:69
struct demangle_info * info
Definition cp-support.h:66
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:399
domain_enum
Definition symtab.h:900