1 /* Helper routines for C++ support in GDB. 2 Copyright (C) 2002-2017 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 /* The result of parsing a name. */ 50 51 struct demangle_parse_info 52 { 53 demangle_parse_info (); 54 55 ~demangle_parse_info (); 56 57 /* The memory used during the parse. */ 58 struct demangle_info *info; 59 60 /* The result of the parse. */ 61 struct demangle_component *tree; 62 63 /* Any temporary memory used during typedef replacement. */ 64 struct obstack obstack; 65 }; 66 67 68 /* Functions from cp-support.c. */ 69 70 extern std::string cp_canonicalize_string (const char *string); 71 72 extern std::string cp_canonicalize_string_no_typedefs (const char *string); 73 74 typedef const char *(canonicalization_ftype) (struct type *, void *); 75 76 extern std::string cp_canonicalize_string_full (const char *string, 77 canonicalization_ftype *finder, 78 void *data); 79 80 extern char *cp_class_name_from_physname (const char *physname); 81 82 extern char *method_name_from_physname (const char *physname); 83 84 extern unsigned int cp_find_first_component (const char *name); 85 86 extern unsigned int cp_entire_prefix_len (const char *name); 87 88 extern char *cp_func_name (const char *full_name); 89 90 extern char *cp_remove_params (const char *demangled_name); 91 92 extern struct symbol **make_symbol_overload_list (const char *, 93 const char *); 94 95 extern struct symbol **make_symbol_overload_list_adl (struct type **arg_types, 96 int nargs, 97 const char *func_name); 98 99 extern struct type *cp_lookup_rtti_type (const char *name, 100 struct block *block); 101 102 /* Functions/variables from cp-namespace.c. */ 103 104 extern int cp_is_in_anonymous (const char *symbol_name); 105 106 extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol, 107 struct objfile *objfile); 108 109 extern struct block_symbol cp_lookup_symbol_nonlocal 110 (const struct language_defn *langdef, 111 const char *name, 112 const struct block *block, 113 const domain_enum domain); 114 115 extern struct block_symbol 116 cp_lookup_symbol_namespace (const char *the_namespace, 117 const char *name, 118 const struct block *block, 119 const domain_enum domain); 120 121 extern struct block_symbol cp_lookup_symbol_imports_or_template 122 (const char *scope, 123 const char *name, 124 const struct block *block, 125 const domain_enum domain); 126 127 extern struct block_symbol 128 cp_lookup_nested_symbol (struct type *parent_type, 129 const char *nested_name, 130 const struct block *block, 131 const domain_enum domain); 132 133 struct type *cp_lookup_transparent_type (const char *name); 134 135 /* See description in cp-namespace.c. */ 136 137 struct type *cp_find_type_baseclass_by_name (struct type *parent_type, 138 const char *name); 139 140 /* Functions from cp-name-parser.y. */ 141 142 extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp 143 (const char *demangled_name, const char **errmsg); 144 145 extern char *cp_comp_to_string (struct demangle_component *result, 146 int estimated_len); 147 148 extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *, 149 struct demangle_component *, 150 struct demangle_parse_info *); 151 152 /* The list of "maint cplus" commands. */ 153 154 extern struct cmd_list_element *maint_cplus_cmd_list; 155 156 /* A wrapper for bfd_demangle. */ 157 158 char *gdb_demangle (const char *name, int options); 159 160 /* Like gdb_demangle, but suitable for use as la_sniff_from_mangled_name. */ 161 162 int gdb_sniff_from_mangled_name (const char *mangled, char **demangled); 163 164 #endif /* CP_SUPPORT_H */ 165