cp-support.h 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200
  1. /* Helper routines for C++ support in GDB.
  2. Copyright (C) 2002-2022 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 "gdbsupport/gdb_vecs.h"
  21. #include "gdbsupport/gdb_obstack.h"
  22. #include "gdbsupport/array-view.h"
  23. #include <vector>
  24. /* Opaque declarations. */
  25. struct symbol;
  26. struct block;
  27. struct buildsym_compunit;
  28. struct objfile;
  29. struct type;
  30. struct demangle_component;
  31. struct using_direct;
  32. /* A string representing the name of the anonymous namespace used in GDB. */
  33. #define CP_ANONYMOUS_NAMESPACE_STR "(anonymous namespace)"
  34. /* The length of the string representing the anonymous namespace. */
  35. #define CP_ANONYMOUS_NAMESPACE_LEN 21
  36. /* A string representing the start of an operator name. */
  37. #define CP_OPERATOR_STR "operator"
  38. /* The length of CP_OPERATOR_STR. */
  39. #define CP_OPERATOR_LEN 8
  40. /* The result of parsing a name. */
  41. struct demangle_parse_info
  42. {
  43. demangle_parse_info ();
  44. ~demangle_parse_info ();
  45. /* The memory used during the parse. */
  46. struct demangle_info *info;
  47. /* The result of the parse. */
  48. struct demangle_component *tree;
  49. /* Any temporary memory used during typedef replacement. */
  50. struct obstack obstack;
  51. };
  52. /* Functions from cp-support.c. */
  53. extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string
  54. (const char *string);
  55. extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_no_typedefs
  56. (const char *string);
  57. typedef const char *(canonicalization_ftype) (struct type *, void *);
  58. extern gdb::unique_xmalloc_ptr<char> cp_canonicalize_string_full
  59. (const char *string, canonicalization_ftype *finder, void *data);
  60. extern char *cp_class_name_from_physname (const char *physname);
  61. extern char *method_name_from_physname (const char *physname);
  62. extern unsigned int cp_find_first_component (const char *name);
  63. extern unsigned int cp_entire_prefix_len (const char *name);
  64. extern gdb::unique_xmalloc_ptr<char> cp_func_name (const char *full_name);
  65. extern gdb::unique_xmalloc_ptr<char> cp_remove_params
  66. (const char *demanged_name);
  67. /* DEMANGLED_NAME is the name of a function, (optionally) including
  68. parameters and (optionally) a return type. Return the name of the
  69. function without parameters or return type, or NULL if we can not
  70. parse the name. If COMPLETION_MODE is true, then tolerate a
  71. non-existing or unbalanced parameter list. */
  72. extern gdb::unique_xmalloc_ptr<char> cp_remove_params_if_any
  73. (const char *demangled_name, bool completion_mode);
  74. extern std::vector<symbol *> make_symbol_overload_list (const char *,
  75. const char *);
  76. extern void add_symbol_overload_list_adl
  77. (gdb::array_view<type *> arg_types,
  78. const char *func_name,
  79. std::vector<symbol *> *overload_list);
  80. extern struct type *cp_lookup_rtti_type (const char *name,
  81. const struct block *block);
  82. /* Produce an unsigned hash value from SEARCH_NAME that is compatible
  83. with cp_symbol_name_matches. Only the last component in
  84. "foo::bar::function()" is considered for hashing purposes (i.e.,
  85. the entire prefix is skipped), so that later on looking up for
  86. "function" or "bar::function" in all namespaces is possible. */
  87. extern unsigned int cp_search_name_hash (const char *search_name);
  88. /* Implement the "get_symbol_name_matcher" language_defn method for C++. */
  89. extern symbol_name_matcher_ftype *cp_get_symbol_name_matcher
  90. (const lookup_name_info &lookup_name);
  91. /* Functions/variables from cp-namespace.c. */
  92. extern int cp_is_in_anonymous (const char *symbol_name);
  93. extern void cp_scan_for_anonymous_namespaces (struct buildsym_compunit *,
  94. const struct symbol *symbol,
  95. struct objfile *objfile);
  96. extern struct block_symbol cp_lookup_symbol_nonlocal
  97. (const struct language_defn *langdef,
  98. const char *name,
  99. const struct block *block,
  100. const domain_enum domain);
  101. extern struct block_symbol
  102. cp_lookup_symbol_namespace (const char *the_namespace,
  103. const char *name,
  104. const struct block *block,
  105. const domain_enum domain);
  106. extern struct block_symbol cp_lookup_symbol_imports_or_template
  107. (const char *scope,
  108. const char *name,
  109. const struct block *block,
  110. const domain_enum domain);
  111. extern struct block_symbol
  112. cp_lookup_nested_symbol (struct type *parent_type,
  113. const char *nested_name,
  114. const struct block *block,
  115. const domain_enum domain);
  116. struct type *cp_lookup_transparent_type (const char *name);
  117. /* See description in cp-namespace.c. */
  118. struct type *cp_find_type_baseclass_by_name (struct type *parent_type,
  119. const char *name);
  120. /* Functions from cp-name-parser.y. */
  121. extern std::unique_ptr<demangle_parse_info> cp_demangled_name_to_comp
  122. (const char *demangled_name, std::string *errmsg);
  123. extern gdb::unique_xmalloc_ptr<char> cp_comp_to_string
  124. (struct demangle_component *result, int estimated_len);
  125. extern void cp_merge_demangle_parse_infos (struct demangle_parse_info *,
  126. struct demangle_component *,
  127. struct demangle_parse_info *);
  128. /* The list of "maint cplus" commands. */
  129. extern struct cmd_list_element *maint_cplus_cmd_list;
  130. /* A wrapper for bfd_demangle. */
  131. gdb::unique_xmalloc_ptr<char> gdb_demangle (const char *name, int options);
  132. /* Find an instance of the character C in the string S that is outside
  133. of all parenthesis pairs, single-quoted strings, and double-quoted
  134. strings. Also, ignore the char within a template name, like a ','
  135. within foo<int, int>. */
  136. extern const char *find_toplevel_char (const char *s, char c);
  137. #endif /* CP_SUPPORT_H */