gdb/cp-support.h - gdb

Data types defined

Macros defined

Source code

  1. /* Helper routines for C++ support in GDB.
  2.    Copyright (C) 2002-2015 Free Software Foundation, Inc.

  3.    Contributed by MontaVista Software.
  4.    Namespace support contributed by David Carlton.

  5.    This file is part of GDB.

  6.    This program is free software; you can redistribute it and/or modify
  7.    it under the terms of the GNU General Public License as published by
  8.    the Free Software Foundation; either version 3 of the License, or
  9.    (at your option) any later version.

  10.    This program is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  13.    GNU General Public License for more details.

  14.    You should have received a copy of the GNU General Public License
  15.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  16. #ifndef CP_SUPPORT_H
  17. #define CP_SUPPORT_H

  18. /* We need this for 'domain_enum', alas...  */

  19. #include "symtab.h"
  20. #include "vec.h"
  21. #include "gdb_vecs.h"
  22. #include "gdb_obstack.h"

  23. /* Opaque declarations.  */

  24. struct symbol;
  25. struct block;
  26. struct objfile;
  27. struct type;
  28. struct demangle_component;

  29. /* A string representing the name of the anonymous namespace used in GDB.  */

  30. #define CP_ANONYMOUS_NAMESPACE_STR "(anonymous namespace)"

  31. /* The length of the string representing the anonymous namespace.  */

  32. #define CP_ANONYMOUS_NAMESPACE_LEN 21

  33. /* The result of parsing a name.  */

  34. struct demangle_parse_info
  35. {
  36.   /* The memory used during the parse.  */
  37.   struct demangle_info *info;

  38.   /* The result of the parse.  */
  39.   struct demangle_component *tree;

  40.   /* Any temporary memory used during typedef replacement.  */
  41.   struct obstack obstack;
  42. };

  43. /* This struct is designed to store data from using directives.  It
  44.    says that names from namespace IMPORT_SRC should be visible within
  45.    namespace IMPORT_DEST.  These form a linked list; NEXT is the next
  46.    element of the list.  If the imported namespace or declaration has
  47.    been aliased within the IMPORT_DEST namespace, ALIAS is set to a
  48.    string representing the alias.  Otherwise, ALIAS is NULL.
  49.    DECLARATION is the name of the imported declaration, if this import
  50.    statement represents one.  Otherwise DECLARATION is NULL and this
  51.    import statement represents a namespace.

  52.    C++:      using namespace A;
  53.    Fortran:  use A
  54.    import_src = "A"
  55.    import_dest = local scope of the import statement even such as ""
  56.    alias = NULL
  57.    declaration = NULL
  58.    excludes = NULL

  59.    C++:      using A::x;
  60.    Fortran:  use A, only: x
  61.    import_src = "A"
  62.    import_dest = local scope of the import statement even such as ""
  63.    alias = NULL
  64.    declaration = "x"
  65.    excludes = NULL
  66.    The declaration will get imported as import_dest::x.

  67.    C++ has no way to import all names except those listed ones.
  68.    Fortran:  use A, localname => x
  69.    import_src = "A"
  70.    import_dest = local scope of the import statement even such as ""
  71.    alias = "localname"
  72.    declaration = "x"
  73.    excludes = NULL
  74.    +
  75.    import_src = "A"
  76.    import_dest = local scope of the import statement even such as ""
  77.    alias = NULL
  78.    declaration = NULL
  79.    excludes = ["x"]
  80.    All the entries of A get imported except of "x".  "x" gets imported as
  81.    "localname".  "x" is not defined as a local name by this statement.

  82.    C++:      namespace LOCALNS = A;
  83.    Fortran has no way to address non-local namespace/module.
  84.    import_src = "A"
  85.    import_dest = local scope of the import statement even such as ""
  86.    alias = "LOCALNS"
  87.    declaration = NULL
  88.    excludes = NULL
  89.    The namespace will get imported as the import_dest::LOCALNS
  90.    namespace.

  91.    C++ cannot express it, it would be something like: using localname
  92.    = A::x;
  93.    Fortran:  use A, only localname => x
  94.    import_src = "A"
  95.    import_dest = local scope of the import statement even such as ""
  96.    alias = "localname"
  97.    declaration = "x"
  98.    excludes = NULL
  99.    The declaration will get imported as localname or
  100.    `import_dest`localname.  */

  101. struct using_direct
  102. {
  103.   const char *import_src;
  104.   const char *import_dest;

  105.   const char *alias;
  106.   const char *declaration;

  107.   struct using_direct *next;

  108.   /* Used during import search to temporarily mark this node as
  109.      searched.  */
  110.   int searched;

  111.   /* USING_DIRECT has variable allocation size according to the number of
  112.      EXCLUDES entries, the last entry is NULL.  */
  113.   const char *excludes[1];
  114. };


  115. /* Functions from cp-support.c.  */

  116. extern char *cp_canonicalize_string (const char *string);

  117. extern char *cp_canonicalize_string_no_typedefs (const char *string);

  118. typedef const char *(canonicalization_ftype) (struct type *, void *);

  119. extern char *cp_canonicalize_string_full (const char *string,
  120.                                           canonicalization_ftype *finder,
  121.                                           void *data);

  122. extern char *cp_class_name_from_physname (const char *physname);

  123. extern char *method_name_from_physname (const char *physname);

  124. extern unsigned int cp_find_first_component (const char *name);

  125. extern unsigned int cp_entire_prefix_len (const char *name);

  126. extern char *cp_func_name (const char *full_name);

  127. extern char *cp_remove_params (const char *demangled_name);

  128. extern struct symbol **make_symbol_overload_list (const char *,
  129.                                                   const char *);

  130. extern struct symbol **make_symbol_overload_list_adl (struct type **arg_types,
  131.                                                       int nargs,
  132.                                                       const char *func_name);

  133. extern struct type *cp_lookup_rtti_type (const char *name,
  134.                                          struct block *block);

  135. /* Functions/variables from cp-namespace.c.  */

  136. extern int cp_is_in_anonymous (const char *symbol_name);

  137. extern void cp_add_using_directive (const char *dest,
  138.                                     const char *src,
  139.                                     const char *alias,
  140.                                     const char *declaration,
  141.                                     VEC (const_char_ptr) *excludes,
  142.                                     int copy_names,
  143.                                     struct obstack *obstack);

  144. extern void cp_scan_for_anonymous_namespaces (const struct symbol *symbol,
  145.                                               struct objfile *objfile);

  146. extern struct symbol *cp_lookup_symbol_nonlocal
  147.      (const struct language_defn *langdef,
  148.       const char *name,
  149.       const struct block *block,
  150.       const domain_enum domain);

  151. extern struct symbol *cp_lookup_symbol_namespace (const char *namespace,
  152.                                                   const char *name,
  153.                                                   const struct block *block,
  154.                                                   const domain_enum domain);

  155. extern struct symbol *cp_lookup_symbol_imports_or_template
  156.      (const char *scope,
  157.       const char *name,
  158.       const struct block *block,
  159.       const domain_enum domain);

  160. extern struct symbol *cp_lookup_nested_symbol (struct type *parent_type,
  161.                                                const char *nested_name,
  162.                                                const struct block *block);

  163. struct type *cp_lookup_transparent_type (const char *name);

  164. /* See description in cp-namespace.c.  */

  165. struct type *cp_find_type_baseclass_by_name (struct type *parent_type,
  166.                                              const char *name);

  167. /* Functions from cp-name-parser.y.  */

  168. extern struct demangle_parse_info *cp_demangled_name_to_comp
  169.      (const char *demangled_name, const char **errmsg);

  170. extern char *cp_comp_to_string (struct demangle_component *result,
  171.                                 int estimated_len);

  172. extern void cp_demangled_name_parse_free (struct demangle_parse_info *);
  173. extern struct cleanup *make_cleanup_cp_demangled_name_parse_free
  174.      (struct demangle_parse_info *);
  175. extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *,
  176.                                            struct demangle_component *,
  177.                                            struct demangle_parse_info *);

  178. extern struct demangle_parse_info *cp_new_demangle_parse_info (void);

  179. /* The list of "maint cplus" commands.  */

  180. extern struct cmd_list_element *maint_cplus_cmd_list;

  181. /* A wrapper for bfd_demangle.  */

  182. char *gdb_demangle (const char *name, int options);

  183. #endif /* CP_SUPPORT_H */