gdb/go-lang.c - gdb

Global variables defined

Data types defined

Functions defined

Source code

  1. /* Go language support routines for GDB, the GNU debugger.

  2.    Copyright (C) 2012-2015 Free Software Foundation, Inc.

  3.    This file is part of GDB.

  4.    This program is free software; you can redistribute it and/or modify
  5.    it under the terms of the GNU General Public License as published by
  6.    the Free Software Foundation; either version 3 of the License, or
  7.    (at your option) any later version.

  8.    This program is distributed in the hope that it will be useful,
  9.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  10.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  11.    GNU General Public License for more details.

  12.    You should have received a copy of the GNU General Public License
  13.    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */

  14. /* TODO:
  15.    - split stacks
  16.    - printing of native types
  17.    - goroutines
  18.    - lots more
  19.    - gccgo mangling needs redoing
  20.      It's too hard, for example, to know whether one is looking at a mangled
  21.      Go symbol or not, and their are ambiguities, e.g., the demangler may
  22.      get passed *any* symbol, including symbols from other languages
  23.      and including symbols that are already demangled.
  24.      One thought is to at least add an _G prefix.
  25.    - 6g mangling isn't supported yet
  26. */

  27. #include "defs.h"
  28. #include "gdb_obstack.h"
  29. #include "block.h"
  30. #include "symtab.h"
  31. #include "language.h"
  32. #include "varobj.h"
  33. #include "go-lang.h"
  34. #include "c-lang.h"
  35. #include "parser-defs.h"

  36. #include <ctype.h>

  37. /* The main function in the main package.  */
  38. static const char GO_MAIN_MAIN[] = "main.main";

  39. /* Function returning the special symbol name used by Go for the main
  40.    procedure in the main program if it is found in minimal symbol list.
  41.    This function tries to find minimal symbols so that it finds them even
  42.    if the program was compiled without debugging information.  */

  43. const char *
  44. go_main_name (void)
  45. {
  46.   struct bound_minimal_symbol msym;

  47.   msym = lookup_minimal_symbol (GO_MAIN_MAIN, NULL, NULL);
  48.   if (msym.minsym != NULL)
  49.     return GO_MAIN_MAIN;

  50.   /* No known entry procedure found, the main program is probably not Go.  */
  51.   return NULL;
  52. }

  53. /* Return non-zero if TYPE is a gccgo string.
  54.    We assume CHECK_TYPEDEF has already been done.  */

  55. static int
  56. gccgo_string_p (struct type *type)
  57. {
  58.   /* gccgo strings don't necessarily have a name we can use.  */

  59.   if (TYPE_NFIELDS (type) == 2)
  60.     {
  61.       struct type *type0 = TYPE_FIELD_TYPE (type, 0);
  62.       struct type *type1 = TYPE_FIELD_TYPE (type, 1);

  63.       CHECK_TYPEDEF (type0);
  64.       CHECK_TYPEDEF (type1);

  65.       if (TYPE_CODE (type0) == TYPE_CODE_PTR
  66.           && strcmp (TYPE_FIELD_NAME (type, 0), "__data") == 0
  67.           && TYPE_CODE (type1) == TYPE_CODE_INT
  68.           && strcmp (TYPE_FIELD_NAME (type, 1), "__length") == 0)
  69.         {
  70.           struct type *target_type = TYPE_TARGET_TYPE (type0);

  71.           CHECK_TYPEDEF (target_type);

  72.           if (TYPE_CODE (target_type) == TYPE_CODE_INT
  73.               && TYPE_LENGTH (target_type) == 1
  74.               && strcmp (TYPE_NAME (target_type), "uint8") == 0)
  75.             return 1;
  76.         }
  77.     }

  78.   return 0;
  79. }

  80. /* Return non-zero if TYPE is a 6g string.
  81.    We assume CHECK_TYPEDEF has already been done.  */

  82. static int
  83. sixg_string_p (struct type *type)
  84. {
  85.   if (TYPE_NFIELDS (type) == 2
  86.       && TYPE_TAG_NAME (type) != NULL
  87.       && strcmp (TYPE_TAG_NAME (type), "string") == 0)
  88.     return 1;

  89.   return 0;
  90. }

  91. /* Classify the kind of Go object that TYPE is.
  92.    TYPE is a TYPE_CODE_STRUCT, used to represent a Go object.  */

  93. enum go_type
  94. go_classify_struct_type (struct type *type)
  95. {
  96.   CHECK_TYPEDEF (type);

  97.   /* Recognize strings as they're useful to be able to print without
  98.      pretty-printers.  */
  99.   if (gccgo_string_p (type)
  100.       || sixg_string_p (type))
  101.     return GO_TYPE_STRING;

  102.   return GO_TYPE_NONE;
  103. }

  104. /* Subroutine of unpack_mangled_go_symbol to simplify it.
  105.    Given "[foo.]bar.baz", store "bar" in *PACKAGEP and "baz" in *OBJECTP.
  106.    We stomp on the last '.' to nul-terminate "bar".
  107.    The caller is responsible for memory management.  */

  108. static void
  109. unpack_package_and_object (char *buf,
  110.                            const char **packagep, const char **objectp)
  111. {
  112.   char *last_dot;

  113.   last_dot = strrchr (buf, '.');
  114.   gdb_assert (last_dot != NULL);
  115.   *objectp = last_dot + 1;
  116.   *last_dot = '\0';
  117.   last_dot = strrchr (buf, '.');
  118.   if (last_dot != NULL)
  119.     *packagep = last_dot + 1;
  120.   else
  121.     *packagep = buf;
  122. }

  123. /* Given a mangled Go symbol, find its package name, object name, and
  124.    method type (if present).
  125.    E.g., for "libgo_net.textproto.String.N33_libgo_net.textproto.ProtocolError"
  126.    *PACKAGEP = "textproto"
  127.    *OBJECTP = "String"
  128.    *METHOD_TYPE_PACKAGEP = "textproto"
  129.    *METHOD_TYPE_OBJECTP = "ProtocolError"

  130.    Space for the resulting strings is malloc'd in one buffer.
  131.    PACKAGEP,OBJECTP,METHOD_TYPE* will (typically) point into this buffer.
  132.    [There are a few exceptions, but the caller is still responsible for
  133.    freeing the resulting pointer.]
  134.    A pointer to this buffer is returned, or NULL if symbol isn't a
  135.    mangled Go symbol.
  136.    The caller is responsible for freeing the result.

  137.    *METHOD_TYPE_IS_POINTERP is set to a boolean indicating if
  138.    the method type is a pointer.

  139.    There may be value in returning the outer container,
  140.    i.e., "net" in the above example, but for now it's not needed.
  141.    Plus it's currently not straightforward to compute,
  142.    it comes from -fgo-prefix, and there's no algorithm to compute it.

  143.    If we ever need to unpack the method type, this routine should work
  144.    for that too.  */

  145. static char *
  146. unpack_mangled_go_symbol (const char *mangled_name,
  147.                           const char **packagep,
  148.                           const char **objectp,
  149.                           const char **method_type_packagep,
  150.                           const char **method_type_objectp,
  151.                           int *method_type_is_pointerp)
  152. {
  153.   char *buf;
  154.   char *p;
  155.   int len = strlen (mangled_name);
  156.   /* Pointer to last digit in "N<digit(s)>_".  */
  157.   char *saw_digit;
  158.   /* Pointer to "N" if valid "N<digit(s)>_" found.  */
  159.   char *method_type;
  160.   /* Pointer to the first '.'.  */
  161.   char *first_dot;
  162.   /* Pointer to the last '.'.  */
  163.   char *last_dot;
  164.   /* Non-zero if we saw a pointer indicator.  */
  165.   int saw_pointer;

  166.   *packagep = *objectp = NULL;
  167.   *method_type_packagep = *method_type_objectp = NULL;
  168.   *method_type_is_pointerp = 0;

  169.   /* main.init is mangled specially.  */
  170.   if (strcmp (mangled_name, "__go_init_main") == 0)
  171.     {
  172.       char *package = xstrdup ("main");

  173.       *packagep = package;
  174.       *objectp = "init";
  175.       return package;
  176.     }

  177.   /* main.main is mangled specially (missing prefix).  */
  178.   if (strcmp (mangled_name, "main.main") == 0)
  179.     {
  180.       char *package = xstrdup ("main");

  181.       *packagep = package;
  182.       *objectp = "main";
  183.       return package;
  184.     }

  185.   /* We may get passed, e.g., "main.T.Foo", which is *not* mangled.
  186.      Alas it looks exactly like "prefix.package.object."
  187.      To cope for now we only recognize the following prefixes:

  188.      go: the default
  189.      libgo_.*: used by gccgo's runtime

  190.      Thus we don't support -fgo-prefix (except as used by the runtime).  */
  191.   if (strncmp (mangled_name, "go.", 3) != 0
  192.       && strncmp (mangled_name, "libgo_", 6) != 0)
  193.     return NULL;

  194.   /* Quick check for whether a search may be fruitful.  */
  195.   /* Ignore anything with @plt, etc. in it.  */
  196.   if (strchr (mangled_name, '@') != NULL)
  197.     return NULL;
  198.   /* It must have at least two dots.  */
  199.   first_dot = strchr (mangled_name, '.');
  200.   if (first_dot == NULL)
  201.     return NULL;
  202.   /* Treat "foo.bar" as unmangled.  It can collide with lots of other
  203.      languages and it's not clear what the consequences are.
  204.      And except for main.main, all gccgo symbols are at least
  205.      prefix.package.object.  */
  206.   last_dot = strrchr (mangled_name, '.');
  207.   if (last_dot == first_dot)
  208.     return NULL;

  209.   /* More quick checks.  */
  210.   if (last_dot[1] == '\0' /* foo. */
  211.       || last_dot[-1] == '.') /* foo..bar */
  212.     return NULL;

  213.   /* At this point we've decided we have a mangled Go symbol.  */

  214.   buf = xstrdup (mangled_name);

  215.   /* Search backwards looking for "N<digit(s)>".  */
  216.   p = buf + len;
  217.   saw_digit = method_type = NULL;
  218.   saw_pointer = 0;
  219.   while (p > buf)
  220.     {
  221.       int current = *(const unsigned char *) --p;
  222.       int current_is_digit = isdigit (current);

  223.       if (saw_digit)
  224.         {
  225.           if (current_is_digit)
  226.             continue;
  227.           if (current == 'N'
  228.               && ((p > buf && p[-1] == '.')
  229.                   || (p > buf + 1 && p[-1] == 'p' && p[-2] == '.')))
  230.             {
  231.               if (atoi (p + 1) == strlen (saw_digit + 2))
  232.                 {
  233.                   if (p[-1] == '.')
  234.                     method_type = p - 1;
  235.                   else
  236.                     {
  237.                       gdb_assert (p[-1] == 'p');
  238.                       saw_pointer = 1;
  239.                       method_type = p - 2;
  240.                     }
  241.                   break;
  242.                 }
  243.             }
  244.           /* Not what we're looking for, reset and keep looking.  */
  245.           saw_digit = NULL;
  246.           saw_pointer = 0;
  247.           continue;
  248.         }
  249.       if (current_is_digit && p[1] == '_')
  250.         {
  251.           /* Possible start of method "this" [sic] type.  */
  252.           saw_digit = p;
  253.           continue;
  254.         }
  255.     }

  256.   if (method_type != NULL
  257.       /* Ensure not something like "..foo".  */
  258.       && (method_type > buf && method_type[-1] != '.'))
  259.     {
  260.       unpack_package_and_object (saw_digit + 2,
  261.                                  method_type_packagep, method_type_objectp);
  262.       *method_type = '\0';
  263.       *method_type_is_pointerp = saw_pointer;
  264.     }

  265.   unpack_package_and_object (buf, packagep, objectp);
  266.   return buf;
  267. }

  268. /* Implements the la_demangle language_defn routine for language Go.

  269.    N.B. This may get passed *any* symbol, including symbols from other
  270.    languages and including symbols that are already demangled.
  271.    Both of these situations are kinda unfortunate, but that's how things
  272.    are today.

  273.    N.B. This currently only supports gccgo's mangling.

  274.    N.B. gccgo's mangling needs, I think, changing.
  275.    This demangler can't work in all situations,
  276.    thus not too much effort is currently put into it.  */

  277. char *
  278. go_demangle (const char *mangled_name, int options)
  279. {
  280.   struct obstack tempbuf;
  281.   char *result;
  282.   char *name_buf;
  283.   const char *package_name;
  284.   const char *object_name;
  285.   const char *method_type_package_name;
  286.   const char *method_type_object_name;
  287.   int method_type_is_pointer;

  288.   if (mangled_name == NULL)
  289.     return NULL;

  290.   name_buf = unpack_mangled_go_symbol (mangled_name,
  291.                                        &package_name, &object_name,
  292.                                        &method_type_package_name,
  293.                                        &method_type_object_name,
  294.                                        &method_type_is_pointer);
  295.   if (name_buf == NULL)
  296.     return NULL;

  297.   obstack_init (&tempbuf);

  298.   /* Print methods as they appear in "method expressions".  */
  299.   if (method_type_package_name != NULL)
  300.     {
  301.       /* FIXME: Seems like we should include package_name here somewhere.  */
  302.       if (method_type_is_pointer)
  303.           obstack_grow_str (&tempbuf, "(*");
  304.       obstack_grow_str (&tempbuf, method_type_package_name);
  305.       obstack_grow_str (&tempbuf, ".");
  306.       obstack_grow_str (&tempbuf, method_type_object_name);
  307.       if (method_type_is_pointer)
  308.         obstack_grow_str (&tempbuf, ")");
  309.       obstack_grow_str (&tempbuf, ".");
  310.       obstack_grow_str (&tempbuf, object_name);
  311.     }
  312.   else
  313.     {
  314.       obstack_grow_str (&tempbuf, package_name);
  315.       obstack_grow_str (&tempbuf, ".");
  316.       obstack_grow_str (&tempbuf, object_name);
  317.     }
  318.   obstack_grow_str0 (&tempbuf, "");

  319.   result = xstrdup (obstack_finish (&tempbuf));
  320.   obstack_free (&tempbuf, NULL);
  321.   xfree (name_buf);
  322.   return result;
  323. }

  324. /* Given a Go symbol, return its package or NULL if unknown.
  325.    Space for the result is malloc'd, caller must free.  */

  326. char *
  327. go_symbol_package_name (const struct symbol *sym)
  328. {
  329.   const char *mangled_name = SYMBOL_LINKAGE_NAME (sym);
  330.   const char *package_name;
  331.   const char *object_name;
  332.   const char *method_type_package_name;
  333.   const char *method_type_object_name;
  334.   int method_type_is_pointer;
  335.   char *name_buf;
  336.   char *result;

  337.   gdb_assert (SYMBOL_LANGUAGE (sym) == language_go);
  338.   name_buf = unpack_mangled_go_symbol (mangled_name,
  339.                                        &package_name, &object_name,
  340.                                        &method_type_package_name,
  341.                                        &method_type_object_name,
  342.                                        &method_type_is_pointer);
  343.   /* Some Go symbols don't have mangled form we interpret (yet).  */
  344.   if (name_buf == NULL)
  345.     return NULL;
  346.   result = xstrdup (package_name);
  347.   xfree (name_buf);
  348.   return result;
  349. }

  350. /* Return the package that BLOCK is in, or NULL if there isn't one.
  351.    Space for the result is malloc'd, caller must free.  */

  352. char *
  353. go_block_package_name (const struct block *block)
  354. {
  355.   while (block != NULL)
  356.     {
  357.       struct symbol *function = BLOCK_FUNCTION (block);

  358.       if (function != NULL)
  359.         {
  360.           char *package_name = go_symbol_package_name (function);

  361.           if (package_name != NULL)
  362.             return package_name;

  363.           /* Stop looking if we find a function without a package name.
  364.              We're most likely outside of Go and thus the concept of the
  365.              "current" package is gone.  */
  366.           return NULL;
  367.         }

  368.       block = BLOCK_SUPERBLOCK (block);
  369.     }

  370.   return NULL;
  371. }

  372. /* Table mapping opcodes into strings for printing operators
  373.    and precedences of the operators.
  374.    TODO(dje): &^ ?  */

  375. static const struct op_print go_op_print_tab[] =
  376. {
  377.   {",", BINOP_COMMA, PREC_COMMA, 0},
  378.   {"=", BINOP_ASSIGN, PREC_ASSIGN, 1},
  379.   {"||", BINOP_LOGICAL_OR, PREC_LOGICAL_OR, 0},
  380.   {"&&", BINOP_LOGICAL_AND, PREC_LOGICAL_AND, 0},
  381.   {"|", BINOP_BITWISE_IOR, PREC_BITWISE_IOR, 0},
  382.   {"^", BINOP_BITWISE_XOR, PREC_BITWISE_XOR, 0},
  383.   {"&", BINOP_BITWISE_AND, PREC_BITWISE_AND, 0},
  384.   {"==", BINOP_EQUAL, PREC_EQUAL, 0},
  385.   {"!=", BINOP_NOTEQUAL, PREC_EQUAL, 0},
  386.   {"<=", BINOP_LEQ, PREC_ORDER, 0},
  387.   {">=", BINOP_GEQ, PREC_ORDER, 0},
  388.   {">", BINOP_GTR, PREC_ORDER, 0},
  389.   {"<", BINOP_LESS, PREC_ORDER, 0},
  390.   {">>", BINOP_RSH, PREC_SHIFT, 0},
  391.   {"<<", BINOP_LSH, PREC_SHIFT, 0},
  392.   {"+", BINOP_ADD, PREC_ADD, 0},
  393.   {"-", BINOP_SUB, PREC_ADD, 0},
  394.   {"*", BINOP_MUL, PREC_MUL, 0},
  395.   {"/", BINOP_DIV, PREC_MUL, 0},
  396.   {"%", BINOP_REM, PREC_MUL, 0},
  397.   {"@", BINOP_REPEAT, PREC_REPEAT, 0},
  398.   {"-", UNOP_NEG, PREC_PREFIX, 0},
  399.   {"!", UNOP_LOGICAL_NOT, PREC_PREFIX, 0},
  400.   {"^", UNOP_COMPLEMENT, PREC_PREFIX, 0},
  401.   {"*", UNOP_IND, PREC_PREFIX, 0},
  402.   {"&", UNOP_ADDR, PREC_PREFIX, 0},
  403.   {"unsafe.Sizeof ", UNOP_SIZEOF, PREC_PREFIX, 0},
  404.   {"++", UNOP_POSTINCREMENT, PREC_SUFFIX, 0},
  405.   {"--", UNOP_POSTDECREMENT, PREC_SUFFIX, 0},
  406.   {NULL, 0, 0, 0}
  407. };

  408. enum go_primitive_types {
  409.   go_primitive_type_void,
  410.   go_primitive_type_char,
  411.   go_primitive_type_bool,
  412.   go_primitive_type_int,
  413.   go_primitive_type_uint,
  414.   go_primitive_type_uintptr,
  415.   go_primitive_type_int8,
  416.   go_primitive_type_int16,
  417.   go_primitive_type_int32,
  418.   go_primitive_type_int64,
  419.   go_primitive_type_uint8,
  420.   go_primitive_type_uint16,
  421.   go_primitive_type_uint32,
  422.   go_primitive_type_uint64,
  423.   go_primitive_type_float32,
  424.   go_primitive_type_float64,
  425.   go_primitive_type_complex64,
  426.   go_primitive_type_complex128,
  427.   nr_go_primitive_types
  428. };

  429. static void
  430. go_language_arch_info (struct gdbarch *gdbarch,
  431.                        struct language_arch_info *lai)
  432. {
  433.   const struct builtin_go_type *builtin = builtin_go_type (gdbarch);

  434.   lai->string_char_type = builtin->builtin_char;

  435.   lai->primitive_type_vector
  436.     = GDBARCH_OBSTACK_CALLOC (gdbarch, nr_go_primitive_types + 1,
  437.                               struct type *);

  438.   lai->primitive_type_vector [go_primitive_type_void]
  439.     = builtin->builtin_void;
  440.   lai->primitive_type_vector [go_primitive_type_char]
  441.     = builtin->builtin_char;
  442.   lai->primitive_type_vector [go_primitive_type_bool]
  443.     = builtin->builtin_bool;
  444.   lai->primitive_type_vector [go_primitive_type_int]
  445.     = builtin->builtin_int;
  446.   lai->primitive_type_vector [go_primitive_type_uint]
  447.     = builtin->builtin_uint;
  448.   lai->primitive_type_vector [go_primitive_type_uintptr]
  449.     = builtin->builtin_uintptr;
  450.   lai->primitive_type_vector [go_primitive_type_int8]
  451.     = builtin->builtin_int8;
  452.   lai->primitive_type_vector [go_primitive_type_int16]
  453.     = builtin->builtin_int16;
  454.   lai->primitive_type_vector [go_primitive_type_int32]
  455.     = builtin->builtin_int32;
  456.   lai->primitive_type_vector [go_primitive_type_int64]
  457.     = builtin->builtin_int64;
  458.   lai->primitive_type_vector [go_primitive_type_uint8]
  459.     = builtin->builtin_uint8;
  460.   lai->primitive_type_vector [go_primitive_type_uint16]
  461.     = builtin->builtin_uint16;
  462.   lai->primitive_type_vector [go_primitive_type_uint32]
  463.     = builtin->builtin_uint32;
  464.   lai->primitive_type_vector [go_primitive_type_uint64]
  465.     = builtin->builtin_uint64;
  466.   lai->primitive_type_vector [go_primitive_type_float32]
  467.     = builtin->builtin_float32;
  468.   lai->primitive_type_vector [go_primitive_type_float64]
  469.     = builtin->builtin_float64;
  470.   lai->primitive_type_vector [go_primitive_type_complex64]
  471.     = builtin->builtin_complex64;
  472.   lai->primitive_type_vector [go_primitive_type_complex128]
  473.     = builtin->builtin_complex128;

  474.   lai->bool_type_symbol = "bool";
  475.   lai->bool_type_default = builtin->builtin_bool;
  476. }

  477. static const struct language_defn go_language_defn =
  478. {
  479.   "go",
  480.   "Go",
  481.   language_go,
  482.   range_check_off,
  483.   case_sensitive_on,
  484.   array_row_major,
  485.   macro_expansion_no,
  486.   &exp_descriptor_c,
  487.   go_parse,
  488.   go_error,
  489.   null_post_parser,
  490.   c_printchar,                        /* Print a character constant.  */
  491.   c_printstr,                        /* Function to print string constant.  */
  492.   c_emit_char,                        /* Print a single char.  */
  493.   go_print_type,                /* Print a type using appropriate syntax.  */
  494.   c_print_typedef,                /* Print a typedef using appropriate
  495.                                    syntax.  */
  496.   go_val_print,                        /* Print a value using appropriate syntax.  */
  497.   c_value_print,                /* Print a top-level value.  */
  498.   default_read_var_value,        /* la_read_var_value */
  499.   NULL,                                /* Language specific skip_trampoline.  */
  500.   NULL,                                /* name_of_this */
  501.   basic_lookup_symbol_nonlocal,
  502.   basic_lookup_transparent_type,
  503.   go_demangle,                        /* Language specific symbol demangler.  */
  504.   NULL,                                /* Language specific
  505.                                    class_name_from_physname.  */
  506.   go_op_print_tab,                /* Expression operators for printing.  */
  507.   1,                                /* C-style arrays.  */
  508.   0,                                /* String lower bound.  */
  509.   default_word_break_characters,
  510.   default_make_symbol_completion_list,
  511.   go_language_arch_info,
  512.   default_print_array_index,
  513.   default_pass_by_reference,
  514.   c_get_string,
  515.   NULL,
  516.   iterate_over_symbols,
  517.   &default_varobj_ops,
  518.   NULL,
  519.   NULL,
  520.   LANG_MAGIC
  521. };

  522. static void *
  523. build_go_types (struct gdbarch *gdbarch)
  524. {
  525.   struct builtin_go_type *builtin_go_type
  526.     = GDBARCH_OBSTACK_ZALLOC (gdbarch, struct builtin_go_type);

  527.   builtin_go_type->builtin_void
  528.     = arch_type (gdbarch, TYPE_CODE_VOID, 1, "void");
  529.   builtin_go_type->builtin_char
  530.     = arch_character_type (gdbarch, 8, 1, "char");
  531.   builtin_go_type->builtin_bool
  532.     = arch_boolean_type (gdbarch, 8, 0, "bool");
  533.   builtin_go_type->builtin_int
  534.     = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 0, "int");
  535.   builtin_go_type->builtin_uint
  536.     = arch_integer_type (gdbarch, gdbarch_int_bit (gdbarch), 1, "uint");
  537.   builtin_go_type->builtin_uintptr
  538.     = arch_integer_type (gdbarch, gdbarch_ptr_bit (gdbarch), 1, "uintptr");
  539.   builtin_go_type->builtin_int8
  540.     = arch_integer_type (gdbarch, 8, 0, "int8");
  541.   builtin_go_type->builtin_int16
  542.     = arch_integer_type (gdbarch, 16, 0, "int16");
  543.   builtin_go_type->builtin_int32
  544.     = arch_integer_type (gdbarch, 32, 0, "int32");
  545.   builtin_go_type->builtin_int64
  546.     = arch_integer_type (gdbarch, 64, 0, "int64");
  547.   builtin_go_type->builtin_uint8
  548.     = arch_integer_type (gdbarch, 8, 1, "uint8");
  549.   builtin_go_type->builtin_uint16
  550.     = arch_integer_type (gdbarch, 16, 1, "uint16");
  551.   builtin_go_type->builtin_uint32
  552.     = arch_integer_type (gdbarch, 32, 1, "uint32");
  553.   builtin_go_type->builtin_uint64
  554.     = arch_integer_type (gdbarch, 64, 1, "uint64");
  555.   builtin_go_type->builtin_float32
  556.     = arch_float_type (gdbarch, 32, "float32", NULL);
  557.   builtin_go_type->builtin_float64
  558.     = arch_float_type (gdbarch, 64, "float64", NULL);
  559.   builtin_go_type->builtin_complex64
  560.     = arch_complex_type (gdbarch, "complex64",
  561.                          builtin_go_type->builtin_float32);
  562.   builtin_go_type->builtin_complex128
  563.     = arch_complex_type (gdbarch, "complex128",
  564.                          builtin_go_type->builtin_float64);

  565.   return builtin_go_type;
  566. }

  567. static struct gdbarch_data *go_type_data;

  568. const struct builtin_go_type *
  569. builtin_go_type (struct gdbarch *gdbarch)
  570. {
  571.   return gdbarch_data (gdbarch, go_type_data);
  572. }

  573. extern initialize_file_ftype _initialize_go_language;

  574. void
  575. _initialize_go_language (void)
  576. {
  577.   go_type_data = gdbarch_data_register_post_init (build_go_types);

  578.   add_language (&go_language_defn);
  579. }