1 1.1 christos /* Go language support definitions for GDB, the GNU debugger. 2 1.1 christos 3 1.11 christos Copyright (C) 2012-2024 Free Software Foundation, Inc. 4 1.1 christos 5 1.1 christos This file is part of GDB. 6 1.1 christos 7 1.1 christos This program is free software; you can redistribute it and/or modify 8 1.1 christos it under the terms of the GNU General Public License as published by 9 1.1 christos the Free Software Foundation; either version 3 of the License, or 10 1.1 christos (at your option) any later version. 11 1.1 christos 12 1.1 christos This program is distributed in the hope that it will be useful, 13 1.1 christos but WITHOUT ANY WARRANTY; without even the implied warranty of 14 1.1 christos MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 1.1 christos GNU General Public License for more details. 16 1.1 christos 17 1.1 christos You should have received a copy of the GNU General Public License 18 1.1 christos along with this program. If not, see <http://www.gnu.org/licenses/>. */ 19 1.1 christos 20 1.1 christos #if !defined (GO_LANG_H) 21 1.1 christos #define GO_LANG_H 1 22 1.1 christos 23 1.1 christos struct type_print_options; 24 1.1 christos 25 1.11 christos #include "language.h" 26 1.1 christos #include "gdbtypes.h" 27 1.1 christos #include "symtab.h" 28 1.1 christos #include "value.h" 29 1.1 christos 30 1.3 christos struct parser_state; 31 1.3 christos 32 1.1 christos struct builtin_go_type 33 1.1 christos { 34 1.10 christos struct type *builtin_void = nullptr; 35 1.10 christos struct type *builtin_char = nullptr; 36 1.10 christos struct type *builtin_bool = nullptr; 37 1.10 christos struct type *builtin_int = nullptr; 38 1.10 christos struct type *builtin_uint = nullptr; 39 1.10 christos struct type *builtin_uintptr = nullptr; 40 1.10 christos struct type *builtin_int8 = nullptr; 41 1.10 christos struct type *builtin_int16 = nullptr; 42 1.10 christos struct type *builtin_int32 = nullptr; 43 1.10 christos struct type *builtin_int64 = nullptr; 44 1.10 christos struct type *builtin_uint8 = nullptr; 45 1.10 christos struct type *builtin_uint16 = nullptr; 46 1.10 christos struct type *builtin_uint32 = nullptr; 47 1.10 christos struct type *builtin_uint64 = nullptr; 48 1.10 christos struct type *builtin_float32 = nullptr; 49 1.10 christos struct type *builtin_float64 = nullptr; 50 1.10 christos struct type *builtin_complex64 = nullptr; 51 1.10 christos struct type *builtin_complex128 = nullptr; 52 1.1 christos }; 53 1.1 christos 54 1.1 christos enum go_type 55 1.1 christos { 56 1.1 christos GO_TYPE_NONE, /* Not a Go object. */ 57 1.1 christos GO_TYPE_STRING 58 1.1 christos }; 59 1.1 christos 60 1.1 christos /* Defined in go-lang.c. */ 61 1.1 christos 62 1.1 christos extern const char *go_main_name (void); 63 1.1 christos 64 1.1 christos extern enum go_type go_classify_struct_type (struct type *type); 65 1.1 christos 66 1.11 christos /* Given a symbol, return its package or nullptr if unknown. */ 67 1.11 christos extern gdb::unique_xmalloc_ptr<char> go_symbol_package_name 68 1.11 christos (const struct symbol *sym); 69 1.11 christos 70 1.11 christos /* Return the package that BLOCK is in, or nullptr if there isn't 71 1.11 christos one. */ 72 1.11 christos extern gdb::unique_xmalloc_ptr<char> go_block_package_name 73 1.11 christos (const struct block *block); 74 1.1 christos 75 1.1 christos extern const struct builtin_go_type *builtin_go_type (struct gdbarch *); 76 1.1 christos 77 1.10 christos /* Class representing the Go language. */ 78 1.10 christos 79 1.10 christos class go_language : public language_defn 80 1.10 christos { 81 1.10 christos public: 82 1.10 christos go_language () 83 1.10 christos : language_defn (language_go) 84 1.10 christos { /* Nothing. */ } 85 1.10 christos 86 1.10 christos /* See language.h. */ 87 1.10 christos 88 1.10 christos const char *name () const override 89 1.10 christos { return "go"; } 90 1.10 christos 91 1.10 christos /* See language.h. */ 92 1.10 christos 93 1.10 christos const char *natural_name () const override 94 1.10 christos { return "Go"; } 95 1.10 christos 96 1.10 christos /* See language.h. */ 97 1.10 christos 98 1.10 christos void language_arch_info (struct gdbarch *gdbarch, 99 1.10 christos struct language_arch_info *lai) const override; 100 1.10 christos 101 1.10 christos /* See language.h. */ 102 1.1 christos 103 1.10 christos bool sniff_from_mangled_name 104 1.10 christos (const char *mangled, gdb::unique_xmalloc_ptr<char> *demangled) 105 1.10 christos const override 106 1.10 christos { 107 1.10 christos *demangled = demangle_symbol (mangled, 0); 108 1.10 christos return *demangled != NULL; 109 1.10 christos } 110 1.1 christos 111 1.10 christos /* See language.h. */ 112 1.1 christos 113 1.10 christos gdb::unique_xmalloc_ptr<char> demangle_symbol (const char *mangled, 114 1.10 christos int options) const override; 115 1.10 christos 116 1.10 christos /* See language.h. */ 117 1.10 christos 118 1.10 christos void print_type (struct type *type, const char *varstring, 119 1.10 christos struct ui_file *stream, int show, int level, 120 1.10 christos const struct type_print_options *flags) const override; 121 1.10 christos 122 1.10 christos /* See language.h. */ 123 1.10 christos 124 1.10 christos void value_print_inner 125 1.10 christos (struct value *val, struct ui_file *stream, int recurse, 126 1.10 christos const struct value_print_options *options) const override; 127 1.10 christos 128 1.10 christos /* See language.h. */ 129 1.10 christos 130 1.10 christos int parser (struct parser_state *ps) const override; 131 1.10 christos 132 1.10 christos /* See language.h. */ 133 1.10 christos 134 1.10 christos bool is_string_type_p (struct type *type) const override 135 1.10 christos { 136 1.10 christos type = check_typedef (type); 137 1.10 christos return (type->code () == TYPE_CODE_STRUCT 138 1.10 christos && go_classify_struct_type (type) == GO_TYPE_STRING); 139 1.10 christos } 140 1.10 christos 141 1.10 christos /* See language.h. */ 142 1.10 christos 143 1.10 christos bool store_sym_names_in_linkage_form_p () const override 144 1.10 christos { return true; } 145 1.10 christos }; 146 1.1 christos 147 1.1 christos #endif /* !defined (GO_LANG_H) */ 148