c-lang.h 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. /* C language support definitions for GDB, the GNU debugger.
  2. Copyright (C) 1992-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. #if !defined (C_LANG_H)
  15. #define C_LANG_H 1
  16. struct ui_file;
  17. struct language_arch_info;
  18. struct type_print_options;
  19. struct parser_state;
  20. #include "value.h"
  21. #include "macroexp.h"
  22. #include "gdbsupport/enum-flags.h"
  23. /* The various kinds of C string and character. Note that these
  24. values are chosen so that they may be or'd together in certain
  25. ways. */
  26. enum c_string_type_values : unsigned
  27. {
  28. /* An ordinary string: "value". */
  29. C_STRING = 0,
  30. /* A wide string: L"value". */
  31. C_WIDE_STRING = 1,
  32. /* A 16-bit Unicode string: u"value". */
  33. C_STRING_16 = 2,
  34. /* A 32-bit Unicode string: U"value". */
  35. C_STRING_32 = 3,
  36. /* An ordinary char: 'v'. This can also be or'd with one of the
  37. above to form the corresponding CHAR value from a STRING
  38. value. */
  39. C_CHAR = 4,
  40. /* A wide char: L'v'. */
  41. C_WIDE_CHAR = 5,
  42. /* A 16-bit Unicode char: u'v'. */
  43. C_CHAR_16 = 6,
  44. /* A 32-bit Unicode char: U'v'. */
  45. C_CHAR_32 = 7
  46. };
  47. DEF_ENUM_FLAGS_TYPE (enum c_string_type_values, c_string_type);
  48. /* Defined in c-exp.y. */
  49. extern int c_parse (struct parser_state *);
  50. extern int c_parse_escape (const char **, struct obstack *);
  51. /* Defined in c-typeprint.c */
  52. extern void c_print_type (struct type *, const char *,
  53. struct ui_file *, int, int,
  54. const struct type_print_options *);
  55. /* Print a type but allow the precise language to be specified. */
  56. extern void c_print_type (struct type *, const char *,
  57. struct ui_file *, int, int,
  58. enum language,
  59. const struct type_print_options *);
  60. extern void c_print_typedef (struct type *,
  61. struct symbol *,
  62. struct ui_file *);
  63. /* Implement la_value_print_inner for the C family of languages. */
  64. extern void c_value_print_inner (struct value *, struct ui_file *, int,
  65. const struct value_print_options *);
  66. extern void c_value_print (struct value *, struct ui_file *,
  67. const struct value_print_options *);
  68. /* These are in c-lang.c: */
  69. extern void c_printchar (int, struct type *, struct ui_file *);
  70. extern void c_printstr (struct ui_file * stream,
  71. struct type *elttype,
  72. const gdb_byte *string,
  73. unsigned int length,
  74. const char *user_encoding,
  75. int force_ellipses,
  76. const struct value_print_options *options);
  77. extern void c_language_arch_info (struct gdbarch *gdbarch,
  78. struct language_arch_info *lai);
  79. extern void c_emit_char (int c, struct type *type,
  80. struct ui_file *stream, int quoter);
  81. /* These are in c-typeprint.c: */
  82. extern void c_type_print_base (struct type *, struct ui_file *,
  83. int, int, const struct type_print_options *);
  84. /* These are in cp-valprint.c */
  85. extern void cp_print_class_member (const gdb_byte *, struct type *,
  86. struct ui_file *, const char *);
  87. extern void cp_print_value_fields (struct value *,
  88. struct ui_file *, int,
  89. const struct value_print_options *,
  90. struct type **, int);
  91. /* gcc-2.6 or later (when using -fvtable-thunks)
  92. emits a unique named type for a vtable entry.
  93. Some gdb code depends on that specific name. */
  94. extern const char vtbl_ptr_name[];
  95. extern int cp_is_vtbl_ptr_type (struct type *);
  96. extern int cp_is_vtbl_member (struct type *);
  97. /* Return true if TYPE is a string type. Unlike DEFAULT_IS_STRING_TYPE_P
  98. this will detect arrays of characters not just TYPE_CODE_STRING. */
  99. extern bool c_is_string_type_p (struct type *type);
  100. /* These are in c-valprint.c. */
  101. extern int c_textual_element_type (struct type *, char);
  102. /* Create a new instance of the C compiler and return it. This
  103. function never returns NULL, but rather throws an exception on
  104. failure. This is suitable for use as the
  105. language_defn::get_compile_instance method. */
  106. extern std::unique_ptr<compile_instance> c_get_compile_context ();
  107. /* Create a new instance of the C++ compiler and return it. This
  108. function never returns NULL, but rather throws an exception on
  109. failure. This is suitable for use as the
  110. language_defn::get_compile_instance method. */
  111. extern std::unique_ptr<compile_instance> cplus_get_compile_context ();
  112. /* This takes the user-supplied text and returns a new bit of code to
  113. compile.
  114. This is used as the compute_program language method; see that
  115. for a description of the arguments. */
  116. extern std::string c_compute_program (compile_instance *inst,
  117. const char *input,
  118. struct gdbarch *gdbarch,
  119. const struct block *expr_block,
  120. CORE_ADDR expr_pc);
  121. /* This takes the user-supplied text and returns a new bit of code to compile.
  122. This is used as the compute_program language method; see that
  123. for a description of the arguments. */
  124. extern std::string cplus_compute_program (compile_instance *inst,
  125. const char *input,
  126. struct gdbarch *gdbarch,
  127. const struct block *expr_block,
  128. CORE_ADDR expr_pc);
  129. #endif /* !defined (C_LANG_H) */