35#include "gdbsupport/gdb_obstack.h"
84 if (type0->
code () == TYPE_CODE_PTR
86 && type1->
code () == TYPE_CODE_INT
111 && strcmp (
type->
name (),
"string") == 0)
141 const char **packagep,
const char **objectp)
145 last_dot = strrchr (buf,
'.');
146 gdb_assert (last_dot != NULL);
147 *objectp = last_dot + 1;
149 last_dot = strrchr (buf,
'.');
150 if (last_dot != NULL)
151 *packagep = last_dot + 1;
185 const char **packagep,
186 const char **objectp,
187 const char **method_type_packagep,
188 const char **method_type_objectp,
189 int *method_type_is_pointerp)
193 int len = strlen (mangled_name);
199 const char *first_dot;
201 const char *last_dot;
205 *packagep = *objectp = NULL;
206 *method_type_packagep = *method_type_objectp = NULL;
207 *method_type_is_pointerp = 0;
210 if (strcmp (mangled_name,
"__go_init_main") == 0)
212 char *
package = xstrdup ("main");
220 if (strcmp (mangled_name,
"main.main") == 0)
222 char *
package = xstrdup ("main");
237 if (!startswith (mangled_name,
"go.")
238 && !startswith (mangled_name,
"libgo_"))
243 if (strchr (mangled_name,
'@') != NULL)
246 first_dot = strchr (mangled_name,
'.');
247 if (first_dot == NULL)
253 last_dot = strrchr (mangled_name,
'.');
254 if (last_dot == first_dot)
258 if (last_dot[1] ==
'\0'
259 || last_dot[-1] ==
'.')
264 buf = xstrdup (mangled_name);
268 saw_digit = method_type = NULL;
272 int current = *(
const unsigned char *) --p;
273 int current_is_digit = isdigit (current);
277 if (current_is_digit)
280 && ((p > buf && p[-1] ==
'.')
281 || (p > buf + 1 && p[-1] ==
'p' && p[-2] ==
'.')))
283 if (atoi (p + 1) == strlen (saw_digit + 2))
289 gdb_assert (p[-1] ==
'p');
301 if (current_is_digit && p[1] ==
'_')
309 if (method_type != NULL
311 && (method_type > buf && method_type[-1] !=
'.'))
314 method_type_packagep, method_type_objectp);
316 *method_type_is_pointerp = saw_pointer;
336gdb::unique_xmalloc_ptr<char>
339 const char *package_name;
340 const char *object_name;
341 const char *method_type_package_name;
342 const char *method_type_object_name;
343 int method_type_is_pointer;
345 if (mangled_name == NULL)
348 gdb::unique_xmalloc_ptr<char> name_buf
350 &package_name, &object_name,
351 &method_type_package_name,
352 &method_type_object_name,
353 &method_type_is_pointer));
354 if (name_buf == NULL)
360 if (method_type_package_name != NULL)
363 if (method_type_is_pointer)
364 obstack_grow_str (&
tempbuf,
"(*");
365 obstack_grow_str (&
tempbuf, method_type_package_name);
366 obstack_grow_str (&
tempbuf,
".");
367 obstack_grow_str (&
tempbuf, method_type_object_name);
368 if (method_type_is_pointer)
369 obstack_grow_str (&
tempbuf,
")");
370 obstack_grow_str (&
tempbuf,
".");
371 obstack_grow_str (&
tempbuf, object_name);
375 obstack_grow_str (&
tempbuf, package_name);
376 obstack_grow_str (&
tempbuf,
".");
377 obstack_grow_str (&
tempbuf, object_name);
379 obstack_grow_str0 (&
tempbuf,
"");
381 return make_unique_xstrdup ((
const char *) obstack_finish (&
tempbuf));
391 const char *package_name;
392 const char *object_name;
393 const char *method_type_package_name;
394 const char *method_type_object_name;
395 int method_type_is_pointer;
401 &package_name, &object_name,
402 &method_type_package_name,
403 &method_type_object_name,
404 &method_type_is_pointer);
406 if (name_buf == NULL)
408 result = xstrdup (package_name);
419 while (
block != NULL)
423 if (function != NULL)
427 if (package_name != NULL)
451 auto add = [&] (
struct type * t) ->
struct type *
535 if (result ==
nullptr)
static struct obstack tempbuf
void language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai) const override
gdb::unique_xmalloc_ptr< char > demangle_symbol(const char *mangled, int options) const override
void set(unsigned key, void *datum)
int gdbarch_int_bit(struct gdbarch *gdbarch)
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
struct type * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, const char *name, const struct floatformat **floatformats)
struct type * arch_character_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
struct type * init_complex_type(const char *name, struct type *target_type)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
struct type * check_typedef(struct type *type)
static const registry< gdbarch >::key< struct builtin_go_type > go_type_data
static go_language go_language_defn
enum go_type go_classify_struct_type(struct type *type)
static void unpack_package_and_object(char *buf, const char **packagep, const char **objectp)
static const char GO_MAIN_MAIN[]
char * go_block_package_name(const struct block *block)
static char * unpack_mangled_go_symbol(const char *mangled_name, const char **packagep, const char **objectp, const char **method_type_packagep, const char **method_type_objectp, int *method_type_is_pointerp)
const char * go_main_name(void)
static int gccgo_string_p(struct type *type)
static struct builtin_go_type * build_go_types(struct gdbarch *gdbarch)
static int sixg_string_p(struct type *type)
char * go_symbol_package_name(const struct symbol *sym)
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
const block * superblock() const
symbol * function() const
struct minimal_symbol * minsym
struct type * builtin_uint
struct type * builtin_complex64
struct type * builtin_complex128
struct type * builtin_int64
struct type * builtin_int32
struct type * builtin_char
struct type * builtin_void
struct type * builtin_int
struct type * builtin_uint64
struct type * builtin_uintptr
struct type * builtin_float64
struct type * builtin_int16
struct type * builtin_bool
struct type * builtin_float32
struct type * builtin_uint32
struct type * builtin_uint16
struct type * builtin_int8
struct type * builtin_uint8
const char * name() const
struct type * type() const
enum language language() const
const char * linkage_name() const
void set_string_char_type(struct type *type)
void add_primitive_type(struct type *type)
void set_bool_type(struct type *type, const char *name=nullptr)
struct type * target_type() const
struct field & field(int idx) const
const char * name() const