gcc-cp-plugin.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. /* GCC C++ plug-in wrapper for GDB.
  2. Copyright (C) 2018-2022 Free Software Foundation, Inc.
  3. This file is part of GDB.
  4. This program is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 3 of the License, or
  7. (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program. If not, see <http://www.gnu.org/licenses/>. */
  14. #ifndef COMPILE_GCC_CP_PLUGIN_H
  15. #define COMPILE_GCC_CP_PLUGIN_H
  16. /* A class representing the GCC C++ plug-in. */
  17. #include "gcc-cp-interface.h"
  18. class gcc_cp_plugin
  19. {
  20. public:
  21. explicit gcc_cp_plugin (struct gcc_cp_context *gcc_cp)
  22. : m_context (gcc_cp)
  23. {
  24. }
  25. /* Set the oracle callbacks to be used by the compiler plug-in. */
  26. void set_callbacks (gcc_cp_oracle_function *binding_oracle,
  27. gcc_cp_symbol_address_function *address_oracle,
  28. gcc_cp_enter_leave_user_expr_scope_function *enter_scope,
  29. gcc_cp_enter_leave_user_expr_scope_function *leave_scope,
  30. void *datum)
  31. {
  32. m_context->cp_ops->set_callbacks (m_context, binding_oracle,
  33. address_oracle, enter_scope, leave_scope,
  34. datum);
  35. }
  36. /* Returns the interface version of the compiler plug-in. */
  37. int version () const { return m_context->cp_ops->cp_version; }
  38. #define GCC_METHOD0(R, N) R N () const;
  39. #define GCC_METHOD1(R, N, A) R N (A) const;
  40. #define GCC_METHOD2(R, N, A, B) R N (A, B) const;
  41. #define GCC_METHOD3(R, N, A, B, C) R N (A, B, C) const;
  42. #define GCC_METHOD4(R, N, A, B, C, D) R N (A, B, C, D) const;
  43. #define GCC_METHOD5(R, N, A, B, C, D, E) R N (A, B, C, D, E) const;
  44. #define GCC_METHOD7(R, N, A, B, C, D, E, F, G) R N (A, B, C, D, E, F, G) const;
  45. #include "gcc-cp-fe.def"
  46. #undef GCC_METHOD0
  47. #undef GCC_METHOD1
  48. #undef GCC_METHOD2
  49. #undef GCC_METHOD3
  50. #undef GCC_METHOD4
  51. #undef GCC_METHOD5
  52. #undef GCC_METHOD7
  53. /* Special overloads of plug-in methods with added debugging information. */
  54. gcc_expr build_decl (const char *debug_decltype, const char *name,
  55. enum gcc_cp_symbol_kind sym_kind, gcc_type sym_type,
  56. const char *substitution_name, gcc_address address,
  57. const char *filename, unsigned int line_number);
  58. gcc_type start_class_type (const char *debug_name, gcc_decl typedecl,
  59. const struct gcc_vbase_array *base_classes,
  60. const char *filename, unsigned int line_number);
  61. int finish_class_type (const char *debug_name, unsigned long size_in_bytes);
  62. int pop_binding_level (const char *debug_name);
  63. private:
  64. /* The GCC C++ context. */
  65. struct gcc_cp_context *m_context;
  66. };
  67. #endif /* COMPILE_GCC_CP_PLUGIN_H */