1 /* Helper routines for C++ support in GDB.
2 Copyright (C) 2002-2017 Free Software Foundation, Inc.
4 Contributed by MontaVista Software.
5 Namespace support contributed by David Carlton.
7 This file is part of GDB.
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.
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.
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/>. */
25 /* We need this for 'domain_enum', alas... */
30 #include "gdb_obstack.h"
32 /* Opaque declarations. */
38 struct demangle_component;
41 /* A string representing the name of the anonymous namespace used in GDB. */
43 #define CP_ANONYMOUS_NAMESPACE_STR "(anonymous namespace)"
45 /* The length of the string representing the anonymous namespace. */
47 #define CP_ANONYMOUS_NAMESPACE_LEN 21
49 /* A string representing the start of an operator name. */
51 #define CP_OPERATOR_STR "operator"
53 /* The length of CP_OPERATOR_STR. */
55 #define CP_OPERATOR_LEN 8
57 /* The result of parsing a name. */
59 struct demangle_parse_info
61 demangle_parse_info ();
63 ~demangle_parse_info ();
65 /* The memory used during the parse. */
66 struct demangle_info *info;
68 /* The result of the parse. */
69 struct demangle_component *tree;
71 /* Any temporary memory used during typedef replacement. */
72 struct obstack obstack;
76 /* Functions from cp-support.c. */
78 extern std::string cp_canonicalize_string (const char *string);
80 extern std::string cp_canonicalize_string_no_typedefs (const char *string);
82 typedef const char *(canonicalization_ftype) (struct type *, void *);
84 extern std::string cp_canonicalize_string_full (const char *string,
85 canonicalization_ftype *finder,
88 extern char *cp_class_name_from_physname (const char *physname);
90 extern char *method_name_from_physname (const char *physname);
92 extern unsigned int cp_find_first_component (const char *name);
94 extern unsigned int cp_entire_prefix_len (const char *name);
96 extern char *cp_func_name (const char *full_name);
98 extern char *cp_remove_params (const char *demangled_name);
100 extern struct symbol **make_symbol_overload_list (const char *,
103 extern struct symbol **make_symbol_overload_list_adl (struct type **arg_types,
105 const char *func_name);
107 extern struct type *cp_lookup_rtti_type (const char *name,
108 struct block *block);
110 /* Functions/variables from cp-namespace.c. */
112 extern int cp_is_in_anonymous (const char *symbol_name);
114 extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
115 struct objfile *objfile);
117 extern struct block_symbol cp_lookup_symbol_nonlocal
118 (const struct language_defn *langdef,
120 const struct block *block,
121 const domain_enum domain);
123 extern struct block_symbol
124 cp_lookup_symbol_namespace (const char *the_namespace,
126 const struct block *block,
127 const domain_enum domain);
129 extern struct block_symbol cp_lookup_symbol_imports_or_template
132 const struct block *block,
133 const domain_enum domain);
135 extern struct block_symbol
136 cp_lookup_nested_symbol (struct type *parent_type,
137 const char *nested_name,
138 const struct block *block,
139 const domain_enum domain);
141 struct type *cp_lookup_transparent_type (const char *name);
143 /* See description in cp-namespace.c. */
145 struct type *cp_find_type_baseclass_by_name (struct type *parent_type,
148 /* Functions from cp-name-parser.y. */
150 extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp
151 (const char *demangled_name, const char **errmsg);
153 extern gdb::unique_xmalloc_ptr<char> cp_comp_to_string
154 (struct demangle_component *result, int estimated_len);
156 extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *,
157 struct demangle_component *,
158 struct demangle_parse_info *);
160 /* The list of "maint cplus" commands. */
162 extern struct cmd_list_element *maint_cplus_cmd_list;
164 /* A wrapper for bfd_demangle. */
166 char *gdb_demangle (const char *name, int options);
168 /* Like gdb_demangle, but suitable for use as la_sniff_from_mangled_name. */
170 int gdb_sniff_from_mangled_name (const char *mangled, char **demangled);
172 #endif /* CP_SUPPORT_H */