* Makefile.in (diststuff): New target.
[deliverable/binutils-gdb.git] / gdb / ch-typeprint.c
CommitLineData
a8a69e63
FF
1/* Support for printing Chill types for GDB, the GNU debugger.
2 Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc.
3
4This file is part of GDB.
5
6This program is free software; you can redistribute it and/or modify
7it under the terms of the GNU General Public License as published by
8the Free Software Foundation; either version 2 of the License, or
9(at your option) any later version.
10
11This program is distributed in the hope that it will be useful,
12but WITHOUT ANY WARRANTY; without even the implied warranty of
13MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14GNU General Public License for more details.
15
16You should have received a copy of the GNU General Public License
17along with this program; if not, write to the Free Software
18Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */
19
20#include "defs.h"
21#include "obstack.h"
22#include "bfd.h" /* Binary File Description */
23#include "symtab.h"
24#include "gdbtypes.h"
25#include "expression.h"
26#include "value.h"
27#include "gdbcore.h"
28#include "target.h"
29#include "command.h"
30#include "gdbcmd.h"
31#include "language.h"
32#include "demangle.h"
33#include "ch-lang.h"
100f92e2 34#include "typeprint.h"
a8a69e63
FF
35
36#include <string.h>
37#include <errno.h>
38
8fbdca53 39static void
199b2450 40chill_type_print_base PARAMS ((struct type *, GDB_FILE *, int, int));
a8a69e63
FF
41
42void
43chill_print_type (type, varstring, stream, show, level)
44 struct type *type;
45 char *varstring;
199b2450 46 GDB_FILE *stream;
a8a69e63
FF
47 int show;
48 int level;
49{
a8a69e63
FF
50 if (varstring != NULL && *varstring != '\0')
51 {
52 fputs_filtered (varstring, stream);
53 fputs_filtered (" ", stream);
54 }
8a177da6 55 chill_type_print_base (type, stream, show, level);
a8a69e63
FF
56}
57
58/* Print the name of the type (or the ultimate pointer target,
59 function value or array element).
60
61 SHOW nonzero means don't print this type as just its name;
62 show its real definition even if it has a name.
63 SHOW zero means print just typename or tag if there is one
64 SHOW negative means abbreviate structure elements.
65 SHOW is decremented for printing of structure elements.
66
67 LEVEL is the depth to indent by.
68 We increase it for some recursive calls. */
69
8fbdca53
FF
70static void
71chill_type_print_base (type, stream, show, level)
a8a69e63 72 struct type *type;
199b2450 73 GDB_FILE *stream;
a8a69e63
FF
74 int show;
75 int level;
76{
8fbdca53
FF
77 char *name;
78 register int len;
79 register int i;
8a177da6
PB
80 struct type *index_type;
81 struct type *range_type;
82 LONGEST low_bound;
83 LONGEST high_bound;
8fbdca53 84
a8a69e63
FF
85 QUIT;
86
87 wrap_here (" ");
88 if (type == NULL)
89 {
90 fputs_filtered ("<type unknown>", stream);
91 return;
92 }
93
94 /* When SHOW is zero or less, and there is a valid type name, then always
95 just print the type name directly from the type. */
96
97 if ((show <= 0) && (TYPE_NAME (type) != NULL))
98 {
99 fputs_filtered (TYPE_NAME (type), stream);
100 return;
101 }
102
103 switch (TYPE_CODE (type))
104 {
a8a69e63 105 case TYPE_CODE_PTR:
8a177da6
PB
106 if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_VOID)
107 {
108 fprintf_filtered (stream, "PTR");
109 break;
110 }
111 fprintf_filtered (stream, "REF ");
112 chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
113 break;
114
115 case TYPE_CODE_ARRAY:
116 range_type = TYPE_FIELD_TYPE (type, 0);
117 index_type = TYPE_TARGET_TYPE (range_type);
118 low_bound = TYPE_FIELD_BITPOS (range_type, 0);
119 high_bound = TYPE_FIELD_BITPOS (range_type, 1);
120 fputs_filtered ("ARRAY (", stream);
121 print_type_scalar (index_type, low_bound, stream);
122 fputs_filtered (":", stream);
123 print_type_scalar (index_type, high_bound, stream);
124 fputs_filtered (") ", stream);
125 chill_print_type (TYPE_TARGET_TYPE (type), "", stream, show, level);
126 break;
127
128 case TYPE_CODE_STRING:
129 range_type = TYPE_FIELD_TYPE (type, 0);
130 index_type = TYPE_TARGET_TYPE (range_type);
131 high_bound = TYPE_FIELD_BITPOS (range_type, 1);
132 fputs_filtered ("CHAR (", stream);
133 print_type_scalar (index_type, high_bound + 1, stream);
134 fputs_filtered (")", stream);
135 break;
136
a8a69e63 137 case TYPE_CODE_MEMBER:
8a177da6
PB
138 fprintf_filtered (stream, "MEMBER ");
139 chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
140 break;
a8a69e63 141 case TYPE_CODE_REF:
8a177da6
PB
142 fprintf_filtered (stream, "/*LOC*/ ");
143 chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
144 break;
a8a69e63 145 case TYPE_CODE_FUNC:
8a177da6 146 fprintf_filtered (stream, "PROC (?)");
8fbdca53
FF
147 chill_type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
148 break;
149
150 case TYPE_CODE_STRUCT:
151 fprintf_filtered (stream, "STRUCT ");
152 if ((name = type_name_no_tag (type)) != NULL)
153 {
154 fputs_filtered (name, stream);
155 fputs_filtered (" ", stream);
156 wrap_here (" ");
157 }
158 if (show < 0)
159 {
160 fprintf_filtered (stream, "(...)");
161 }
162 else
163 {
164 check_stub_type (type);
165 fprintf_filtered (stream, "(\n");
166 if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0))
167 {
168 if (TYPE_FLAGS (type) & TYPE_FLAG_STUB)
169 {
170 fprintfi_filtered (level + 4, stream, "<incomplete type>\n");
171 }
172 else
173 {
174 fprintfi_filtered (level + 4, stream, "<no data fields>\n");
175 }
176 }
177 else
178 {
179 len = TYPE_NFIELDS (type);
180 for (i = TYPE_N_BASECLASSES (type); i < len; i++)
181 {
182 QUIT;
183 print_spaces_filtered (level + 4, stream);
184 chill_print_type (TYPE_FIELD_TYPE (type, i),
185 TYPE_FIELD_NAME (type, i),
186 stream, show - 1, level + 4);
187 if (i < (len - 1))
188 {
189 fputs_filtered (",", stream);
190 }
191 fputs_filtered ("\n", stream);
192 }
193 }
194 fprintfi_filtered (level, stream, ")");
195 }
a8a69e63
FF
196 break;
197
198 case TYPE_CODE_VOID:
199 case TYPE_CODE_UNDEF:
200 case TYPE_CODE_ERROR:
201 case TYPE_CODE_RANGE:
202 case TYPE_CODE_ENUM:
203 case TYPE_CODE_UNION:
a8a69e63 204 case TYPE_CODE_METHOD:
8fbdca53 205 error ("missing language support in chill_type_print_base");
a8a69e63
FF
206 break;
207
208 default:
209
210 /* Handle types not explicitly handled by the other cases,
211 such as fundamental types. For these, just print whatever
212 the type name is, as recorded in the type itself. If there
213 is no type name, then complain. */
214
215 if (TYPE_NAME (type) != NULL)
216 {
217 fputs_filtered (TYPE_NAME (type), stream);
218 }
219 else
220 {
221 error ("Unrecognized type code (%d) in symbol table.",
222 TYPE_CODE (type));
223 }
224 break;
225 }
226}
This page took 0.075351 seconds and 4 git commands to generate.