go-lang.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* Go language support definitions for GDB, the GNU debugger.
  2. Copyright (C) 2012-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 (GO_LANG_H)
  15. #define GO_LANG_H 1
  16. struct type_print_options;
  17. #include "gdbtypes.h"
  18. #include "symtab.h"
  19. #include "value.h"
  20. struct parser_state;
  21. struct builtin_go_type
  22. {
  23. struct type *builtin_void;
  24. struct type *builtin_char;
  25. struct type *builtin_bool;
  26. struct type *builtin_int;
  27. struct type *builtin_uint;
  28. struct type *builtin_uintptr;
  29. struct type *builtin_int8;
  30. struct type *builtin_int16;
  31. struct type *builtin_int32;
  32. struct type *builtin_int64;
  33. struct type *builtin_uint8;
  34. struct type *builtin_uint16;
  35. struct type *builtin_uint32;
  36. struct type *builtin_uint64;
  37. struct type *builtin_float32;
  38. struct type *builtin_float64;
  39. struct type *builtin_complex64;
  40. struct type *builtin_complex128;
  41. };
  42. enum go_type
  43. {
  44. GO_TYPE_NONE, /* Not a Go object. */
  45. GO_TYPE_STRING
  46. };
  47. /* Defined in go-lang.c. */
  48. extern const char *go_main_name (void);
  49. extern enum go_type go_classify_struct_type (struct type *type);
  50. extern char *go_symbol_package_name (const struct symbol *sym);
  51. extern char *go_block_package_name (const struct block *block);
  52. extern const struct builtin_go_type *builtin_go_type (struct gdbarch *);
  53. /* Class representing the Go language. */
  54. class go_language : public language_defn
  55. {
  56. public:
  57. go_language ()
  58. : language_defn (language_go)
  59. { /* Nothing. */ }
  60. /* See language.h. */
  61. const char *name () const override
  62. { return "go"; }
  63. /* See language.h. */
  64. const char *natural_name () const override
  65. { return "Go"; }
  66. /* See language.h. */
  67. void language_arch_info (struct gdbarch *gdbarch,
  68. struct language_arch_info *lai) const override;
  69. /* See language.h. */
  70. bool sniff_from_mangled_name
  71. (const char *mangled, gdb::unique_xmalloc_ptr<char> *demangled)
  72. const override
  73. {
  74. *demangled = demangle_symbol (mangled, 0);
  75. return *demangled != NULL;
  76. }
  77. /* See language.h. */
  78. gdb::unique_xmalloc_ptr<char> demangle_symbol (const char *mangled,
  79. int options) const override;
  80. /* See language.h. */
  81. void print_type (struct type *type, const char *varstring,
  82. struct ui_file *stream, int show, int level,
  83. const struct type_print_options *flags) const override;
  84. /* See language.h. */
  85. void value_print_inner
  86. (struct value *val, struct ui_file *stream, int recurse,
  87. const struct value_print_options *options) const override;
  88. /* See language.h. */
  89. int parser (struct parser_state *ps) const override;
  90. /* See language.h. */
  91. bool is_string_type_p (struct type *type) const override
  92. {
  93. type = check_typedef (type);
  94. return (type->code () == TYPE_CODE_STRUCT
  95. && go_classify_struct_type (type) == GO_TYPE_STRING);
  96. }
  97. /* See language.h. */
  98. bool store_sym_names_in_linkage_form_p () const override
  99. { return true; }
  100. };
  101. #endif /* !defined (GO_LANG_H) */