1*ef5ccd6cSJohn Marino /* Support for printing Go types for GDB, the GNU debugger.
2*ef5ccd6cSJohn Marino
3*ef5ccd6cSJohn Marino Copyright (C) 2012-2013 Free Software Foundation, Inc.
4*ef5ccd6cSJohn Marino
5*ef5ccd6cSJohn Marino This file is part of GDB.
6*ef5ccd6cSJohn Marino
7*ef5ccd6cSJohn Marino This program is free software; you can redistribute it and/or modify
8*ef5ccd6cSJohn Marino it under the terms of the GNU General Public License as published by
9*ef5ccd6cSJohn Marino the Free Software Foundation; either version 3 of the License, or
10*ef5ccd6cSJohn Marino (at your option) any later version.
11*ef5ccd6cSJohn Marino
12*ef5ccd6cSJohn Marino This program is distributed in the hope that it will be useful,
13*ef5ccd6cSJohn Marino but WITHOUT ANY WARRANTY; without even the implied warranty of
14*ef5ccd6cSJohn Marino MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15*ef5ccd6cSJohn Marino GNU General Public License for more details.
16*ef5ccd6cSJohn Marino
17*ef5ccd6cSJohn Marino You should have received a copy of the GNU General Public License
18*ef5ccd6cSJohn Marino along with this program. If not, see <http://www.gnu.org/licenses/>. */
19*ef5ccd6cSJohn Marino
20*ef5ccd6cSJohn Marino /* TODO:
21*ef5ccd6cSJohn Marino - lots
22*ef5ccd6cSJohn Marino - if the more complex types get Python pretty-printers, we'll
23*ef5ccd6cSJohn Marino want a Python API for type printing
24*ef5ccd6cSJohn Marino */
25*ef5ccd6cSJohn Marino
26*ef5ccd6cSJohn Marino #include "defs.h"
27*ef5ccd6cSJohn Marino #include "gdbtypes.h"
28*ef5ccd6cSJohn Marino #include "c-lang.h"
29*ef5ccd6cSJohn Marino #include "go-lang.h"
30*ef5ccd6cSJohn Marino
31*ef5ccd6cSJohn Marino /* Print a description of a type TYPE.
32*ef5ccd6cSJohn Marino Output goes to STREAM (via stdio).
33*ef5ccd6cSJohn Marino If VARSTRING is a non-empty string, print as an Ada variable/field
34*ef5ccd6cSJohn Marino declaration.
35*ef5ccd6cSJohn Marino SHOW+1 is the maximum number of levels of internal type structure
36*ef5ccd6cSJohn Marino to show (this applies to record types, enumerated types, and
37*ef5ccd6cSJohn Marino array types).
38*ef5ccd6cSJohn Marino SHOW is the number of levels of internal type structure to show
39*ef5ccd6cSJohn Marino when there is a type name for the SHOWth deepest level (0th is
40*ef5ccd6cSJohn Marino outer level).
41*ef5ccd6cSJohn Marino When SHOW<0, no inner structure is shown.
42*ef5ccd6cSJohn Marino LEVEL indicates level of recursion (for nested definitions). */
43*ef5ccd6cSJohn Marino
44*ef5ccd6cSJohn Marino void
go_print_type(struct type * type,const char * varstring,struct ui_file * stream,int show,int level,const struct type_print_options * flags)45*ef5ccd6cSJohn Marino go_print_type (struct type *type, const char *varstring,
46*ef5ccd6cSJohn Marino struct ui_file *stream, int show, int level,
47*ef5ccd6cSJohn Marino const struct type_print_options *flags)
48*ef5ccd6cSJohn Marino {
49*ef5ccd6cSJohn Marino /* Borrowed from c-typeprint.c. */
50*ef5ccd6cSJohn Marino if (show > 0)
51*ef5ccd6cSJohn Marino CHECK_TYPEDEF (type);
52*ef5ccd6cSJohn Marino
53*ef5ccd6cSJohn Marino /* Print the type of "abc" as "string", not char[4]. */
54*ef5ccd6cSJohn Marino if (TYPE_CODE (type) == TYPE_CODE_ARRAY
55*ef5ccd6cSJohn Marino && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR)
56*ef5ccd6cSJohn Marino {
57*ef5ccd6cSJohn Marino fputs_filtered ("string", stream);
58*ef5ccd6cSJohn Marino return;
59*ef5ccd6cSJohn Marino }
60*ef5ccd6cSJohn Marino
61*ef5ccd6cSJohn Marino /* Punt the rest to C for now. */
62*ef5ccd6cSJohn Marino c_print_type (type, varstring, stream, show, level, flags);
63*ef5ccd6cSJohn Marino }
64