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;
180static gdb::unique_xmalloc_ptr<char>
182 const char **packagep,
183 const char **objectp,
184 const char **method_type_packagep,
185 const char **method_type_objectp,
186 int *method_type_is_pointerp)
190 int len = strlen (mangled_name);
196 const char *first_dot;
198 const char *last_dot;
202 *packagep = *objectp = NULL;
203 *method_type_packagep = *method_type_objectp = NULL;
204 *method_type_is_pointerp = 0;
207 if (strcmp (mangled_name,
"__go_init_main") == 0)
209 gdb::unique_xmalloc_ptr<char>
package
210 = make_unique_xstrdup ("main");
212 *packagep = package.get ();
218 if (strcmp (mangled_name,
"main.main") == 0)
220 gdb::unique_xmalloc_ptr<char>
package
221 = make_unique_xstrdup ("main");
223 *packagep = package.get ();
237 if (startswith (mangled_name,
"go_0"))
241 else if (startswith (mangled_name,
"go.")
242 || startswith (mangled_name,
"libgo_"))
249 if (strchr (mangled_name,
'@') != NULL)
254 first_dot = strchr (mangled_name,
'0');
256 first_dot = strchr (mangled_name,
'.');
258 if (first_dot == NULL)
264 last_dot = strrchr (mangled_name,
'.');
265 if (last_dot == first_dot)
269 if (last_dot[1] ==
'\0'
270 || last_dot[-1] ==
'.')
275 gdb::unique_xmalloc_ptr<char> result = make_unique_xstrdup (mangled_name);
292 saw_digit = method_type = NULL;
296 int current = *(
const unsigned char *) --p;
297 int current_is_digit = isdigit (current);
301 if (current_is_digit)
304 && ((p > buf && p[-1] ==
'.')
305 || (p > buf + 1 && p[-1] ==
'p' && p[-2] ==
'.')))
307 if (atoi (p + 1) == strlen (saw_digit + 2))
313 gdb_assert (p[-1] ==
'p');
325 if (current_is_digit && p[1] ==
'_')
333 if (method_type != NULL
335 && (method_type > buf && method_type[-1] !=
'.'))
338 method_type_packagep, method_type_objectp);
340 *method_type_is_pointerp = saw_pointer;
360gdb::unique_xmalloc_ptr<char>
363 const char *package_name;
364 const char *object_name;
365 const char *method_type_package_name;
366 const char *method_type_object_name;
367 int method_type_is_pointer;
369 if (mangled_name == NULL)
372 gdb::unique_xmalloc_ptr<char> name_buf
374 &package_name, &object_name,
375 &method_type_package_name,
376 &method_type_object_name,
377 &method_type_is_pointer));
378 if (name_buf == NULL)
384 if (method_type_package_name != NULL)
387 if (method_type_is_pointer)
388 obstack_grow_str (&
tempbuf,
"(*");
389 obstack_grow_str (&
tempbuf, method_type_package_name);
390 obstack_grow_str (&
tempbuf,
".");
391 obstack_grow_str (&
tempbuf, method_type_object_name);
392 if (method_type_is_pointer)
393 obstack_grow_str (&
tempbuf,
")");
394 obstack_grow_str (&
tempbuf,
".");
395 obstack_grow_str (&
tempbuf, object_name);
399 obstack_grow_str (&
tempbuf, package_name);
400 obstack_grow_str (&
tempbuf,
".");
401 obstack_grow_str (&
tempbuf, object_name);
403 obstack_grow_str0 (&
tempbuf,
"");
405 return make_unique_xstrdup ((
const char *) obstack_finish (&
tempbuf));
410gdb::unique_xmalloc_ptr<char>
414 const char *package_name;
415 const char *object_name;
416 const char *method_type_package_name;
417 const char *method_type_object_name;
418 int method_type_is_pointer;
419 gdb::unique_xmalloc_ptr<char> name_buf;
424 &package_name, &object_name,
425 &method_type_package_name,
426 &method_type_object_name,
427 &method_type_is_pointer);
429 if (name_buf == NULL)
431 return make_unique_xstrdup (package_name);
436gdb::unique_xmalloc_ptr<char>
439 while (
block != NULL)
443 if (function != NULL)
445 gdb::unique_xmalloc_ptr<char> package_name
448 if (package_name != NULL)
472 auto add = [&] (
struct type * t) ->
struct type *
556 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 * init_character_type(type_allocator &alloc, int bit, int unsigned_p, const char *name)
struct type * init_integer_type(type_allocator &alloc, int bit, int unsigned_p, const char *name)
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
struct type * init_float_type(type_allocator &alloc, int bit, const char *name, const struct floatformat **floatformats, enum bfd_endian byte_order)
const struct builtin_type * builtin_type(struct gdbarch *gdbarch)
struct type * init_complex_type(const char *name, struct type *target_type)
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
struct type * init_boolean_type(type_allocator &alloc, 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)
gdb::unique_xmalloc_ptr< char > go_symbol_package_name(const struct symbol *sym)
static const char GO_MAIN_MAIN[]
const struct builtin_go_type * builtin_go_type(struct gdbarch *gdbarch)
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)
gdb::unique_xmalloc_ptr< char > go_block_package_name(const struct block *block)
static gdb::unique_xmalloc_ptr< 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 struct builtin_go_type * builtin_go_type(struct gdbarch *)
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
struct type * builtin_void
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
unsigned int num_fields() const
const char * name() const