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