GDB (xrefs)

/tmp/gdb-8.1/gdb/go-lang.c
Go to the documentation of this file.
1 /* Go language support routines for GDB, the GNU debugger.
2
3 Copyright (C) 2012-2018 Free Software Foundation, Inc.
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 /* TODO:
21 - split stacks
22 - printing of native types
23 - goroutines
24 - lots more
25 - gccgo mangling needs redoing
26 It's too hard, for example, to know whether one is looking at a mangled
27 Go symbol or not, and their are ambiguities, e.g., the demangler may
28 get passed *any* symbol, including symbols from other languages
29 and including symbols that are already demangled.
30 One thought is to at least add an _G prefix.
31 - 6g mangling isn't supported yet
32 */
33
34 #include "defs.h"
35 #include "gdb_obstack.h"
36 #include "block.h"
37 #include "symtab.h"
38 #include "language.h"
39 #include "varobj.h"
40 #include "go-lang.h"
41 #include "c-lang.h"
42 #include "parser-defs.h"
43
44 #include <ctype.h>
45
46 /* The main function in the main package. */
47 static const char GO_MAIN_MAIN[] = "main.main";
48
49 /* Function returning the special symbol name used by Go for the main
50 procedure in the main program if it is found in minimal symbol list.
51 This function tries to find minimal symbols so that it finds them even
52 if the program was compiled without debugging information. */
53
54 const char *
55 go_main_name (void)
56 {
57 struct bound_minimal_symbol msym;
58
59 msym = lookup_minimal_symbol (GO_MAIN_MAIN, NULL, NULL);
60 if (msym.minsym != NULL)
61 return GO_MAIN_MAIN;
62
63 /* No known entry procedure found, the main program is probably not Go. */
64 return NULL;
65 }
66
67 /* Return non-zero if TYPE is a gccgo string.
68 We assume CHECK_TYPEDEF has already been done. */
69
70 static int
71 gccgo_string_p (struct type *type)
72 {
73 /* gccgo strings don't necessarily have a name we can use. */
74
75 if (TYPE_NFIELDS (type) == 2)
76 {
77 struct type *type0 = TYPE_FIELD_TYPE (type, 0);
78 struct type *type1 = TYPE_FIELD_TYPE (type, 1);
79
80 type0 = check_typedef (type0);
81 type1 = check_typedef (type1);
82
83 if (TYPE_CODE (type0) == TYPE_CODE_PTR
84 && strcmp (TYPE_FIELD_NAME (type, 0), "__data") == 0
85 && TYPE_CODE (type1) == TYPE_CODE_INT
86 && strcmp (TYPE_FIELD_NAME (type, 1), "__length") == 0)
87 {
88 struct type *target_type = TYPE_TARGET_TYPE (type0);
89
90 target_type = check_typedef (target_type);
91
92 if (TYPE_CODE (target_type) == TYPE_CODE_INT
93 && TYPE_LENGTH (target_type) == 1
94 && strcmp (TYPE_NAME (target_type), "uint8") == 0)
95 return 1;
96 }
97 }
98
99 return 0;
100 }
101
102 /* Return non-zero if TYPE is a 6g string.
103 We assume CHECK_TYPEDEF has already been done. */
104
105 static int
106 sixg_string_p (struct type *type)
107 {
108 if (TYPE_NFIELDS (type) == 2
109 && TYPE_TAG_NAME (type) != NULL
110 && strcmp (TYPE_TAG_NAME (type), "string") == 0)
111 return 1;
112
113 return 0;
114 }
115
116 /* Classify the kind of Go object that TYPE is.
117 TYPE is a TYPE_CODE_STRUCT, used to represent a Go object. */
118
119 enum go_type
120 go_classify_struct_type (struct type *type)
121 {
122 type = check_typedef (type);
123
124 /* Recognize strings as they're useful to be able to print without
125 pretty-printers. */
126 if (gccgo_string_p (type)
127 || sixg_string_p (type))
128 return GO_TYPE_STRING;
129
130 return GO_TYPE_NONE;
131 }
132
133 /* Subroutine of unpack_mangled_go_symbol to simplify it.
134 Given "[foo.]bar.baz", store "bar" in *PACKAGEP and "baz" in *OBJECTP.
135 We stomp on the last '.' to nul-terminate "bar".
136 The caller is responsible for memory management. */
137
138 static void
139 unpack_package_and_object (char *buf,
140 const char **packagep, const char **objectp)
141 {
142 char *last_dot;
143
144 last_dot = strrchr (buf, '.');
145 gdb_assert (last_dot != NULL);
146 *objectp = last_dot + 1;
147 *last_dot = '\0';
148 last_dot = strrchr (buf, '.');
149 if (last_dot != NULL)
150 *packagep = last_dot + 1;
151 else
152 *packagep = buf;
153 }
154
155 /* Given a mangled Go symbol, find its package name, object name, and
156 method type (if present).
157 E.g., for "libgo_net.textproto.String.N33_libgo_net.textproto.ProtocolError"
158 *PACKAGEP = "textproto"
159 *OBJECTP = "String"
160 *METHOD_TYPE_PACKAGEP = "textproto"
161 *METHOD_TYPE_OBJECTP = "ProtocolError"
162
163 Space for the resulting strings is malloc'd in one buffer.
164 PACKAGEP,OBJECTP,METHOD_TYPE* will (typically) point into this buffer.
165 [There are a few exceptions, but the caller is still responsible for
166 freeing the resulting pointer.]
167 A pointer to this buffer is returned, or NULL if symbol isn't a
168 mangled Go symbol.
169 The caller is responsible for freeing the result.
170
171 *METHOD_TYPE_IS_POINTERP is set to a boolean indicating if
172 the method type is a pointer.
173
174 There may be value in returning the outer container,
175 i.e., "net" in the above example, but for now it's not needed.
176 Plus it's currently not straightforward to compute,
177 it comes from -fgo-prefix, and there's no algorithm to compute it.
178
179 If we ever need to unpack the method type, this routine should work
180 for that too. */
181
182 static char *
183 unpack_mangled_go_symbol (const char *mangled_name,
184 const char **packagep,
185 const char **objectp,
186 const char **method_type_packagep,
187 const char **method_type_objectp,
188 int *method_type_is_pointerp)
189 {
190 char *buf;
191 char *p;
192 int len = strlen (mangled_name);
193 /* Pointer to last digit in "N<digit(s)>_". */
194 char *saw_digit;
195 /* Pointer to "N" if valid "N<digit(s)>_" found. */
196 char *method_type;
197 /* Pointer to the first '.'. */
198 const char *first_dot;
199 /* Pointer to the last '.'. */
200 const char *last_dot;
201 /* Non-zero if we saw a pointer indicator. */
202 int saw_pointer;
203
204 *packagep = *objectp = NULL;
205 *method_type_packagep = *method_type_objectp = NULL;
206 *method_type_is_pointerp = 0;
207
208 /* main.init is mangled specially. */
209 if (strcmp (mangled_name, "__go_init_main") == 0)
210 {
211 char *package = xstrdup ("main");
212
213 *packagep = package;
214 *objectp = "init";
215 return package;
216 }
217
218 /* main.main is mangled specially (missing prefix). */
219 if (strcmp (mangled_name, "main.main") == 0)
220 {
221 char *package = xstrdup ("main");
222
223 *packagep = package;
224 *objectp = "main";
225 return package;
226 }
227
228 /* We may get passed, e.g., "main.T.Foo", which is *not* mangled.
229 Alas it looks exactly like "prefix.package.object."
230 To cope for now we only recognize the following prefixes:
231
232 go: the default
233 libgo_.*: used by gccgo's runtime
234
235 Thus we don't support -fgo-prefix (except as used by the runtime). */
236 if (!startswith (mangled_name, "go.")
237 && !startswith (mangled_name, "libgo_"))
238 return NULL;
239
240 /* Quick check for whether a search may be fruitful. */
241 /* Ignore anything with @plt, etc. in it. */
242 if (strchr (mangled_name, '@') != NULL)
243 return NULL;
244 /* It must have at least two dots. */
245 first_dot = strchr (mangled_name, '.');
246 if (first_dot == NULL)
247 return NULL;
248 /* Treat "foo.bar" as unmangled. It can collide with lots of other
249 languages and it's not clear what the consequences are.
250 And except for main.main, all gccgo symbols are at least
251 prefix.package.object. */
252 last_dot = strrchr (mangled_name, '.');
253 if (last_dot == first_dot)
254 return NULL;
255
256 /* More quick checks. */
257 if (last_dot[1] == '\0' /* foo. */
258 || last_dot[-1] == '.') /* foo..bar */
259 return NULL;
260
261 /* At this point we've decided we have a mangled Go symbol. */
262
263 buf = xstrdup (mangled_name);
264
265 /* Search backwards looking for "N<digit(s)>". */
266 p = buf + len;
267 saw_digit = method_type = NULL;
268 saw_pointer = 0;
269 while (p > buf)
270 {
271 int current = *(const unsigned char *) --p;
272 int current_is_digit = isdigit (current);
273
274 if (saw_digit)
275 {
276 if (current_is_digit)
277 continue;
278 if (current == 'N'
279 && ((p > buf && p[-1] == '.')
280 || (p > buf + 1 && p[-1] == 'p' && p[-2] == '.')))
281 {
282 if (atoi (p + 1) == strlen (saw_digit + 2))
283 {
284 if (p[-1] == '.')
285 method_type = p - 1;
286 else
287 {
288 gdb_assert (p[-1] == 'p');
289 saw_pointer = 1;
290 method_type = p - 2;
291 }
292 break;
293 }
294 }
295 /* Not what we're looking for, reset and keep looking. */
296 saw_digit = NULL;
297 saw_pointer = 0;
298 continue;
299 }
300 if (current_is_digit && p[1] == '_')
301 {
302 /* Possible start of method "this" [sic] type. */
303 saw_digit = p;
304 continue;
305 }
306 }
307
308 if (method_type != NULL
309 /* Ensure not something like "..foo". */
310 && (method_type > buf && method_type[-1] != '.'))
311 {
312 unpack_package_and_object (saw_digit + 2,
313 method_type_packagep, method_type_objectp);
314 *method_type = '\0';
315 *method_type_is_pointerp = saw_pointer;
316 }
317
318 unpack_package_and_object (buf, packagep, objectp);
319 return buf;
320 }
321
322 /* Implements the la_demangle language_defn routine for language Go.
323
324 N.B. This may get passed *any* symbol, including symbols from other
325 languages and including symbols that are already demangled.
326 Both of these situations are kinda unfortunate, but that's how things
327 are today.
328
329 N.B. This currently only supports gccgo's mangling.
330
331 N.B. gccgo's mangling needs, I think, changing.
332 This demangler can't work in all situations,
333 thus not too much effort is currently put into it. */
334
335 char *
336 go_demangle (const char *mangled_name, int options)
337 {
338 struct obstack tempbuf;
339 char *result;
340 char *name_buf;
341 const char *package_name;
342 const char *object_name;
343 const char *method_type_package_name;
344 const char *method_type_object_name;
345 int method_type_is_pointer;
346
347 if (mangled_name == NULL)
348 return NULL;
349
350 name_buf = unpack_mangled_go_symbol (mangled_name,
351 &package_name, &object_name,
352 &method_type_package_name,
353 &method_type_object_name,
354 &method_type_is_pointer);
355 if (name_buf == NULL)
356 return NULL;
357
358 obstack_init (&tempbuf);
359
360 /* Print methods as they appear in "method expressions". */
361 if (method_type_package_name != NULL)
362 {
363 /* FIXME: Seems like we should include package_name here somewhere. */
364 if (method_type_is_pointer)
365 obstack_grow_str (&tempbuf, "(*");
366 obstack_grow_str (&tempbuf, method_type_package_name);
367 obstack_grow_str (&tempbuf, ".");
368 obstack_grow_str (&tempbuf, method_type_object_name);
369 if (method_type_is_pointer)
370 obstack_grow_str (&tempbuf, ")");
371 obstack_grow_str (&tempbuf, ".");
372 obstack_grow_str (&tempbuf, object_name);
373 }
374 else
375 {
376 obstack_grow_str (&tempbuf, package_name);
377 obstack_grow_str (&tempbuf, ".");
378 obstack_grow_str (&tempbuf, object_name);
379 }
380 obstack_grow_str0 (&tempbuf, "");
381
382 result = xstrdup ((const char *) obstack_finish (&tempbuf));
383 obstack_free (&tempbuf, NULL);
384 xfree (name_buf);
385 return result;
386 }
387
388 /* la_sniff_from_mangled_name for Go. */
389
390 static int
391 go_sniff_from_mangled_name (const char *mangled, char **demangled)
392 {
393 *demangled = go_demangle (mangled, 0);
394 return *demangled != NULL;
395 }
396
397 /* Given a Go symbol, return its package or NULL if unknown.
398 Space for the result is malloc'd, caller must free. */
399
400 char *
401 go_symbol_package_name (const struct symbol *sym)
402 {
403 const char *mangled_name = SYMBOL_LINKAGE_NAME (sym);
404 const char *package_name;
405 const char *object_name;
406 const char *method_type_package_name;
407 const char *method_type_object_name;
408 int method_type_is_pointer;
409 char *name_buf;
410 char *result;
411
412 gdb_assert (SYMBOL_LANGUAGE (sym) == language_go);
413 name_buf = unpack_mangled_go_symbol (mangled_name,
414 &package_name, &object_name,
415 &method_type_package_name,
416 &method_type_object_name,
417 &method_type_is_pointer);
418 /* Some Go symbols don't have mangled form we interpret (yet). */
419 if (name_buf == NULL)
420 return NULL;
421 result = xstrdup (package_name);
422 xfree (name_buf);
423 return result;
424 }
425
426 /* Return the package that BLOCK is in, or NULL if there isn't one.
427 Space for the result is malloc'd, caller must free. */
428
429 char *
430 go_block_package_name (const struct block *block)
431 {
432 while (block != NULL)
433 {
434 struct symbol *function = BLOCK_FUNCTION (block);
435
436 if (function != NULL)
437 {
438 char *package_name = go_symbol_package_name (function);
439
440 if (package_name != NULL)
441 return package_name;
442
443 /* Stop looking if we find a function without a package name.
444 We're most likely outside of Go and thus the concept of the
445 "current" package is gone. */
446 return NULL;
447 }
448
449 block = BLOCK_SUPERBLOCK (block);
450 }
451
452 return NULL;
453 }
454
455 /* Table mapping opcodes into strings for printing operators
456 and precedences of the operators.
457 TODO(dje): &^ ? */
458
459 static const struct op_print go_op_print_tab[] =
460 {
461 {",", BINOP_COMMA, PREC_COMMA, 0},
462 {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
463 {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
464 {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
465 {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
466 {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
467 {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
468 {"==", BINOP_EQUAL, PREC_EQUAL, 0},
469 {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
470 {"<=", BINOP_LEQ, PREC_ORDER, 0},
471 {">=", BINOP_GEQ, PREC_ORDER, 0},
472 {">", BINOP_GTR, PREC_ORDER, 0},
473 {"<", BINOP_LESS, PREC_ORDER, 0},
474 {">>", BINOP_RSH, PREC_SHIFT, 0},
475 {"<<", BINOP_LSH, PREC_SHIFT, 0},
476 {"+", BINOP_ADD, PREC_ADD, 0},
477 {"-", BINOP_SUB, PREC_ADD, 0},
478 {"*", BINOP_MUL, PREC_MUL, 0},
479 {"/", BINOP_DIV, PREC_MUL, 0},
480 {"%", BINOP_REM, PREC_MUL, 0},
481 {"@", BINOP_REPEAT, PREC_REPEAT, 0},
482 {"-", UNOP_NEG, PREC_PREFIX, 0},
483 {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
484 {"^", UNOP_COMPLEMENT, PREC_PREFIX, 0},
485 {"*", UNOP_IND, PREC_PREFIX, 0},
486 {"&", UNOP_ADDR, PREC_PREFIX, 0},
487 {"unsafe.Sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
488 {"++", UNOP_POSTINCREMENT, PREC_SUFFIX, 0},
489 {"--", UNOP_POSTDECREMENT, PREC_SUFFIX, 0},
490 {NULL, OP_NULL, PREC_SUFFIX, 0}
491 };
492
493 enum go_primitive_types {
494 go_primitive_type_void,
495 go_primitive_type_char,
496 go_primitive_type_bool,
497 go_primitive_type_int,
498 go_primitive_type_uint,
499 go_primitive_type_uintptr,
500 go_primitive_type_int8,
501 go_primitive_type_int16,
502 go_primitive_type_int32,
503 go_primitive_type_int64,
504 go_primitive_type_uint8,
505 go_primitive_type_uint16,
506 go_primitive_type_uint32,
507 go_primitive_type_uint64,
508 go_primitive_type_float32,
509 go_primitive_type_float64,
510 go_primitive_type_complex64,
511 go_primitive_type_complex128,
512 nr_go_primitive_types
513 };
514
515 static void
516 go_language_arch_info (struct gdbarch *gdbarch,
517 struct language_arch_info *lai)
518 {
519 const struct builtin_go_type *builtin = builtin_go_type (gdbarch);
520
521 lai->string_char_type = builtin->builtin_char;
522
523 lai->primitive_type_vector
524 = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_go_primitive_types + 1,
525 struct type *);
526
527 lai->primitive_type_vector [go_primitive_type_void]
528 = builtin->builtin_void;
529 lai->primitive_type_vector [go_primitive_type_char]
530 = builtin->builtin_char;
531 lai->primitive_type_vector [go_primitive_type_bool]
532 = builtin->builtin_bool;
533 lai->primitive_type_vector [go_primitive_type_int]
534 = builtin->builtin_int;
535 lai->primitive_type_vector [go_primitive_type_uint]
536 = builtin->builtin_uint;
537 lai->primitive_type_vector [go_primitive_type_uintptr]
538 = builtin->builtin_uintptr;
539 lai->primitive_type_vector [go_primitive_type_int8]
540 = builtin->builtin_int8;
541 lai->primitive_type_vector [go_primitive_type_int16]
542 = builtin->builtin_int16;
543 lai->primitive_type_vector [go_primitive_type_int32]
544 = builtin->builtin_int32;
545 lai->primitive_type_vector [go_primitive_type_int64]
546 = builtin->builtin_int64;
547 lai->primitive_type_vector [go_primitive_type_uint8]
548 = builtin->builtin_uint8;
549 lai->primitive_type_vector [go_primitive_type_uint16]
550 = builtin->builtin_uint16;
551 lai->primitive_type_vector [go_primitive_type_uint32]
552 = builtin->builtin_uint32;
553 lai->primitive_type_vector [go_primitive_type_uint64]
554 = builtin->builtin_uint64;
555 lai->primitive_type_vector [go_primitive_type_float32]
556 = builtin->builtin_float32;
557 lai->primitive_type_vector [go_primitive_type_float64]
558 = builtin->builtin_float64;
559 lai->primitive_type_vector [go_primitive_type_complex64]
560 = builtin->builtin_complex64;
561 lai->primitive_type_vector [go_primitive_type_complex128]
562 = builtin->builtin_complex128;
563
564 lai->bool_type_symbol = "bool";
565 lai->bool_type_default = builtin->builtin_bool;
566 }
567
568 extern const struct language_defn go_language_defn =
569 {
570 "go",
571 "Go",
572 language_go,
573 range_check_off,
574 case_sensitive_on,
575 array_row_major,
576 macro_expansion_no,
577 NULL,
578 &exp_descriptor_c,
579 go_parse,
580 go_yyerror,
581 null_post_parser,
582 c_printchar, /* Print a character constant. */
583 c_printstr, /* Function to print string constant. */
584 c_emit_char, /* Print a single char. */
585 go_print_type, /* Print a type using appropriate syntax. */
586 c_print_typedef, /* Print a typedef using appropriate
587 syntax. */
588 go_val_print, /* Print a value using appropriate syntax. */
589 c_value_print, /* Print a top-level value. */
590 default_read_var_value, /* la_read_var_value */
591 NULL, /* Language specific skip_trampoline. */
592 NULL, /* name_of_this */
593 basic_lookup_symbol_nonlocal,
594 basic_lookup_transparent_type,
595 go_demangle, /* Language specific symbol demangler. */
596 go_sniff_from_mangled_name,
597 NULL, /* Language specific
598 class_name_from_physname. */
599 go_op_print_tab, /* Expression operators for printing. */
600 1, /* C-style arrays. */
601 0, /* String lower bound. */
602 default_word_break_characters,
603 default_collect_symbol_completion_matches,
604 go_language_arch_info,
605 default_print_array_index,
606 default_pass_by_reference,
607 c_get_string,
608 c_watch_location_expression,
609 NULL, /* la_get_symbol_name_matcher */
610 iterate_over_symbols,
611 default_search_name_hash,
612 &default_varobj_ops,
613 NULL,
614 NULL,
615 LANG_MAGIC
616 };
617
618 static void *
619 build_go_types (struct gdbarch *gdbarch)
620 {
621 struct builtin_go_type *builtin_go_type
622 = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_go_type);
623
624 builtin_go_type->builtin_void
625 = arch_type (gdbarch, TYPE_CODE_VOID, TARGET_CHAR_BIT, "void");
626 builtin_go_type->builtin_char
627 = arch_character_type (gdbarch, 8, 1, "char");
628 builtin_go_type->builtin_bool
629 = arch_boolean_type (gdbarch, 8, 0, "bool");
630 builtin_go_type->builtin_int
631 = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "int");
632 builtin_go_type->builtin_uint
633 = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "uint");
634 builtin_go_type->builtin_uintptr
635 = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr");
636 builtin_go_type->builtin_int8
637 = arch_integer_type (gdbarch, 8, 0, "int8");
638 builtin_go_type->builtin_int16
639 = arch_integer_type (gdbarch, 16, 0, "int16");
640 builtin_go_type->builtin_int32
641 = arch_integer_type (gdbarch, 32, 0, "int32");
642 builtin_go_type->builtin_int64
643 = arch_integer_type (gdbarch, 64, 0, "int64");
644 builtin_go_type->builtin_uint8
645 = arch_integer_type (gdbarch, 8, 1, "uint8");
646 builtin_go_type->builtin_uint16
647 = arch_integer_type (gdbarch, 16, 1, "uint16");
648 builtin_go_type->builtin_uint32
649 = arch_integer_type (gdbarch, 32, 1, "uint32");
650 builtin_go_type->builtin_uint64
651 = arch_integer_type (gdbarch, 64, 1, "uint64");
652 builtin_go_type->builtin_float32
653 = arch_float_type (gdbarch, 32, "float32", floatformats_ieee_single);
654 builtin_go_type->builtin_float64
655 = arch_float_type (gdbarch, 64, "float64", floatformats_ieee_double);
656 builtin_go_type->builtin_complex64
657 = arch_complex_type (gdbarch, "complex64",
658 builtin_go_type->builtin_float32);
659 builtin_go_type->builtin_complex128
660 = arch_complex_type (gdbarch, "complex128",
661 builtin_go_type->builtin_float64);
662
663 return builtin_go_type;
664 }
665
666 static struct gdbarch_data *go_type_data;
667
668 const struct builtin_go_type *
669 builtin_go_type (struct gdbarch *gdbarch)
670 {
671 return (const struct builtin_go_type *) gdbarch_data (gdbarch, go_type_data);
672 }
673
674 void
675 _initialize_go_language (void)
676 {
677 go_type_data = gdbarch_data_register_post_init (build_go_types);
678 }
gdbarch
Definition: gdbarch.c:127
builtin_go_type::builtin_uint16
struct type * builtin_uint16
Definition: go-lang.h:44
PREC_ADD
Definition: parser-defs.h:298
go_print_type
void go_print_type(struct type *type, const char *varstring, struct ui_file *stream, int show, int level, const struct type_print_options *flags)
Definition: go-typeprint.c:45
go_block_package_name
char * go_block_package_name(const struct block *block)
Definition: go-lang.c:430
go_primitive_type_void
Definition: go-lang.c:494
go_primitive_type_uint
Definition: go-lang.c:498
arch_type
struct type * arch_type(struct gdbarch *gdbarch, enum type_code code, int bit, const char *name)
Definition: gdbtypes.c:4941
gdb_obstack.h
range_check_off
Definition: language.h:61
PREC_PREFIX
Definition: parser-defs.h:299
PREC_EQUAL
Definition: parser-defs.h:298
go_language_arch_info
static void go_language_arch_info(struct gdbarch *gdbarch, struct language_arch_info *lai)
Definition: go-lang.c:516
TYPE_FIELD_NAME
#define TYPE_FIELD_NAME(thistype, n)
Definition: gdbtypes.h:1372
go_primitive_type_uint64
Definition: go-lang.c:507
default_search_name_hash
unsigned int default_search_name_hash(const char *string0)
Definition: dictionary.c:769
nr_go_primitive_types
Definition: go-lang.c:512
builtin_go_type::builtin_uint32
struct type * builtin_uint32
Definition: go-lang.h:45
go_main_name
const char * go_main_name(void)
Definition: go-lang.c:55
xfree
void xfree(void *)
floatformats_ieee_double
const struct floatformat * floatformats_ieee_double[BFD_ENDIAN_UNKNOWN]
Definition: gdbtypes.c:76
builtin_go_type
Definition: go-lang.h:31
GDBARCH_OBSTACK_CALLOC
#define GDBARCH_OBSTACK_CALLOC(GDBARCH, NR, TYPE)
Definition: gdbarch.h:1708
builtin_go_type::builtin_int16
struct type * builtin_int16
Definition: go-lang.h:40
gdbarch_int_bit
int gdbarch_int_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1579
default_word_break_characters
const char * default_word_break_characters(void)
Definition: language.c:679
builtin_go_type::builtin_complex128
struct type * builtin_complex128
Definition: go-lang.h:50
TYPE_NAME
#define TYPE_NAME(thistype)
Definition: gdbtypes.h:1224
PREC_ORDER
Definition: parser-defs.h:298
gdbarch_ptr_bit
int gdbarch_ptr_bit(struct gdbarch *gdbarch)
Definition: gdbarch.c:1831
go_primitive_type_int16
Definition: go-lang.c:501
gdbarch_data
void * gdbarch_data(struct gdbarch *gdbarch, struct gdbarch_data *data)
Definition: gdbarch.c:5169
arch_character_type
struct type * arch_character_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
Definition: gdbtypes.c:4979
TYPE_CODE_INT
Definition: gdbtypes.h:111
builtin_go_type::builtin_int
struct type * builtin_int
Definition: go-lang.h:36
PREC_BITWISE_XOR
Definition: parser-defs.h:297
go_primitive_type_int32
Definition: go-lang.c:502
varobj.h
default_read_var_value
struct value * default_read_var_value(struct symbol *var, const struct block *var_block, struct frame_info *frame)
Definition: findvar.c:587
builtin_go_type::builtin_int8
struct type * builtin_int8
Definition: go-lang.h:39
unpack_package_and_object
static void unpack_package_and_object(char *buf, const char **packagep, const char **objectp)
Definition: go-lang.c:139
gccgo_string_p
static int gccgo_string_p(struct type *type)
Definition: go-lang.c:71
language_arch_info::string_char_type
struct type * string_char_type
Definition: language.h:122
defs.h
go_primitive_type_uint16
Definition: go-lang.c:505
go_symbol_package_name
char * go_symbol_package_name(const struct symbol *sym)
Definition: go-lang.c:401
arch_boolean_type
struct type * arch_boolean_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
Definition: gdbtypes.c:4996
TYPE_FIELD_TYPE
#define TYPE_FIELD_TYPE(thistype, n)
Definition: gdbtypes.h:1371
arch_complex_type
struct type * arch_complex_type(struct gdbarch *gdbarch, const char *name, struct type *target_type)
Definition: gdbtypes.c:5044
c_get_string
void c_get_string(struct value *value, gdb_byte **buffer, int *length, struct type **char_type, const char **charset)
Definition: c-lang.c:236
case_sensitive_on
Definition: language.h:92
op_print
Definition: parser-defs.h:305
GDBARCH_OBSTACK_ZALLOC
#define GDBARCH_OBSTACK_ZALLOC(GDBARCH, TYPE)
Definition: gdbarch.h:1709
go_primitive_type_int64
Definition: go-lang.c:503
arch_integer_type
struct type * arch_integer_type(struct gdbarch *gdbarch, int bit, int unsigned_p, const char *name)
Definition: gdbtypes.c:4962
PREC_LOGICAL_OR
Definition: parser-defs.h:296
language_defn
Definition: language.h:132
builtin_go_type::builtin_int32
struct type * builtin_int32
Definition: go-lang.h:41
BLOCK_FUNCTION
#define BLOCK_FUNCTION(bl)
Definition: block.h:107
go_primitive_type_complex128
Definition: go-lang.c:511
parser-defs.h
TYPE_CODE_VOID
Definition: gdbtypes.h:124
symtab.h
array_row_major
Definition: language.h:81
builtin_go_type::builtin_char
struct type * builtin_char
Definition: go-lang.h:34
go_yyerror
void go_yyerror(const char *)
check_typedef
struct type * check_typedef(struct type *type)
Definition: gdbtypes.c:2421
exp_descriptor_c
const struct exp_descriptor exp_descriptor_c
Definition: c-lang.c:817
basic_lookup_symbol_nonlocal
struct block_symbol basic_lookup_symbol_nonlocal(const struct language_defn *langdef, const char *name, const struct block *block, const domain_enum domain)
Definition: symtab.c:2417
language_arch_info::bool_type_default
struct type * bool_type_default
Definition: language.h:127
go_language_defn
const struct language_defn go_language_defn
builtin_go_type::builtin_uint8
struct type * builtin_uint8
Definition: go-lang.h:43
builtin_go_type::builtin_int64
struct type * builtin_int64
Definition: go-lang.h:42
PREC_MUL
Definition: parser-defs.h:298
go_primitive_type_int8
Definition: go-lang.c:500
c_emit_char
void c_emit_char(int c, struct type *type, struct ui_file *stream, int quoter)
Definition: c-lang.c:143
tempbuf
static struct obstack tempbuf
Definition: c-exp.c:4578
arch_float_type
struct type * arch_float_type(struct gdbarch *gdbarch, int bit, const char *name, const struct floatformat **floatformats)
Definition: gdbtypes.c:5014
bound_minimal_symbol
Definition: minsyms.h:29
builtin_go_type::builtin_uintptr
struct type * builtin_uintptr
Definition: go-lang.h:38
language_arch_info::bool_type_symbol
const char * bool_type_symbol
Definition: language.h:125
default_pass_by_reference
int default_pass_by_reference(struct type *type)
Definition: language.c:669
builtin_go_type
const struct builtin_go_type * builtin_go_type(struct gdbarch *gdbarch)
Definition: go-lang.c:669
basic_lookup_transparent_type
struct type * basic_lookup_transparent_type(const char *name)
Definition: symtab.c:2792
TARGET_CHAR_BIT
#define TARGET_CHAR_BIT
Definition: host-defs.h:29
type
Definition: gdbtypes.h:749
language.h
go_primitive_type_uint8
Definition: go-lang.c:504
sixg_string_p
static int sixg_string_p(struct type *type)
Definition: go-lang.c:106
BLOCK_SUPERBLOCK
#define BLOCK_SUPERBLOCK(bl)
Definition: block.h:108
_initialize_go_language
void _initialize_go_language(void)
Definition: go-lang.c:675
null_post_parser
void null_post_parser(expression_up *exp, int void_context_p)
Definition: parse.c:1319
SYMBOL_LINKAGE_NAME
#define SYMBOL_LINKAGE_NAME(symbol)
Definition: symtab.h:523
startswith
static int startswith(const char *string, const char *pattern)
Definition: common-utils.h:107
go_parse
int go_parse(struct parser_state *par_state)
Definition: go-exp.c:3182
builtin_go_type::builtin_void
struct type * builtin_void
Definition: go-lang.h:33
default_print_array_index
void default_print_array_index(struct value *index_value, struct ui_file *stream, const struct value_print_options *options)
Definition: language.c:687
go_classify_struct_type
enum go_type go_classify_struct_type(struct type *type)
Definition: go-lang.c:120
c_print_typedef
void c_print_typedef(struct type *, struct symbol *, struct ui_file *)
Definition: c-typeprint.c:180
builtin_go_type::builtin_uint64
struct type * builtin_uint64
Definition: go-lang.h:46
builtin_go_type::builtin_float64
struct type * builtin_float64
Definition: go-lang.h:48
builtin_go_type::builtin_complex64
struct type * builtin_complex64
Definition: go-lang.h:49
gdb_assert
#define gdb_assert(expr)
Definition: gdb_assert.h:32
block
Definition: block.h:60
c_printstr
void c_printstr(struct ui_file *stream, struct type *type, const gdb_byte *string, unsigned int length, const char *user_encoding, int force_ellipses, const struct value_print_options *options)
Definition: c-lang.c:186
floatformats_ieee_single
const struct floatformat * floatformats_ieee_single[BFD_ENDIAN_UNKNOWN]
Definition: gdbtypes.c:72
default_collect_symbol_completion_matches
void default_collect_symbol_completion_matches(completion_tracker &tracker, complete_symbol_mode mode, symbol_name_match_type name_match_type, const char *text, const char *word, enum type_code code)
Definition: symtab.c:5190
TYPE_CODE_PTR
Definition: gdbtypes.h:84
unpack_mangled_go_symbol
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)
Definition: go-lang.c:183
c_watch_location_expression
gdb::unique_xmalloc_ptr< char > c_watch_location_expression(struct type *type, CORE_ADDR addr)
Definition: c-lang.c:712
go_primitive_type_complex64
Definition: go-lang.c:510
go_type
go_type
Definition: go-lang.h:53
TYPE_TARGET_TYPE
#define TYPE_TARGET_TYPE(thistype)
Definition: gdbtypes.h:1226
macro_expansion_no
Definition: language.h:103
TYPE_CODE
#define TYPE_CODE(thistype)
Definition: gdbtypes.h:1238
default_varobj_ops
#define default_varobj_ops
Definition: varobj.h:236
c-lang.h
go_sniff_from_mangled_name
static int go_sniff_from_mangled_name(const char *mangled, char **demangled)
Definition: go-lang.c:391
PREC_BITWISE_IOR
Definition: parser-defs.h:297
go-lang.h
language_go
Definition: defs.h:211
PREC_BITWISE_AND
Definition: parser-defs.h:297
TYPE_NFIELDS
#define TYPE_NFIELDS(thistype)
Definition: gdbtypes.h:1239
SYMBOL_LANGUAGE
#define SYMBOL_LANGUAGE(symbol)
Definition: symtab.h:469
obstack_grow_str
#define obstack_grow_str(OBSTACK, STRING)
Definition: gdb_obstack.h:46
go_val_print
void go_val_print(struct type *type, int embedded_offset, CORE_ADDR address, struct ui_file *stream, int recurse, struct value *val, const struct value_print_options *options)
Definition: go-valprint.c:89
TYPE_TAG_NAME
#define TYPE_TAG_NAME(type)
Definition: gdbtypes.h:1225
GO_MAIN_MAIN
static const char GO_MAIN_MAIN[]
Definition: go-lang.c:47
go_primitive_types
go_primitive_types
Definition: go-lang.c:493
PREC_ASSIGN
Definition: parser-defs.h:296
GO_TYPE_NONE
Definition: go-lang.h:55
obstack_grow_str0
#define obstack_grow_str0(OBSTACK, STRING)
Definition: gdb_obstack.h:48
c_printchar
void c_printchar(int c, struct type *type, struct ui_file *stream)
Definition: c-lang.c:153
PREC_SUFFIX
Definition: parser-defs.h:299
language_arch_info
Definition: language.h:109
symbol
Definition: symtab.h:1049
go_primitive_type_float64
Definition: go-lang.c:509
builtin_go_type::builtin_bool
struct type * builtin_bool
Definition: go-lang.h:35
PREC_REPEAT
Definition: parser-defs.h:298
TYPE_LENGTH
#define TYPE_LENGTH(thistype)
Definition: gdbtypes.h:1235
iterate_over_symbols
void iterate_over_symbols(const struct block *block, const lookup_name_info &name, const domain_enum domain, gdb::function_view< symbol_found_callback_ftype > callback)
Definition: symtab.c:2849
PREC_SHIFT
Definition: parser-defs.h:298
go_primitive_type_uintptr
Definition: go-lang.c:499
go_primitive_type_int
Definition: go-lang.c:497
go_primitive_type_bool
Definition: go-lang.c:496
LANG_MAGIC
#define LANG_MAGIC
Definition: language.h:438
go_primitive_type_uint32
Definition: go-lang.c:506
PREC_COMMA
Definition: parser-defs.h:296
gdbarch_data
Definition: gdbarch.c:5084
language_arch_info::primitive_type_vector
struct type ** primitive_type_vector
Definition: language.h:115
lookup_minimal_symbol
struct bound_minimal_symbol lookup_minimal_symbol(const char *name, const char *sfile, struct objfile *objf)
Definition: minsyms.c:311
builtin_go_type::builtin_float32
struct type * builtin_float32
Definition: go-lang.h:47
c_value_print
void c_value_print(struct value *, struct ui_file *, const struct value_print_options *)
Definition: c-valprint.c:571
build_go_types
static void * build_go_types(struct gdbarch *gdbarch)
Definition: go-lang.c:619
builtin_go_type::builtin_uint
struct type * builtin_uint
Definition: go-lang.h:37
go_op_print_tab
static const struct op_print go_op_print_tab[]
Definition: go-lang.c:459
gdbarch_data_register_post_init
struct gdbarch_data * gdbarch_data_register_post_init(gdbarch_data_post_init_ftype *post_init)
Definition: gdbarch.c:5136
go_primitive_type_float32
Definition: go-lang.c:508
PREC_LOGICAL_AND
Definition: parser-defs.h:297
block.h
GO_TYPE_STRING
Definition: go-lang.h:56
go_primitive_type_char
Definition: go-lang.c:495
go_demangle
char * go_demangle(const char *mangled_name, int options)
Definition: go-lang.c:336
go_type_data
static struct gdbarch_data * go_type_data
Definition: go-lang.c:666