GDB (API)
/home/stan/gdb/src/gdb/go-typeprint.c
Go to the documentation of this file.
00001 /* Support for printing Go types for GDB, the GNU debugger.
00002 
00003    Copyright (C) 2012-2013 Free Software Foundation, Inc.
00004 
00005    This file is part of GDB.
00006 
00007    This program is free software; you can redistribute it and/or modify
00008    it under the terms of the GNU General Public License as published by
00009    the Free Software Foundation; either version 3 of the License, or
00010    (at your option) any later version.
00011 
00012    This program is distributed in the hope that it will be useful,
00013    but WITHOUT ANY WARRANTY; without even the implied warranty of
00014    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015    GNU General Public License for more details.
00016 
00017    You should have received a copy of the GNU General Public License
00018    along with this program.  If not, see <http://www.gnu.org/licenses/>.  */
00019 
00020 /* TODO:
00021    - lots
00022    - if the more complex types get Python pretty-printers, we'll
00023      want a Python API for type printing
00024 */
00025 
00026 #include "defs.h"
00027 #include "gdbtypes.h"
00028 #include "c-lang.h"
00029 #include "go-lang.h"
00030 
00031 /* Print a description of a type TYPE.
00032    Output goes to STREAM (via stdio).
00033    If VARSTRING is a non-empty string, print as an Ada variable/field
00034        declaration.
00035    SHOW+1 is the maximum number of levels of internal type structure
00036       to show (this applies to record types, enumerated types, and
00037       array types).
00038    SHOW is the number of levels of internal type structure to show
00039       when there is a type name for the SHOWth deepest level (0th is
00040       outer level).
00041    When SHOW<0, no inner structure is shown.
00042    LEVEL indicates level of recursion (for nested definitions).  */
00043 
00044 void
00045 go_print_type (struct type *type, const char *varstring,
00046                struct ui_file *stream, int show, int level,
00047                const struct type_print_options *flags)
00048 {
00049   /* Borrowed from c-typeprint.c.  */
00050   if (show > 0)
00051     CHECK_TYPEDEF (type);
00052 
00053   /* Print the type of "abc" as "string", not char[4].  */
00054   if (TYPE_CODE (type) == TYPE_CODE_ARRAY
00055       && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_CHAR)
00056     {
00057       fputs_filtered ("string", stream);
00058       return;
00059     }
00060 
00061   /* Punt the rest to C for now.  */
00062   c_print_type (type, varstring, stream, show, level, flags);
00063 }
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Defines