GDB (API)
/home/stan/gdb/src/gdb/cp-support.h
Go to the documentation of this file.
00001 /* Helper routines for C++ support in GDB.
00002    Copyright (C) 2002-2013 Free Software Foundation, Inc.
00003 
00004    Contributed by MontaVista Software.
00005    Namespace support contributed by David Carlton.
00006 
00007    This file is part of GDB.
00008 
00009    This program is free software; you can redistribute it and/or modify
00010    it under the terms of the GNU General Public License as published by
00011    the Free Software Foundation; either version 3 of the License, or
00012    (at your option) any later version.
00013 
00014    This program is distributed in the hope that it will be useful,
00015    but WITHOUT ANY WARRANTY; without even the implied warranty of
00016    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017    GNU General Public License for more details.
00018 
00019    You should have received a copy of the GNU General Public License
00020    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00021 
00022 #ifndef CP_SUPPORT_H
00023 #define CP_SUPPORT_H
00024 
00025 /* We need this for 'domain_enum', alas...  */
00026 
00027 #include "symtab.h"
00028 #include "vec.h"
00029 #include "gdb_vecs.h"
00030 #include "gdb_obstack.h"
00031 
00032 /* Opaque declarations.  */
00033 
00034 struct symbol;
00035 struct block;
00036 struct objfile;
00037 struct type;
00038 struct demangle_component;
00039 
00040 /* A string representing the name of the anonymous namespace used in GDB.  */
00041 
00042 #define CP_ANONYMOUS_NAMESPACE_STR "(anonymous namespace)"
00043 
00044 /* The length of the string representing the anonymous namespace.  */
00045 
00046 #define CP_ANONYMOUS_NAMESPACE_LEN 21
00047 
00048 /* The result of parsing a name.  */
00049 
00050 struct demangle_parse_info
00051 {
00052   /* The memory used during the parse.  */
00053   struct demangle_info *info;
00054 
00055   /* The result of the parse.  */
00056   struct demangle_component *tree;
00057 
00058   /* Any temporary memory used during typedef replacement.  */
00059   struct obstack obstack;
00060 };
00061 
00062 /* This struct is designed to store data from using directives.  It
00063    says that names from namespace IMPORT_SRC should be visible within
00064    namespace IMPORT_DEST.  These form a linked list; NEXT is the next
00065    element of the list.  If the imported namespace or declaration has
00066    been aliased within the IMPORT_DEST namespace, ALIAS is set to a
00067    string representing the alias.  Otherwise, ALIAS is NULL.
00068    DECLARATION is the name of the imported declaration, if this import
00069    statement represents one.  Otherwise DECLARATION is NULL and this
00070    import statement represents a namespace.
00071 
00072    C++:      using namespace A;
00073    Fortran:  use A
00074    import_src = "A"
00075    import_dest = local scope of the import statement even such as ""
00076    alias = NULL
00077    declaration = NULL
00078    excludes = NULL
00079 
00080    C++:      using A::x;
00081    Fortran:  use A, only: x
00082    import_src = "A"
00083    import_dest = local scope of the import statement even such as ""
00084    alias = NULL
00085    declaration = "x"
00086    excludes = NULL
00087    The declaration will get imported as import_dest::x.
00088 
00089    C++ has no way to import all names except those listed ones.
00090    Fortran:  use A, localname => x
00091    import_src = "A"
00092    import_dest = local scope of the import statement even such as ""
00093    alias = "localname"
00094    declaration = "x"
00095    excludes = NULL
00096    +
00097    import_src = "A"
00098    import_dest = local scope of the import statement even such as ""
00099    alias = NULL
00100    declaration = NULL
00101    excludes = ["x"]
00102    All the entries of A get imported except of "x".  "x" gets imported as
00103    "localname".  "x" is not defined as a local name by this statement.
00104 
00105    C++:      namespace LOCALNS = A;
00106    Fortran has no way to address non-local namespace/module.
00107    import_src = "A"
00108    import_dest = local scope of the import statement even such as ""
00109    alias = "LOCALNS"
00110    declaration = NULL
00111    excludes = NULL
00112    The namespace will get imported as the import_dest::LOCALNS
00113    namespace.
00114 
00115    C++ cannot express it, it would be something like: using localname
00116    = A::x;
00117    Fortran:  use A, only localname => x
00118    import_src = "A"
00119    import_dest = local scope of the import statement even such as ""
00120    alias = "localname"
00121    declaration = "x"
00122    excludes = NULL
00123    The declaration will get imported as localname or
00124    `import_dest`localname.  */
00125 
00126 struct using_direct
00127 {
00128   const char *import_src;
00129   const char *import_dest;
00130 
00131   const char *alias;
00132   const char *declaration;
00133 
00134   struct using_direct *next;
00135 
00136   /* Used during import search to temporarily mark this node as
00137      searched.  */
00138   int searched;
00139 
00140   /* USING_DIRECT has variable allocation size according to the number of
00141      EXCLUDES entries, the last entry is NULL.  */
00142   const char *excludes[1];
00143 };
00144 
00145 
00146 /* Functions from cp-support.c.  */
00147 
00148 extern char *cp_canonicalize_string (const char *string);
00149 
00150 extern char *cp_canonicalize_string_no_typedefs (const char *string);
00151 
00152 typedef const char *(canonicalization_ftype) (struct type *, void *);
00153 
00154 extern char *cp_canonicalize_string_full (const char *string,
00155                                           canonicalization_ftype *finder,
00156                                           void *data);
00157 
00158 extern char *cp_class_name_from_physname (const char *physname);
00159 
00160 extern char *method_name_from_physname (const char *physname);
00161 
00162 extern unsigned int cp_find_first_component (const char *name);
00163 
00164 extern unsigned int cp_entire_prefix_len (const char *name);
00165 
00166 extern char *cp_func_name (const char *full_name);
00167 
00168 extern char *cp_remove_params (const char *demangled_name);
00169 
00170 extern struct symbol **make_symbol_overload_list (const char *,
00171                                                   const char *);
00172 
00173 extern struct symbol **make_symbol_overload_list_adl (struct type **arg_types,
00174                                                       int nargs,
00175                                                       const char *func_name);
00176 
00177 extern struct type *cp_lookup_rtti_type (const char *name,
00178                                          struct block *block);
00179 
00180 /* Functions/variables from cp-namespace.c.  */
00181 
00182 extern int cp_is_anonymous (const char *namespace);
00183 
00184 extern void cp_add_using_directive (const char *dest,
00185                                     const char *src,
00186                                     const char *alias,
00187                                     const char *declaration,
00188                                     VEC (const_char_ptr) *excludes,
00189                                     int copy_names,
00190                                     struct obstack *obstack);
00191 
00192 extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
00193                                               struct objfile *objfile);
00194 
00195 extern struct symbol *cp_lookup_symbol_nonlocal (const char *name,
00196                                                  const struct block *block,
00197                                                  const domain_enum domain);
00198 
00199 extern struct symbol *cp_lookup_symbol_namespace (const char *namespace,
00200                                                   const char *name,
00201                                                   const struct block *block,
00202                                                   const domain_enum domain);
00203 
00204 extern struct symbol *cp_lookup_symbol_imports (const char *scope,
00205                                                 const char *name,
00206                                                 const struct block *block,
00207                                                 const domain_enum domain,
00208                                                 const int declaration_only,
00209                                                 const int search_parents);
00210 
00211 extern struct symbol *cp_lookup_symbol_imports_or_template
00212      (const char *scope,
00213       const char *name,
00214       const struct block *block,
00215       const domain_enum domain);
00216 
00217 extern struct symbol *cp_lookup_nested_symbol (struct type *parent_type,
00218                                                const char *nested_name,
00219                                                const struct block *block);
00220 
00221 struct type *cp_lookup_transparent_type (const char *name);
00222 
00223 /* Functions from cp-name-parser.y.  */
00224 
00225 extern struct demangle_parse_info *cp_demangled_name_to_comp
00226      (const char *demangled_name, const char **errmsg);
00227 
00228 extern char *cp_comp_to_string (struct demangle_component *result,
00229                                 int estimated_len);
00230 
00231 extern void cp_demangled_name_parse_free (struct demangle_parse_info *);
00232 extern struct cleanup *make_cleanup_cp_demangled_name_parse_free
00233      (struct demangle_parse_info *);
00234 extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *,
00235                                            struct demangle_component *,
00236                                            struct demangle_parse_info *);
00237 
00238 extern struct demangle_parse_info *cp_new_demangle_parse_info (void);
00239 
00240 /* The list of "maint cplus" commands.  */
00241 
00242 extern struct cmd_list_element *maint_cplus_cmd_list;
00243 
00244 /* A wrapper for bfd_demangle.  */
00245 
00246 char *gdb_demangle (const char *name, int options);
00247 
00248 #endif /* CP_SUPPORT_H */
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines