]>
Commit | Line | Data |
---|---|---|
7d9884b9 JG |
1 | /* Print values for GDB, the GNU debugger. |
2 | Copyright 1986, 1988, 1989, 1991 Free Software Foundation, Inc. | |
bd5635a1 RP |
3 | |
4 | This file is part of GDB. | |
5 | ||
36b9d39c | 6 | This program is free software; you can redistribute it and/or modify |
bd5635a1 | 7 | it under the terms of the GNU General Public License as published by |
36b9d39c JG |
8 | the Free Software Foundation; either version 2 of the License, or |
9 | (at your option) any later version. | |
bd5635a1 | 10 | |
36b9d39c | 11 | This program is distributed in the hope that it will be useful, |
bd5635a1 RP |
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 | GNU General Public License for more details. | |
15 | ||
16 | You should have received a copy of the GNU General Public License | |
36b9d39c JG |
17 | along with this program; if not, write to the Free Software |
18 | Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
bd5635a1 | 19 | |
bd5635a1 | 20 | #include "defs.h" |
2cd99985 | 21 | #include <string.h> |
bd5635a1 | 22 | #include "symtab.h" |
2cd99985 | 23 | #include "gdbtypes.h" |
bd5635a1 RP |
24 | #include "value.h" |
25 | #include "gdbcore.h" | |
26 | #include "gdbcmd.h" | |
27 | #include "target.h" | |
28 | #include "obstack.h" | |
be3bc7ad | 29 | #include "language.h" |
8f793aa5 | 30 | #include "demangle.h" |
bd5635a1 RP |
31 | |
32 | #include <errno.h> | |
2cd99985 PB |
33 | |
34 | /* Prototypes for local functions */ | |
35 | ||
36 | static void | |
37 | print_string PARAMS ((FILE *, char *, unsigned int, int)); | |
38 | ||
39 | static void | |
40 | show_print PARAMS ((char *, int)); | |
41 | ||
42 | static void | |
43 | set_print PARAMS ((char *, int)); | |
44 | ||
45 | static void | |
46 | set_radix PARAMS ((char *, int, struct cmd_list_element *)); | |
47 | ||
48 | static void | |
49 | set_output_radix PARAMS ((char *, int, struct cmd_list_element *)); | |
50 | ||
51 | static void | |
52 | type_print_base PARAMS ((struct type *, FILE *, int, int)); | |
53 | ||
9e4667f6 FF |
54 | static void |
55 | type_print_args PARAMS ((struct type *, FILE *)); | |
56 | ||
2cd99985 | 57 | static void |
f9b5584c | 58 | type_print_varspec_suffix PARAMS ((struct type *, FILE *, int, int, int)); |
2cd99985 PB |
59 | |
60 | static void | |
61 | type_print_varspec_prefix PARAMS ((struct type *, FILE *, int, int)); | |
62 | ||
63 | static void | |
64 | type_print_derivation_info PARAMS ((FILE *, struct type *)); | |
65 | ||
66 | static void | |
67 | type_print_method_args PARAMS ((struct type **, char *, char *, int, FILE *)); | |
68 | ||
69 | static void | |
70 | cplus_val_print PARAMS ((struct type *, char *, FILE *, int, int, | |
71 | enum val_prettyprint, struct type **)); | |
72 | ||
73 | static void | |
74 | val_print_fields PARAMS ((struct type *, char *, FILE *, int, int, | |
75 | enum val_prettyprint, struct type **)); | |
76 | ||
77 | static int | |
78 | is_vtbl_member PARAMS ((struct type *)); | |
79 | ||
80 | static int | |
81 | is_vtbl_ptr_type PARAMS ((struct type *)); | |
82 | ||
83 | static void | |
84 | print_hex_chars PARAMS ((FILE *, unsigned char *, unsigned)); | |
85 | ||
bd5635a1 RP |
86 | extern int demangle; /* whether to print C++ syms raw or source-form */ |
87 | ||
88 | /* Maximum number of chars to print for a string pointer value | |
89 | or vector contents, or UINT_MAX for no limit. */ | |
90 | ||
91 | static unsigned int print_max; | |
92 | ||
bd5635a1 RP |
93 | /* Default input and output radixes, and output format letter. */ |
94 | ||
95 | unsigned input_radix = 10; | |
96 | unsigned output_radix = 10; | |
97 | int output_format = 0; | |
98 | ||
bd5635a1 RP |
99 | /* Print repeat counts if there are more than this |
100 | many repetitions of an element in an array. */ | |
101 | #define REPEAT_COUNT_THRESHOLD 10 | |
0dce3774 JK |
102 | |
103 | /* Define a mess of print controls. */ | |
104 | ||
105 | int prettyprint; /* Controls pretty printing of structures */ | |
106 | int vtblprint; /* Controls printing of vtbl's */ | |
107 | int unionprint; /* Controls printing of nested unions. */ | |
108 | int arrayprint; /* Controls pretty printing of arrays. */ | |
109 | int addressprint; /* Controls pretty printing of addresses. */ | |
110 | int objectprint; /* Controls looking up an object's derived type | |
111 | using what we find in its vtables. */ | |
112 | ||
113 | struct obstack dont_print_obstack; | |
114 | ||
bd5635a1 RP |
115 | \f |
116 | /* Print the character string STRING, printing at most LENGTH characters. | |
117 | Printing stops early if the number hits print_max; repeat counts | |
118 | are printed as appropriate. Print ellipses at the end if we | |
119 | had to stop before printing LENGTH characters, or if FORCE_ELLIPSES. */ | |
120 | ||
2cd99985 | 121 | static void |
bd5635a1 RP |
122 | print_string (stream, string, length, force_ellipses) |
123 | FILE *stream; | |
124 | char *string; | |
125 | unsigned int length; | |
126 | int force_ellipses; | |
127 | { | |
128 | register unsigned int i; | |
129 | unsigned int things_printed = 0; | |
130 | int in_quotes = 0; | |
131 | int need_comma = 0; | |
132 | extern int inspect_it; | |
133 | ||
134 | if (length == 0) | |
135 | { | |
136 | fputs_filtered ("\"\"", stdout); | |
137 | return; | |
138 | } | |
139 | ||
140 | for (i = 0; i < length && things_printed < print_max; ++i) | |
141 | { | |
142 | /* Position of the character we are examining | |
143 | to see whether it is repeated. */ | |
144 | unsigned int rep1; | |
145 | /* Number of repetitions we have detected so far. */ | |
146 | unsigned int reps; | |
147 | ||
148 | QUIT; | |
149 | ||
150 | if (need_comma) | |
151 | { | |
152 | fputs_filtered (", ", stream); | |
153 | need_comma = 0; | |
154 | } | |
155 | ||
156 | rep1 = i + 1; | |
157 | reps = 1; | |
158 | while (rep1 < length && string[rep1] == string[i]) | |
159 | { | |
160 | ++rep1; | |
161 | ++reps; | |
162 | } | |
163 | ||
164 | if (reps > REPEAT_COUNT_THRESHOLD) | |
165 | { | |
166 | if (in_quotes) | |
167 | { | |
168 | if (inspect_it) | |
169 | fputs_filtered ("\\\", ", stream); | |
170 | else | |
171 | fputs_filtered ("\", ", stream); | |
172 | in_quotes = 0; | |
173 | } | |
174 | fputs_filtered ("'", stream); | |
175 | printchar (string[i], stream, '\''); | |
176 | fprintf_filtered (stream, "' <repeats %u times>", reps); | |
177 | i = rep1 - 1; | |
178 | things_printed += REPEAT_COUNT_THRESHOLD; | |
179 | need_comma = 1; | |
180 | } | |
181 | else | |
182 | { | |
183 | if (!in_quotes) | |
184 | { | |
185 | if (inspect_it) | |
186 | fputs_filtered ("\\\"", stream); | |
187 | else | |
188 | fputs_filtered ("\"", stream); | |
189 | in_quotes = 1; | |
190 | } | |
191 | printchar (string[i], stream, '"'); | |
192 | ++things_printed; | |
193 | } | |
194 | } | |
195 | ||
196 | /* Terminate the quotes if necessary. */ | |
197 | if (in_quotes) | |
198 | { | |
199 | if (inspect_it) | |
200 | fputs_filtered ("\\\"", stream); | |
201 | else | |
202 | fputs_filtered ("\"", stream); | |
203 | } | |
204 | ||
205 | if (force_ellipses || i < length) | |
206 | fputs_filtered ("...", stream); | |
207 | } | |
208 | ||
209 | /* Print a floating point value of type TYPE, pointed to in GDB by VALADDR, | |
210 | on STREAM. */ | |
211 | ||
212 | void | |
213 | print_floating (valaddr, type, stream) | |
214 | char *valaddr; | |
215 | struct type *type; | |
216 | FILE *stream; | |
217 | { | |
218 | double doub; | |
219 | int inv; | |
220 | unsigned len = TYPE_LENGTH (type); | |
221 | ||
222 | #if defined (IEEE_FLOAT) | |
223 | ||
224 | /* Check for NaN's. Note that this code does not depend on us being | |
225 | on an IEEE conforming system. It only depends on the target | |
226 | machine using IEEE representation. This means (a) | |
227 | cross-debugging works right, and (2) IEEE_FLOAT can (and should) | |
228 | be defined for systems like the 68881, which uses IEEE | |
229 | representation, but is not IEEE conforming. */ | |
230 | ||
231 | { | |
232 | long low, high; | |
233 | /* Is the sign bit 0? */ | |
234 | int nonnegative; | |
235 | /* Is it is a NaN (i.e. the exponent is all ones and | |
236 | the fraction is nonzero)? */ | |
237 | int is_nan; | |
238 | ||
239 | if (len == sizeof (float)) | |
240 | { | |
241 | /* It's single precision. */ | |
4ed3a9ea | 242 | memcpy ((char *) &low, valaddr, sizeof (low)); |
bd5635a1 RP |
243 | /* target -> host. */ |
244 | SWAP_TARGET_AND_HOST (&low, sizeof (float)); | |
245 | nonnegative = low >= 0; | |
246 | is_nan = ((((low >> 23) & 0xFF) == 0xFF) | |
247 | && 0 != (low & 0x7FFFFF)); | |
248 | low &= 0x7fffff; | |
249 | high = 0; | |
250 | } | |
251 | else | |
252 | { | |
253 | /* It's double precision. Get the high and low words. */ | |
254 | ||
255 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
4ed3a9ea FF |
256 | memcpy (&low, valaddr+4, sizeof (low)); |
257 | memcpy (&high, valaddr+0, sizeof (high)); | |
bd5635a1 | 258 | #else |
4ed3a9ea FF |
259 | memcpy (&low, valaddr+0, sizeof (low)); |
260 | memcpy (&high, valaddr+4, sizeof (high)); | |
bd5635a1 | 261 | #endif |
4ed3a9ea FF |
262 | SWAP_TARGET_AND_HOST (&low, sizeof (low)); |
263 | SWAP_TARGET_AND_HOST (&high, sizeof (high)); | |
264 | nonnegative = high >= 0; | |
265 | is_nan = (((high >> 20) & 0x7ff) == 0x7ff | |
266 | && ! ((((high & 0xfffff) == 0)) && (low == 0))); | |
267 | high &= 0xfffff; | |
268 | } | |
bd5635a1 RP |
269 | |
270 | if (is_nan) | |
271 | { | |
272 | /* The meaning of the sign and fraction is not defined by IEEE. | |
273 | But the user might know what they mean. For example, they | |
274 | (in an implementation-defined manner) distinguish between | |
275 | signaling and quiet NaN's. */ | |
276 | if (high) | |
277 | fprintf_filtered (stream, "-NaN(0x%lx%.8lx)" + nonnegative, | |
278 | high, low); | |
279 | else | |
280 | fprintf_filtered (stream, "-NaN(0x%lx)" + nonnegative, low); | |
281 | return; | |
282 | } | |
283 | } | |
284 | #endif /* IEEE_FLOAT. */ | |
285 | ||
286 | doub = unpack_double (type, valaddr, &inv); | |
287 | if (inv) | |
288 | fprintf_filtered (stream, "<invalid float value>"); | |
289 | else | |
be3bc7ad | 290 | fprintf_filtered (stream, len <= sizeof(float) ? "%.9g" : "%.17g", doub); |
bd5635a1 RP |
291 | } |
292 | ||
293 | /* VALADDR points to an integer of LEN bytes. Print it in hex on stream. */ | |
294 | static void | |
295 | print_hex_chars (stream, valaddr, len) | |
296 | FILE *stream; | |
297 | unsigned char *valaddr; | |
298 | unsigned len; | |
299 | { | |
300 | unsigned char *p; | |
301 | ||
302 | fprintf_filtered (stream, "0x"); | |
303 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
304 | for (p = valaddr; | |
305 | p < valaddr + len; | |
306 | p++) | |
307 | #else /* Little endian. */ | |
308 | for (p = valaddr + len - 1; | |
309 | p >= valaddr; | |
310 | p--) | |
311 | #endif | |
312 | { | |
313 | fprintf_filtered (stream, "%02x", *p); | |
314 | } | |
315 | } | |
316 | \f | |
317 | /* Print the value VAL in C-ish syntax on stream STREAM. | |
318 | FORMAT is a format-letter, or 0 for print in natural format of data type. | |
319 | If the object printed is a string pointer, returns | |
320 | the number of string bytes printed. */ | |
321 | ||
322 | int | |
323 | value_print (val, stream, format, pretty) | |
324 | value val; | |
325 | FILE *stream; | |
2cd99985 | 326 | int format; |
bd5635a1 RP |
327 | enum val_prettyprint pretty; |
328 | { | |
329 | register unsigned int i, n, typelen; | |
330 | ||
331 | if (val == 0) | |
332 | { | |
333 | printf_filtered ("<address of value unknown>"); | |
334 | return 0; | |
335 | } | |
336 | if (VALUE_OPTIMIZED_OUT (val)) | |
337 | { | |
338 | printf_filtered ("<value optimized out>"); | |
339 | return 0; | |
340 | } | |
aec4cb91 | 341 | |
bd5635a1 RP |
342 | /* A "repeated" value really contains several values in a row. |
343 | They are made by the @ operator. | |
344 | Print such values as if they were arrays. */ | |
345 | ||
346 | else if (VALUE_REPEATED (val)) | |
347 | { | |
348 | n = VALUE_REPETITIONS (val); | |
349 | typelen = TYPE_LENGTH (VALUE_TYPE (val)); | |
350 | fprintf_filtered (stream, "{"); | |
351 | /* Print arrays of characters using string syntax. */ | |
352 | if (typelen == 1 && TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_INT | |
353 | && format == 0) | |
354 | print_string (stream, VALUE_CONTENTS (val), n, 0); | |
355 | else | |
356 | { | |
357 | unsigned int things_printed = 0; | |
358 | ||
359 | for (i = 0; i < n && things_printed < print_max; i++) | |
360 | { | |
361 | /* Position of the array element we are examining to see | |
362 | whether it is repeated. */ | |
363 | unsigned int rep1; | |
364 | /* Number of repetitions we have detected so far. */ | |
365 | unsigned int reps; | |
366 | ||
367 | if (i != 0) | |
368 | fprintf_filtered (stream, ", "); | |
369 | wrap_here (""); | |
370 | ||
371 | rep1 = i + 1; | |
372 | reps = 1; | |
373 | while (rep1 < n | |
51b57ded | 374 | && !memcmp (VALUE_CONTENTS (val) + typelen * i, |
bd5635a1 RP |
375 | VALUE_CONTENTS (val) + typelen * rep1, typelen)) |
376 | { | |
377 | ++reps; | |
378 | ++rep1; | |
379 | } | |
380 | ||
381 | if (reps > REPEAT_COUNT_THRESHOLD) | |
382 | { | |
383 | val_print (VALUE_TYPE (val), | |
384 | VALUE_CONTENTS (val) + typelen * i, | |
385 | VALUE_ADDRESS (val) + typelen * i, | |
386 | stream, format, 1, 0, pretty); | |
387 | fprintf (stream, " <repeats %u times>", reps); | |
388 | i = rep1 - 1; | |
389 | things_printed += REPEAT_COUNT_THRESHOLD; | |
390 | } | |
391 | else | |
392 | { | |
393 | val_print (VALUE_TYPE (val), | |
394 | VALUE_CONTENTS (val) + typelen * i, | |
395 | VALUE_ADDRESS (val) + typelen * i, | |
396 | stream, format, 1, 0, pretty); | |
397 | things_printed++; | |
398 | } | |
399 | } | |
400 | if (i < n) | |
401 | fprintf_filtered (stream, "..."); | |
402 | } | |
403 | fprintf_filtered (stream, "}"); | |
404 | return n * typelen; | |
405 | } | |
406 | else | |
407 | { | |
0dce3774 JK |
408 | struct type *type = VALUE_TYPE (val); |
409 | ||
bd5635a1 RP |
410 | /* If it is a pointer, indicate what it points to. |
411 | ||
412 | Print type also if it is a reference. | |
413 | ||
414 | C++: if it is a member pointer, we will take care | |
415 | of that when we print it. */ | |
0dce3774 JK |
416 | if (TYPE_CODE (type) == TYPE_CODE_PTR |
417 | || TYPE_CODE (type) == TYPE_CODE_REF) | |
bd5635a1 RP |
418 | { |
419 | /* Hack: remove (char *) for char strings. Their | |
420 | type is indicated by the quoted string anyway. */ | |
0dce3774 JK |
421 | if (TYPE_CODE (type) == TYPE_CODE_PTR |
422 | && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) == sizeof(char) | |
423 | && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_INT | |
424 | && !TYPE_UNSIGNED (TYPE_TARGET_TYPE (type))) | |
bd5635a1 RP |
425 | { |
426 | /* Print nothing */ | |
427 | } | |
428 | else | |
429 | { | |
430 | fprintf_filtered (stream, "("); | |
0dce3774 | 431 | type_print (type, "", stream, -1); |
bd5635a1 RP |
432 | fprintf_filtered (stream, ") "); |
433 | } | |
434 | } | |
0dce3774 | 435 | return val_print (type, VALUE_CONTENTS (val), |
bd5635a1 RP |
436 | VALUE_ADDRESS (val), stream, format, 1, 0, pretty); |
437 | } | |
438 | } | |
439 | ||
440 | /* Return truth value for assertion that TYPE is of the type | |
441 | "pointer to virtual function". */ | |
442 | static int | |
443 | is_vtbl_ptr_type(type) | |
444 | struct type *type; | |
445 | { | |
abefb1f1 | 446 | char *typename = type_name_no_tag (type); |
bd5635a1 | 447 | static const char vtbl_ptr_name[] = |
bcccec8c | 448 | { CPLUS_MARKER,'v','t','b','l','_','p','t','r','_','t','y','p','e', 0 }; |
bd5635a1 RP |
449 | |
450 | return (typename != NULL && !strcmp(typename, vtbl_ptr_name)); | |
451 | } | |
452 | ||
453 | /* Return truth value for the assertion that TYPE is of the type | |
454 | "pointer to virtual function table". */ | |
455 | static int | |
456 | is_vtbl_member(type) | |
457 | struct type *type; | |
458 | { | |
0dce3774 JK |
459 | if (TYPE_CODE (type) == TYPE_CODE_PTR) |
460 | type = TYPE_TARGET_TYPE (type); | |
461 | else | |
462 | return 0; | |
463 | ||
464 | if (TYPE_CODE (type) == TYPE_CODE_ARRAY | |
465 | && TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_STRUCT) | |
bd5635a1 | 466 | /* Virtual functions tables are full of pointers to virtual functions. */ |
0dce3774 | 467 | return is_vtbl_ptr_type (TYPE_TARGET_TYPE (type)); |
bd5635a1 RP |
468 | return 0; |
469 | } | |
470 | \f | |
bd5635a1 RP |
471 | /* Mutually recursive subroutines of cplus_val_print and val_print to print out |
472 | a structure's fields: val_print_fields and cplus_val_print. | |
473 | ||
474 | TYPE, VALADDR, STREAM, RECURSE, and PRETTY have the | |
475 | same meanings as in cplus_val_print and val_print. | |
476 | ||
477 | DONT_PRINT is an array of baseclass types that we | |
478 | should not print, or zero if called from top level. */ | |
2cd99985 | 479 | |
bd5635a1 RP |
480 | static void |
481 | val_print_fields (type, valaddr, stream, format, recurse, pretty, dont_print) | |
482 | struct type *type; | |
483 | char *valaddr; | |
484 | FILE *stream; | |
2cd99985 | 485 | int format; |
bd5635a1 RP |
486 | int recurse; |
487 | enum val_prettyprint pretty; | |
488 | struct type **dont_print; | |
489 | { | |
490 | int i, len, n_baseclasses; | |
491 | ||
be3bc7ad JG |
492 | check_stub_type (type); |
493 | ||
bd5635a1 RP |
494 | fprintf_filtered (stream, "{"); |
495 | len = TYPE_NFIELDS (type); | |
496 | n_baseclasses = TYPE_N_BASECLASSES (type); | |
497 | ||
498 | /* Print out baseclasses such that we don't print | |
499 | duplicates of virtual baseclasses. */ | |
500 | if (n_baseclasses > 0) | |
501 | cplus_val_print (type, valaddr, stream, format, recurse+1, pretty, dont_print); | |
502 | ||
503 | if (!len && n_baseclasses == 1) | |
504 | fprintf_filtered (stream, "<No data fields>"); | |
505 | else | |
506 | { | |
507 | extern int inspect_it; | |
508 | int fields_seen = 0; | |
509 | ||
510 | for (i = n_baseclasses; i < len; i++) | |
511 | { | |
512 | /* Check if static field */ | |
2640f7e1 | 513 | if (TYPE_FIELD_STATIC (type, i)) |
bd5635a1 RP |
514 | continue; |
515 | if (fields_seen) | |
516 | fprintf_filtered (stream, ", "); | |
517 | else if (n_baseclasses > 0) | |
518 | { | |
0efe20a6 FF |
519 | if (pretty) |
520 | { | |
521 | fprintf_filtered (stream, "\n"); | |
522 | print_spaces_filtered (2 + 2 * recurse, stream); | |
523 | fputs_filtered ("members of ", stream); | |
524 | fputs_filtered (type_name_no_tag (type), stream); | |
525 | fputs_filtered (": ", stream); | |
526 | } | |
bd5635a1 RP |
527 | } |
528 | fields_seen = 1; | |
529 | ||
530 | if (pretty) | |
531 | { | |
532 | fprintf_filtered (stream, "\n"); | |
533 | print_spaces_filtered (2 + 2 * recurse, stream); | |
534 | } | |
535 | else | |
536 | { | |
537 | wrap_here (n_spaces (2 + 2 * recurse)); | |
538 | } | |
539 | if (inspect_it) | |
540 | { | |
541 | if (TYPE_CODE (TYPE_FIELD_TYPE (type, i)) == TYPE_CODE_PTR) | |
542 | fputs_filtered ("\"( ptr \"", stream); | |
543 | else | |
544 | fputs_filtered ("\"( nodef \"", stream); | |
b4cc55b5 | 545 | fprint_symbol (stream, TYPE_FIELD_NAME (type, i)); |
bd5635a1 | 546 | fputs_filtered ("\" \"", stream); |
b4cc55b5 | 547 | fprint_symbol (stream, TYPE_FIELD_NAME (type, i)); |
bd5635a1 RP |
548 | fputs_filtered ("\") \"", stream); |
549 | } | |
550 | else | |
551 | { | |
b4cc55b5 | 552 | fprint_symbol (stream, TYPE_FIELD_NAME (type, i)); |
bd5635a1 RP |
553 | fputs_filtered (" = ", stream); |
554 | } | |
555 | if (TYPE_FIELD_PACKED (type, i)) | |
556 | { | |
f266e564 | 557 | value v; |
bd5635a1 | 558 | |
f266e564 JK |
559 | /* Bitfields require special handling, especially due to byte |
560 | order problems. */ | |
bee3c1a1 | 561 | v = value_from_longest (TYPE_FIELD_TYPE (type, i), |
f266e564 | 562 | unpack_field_as_long (type, valaddr, i)); |
bd5635a1 | 563 | |
f266e564 | 564 | val_print (TYPE_FIELD_TYPE (type, i), VALUE_CONTENTS (v), 0, |
bd5635a1 RP |
565 | stream, format, 0, recurse + 1, pretty); |
566 | } | |
567 | else | |
568 | { | |
569 | val_print (TYPE_FIELD_TYPE (type, i), | |
570 | valaddr + TYPE_FIELD_BITPOS (type, i) / 8, | |
571 | 0, stream, format, 0, recurse + 1, pretty); | |
572 | } | |
573 | } | |
574 | if (pretty) | |
575 | { | |
576 | fprintf_filtered (stream, "\n"); | |
577 | print_spaces_filtered (2 * recurse, stream); | |
578 | } | |
579 | } | |
580 | fprintf_filtered (stream, "}"); | |
581 | } | |
582 | ||
583 | /* Special val_print routine to avoid printing multiple copies of virtual | |
584 | baseclasses. */ | |
585 | ||
586 | static void | |
587 | cplus_val_print (type, valaddr, stream, format, recurse, pretty, dont_print) | |
588 | struct type *type; | |
589 | char *valaddr; | |
590 | FILE *stream; | |
2cd99985 | 591 | int format; |
bd5635a1 RP |
592 | int recurse; |
593 | enum val_prettyprint pretty; | |
594 | struct type **dont_print; | |
595 | { | |
596 | struct obstack tmp_obstack; | |
597 | struct type **last_dont_print | |
598 | = (struct type **)obstack_next_free (&dont_print_obstack); | |
599 | int i, n_baseclasses = TYPE_N_BASECLASSES (type); | |
600 | ||
601 | if (dont_print == 0) | |
602 | { | |
603 | /* If we're at top level, carve out a completely fresh | |
604 | chunk of the obstack and use that until this particular | |
605 | invocation returns. */ | |
606 | tmp_obstack = dont_print_obstack; | |
607 | /* Bump up the high-water mark. Now alpha is omega. */ | |
608 | obstack_finish (&dont_print_obstack); | |
609 | } | |
610 | ||
611 | for (i = 0; i < n_baseclasses; i++) | |
612 | { | |
613 | char *baddr; | |
0dce3774 | 614 | int err; |
bd5635a1 RP |
615 | |
616 | if (BASETYPE_VIA_VIRTUAL (type, i)) | |
617 | { | |
618 | struct type **first_dont_print | |
619 | = (struct type **)obstack_base (&dont_print_obstack); | |
620 | ||
621 | int j = (struct type **)obstack_next_free (&dont_print_obstack) | |
622 | - first_dont_print; | |
623 | ||
624 | while (--j >= 0) | |
625 | if (TYPE_BASECLASS (type, i) == first_dont_print[j]) | |
626 | goto flush_it; | |
627 | ||
628 | obstack_ptr_grow (&dont_print_obstack, TYPE_BASECLASS (type, i)); | |
629 | } | |
630 | ||
0dce3774 JK |
631 | baddr = baseclass_addr (type, i, valaddr, 0, &err); |
632 | if (err == 0 && baddr == 0) | |
bd5635a1 RP |
633 | error ("could not find virtual baseclass `%s'\n", |
634 | type_name_no_tag (TYPE_BASECLASS (type, i))); | |
635 | ||
bd5635a1 | 636 | if (pretty) |
0efe20a6 FF |
637 | { |
638 | fprintf_filtered (stream, "\n"); | |
639 | print_spaces_filtered (2 * recurse, stream); | |
640 | } | |
bd5635a1 RP |
641 | fputs_filtered ("<", stream); |
642 | fputs_filtered (type_name_no_tag (TYPE_BASECLASS (type, i)), stream); | |
643 | fputs_filtered ("> = ", stream); | |
0dce3774 JK |
644 | if (err != 0) |
645 | fprintf_filtered (stream, "<invalid address 0x%x>", baddr); | |
646 | else | |
647 | val_print_fields (TYPE_BASECLASS (type, i), baddr, stream, format, | |
648 | recurse, pretty, | |
649 | (struct type **)obstack_base (&dont_print_obstack)); | |
0efe20a6 FF |
650 | fputs_filtered (", ", stream); |
651 | ||
bd5635a1 RP |
652 | flush_it: |
653 | ; | |
654 | } | |
655 | ||
656 | if (dont_print == 0) | |
657 | { | |
658 | /* Free the space used to deal with the printing | |
659 | of this type from top level. */ | |
660 | obstack_free (&dont_print_obstack, last_dont_print); | |
661 | /* Reset watermark so that we can continue protecting | |
662 | ourselves from whatever we were protecting ourselves. */ | |
663 | dont_print_obstack = tmp_obstack; | |
664 | } | |
665 | } | |
666 | ||
4a11eef2 FF |
667 | static void |
668 | print_class_member (valaddr, domain, stream, prefix) | |
669 | char *valaddr; | |
670 | struct type *domain; | |
671 | FILE *stream; | |
672 | char *prefix; | |
673 | { | |
674 | ||
675 | /* VAL is a byte offset into the structure type DOMAIN. | |
676 | Find the name of the field for that offset and | |
677 | print it. */ | |
678 | int extra = 0; | |
679 | int bits = 0; | |
680 | register unsigned int i; | |
681 | unsigned len = TYPE_NFIELDS (domain); | |
682 | /* @@ Make VAL into bit offset */ | |
683 | LONGEST val = unpack_long (builtin_type_int, valaddr) << 3; | |
684 | for (i = TYPE_N_BASECLASSES (domain); i < len; i++) | |
685 | { | |
686 | int bitpos = TYPE_FIELD_BITPOS (domain, i); | |
687 | QUIT; | |
688 | if (val == bitpos) | |
689 | break; | |
690 | if (val < bitpos && i != 0) | |
691 | { | |
692 | /* Somehow pointing into a field. */ | |
693 | i -= 1; | |
694 | extra = (val - TYPE_FIELD_BITPOS (domain, i)); | |
695 | if (extra & 0x7) | |
696 | bits = 1; | |
697 | else | |
698 | extra >>= 3; | |
699 | break; | |
700 | } | |
701 | } | |
702 | if (i < len) | |
703 | { | |
704 | char *name; | |
705 | fprintf_filtered (stream, prefix); | |
706 | name = type_name_no_tag (domain); | |
707 | if (name) | |
708 | fputs_filtered (name, stream); | |
709 | else | |
710 | type_print_base (domain, stream, 0, 0); | |
711 | fprintf_filtered (stream, "::"); | |
712 | fputs_filtered (TYPE_FIELD_NAME (domain, i), stream); | |
713 | if (extra) | |
714 | fprintf_filtered (stream, " + %d bytes", extra); | |
715 | if (bits) | |
716 | fprintf_filtered (stream, " (offset in bits)"); | |
717 | } | |
718 | else | |
719 | fprintf_filtered (stream, "%d", val >> 3); | |
720 | } | |
721 | ||
bd5635a1 RP |
722 | /* Print data of type TYPE located at VALADDR (within GDB), |
723 | which came from the inferior at address ADDRESS, | |
724 | onto stdio stream STREAM according to FORMAT | |
725 | (a letter or 0 for natural format). The data at VALADDR | |
726 | is in target byte order. | |
727 | ||
728 | If the data are a string pointer, returns the number of | |
729 | sting characters printed. | |
730 | ||
731 | if DEREF_REF is nonzero, then dereference references, | |
732 | otherwise just print them like pointers. | |
733 | ||
734 | The PRETTY parameter controls prettyprinting. */ | |
735 | ||
736 | int | |
2cd99985 | 737 | val_print (type, valaddr, address, stream, format, deref_ref, recurse, pretty) |
bd5635a1 RP |
738 | struct type *type; |
739 | char *valaddr; | |
740 | CORE_ADDR address; | |
741 | FILE *stream; | |
2cd99985 | 742 | int format; |
bd5635a1 RP |
743 | int deref_ref; |
744 | int recurse; | |
745 | enum val_prettyprint pretty; | |
746 | { | |
747 | register unsigned int i; | |
748 | unsigned len; | |
749 | struct type *elttype; | |
750 | unsigned eltlen; | |
751 | LONGEST val; | |
752 | unsigned char c; | |
753 | ||
754 | if (pretty == Val_pretty_default) | |
755 | { | |
756 | pretty = prettyprint ? Val_prettyprint : Val_no_prettyprint; | |
757 | } | |
758 | ||
759 | QUIT; | |
760 | ||
761 | check_stub_type (type); | |
762 | ||
763 | if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) | |
764 | { | |
765 | fprintf_filtered (stream, "<unknown struct>"); | |
766 | fflush (stream); | |
767 | return 0; | |
768 | } | |
769 | ||
770 | switch (TYPE_CODE (type)) | |
771 | { | |
772 | case TYPE_CODE_ARRAY: | |
2a5ec41d | 773 | if (TYPE_LENGTH (type) > 0 |
bd5635a1 RP |
774 | && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) |
775 | { | |
776 | elttype = TYPE_TARGET_TYPE (type); | |
777 | eltlen = TYPE_LENGTH (elttype); | |
778 | len = TYPE_LENGTH (type) / eltlen; | |
779 | if (arrayprint) | |
780 | print_spaces_filtered (2 + 2 * recurse, stream); | |
781 | fprintf_filtered (stream, "{"); | |
782 | /* For an array of chars, print with string syntax. */ | |
783 | if (eltlen == 1 && TYPE_CODE (elttype) == TYPE_CODE_INT | |
784 | && (format == 0 || format == 's') ) | |
785 | print_string (stream, valaddr, len, 0); | |
786 | else | |
787 | { | |
788 | unsigned int things_printed = 0; | |
789 | ||
0dce3774 JK |
790 | /* If this is a virtual function table, print the 0th |
791 | entry specially, and the rest of the members normally. */ | |
792 | if (is_vtbl_ptr_type (elttype)) | |
793 | { | |
794 | fprintf_filtered (stream, "%d vtable entries", len-1); | |
795 | i = 1; | |
796 | } | |
797 | else | |
798 | i = 0; | |
799 | ||
800 | for (; i < len && things_printed < print_max; i++) | |
bd5635a1 RP |
801 | { |
802 | /* Position of the array element we are examining to see | |
803 | whether it is repeated. */ | |
804 | unsigned int rep1; | |
805 | /* Number of repetitions we have detected so far. */ | |
806 | unsigned int reps; | |
807 | ||
808 | if (i != 0) | |
809 | if (arrayprint) | |
810 | { | |
811 | fprintf_filtered (stream, ",\n"); | |
812 | print_spaces_filtered (2 + 2 * recurse, stream); | |
813 | } | |
814 | else | |
815 | fprintf_filtered (stream, ", "); | |
816 | wrap_here (n_spaces (2 + 2 * recurse)); | |
817 | ||
818 | rep1 = i + 1; | |
819 | reps = 1; | |
820 | while (rep1 < len | |
51b57ded FF |
821 | && !memcmp (valaddr + i * eltlen, |
822 | valaddr + rep1 * eltlen, eltlen)) | |
bd5635a1 RP |
823 | { |
824 | ++reps; | |
825 | ++rep1; | |
826 | } | |
827 | ||
828 | if (reps > REPEAT_COUNT_THRESHOLD) | |
829 | { | |
830 | val_print (elttype, valaddr + i * eltlen, | |
831 | 0, stream, format, deref_ref, | |
832 | recurse + 1, pretty); | |
833 | fprintf_filtered (stream, " <repeats %u times>", reps); | |
834 | i = rep1 - 1; | |
835 | things_printed += REPEAT_COUNT_THRESHOLD; | |
836 | } | |
837 | else | |
838 | { | |
839 | val_print (elttype, valaddr + i * eltlen, | |
840 | 0, stream, format, deref_ref, | |
841 | recurse + 1, pretty); | |
842 | things_printed++; | |
843 | } | |
844 | } | |
845 | if (i < len) | |
846 | fprintf_filtered (stream, "..."); | |
847 | } | |
848 | fprintf_filtered (stream, "}"); | |
849 | break; | |
850 | } | |
851 | /* Array of unspecified length: treat like pointer to first elt. */ | |
852 | valaddr = (char *) &address; | |
853 | ||
854 | case TYPE_CODE_PTR: | |
855 | if (format && format != 's') | |
856 | { | |
857 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
858 | break; | |
859 | } | |
860 | if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_METHOD) | |
861 | { | |
862 | struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)); | |
863 | struct fn_field *f; | |
864 | int j, len2; | |
865 | char *kind = ""; | |
e1ce8aa5 | 866 | CORE_ADDR addr; |
bd5635a1 | 867 | |
e1ce8aa5 JK |
868 | addr = unpack_pointer (lookup_pointer_type (builtin_type_void), |
869 | valaddr); | |
2640f7e1 | 870 | if (addr < 128) /* FIXME! What is this 128? */ |
bd5635a1 RP |
871 | { |
872 | len = TYPE_NFN_FIELDS (domain); | |
873 | for (i = 0; i < len; i++) | |
874 | { | |
875 | f = TYPE_FN_FIELDLIST1 (domain, i); | |
876 | len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i); | |
877 | ||
878 | for (j = 0; j < len2; j++) | |
879 | { | |
880 | QUIT; | |
2640f7e1 | 881 | if (TYPE_FN_FIELD_VOFFSET (f, j) == addr) |
bd5635a1 | 882 | { |
2640f7e1 | 883 | kind = "virtual"; |
bd5635a1 RP |
884 | goto common; |
885 | } | |
886 | } | |
887 | } | |
888 | } | |
889 | else | |
890 | { | |
e1ce8aa5 | 891 | struct symbol *sym = find_pc_function (addr); |
bd5635a1 RP |
892 | if (sym == 0) |
893 | error ("invalid pointer to member function"); | |
894 | len = TYPE_NFN_FIELDS (domain); | |
895 | for (i = 0; i < len; i++) | |
896 | { | |
897 | f = TYPE_FN_FIELDLIST1 (domain, i); | |
898 | len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i); | |
899 | ||
900 | for (j = 0; j < len2; j++) | |
901 | { | |
902 | QUIT; | |
903 | if (!strcmp (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j))) | |
904 | goto common; | |
905 | } | |
906 | } | |
907 | } | |
908 | common: | |
909 | if (i < len) | |
910 | { | |
911 | fprintf_filtered (stream, "&"); | |
912 | type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0); | |
913 | fprintf (stream, kind); | |
914 | if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' | |
915 | && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER) | |
916 | type_print_method_args | |
917 | (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", | |
918 | TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream); | |
919 | else | |
920 | type_print_method_args | |
921 | (TYPE_FN_FIELD_ARGS (f, j), "", | |
922 | TYPE_FN_FIELDLIST_NAME (domain, i), 0, stream); | |
923 | break; | |
924 | } | |
925 | fprintf_filtered (stream, "("); | |
926 | type_print (type, "", stream, -1); | |
e1ce8aa5 | 927 | fprintf_filtered (stream, ") %d", (int) addr >> 3); |
bd5635a1 RP |
928 | } |
929 | else if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER) | |
930 | { | |
4a11eef2 FF |
931 | print_class_member (valaddr, |
932 | TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)), | |
933 | stream, "&"); | |
bd5635a1 RP |
934 | } |
935 | else | |
936 | { | |
e1ce8aa5 | 937 | CORE_ADDR addr = unpack_pointer (type, valaddr); |
bd5635a1 RP |
938 | elttype = TYPE_TARGET_TYPE (type); |
939 | ||
940 | if (TYPE_CODE (elttype) == TYPE_CODE_FUNC) | |
941 | { | |
942 | /* Try to print what function it points to. */ | |
943 | print_address_demangle (addr, stream, demangle); | |
944 | /* Return value is irrelevant except for string pointers. */ | |
945 | return 0; | |
946 | } | |
947 | ||
948 | if (addressprint && format != 's') | |
949 | fprintf_filtered (stream, "0x%x", addr); | |
950 | ||
951 | /* For a pointer to char or unsigned char, | |
952 | also print the string pointed to, unless pointer is null. */ | |
953 | i = 0; /* Number of characters printed. */ | |
954 | if (TYPE_LENGTH (elttype) == 1 | |
955 | && TYPE_CODE (elttype) == TYPE_CODE_INT | |
956 | && (format == 0 || format == 's') | |
957 | && addr != 0 | |
958 | /* If print_max is UINT_MAX, the alloca below will fail. | |
959 | In that case don't try to print the string. */ | |
960 | && print_max < UINT_MAX) | |
961 | { | |
962 | int first_addr_err = 0; | |
963 | int errcode = 0; | |
964 | ||
965 | /* Get first character. */ | |
966 | errcode = target_read_memory (addr, (char *)&c, 1); | |
967 | if (errcode != 0) | |
968 | { | |
969 | /* First address out of bounds. */ | |
970 | first_addr_err = 1; | |
971 | } | |
972 | else | |
973 | { | |
974 | /* A real string. */ | |
975 | char *string = (char *) alloca (print_max); | |
976 | ||
977 | /* If the loop ends by us hitting print_max characters, | |
978 | we need to have elipses at the end. */ | |
979 | int force_ellipses = 1; | |
980 | ||
981 | /* This loop always fetches print_max characters, even | |
982 | though print_string might want to print more or fewer | |
983 | (with repeated characters). This is so that | |
984 | we don't spend forever fetching if we print | |
985 | a long string consisting of the same character | |
986 | repeated. Also so we can do it all in one memory | |
987 | operation, which is faster. However, this will be | |
988 | slower if print_max is set high, e.g. if you set | |
989 | print_max to 1000, not only will it take a long | |
990 | time to fetch short strings, but if you are near | |
2cd99985 | 991 | the end of the address space, it might not work. */ |
bd5635a1 RP |
992 | QUIT; |
993 | errcode = target_read_memory (addr, string, print_max); | |
2cd99985 PB |
994 | if (errcode != 0) |
995 | { | |
996 | /* Try reading just one character. If that succeeds, | |
997 | assume we hit the end of the address space, but | |
998 | the initial part of the string is probably safe. */ | |
999 | char x[1]; | |
1000 | errcode = target_read_memory (addr, x, 1); | |
1001 | } | |
bd5635a1 RP |
1002 | if (errcode != 0) |
1003 | force_ellipses = 0; | |
1004 | else | |
1005 | for (i = 0; i < print_max; i++) | |
1006 | if (string[i] == '\0') | |
1007 | { | |
1008 | force_ellipses = 0; | |
1009 | break; | |
1010 | } | |
1011 | QUIT; | |
1012 | ||
1013 | if (addressprint) | |
1014 | fputs_filtered (" ", stream); | |
1015 | print_string (stream, string, i, force_ellipses); | |
1016 | } | |
1017 | ||
1018 | if (errcode != 0) | |
1019 | { | |
1020 | if (errcode == EIO) | |
1021 | { | |
1022 | fprintf_filtered (stream, | |
1023 | (" <Address 0x%x out of bounds>" | |
1024 | + first_addr_err), | |
1025 | addr + i); | |
1026 | } | |
1027 | else | |
1028 | { | |
4ace50a5 FF |
1029 | error ("Error reading memory address 0x%x: %s.", |
1030 | addr + i, safe_strerror (errcode)); | |
bd5635a1 RP |
1031 | } |
1032 | } | |
1033 | ||
1034 | fflush (stream); | |
1035 | } | |
1036 | else /* print vtbl's nicely */ | |
1037 | if (is_vtbl_member(type)) | |
1038 | { | |
e1ce8aa5 | 1039 | CORE_ADDR vt_address = unpack_pointer (type, valaddr); |
bd5635a1 | 1040 | |
2cd99985 PB |
1041 | struct minimal_symbol *msymbol = |
1042 | lookup_minimal_symbol_by_pc (vt_address); | |
1043 | if ((msymbol != NULL) && (vt_address == msymbol -> address)) | |
bd5635a1 RP |
1044 | { |
1045 | fputs_filtered (" <", stream); | |
8f793aa5 FF |
1046 | fputs_demangled (msymbol -> name, stream, |
1047 | DMGL_ANSI | DMGL_PARAMS); | |
bd5635a1 RP |
1048 | fputs_filtered (">", stream); |
1049 | } | |
1050 | if (vtblprint) | |
1051 | { | |
e1ce8aa5 | 1052 | value vt_val; |
bd5635a1 | 1053 | |
e1ce8aa5 JK |
1054 | vt_val = value_at (TYPE_TARGET_TYPE (type), vt_address); |
1055 | val_print (VALUE_TYPE (vt_val), VALUE_CONTENTS (vt_val), | |
1056 | VALUE_ADDRESS (vt_val), stream, format, | |
bd5635a1 RP |
1057 | deref_ref, recurse + 1, pretty); |
1058 | if (pretty) | |
1059 | { | |
1060 | fprintf_filtered (stream, "\n"); | |
1061 | print_spaces_filtered (2 + 2 * recurse, stream); | |
1062 | } | |
1063 | } | |
1064 | } | |
1065 | ||
1066 | /* Return number of characters printed, plus one for the | |
1067 | terminating null if we have "reached the end". */ | |
1068 | return i + (print_max && i != print_max); | |
1069 | } | |
1070 | break; | |
1071 | ||
1072 | case TYPE_CODE_MEMBER: | |
1073 | error ("not implemented: member type in val_print"); | |
1074 | break; | |
1075 | ||
1076 | case TYPE_CODE_REF: | |
4a11eef2 FF |
1077 | if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER) |
1078 | { | |
1079 | print_class_member (valaddr, | |
1080 | TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type)), | |
1081 | stream, ""); | |
1082 | break; | |
1083 | } | |
bd5635a1 RP |
1084 | if (addressprint) |
1085 | { | |
1086 | fprintf_filtered (stream, "@0x%lx", | |
1087 | unpack_long (builtin_type_int, valaddr)); | |
1088 | if (deref_ref) | |
1089 | fputs_filtered (": ", stream); | |
1090 | } | |
1091 | /* De-reference the reference. */ | |
1092 | if (deref_ref) | |
1093 | { | |
1094 | if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF) | |
1095 | { | |
e1ce8aa5 JK |
1096 | value deref_val = |
1097 | value_at | |
1098 | (TYPE_TARGET_TYPE (type), | |
1099 | unpack_pointer (lookup_pointer_type (builtin_type_void), | |
1100 | valaddr)); | |
1101 | val_print (VALUE_TYPE (deref_val), VALUE_CONTENTS (deref_val), | |
1102 | VALUE_ADDRESS (deref_val), stream, format, | |
bd5635a1 RP |
1103 | deref_ref, recurse + 1, pretty); |
1104 | } | |
1105 | else | |
1106 | fputs_filtered ("???", stream); | |
1107 | } | |
1108 | break; | |
1109 | ||
1110 | case TYPE_CODE_UNION: | |
1111 | if (recurse && !unionprint) | |
1112 | { | |
1113 | fprintf_filtered (stream, "{...}"); | |
1114 | break; | |
1115 | } | |
1116 | /* Fall through. */ | |
1117 | case TYPE_CODE_STRUCT: | |
1118 | if (vtblprint && is_vtbl_ptr_type(type)) | |
1119 | { | |
1120 | /* Print the unmangled name if desired. */ | |
1121 | print_address_demangle(*((int *) (valaddr + /* FIXME bytesex */ | |
1122 | TYPE_FIELD_BITPOS (type, VTBL_FNADDR_OFFSET) / 8)), | |
1123 | stream, demangle); | |
1124 | break; | |
1125 | } | |
1126 | val_print_fields (type, valaddr, stream, format, recurse, pretty, 0); | |
1127 | break; | |
1128 | ||
1129 | case TYPE_CODE_ENUM: | |
1130 | if (format) | |
1131 | { | |
1132 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
1133 | break; | |
1134 | } | |
1135 | len = TYPE_NFIELDS (type); | |
1136 | val = unpack_long (builtin_type_int, valaddr); | |
1137 | for (i = 0; i < len; i++) | |
1138 | { | |
1139 | QUIT; | |
1140 | if (val == TYPE_FIELD_BITPOS (type, i)) | |
1141 | break; | |
1142 | } | |
1143 | if (i < len) | |
1144 | fputs_filtered (TYPE_FIELD_NAME (type, i), stream); | |
1145 | else | |
e1ce8aa5 JK |
1146 | #ifdef LONG_LONG |
1147 | fprintf_filtered (stream, "%lld", val); | |
1148 | #else | |
1149 | fprintf_filtered (stream, "%ld", val); | |
1150 | #endif | |
bd5635a1 RP |
1151 | break; |
1152 | ||
1153 | case TYPE_CODE_FUNC: | |
1154 | if (format) | |
1155 | { | |
1156 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
1157 | break; | |
1158 | } | |
36b9d39c JG |
1159 | /* FIXME, we should consider, at least for ANSI C language, eliminating |
1160 | the distinction made between FUNCs and POINTERs to FUNCs. */ | |
bd5635a1 RP |
1161 | fprintf_filtered (stream, "{"); |
1162 | type_print (type, "", stream, -1); | |
1163 | fprintf_filtered (stream, "} "); | |
36b9d39c JG |
1164 | /* Try to print what function it points to, and its address. */ |
1165 | print_address_demangle (address, stream, demangle); | |
bd5635a1 RP |
1166 | break; |
1167 | ||
1168 | case TYPE_CODE_INT: | |
1169 | if (format || output_format) | |
1170 | { | |
1171 | print_scalar_formatted (valaddr, type, | |
1172 | format? format: output_format, | |
1173 | 0, stream); | |
1174 | break; | |
1175 | } | |
1176 | if (TYPE_LENGTH (type) > sizeof (LONGEST)) | |
1177 | { | |
1178 | if (TYPE_UNSIGNED (type)) | |
1179 | { | |
1180 | /* First figure out whether the number in fact has zeros | |
1181 | in all its bytes more significant than least significant | |
1182 | sizeof (LONGEST) ones. */ | |
1183 | char *p; | |
1184 | /* Pointer to first (i.e. lowest address) nonzero character. */ | |
1185 | char *first_addr; | |
e1ce8aa5 | 1186 | len = TYPE_LENGTH (type); |
bd5635a1 RP |
1187 | |
1188 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
1189 | for (p = valaddr; | |
1190 | len > sizeof (LONGEST) | |
1191 | && p < valaddr + TYPE_LENGTH (type); | |
1192 | p++) | |
1193 | #else /* Little endian. */ | |
1194 | first_addr = valaddr; | |
1195 | for (p = valaddr + TYPE_LENGTH (type); | |
1196 | len > sizeof (LONGEST) && p >= valaddr; | |
1197 | p--) | |
1198 | #endif /* Little endian. */ | |
1199 | { | |
1200 | if (*p == 0) | |
1201 | len--; | |
1202 | else | |
1203 | break; | |
1204 | } | |
1205 | #if TARGET_BYTE_ORDER == BIG_ENDIAN | |
1206 | first_addr = p; | |
1207 | #endif | |
1208 | ||
1209 | if (len <= sizeof (LONGEST)) | |
1210 | { | |
1211 | /* We can print it in decimal. */ | |
1212 | fprintf_filtered | |
1213 | (stream, | |
1214 | #if defined (LONG_LONG) | |
1215 | "%llu", | |
1216 | #else | |
1217 | "%lu", | |
1218 | #endif | |
1219 | unpack_long (BUILTIN_TYPE_LONGEST, first_addr)); | |
1220 | } | |
1221 | else | |
1222 | { | |
1223 | /* It is big, so print it in hex. */ | |
1224 | print_hex_chars (stream, (unsigned char *)first_addr, len); | |
1225 | } | |
1226 | } | |
1227 | else | |
1228 | { | |
1229 | /* Signed. One could assume two's complement (a reasonable | |
1230 | assumption, I think) and do better than this. */ | |
1231 | print_hex_chars (stream, (unsigned char *)valaddr, | |
1232 | TYPE_LENGTH (type)); | |
1233 | } | |
1234 | break; | |
1235 | } | |
1236 | #ifdef PRINT_TYPELESS_INTEGER | |
1237 | PRINT_TYPELESS_INTEGER (stream, type, unpack_long (type, valaddr)); | |
1238 | #else | |
1239 | #ifndef LONG_LONG | |
1240 | fprintf_filtered (stream, | |
1241 | TYPE_UNSIGNED (type) ? "%u" : "%d", | |
1242 | unpack_long (type, valaddr)); | |
1243 | #else | |
1244 | fprintf_filtered (stream, | |
1245 | TYPE_UNSIGNED (type) ? "%llu" : "%lld", | |
1246 | unpack_long (type, valaddr)); | |
1247 | #endif | |
1248 | #endif | |
1249 | ||
1250 | if (TYPE_LENGTH (type) == 1) | |
1251 | { | |
1252 | fprintf_filtered (stream, " '"); | |
1253 | printchar ((unsigned char) unpack_long (type, valaddr), | |
1254 | stream, '\''); | |
1255 | fprintf_filtered (stream, "'"); | |
1256 | } | |
1257 | break; | |
1258 | ||
1259 | case TYPE_CODE_FLT: | |
1260 | if (format) | |
1261 | print_scalar_formatted (valaddr, type, format, 0, stream); | |
1262 | else | |
1263 | print_floating (valaddr, type, stream); | |
1264 | break; | |
1265 | ||
1266 | case TYPE_CODE_VOID: | |
1267 | fprintf_filtered (stream, "void"); | |
1268 | break; | |
1269 | ||
1270 | case TYPE_CODE_UNDEF: | |
1271 | /* This happens (without TYPE_FLAG_STUB set) on systems which don't use | |
1272 | dbx xrefs (NO_DBX_XREFS in gcc) if a file has a "struct foo *bar" | |
1273 | and no complete type for struct foo in that file. */ | |
1274 | fprintf_filtered (stream, "<unknown struct>"); | |
1275 | break; | |
1276 | ||
1277 | case TYPE_CODE_ERROR: | |
1278 | fprintf_filtered (stream, "?"); | |
1279 | break; | |
1280 | ||
e2aab031 FF |
1281 | case TYPE_CODE_RANGE: |
1282 | /* FIXME, we should not ever have to print one of these yet. */ | |
1283 | fprintf_filtered (stream, "<range type>"); | |
1284 | break; | |
1285 | ||
bd5635a1 RP |
1286 | default: |
1287 | error ("Invalid type code in symbol table."); | |
1288 | } | |
1289 | fflush (stream); | |
1290 | return 0; | |
1291 | } | |
1292 | \f | |
be3bc7ad JG |
1293 | /* Print a description of a type in the format of a |
1294 | typedef for the current language. | |
1295 | NEW is the new name for a type TYPE. */ | |
1296 | void | |
1297 | typedef_print (type, new, stream) | |
1298 | struct type *type; | |
1299 | struct symbol *new; | |
1300 | FILE *stream; | |
1301 | { | |
1302 | switch (current_language->la_language) | |
1303 | { | |
1304 | #ifdef _LANG_c | |
1305 | case language_c: | |
7d9884b9 | 1306 | case language_cplus: |
be3bc7ad JG |
1307 | fprintf_filtered(stream, "typedef "); |
1308 | type_print(type,"",stream,0); | |
1309 | if(TYPE_NAME ((SYMBOL_TYPE (new))) == 0 | |
1310 | || 0 != strcmp (TYPE_NAME ((SYMBOL_TYPE (new))), | |
1311 | SYMBOL_NAME (new))) | |
1312 | fprintf_filtered(stream, " %s", SYMBOL_NAME(new)); | |
1313 | break; | |
1314 | #endif | |
1315 | #ifdef _LANG_m2 | |
1316 | case language_m2: | |
1317 | fprintf_filtered(stream, "TYPE "); | |
1318 | if(!TYPE_NAME(SYMBOL_TYPE(new)) || | |
1319 | strcmp (TYPE_NAME(SYMBOL_TYPE(new)), | |
1320 | SYMBOL_NAME(new))) | |
1321 | fprintf_filtered(stream, "%s = ", SYMBOL_NAME(new)); | |
1322 | else | |
1323 | fprintf_filtered(stream, "<builtin> = "); | |
1324 | type_print(type,"",stream,0); | |
1325 | break; | |
1326 | #endif | |
1327 | default: | |
1328 | error("Language not supported."); | |
1329 | } | |
1330 | fprintf_filtered(stream, ";\n"); | |
1331 | } | |
1332 | ||
1333 | ||
bd5635a1 RP |
1334 | /* Print a description of a type TYPE |
1335 | in the form of a declaration of a variable named VARSTRING. | |
1336 | (VARSTRING is demangled if necessary.) | |
1337 | Output goes to STREAM (via stdio). | |
1338 | If SHOW is positive, we show the contents of the outermost level | |
1339 | of structure even if there is a type name that could be used instead. | |
1340 | If SHOW is negative, we never show the details of elements' types. */ | |
1341 | ||
1342 | void | |
1343 | type_print (type, varstring, stream, show) | |
1344 | struct type *type; | |
1345 | char *varstring; | |
1346 | FILE *stream; | |
1347 | int show; | |
1348 | { | |
1349 | type_print_1 (type, varstring, stream, show, 0); | |
1350 | } | |
1351 | ||
1352 | /* LEVEL is the depth to indent lines by. */ | |
1353 | ||
1354 | void | |
1355 | type_print_1 (type, varstring, stream, show, level) | |
1356 | struct type *type; | |
1357 | char *varstring; | |
1358 | FILE *stream; | |
1359 | int show; | |
1360 | int level; | |
1361 | { | |
1362 | register enum type_code code; | |
4341615d FF |
1363 | char *demangled = NULL; |
1364 | int demangled_args; | |
f9b5584c | 1365 | |
bd5635a1 RP |
1366 | type_print_base (type, stream, show, level); |
1367 | code = TYPE_CODE (type); | |
1368 | if ((varstring && *varstring) | |
1369 | || | |
1370 | /* Need a space if going to print stars or brackets; | |
1371 | but not if we will print just a type name. */ | |
1372 | ((show > 0 || TYPE_NAME (type) == 0) | |
1373 | && | |
1374 | (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC | |
1375 | || code == TYPE_CODE_METHOD | |
1376 | || code == TYPE_CODE_ARRAY | |
1377 | || code == TYPE_CODE_MEMBER | |
1378 | || code == TYPE_CODE_REF))) | |
1379 | fprintf_filtered (stream, " "); | |
1380 | type_print_varspec_prefix (type, stream, show, 0); | |
4341615d FF |
1381 | |
1382 | /* See if the name has a C++ demangled equivalent, and if so, print that | |
1383 | instead. */ | |
1384 | ||
f9b5584c FF |
1385 | if (demangle) |
1386 | { | |
1387 | demangled = cplus_demangle (varstring, DMGL_ANSI | DMGL_PARAMS); | |
1388 | } | |
4341615d FF |
1389 | fputs_filtered ((demangled != NULL) ? demangled : varstring, stream); |
1390 | ||
1391 | /* For demangled function names, we have the arglist as part of the name, | |
1392 | so don't print an additional pair of ()'s */ | |
1393 | ||
1394 | demangled_args = (demangled != NULL) && (code == TYPE_CODE_FUNC); | |
1395 | type_print_varspec_suffix (type, stream, show, 0, demangled_args); | |
1396 | ||
1397 | if (demangled) | |
f9b5584c | 1398 | { |
f9b5584c FF |
1399 | free (demangled); |
1400 | } | |
bd5635a1 RP |
1401 | } |
1402 | ||
1403 | /* Print the method arguments ARGS to the file STREAM. */ | |
1404 | static void | |
1405 | type_print_method_args (args, prefix, varstring, staticp, stream) | |
1406 | struct type **args; | |
1407 | char *prefix, *varstring; | |
1408 | int staticp; | |
1409 | FILE *stream; | |
1410 | { | |
1411 | int i; | |
1412 | ||
8f793aa5 FF |
1413 | fputs_demangled (prefix, stream, DMGL_ANSI | DMGL_PARAMS); |
1414 | fputs_demangled (varstring, stream, DMGL_ANSI | DMGL_PARAMS); | |
bd5635a1 RP |
1415 | fputs_filtered (" (", stream); |
1416 | if (args && args[!staticp] && args[!staticp]->code != TYPE_CODE_VOID) | |
1417 | { | |
1418 | i = !staticp; /* skip the class variable */ | |
1419 | while (1) | |
1420 | { | |
1421 | type_print (args[i++], "", stream, 0); | |
1422 | if (!args[i]) | |
1423 | { | |
1424 | fprintf_filtered (stream, " ..."); | |
1425 | break; | |
1426 | } | |
1427 | else if (args[i]->code != TYPE_CODE_VOID) | |
1428 | { | |
1429 | fprintf_filtered (stream, ", "); | |
1430 | } | |
1431 | else break; | |
1432 | } | |
1433 | } | |
1434 | fprintf_filtered (stream, ")"); | |
1435 | } | |
1436 | ||
9e4667f6 FF |
1437 | /* If TYPE is a derived type, then print out derivation information. |
1438 | Print only the actual base classes of this type, not the base classes | |
1439 | of the base classes. I.E. for the derivation hierarchy: | |
1440 | ||
1441 | class A { int a; }; | |
1442 | class B : public A {int b; }; | |
1443 | class C : public B {int c; }; | |
1444 | ||
1445 | Print the type of class C as: | |
1446 | ||
1447 | class C : public B { | |
1448 | int c; | |
1449 | } | |
1450 | ||
1451 | Not as the following (like gdb used to), which is not legal C++ syntax for | |
1452 | derived types and may be confused with the multiple inheritance form: | |
1453 | ||
1454 | class C : public B : public A { | |
1455 | int c; | |
1456 | } | |
1457 | ||
1458 | In general, gdb should try to print the types as closely as possible to | |
1459 | the form that they appear in the source code. */ | |
1460 | ||
bd5635a1 RP |
1461 | static void |
1462 | type_print_derivation_info (stream, type) | |
1463 | FILE *stream; | |
1464 | struct type *type; | |
1465 | { | |
1466 | char *name; | |
9e4667f6 | 1467 | int i; |
bd5635a1 | 1468 | |
9e4667f6 | 1469 | for (i = 0; i < TYPE_N_BASECLASSES (type); i++) |
bd5635a1 | 1470 | { |
9e4667f6 FF |
1471 | fputs_filtered (i == 0 ? ": " : ", ", stream); |
1472 | fprintf_filtered (stream, "%s%s ", | |
1473 | BASETYPE_VIA_PUBLIC (type, i) ? "public" : "private", | |
1474 | BASETYPE_VIA_VIRTUAL(type, i) ? " virtual" : ""); | |
1475 | name = type_name_no_tag (TYPE_BASECLASS (type, i)); | |
35fcebce PB |
1476 | fprintf_filtered (stream, "%s", name ? name : "(null)"); |
1477 | } | |
1478 | if (i > 0) | |
1479 | { | |
1480 | fputs_filtered (" ", stream); | |
bd5635a1 RP |
1481 | } |
1482 | } | |
1483 | ||
1484 | /* Print any asterisks or open-parentheses needed before the | |
1485 | variable name (to describe its type). | |
1486 | ||
1487 | On outermost call, pass 0 for PASSED_A_PTR. | |
1488 | On outermost call, SHOW > 0 means should ignore | |
1489 | any typename for TYPE and show its details. | |
1490 | SHOW is always zero on recursive calls. */ | |
1491 | ||
1492 | static void | |
1493 | type_print_varspec_prefix (type, stream, show, passed_a_ptr) | |
1494 | struct type *type; | |
1495 | FILE *stream; | |
1496 | int show; | |
1497 | int passed_a_ptr; | |
1498 | { | |
4a11eef2 | 1499 | char *name; |
bd5635a1 RP |
1500 | if (type == 0) |
1501 | return; | |
1502 | ||
1503 | if (TYPE_NAME (type) && show <= 0) | |
1504 | return; | |
1505 | ||
1506 | QUIT; | |
1507 | ||
1508 | switch (TYPE_CODE (type)) | |
1509 | { | |
1510 | case TYPE_CODE_PTR: | |
1511 | type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); | |
1512 | fprintf_filtered (stream, "*"); | |
1513 | break; | |
1514 | ||
1515 | case TYPE_CODE_MEMBER: | |
1516 | if (passed_a_ptr) | |
1517 | fprintf_filtered (stream, "("); | |
1518 | type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, | |
1519 | 0); | |
1520 | fprintf_filtered (stream, " "); | |
4a11eef2 FF |
1521 | name = type_name_no_tag (TYPE_DOMAIN_TYPE (type)); |
1522 | if (name) | |
1523 | fputs_filtered (name, stream); | |
1524 | else | |
1525 | type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, passed_a_ptr); | |
bd5635a1 RP |
1526 | fprintf_filtered (stream, "::"); |
1527 | break; | |
1528 | ||
1529 | case TYPE_CODE_METHOD: | |
1530 | if (passed_a_ptr) | |
1531 | fprintf (stream, "("); | |
1532 | type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, | |
1533 | 0); | |
0dce3774 JK |
1534 | if (passed_a_ptr) |
1535 | { | |
1536 | fprintf_filtered (stream, " "); | |
1537 | type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0, | |
1538 | passed_a_ptr); | |
1539 | fprintf_filtered (stream, "::"); | |
1540 | } | |
bd5635a1 RP |
1541 | break; |
1542 | ||
1543 | case TYPE_CODE_REF: | |
1544 | type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1); | |
1545 | fprintf_filtered (stream, "&"); | |
1546 | break; | |
1547 | ||
1548 | case TYPE_CODE_FUNC: | |
1549 | type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, | |
1550 | 0); | |
1551 | if (passed_a_ptr) | |
1552 | fprintf_filtered (stream, "("); | |
1553 | break; | |
1554 | ||
1555 | case TYPE_CODE_ARRAY: | |
1556 | type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, | |
1557 | 0); | |
1558 | if (passed_a_ptr) | |
1559 | fprintf_filtered (stream, "("); | |
2a5ec41d | 1560 | break; |
bd5635a1 RP |
1561 | |
1562 | case TYPE_CODE_UNDEF: | |
1563 | case TYPE_CODE_STRUCT: | |
1564 | case TYPE_CODE_UNION: | |
1565 | case TYPE_CODE_ENUM: | |
1566 | case TYPE_CODE_INT: | |
1567 | case TYPE_CODE_FLT: | |
1568 | case TYPE_CODE_VOID: | |
1569 | case TYPE_CODE_ERROR: | |
7d9884b9 JG |
1570 | case TYPE_CODE_CHAR: |
1571 | case TYPE_CODE_BOOL: | |
51b57ded FF |
1572 | case TYPE_CODE_SET: |
1573 | case TYPE_CODE_RANGE: | |
1574 | case TYPE_CODE_PASCAL_ARRAY: | |
bd5635a1 RP |
1575 | /* These types need no prefix. They are listed here so that |
1576 | gcc -Wall will reveal any types that haven't been handled. */ | |
1577 | break; | |
1578 | } | |
1579 | } | |
1580 | ||
9e4667f6 FF |
1581 | static void |
1582 | type_print_args (type, stream) | |
1583 | struct type *type; | |
1584 | FILE *stream; | |
1585 | { | |
1586 | int i; | |
1587 | struct type **args; | |
1588 | ||
1589 | fprintf_filtered (stream, "("); | |
1590 | args = TYPE_ARG_TYPES (type); | |
1591 | if (args != NULL) | |
1592 | { | |
1593 | if (args[1] == NULL) | |
1594 | { | |
1595 | fprintf_filtered (stream, "..."); | |
1596 | } | |
1597 | else | |
1598 | { | |
1599 | for (i = 1; | |
1600 | args[i] != NULL && args[i]->code != TYPE_CODE_VOID; | |
1601 | i++) | |
1602 | { | |
1603 | type_print_1 (args[i], "", stream, -1, 0); | |
1604 | if (args[i+1] == NULL) | |
1605 | { | |
1606 | fprintf_filtered (stream, "..."); | |
1607 | } | |
1608 | else if (args[i+1]->code != TYPE_CODE_VOID) | |
1609 | { | |
1610 | fprintf_filtered (stream, ","); | |
1611 | wrap_here (" "); | |
1612 | } | |
1613 | } | |
1614 | } | |
1615 | } | |
1616 | fprintf_filtered (stream, ")"); | |
1617 | } | |
1618 | ||
bd5635a1 RP |
1619 | /* Print any array sizes, function arguments or close parentheses |
1620 | needed after the variable name (to describe its type). | |
1621 | Args work like type_print_varspec_prefix. */ | |
1622 | ||
1623 | static void | |
f9b5584c | 1624 | type_print_varspec_suffix (type, stream, show, passed_a_ptr, demangled_args) |
bd5635a1 RP |
1625 | struct type *type; |
1626 | FILE *stream; | |
1627 | int show; | |
1628 | int passed_a_ptr; | |
f9b5584c | 1629 | int demangled_args; |
bd5635a1 RP |
1630 | { |
1631 | if (type == 0) | |
1632 | return; | |
1633 | ||
1634 | if (TYPE_NAME (type) && show <= 0) | |
1635 | return; | |
1636 | ||
1637 | QUIT; | |
1638 | ||
1639 | switch (TYPE_CODE (type)) | |
1640 | { | |
1641 | case TYPE_CODE_ARRAY: | |
1642 | if (passed_a_ptr) | |
1643 | fprintf_filtered (stream, ")"); | |
1644 | ||
1645 | fprintf_filtered (stream, "["); | |
bee3c1a1 JG |
1646 | if (TYPE_LENGTH (type) > 0 |
1647 | && TYPE_LENGTH (TYPE_TARGET_TYPE (type)) > 0) | |
bd5635a1 RP |
1648 | fprintf_filtered (stream, "%d", |
1649 | (TYPE_LENGTH (type) | |
1650 | / TYPE_LENGTH (TYPE_TARGET_TYPE (type)))); | |
1651 | fprintf_filtered (stream, "]"); | |
1652 | ||
1653 | type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, | |
f9b5584c | 1654 | 0, 0); |
bd5635a1 RP |
1655 | break; |
1656 | ||
1657 | case TYPE_CODE_MEMBER: | |
1658 | if (passed_a_ptr) | |
1659 | fprintf_filtered (stream, ")"); | |
f9b5584c | 1660 | type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0); |
bd5635a1 RP |
1661 | break; |
1662 | ||
1663 | case TYPE_CODE_METHOD: | |
1664 | if (passed_a_ptr) | |
1665 | fprintf_filtered (stream, ")"); | |
f9b5584c | 1666 | type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0, 0); |
bd5635a1 RP |
1667 | if (passed_a_ptr) |
1668 | { | |
9e4667f6 | 1669 | type_print_args (type, stream); |
bd5635a1 RP |
1670 | } |
1671 | break; | |
1672 | ||
1673 | case TYPE_CODE_PTR: | |
1674 | case TYPE_CODE_REF: | |
f9b5584c | 1675 | type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1, 0); |
bd5635a1 RP |
1676 | break; |
1677 | ||
1678 | case TYPE_CODE_FUNC: | |
1679 | type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, | |
f9b5584c | 1680 | passed_a_ptr, 0); |
bd5635a1 RP |
1681 | if (passed_a_ptr) |
1682 | fprintf_filtered (stream, ")"); | |
f9b5584c FF |
1683 | if (!demangled_args) |
1684 | fprintf_filtered (stream, "()"); | |
bd5635a1 RP |
1685 | break; |
1686 | ||
1687 | case TYPE_CODE_UNDEF: | |
1688 | case TYPE_CODE_STRUCT: | |
1689 | case TYPE_CODE_UNION: | |
1690 | case TYPE_CODE_ENUM: | |
1691 | case TYPE_CODE_INT: | |
1692 | case TYPE_CODE_FLT: | |
1693 | case TYPE_CODE_VOID: | |
1694 | case TYPE_CODE_ERROR: | |
7d9884b9 JG |
1695 | case TYPE_CODE_CHAR: |
1696 | case TYPE_CODE_BOOL: | |
51b57ded FF |
1697 | case TYPE_CODE_SET: |
1698 | case TYPE_CODE_RANGE: | |
1699 | case TYPE_CODE_PASCAL_ARRAY: | |
bd5635a1 RP |
1700 | /* These types do not need a suffix. They are listed so that |
1701 | gcc -Wall will report types that may not have been considered. */ | |
1702 | break; | |
1703 | } | |
1704 | } | |
1705 | ||
1706 | /* Print the name of the type (or the ultimate pointer target, | |
1707 | function value or array element), or the description of a | |
1708 | structure or union. | |
1709 | ||
1710 | SHOW nonzero means don't print this type as just its name; | |
1711 | show its real definition even if it has a name. | |
1712 | SHOW zero means print just typename or struct tag if there is one | |
1713 | SHOW negative means abbreviate structure elements. | |
1714 | SHOW is decremented for printing of structure elements. | |
1715 | ||
1716 | LEVEL is the depth to indent by. | |
1717 | We increase it for some recursive calls. */ | |
1718 | ||
1719 | static void | |
1720 | type_print_base (type, stream, show, level) | |
1721 | struct type *type; | |
1722 | FILE *stream; | |
1723 | int show; | |
1724 | int level; | |
1725 | { | |
1726 | char *name; | |
1727 | register int i; | |
1728 | register int len; | |
1729 | register int lastval; | |
4341615d FF |
1730 | char *mangled_name; |
1731 | char *demangled_name; | |
8050a57b | 1732 | enum {s_none, s_public, s_private, s_protected} section_type; |
bd5635a1 RP |
1733 | QUIT; |
1734 | ||
8ffd75c8 | 1735 | wrap_here (" "); |
4ace50a5 | 1736 | if (type == NULL) |
bd5635a1 | 1737 | { |
4ace50a5 | 1738 | fputs_filtered ("<type unknown>", stream); |
bd5635a1 RP |
1739 | return; |
1740 | } | |
1741 | ||
4ace50a5 FF |
1742 | /* When SHOW is zero or less, and there is a valid type name, then always |
1743 | just print the type name directly from the type. */ | |
4a11eef2 | 1744 | |
4ace50a5 | 1745 | if ((show <= 0) && (TYPE_NAME (type) != NULL)) |
bd5635a1 RP |
1746 | { |
1747 | fputs_filtered (TYPE_NAME (type), stream); | |
1748 | return; | |
1749 | } | |
1750 | ||
1751 | switch (TYPE_CODE (type)) | |
1752 | { | |
1753 | case TYPE_CODE_ARRAY: | |
1754 | case TYPE_CODE_PTR: | |
1755 | case TYPE_CODE_MEMBER: | |
1756 | case TYPE_CODE_REF: | |
1757 | case TYPE_CODE_FUNC: | |
1758 | case TYPE_CODE_METHOD: | |
1759 | type_print_base (TYPE_TARGET_TYPE (type), stream, show, level); | |
1760 | break; | |
1761 | ||
1762 | case TYPE_CODE_STRUCT: | |
8050a57b FF |
1763 | fprintf_filtered (stream, |
1764 | HAVE_CPLUS_STRUCT (type) ? "class " : "struct "); | |
bd5635a1 RP |
1765 | goto struct_union; |
1766 | ||
1767 | case TYPE_CODE_UNION: | |
1768 | fprintf_filtered (stream, "union "); | |
1769 | struct_union: | |
1770 | if (name = type_name_no_tag (type)) | |
1771 | { | |
1772 | fputs_filtered (name, stream); | |
1773 | fputs_filtered (" ", stream); | |
8ffd75c8 | 1774 | wrap_here (" "); |
bd5635a1 RP |
1775 | } |
1776 | if (show < 0) | |
1777 | fprintf_filtered (stream, "{...}"); | |
1778 | else | |
1779 | { | |
1780 | check_stub_type (type); | |
1781 | ||
1782 | type_print_derivation_info (stream, type); | |
1783 | ||
9e4667f6 FF |
1784 | fprintf_filtered (stream, "{\n"); |
1785 | if ((TYPE_NFIELDS (type) == 0) && (TYPE_NFN_FIELDS (type) == 0)) | |
bd5635a1 RP |
1786 | { |
1787 | if (TYPE_FLAGS (type) & TYPE_FLAG_STUB) | |
9e4667f6 | 1788 | fprintfi_filtered (level + 4, stream, "<incomplete type>\n"); |
bd5635a1 | 1789 | else |
9e4667f6 | 1790 | fprintfi_filtered (level + 4, stream, "<no data fields>\n"); |
bd5635a1 RP |
1791 | } |
1792 | ||
9e4667f6 FF |
1793 | /* Start off with no specific section type, so we can print |
1794 | one for the first field we find, and use that section type | |
1795 | thereafter until we find another type. */ | |
1796 | ||
1797 | section_type = s_none; | |
1798 | ||
bd5635a1 RP |
1799 | /* If there is a base class for this type, |
1800 | do not print the field that it occupies. */ | |
8050a57b | 1801 | |
9e4667f6 | 1802 | len = TYPE_NFIELDS (type); |
bd5635a1 RP |
1803 | for (i = TYPE_N_BASECLASSES (type); i < len; i++) |
1804 | { | |
1805 | QUIT; | |
1806 | /* Don't print out virtual function table. */ | |
1807 | if ((TYPE_FIELD_NAME (type, i))[5] == CPLUS_MARKER && | |
1808 | !strncmp (TYPE_FIELD_NAME (type, i), "_vptr", 5)) | |
1809 | continue; | |
1810 | ||
8050a57b FF |
1811 | /* If this is a C++ class we can print the various C++ section |
1812 | labels. */ | |
1813 | ||
1814 | if (HAVE_CPLUS_STRUCT (type)) | |
1815 | { | |
1816 | if (TYPE_FIELD_PROTECTED (type, i)) | |
1817 | { | |
1818 | if (section_type != s_protected) | |
1819 | { | |
1820 | section_type = s_protected; | |
9e4667f6 FF |
1821 | fprintfi_filtered (level + 2, stream, |
1822 | "protected:\n"); | |
8050a57b FF |
1823 | } |
1824 | } | |
1825 | else if (TYPE_FIELD_PRIVATE (type, i)) | |
1826 | { | |
1827 | if (section_type != s_private) | |
1828 | { | |
1829 | section_type = s_private; | |
9e4667f6 | 1830 | fprintfi_filtered (level + 2, stream, "private:\n"); |
8050a57b FF |
1831 | } |
1832 | } | |
1833 | else | |
1834 | { | |
1835 | if (section_type != s_public) | |
1836 | { | |
1837 | section_type = s_public; | |
9e4667f6 | 1838 | fprintfi_filtered (level + 2, stream, "public:\n"); |
8050a57b FF |
1839 | } |
1840 | } | |
1841 | } | |
1842 | ||
bd5635a1 RP |
1843 | print_spaces_filtered (level + 4, stream); |
1844 | if (TYPE_FIELD_STATIC (type, i)) | |
1845 | { | |
1846 | fprintf_filtered (stream, "static "); | |
1847 | } | |
1848 | type_print_1 (TYPE_FIELD_TYPE (type, i), | |
1849 | TYPE_FIELD_NAME (type, i), | |
1850 | stream, show - 1, level + 4); | |
2640f7e1 | 1851 | if (!TYPE_FIELD_STATIC (type, i) |
bd5635a1 RP |
1852 | && TYPE_FIELD_PACKED (type, i)) |
1853 | { | |
1854 | /* It is a bitfield. This code does not attempt | |
1855 | to look at the bitpos and reconstruct filler, | |
1856 | unnamed fields. This would lead to misleading | |
1857 | results if the compiler does not put out fields | |
1858 | for such things (I don't know what it does). */ | |
1859 | fprintf_filtered (stream, " : %d", | |
1860 | TYPE_FIELD_BITSIZE (type, i)); | |
1861 | } | |
1862 | fprintf_filtered (stream, ";\n"); | |
1863 | } | |
1864 | ||
35fcebce | 1865 | /* C++: print out the methods */ |
2640f7e1 | 1866 | len = TYPE_NFN_FIELDS (type); |
bd5635a1 RP |
1867 | for (i = 0; i < len; i++) |
1868 | { | |
1869 | struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i); | |
1870 | int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i); | |
24b2fbdc | 1871 | char *method_name = TYPE_FN_FIELDLIST_NAME (type, i); |
2cd99985 | 1872 | int is_constructor = name && strcmp(method_name, name) == 0; |
bd5635a1 RP |
1873 | for (j = 0; j < len2; j++) |
1874 | { | |
1875 | QUIT; | |
9e4667f6 FF |
1876 | if (TYPE_FN_FIELD_PROTECTED (f, j)) |
1877 | { | |
1878 | if (section_type != s_protected) | |
1879 | { | |
1880 | section_type = s_protected; | |
1881 | fprintfi_filtered (level + 2, stream, | |
1882 | "protected:\n"); | |
1883 | } | |
1884 | } | |
1885 | else if (TYPE_FN_FIELD_PRIVATE (f, j)) | |
1886 | { | |
1887 | if (section_type != s_private) | |
1888 | { | |
1889 | section_type = s_private; | |
1890 | fprintfi_filtered (level + 2, stream, "private:\n"); | |
1891 | } | |
1892 | } | |
1893 | else | |
1894 | { | |
1895 | if (section_type != s_public) | |
1896 | { | |
1897 | section_type = s_public; | |
1898 | fprintfi_filtered (level + 2, stream, "public:\n"); | |
1899 | } | |
1900 | } | |
1901 | ||
bd5635a1 RP |
1902 | print_spaces_filtered (level + 4, stream); |
1903 | if (TYPE_FN_FIELD_VIRTUAL_P (f, j)) | |
1904 | fprintf_filtered (stream, "virtual "); | |
1905 | else if (TYPE_FN_FIELD_STATIC_P (f, j)) | |
1906 | fprintf_filtered (stream, "static "); | |
aec4cb91 MT |
1907 | if (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)) == 0) |
1908 | { | |
1909 | /* Keep GDB from crashing here. */ | |
1910 | fprintf (stream, "<undefined type> %s;\n", | |
1911 | TYPE_FN_FIELD_PHYSNAME (f, j)); | |
1912 | break; | |
1913 | } | |
24b2fbdc PB |
1914 | else if (!is_constructor) |
1915 | { | |
1916 | type_print (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j)), | |
1917 | "", stream, 0); | |
1918 | fputs_filtered (" ", stream); | |
1919 | } | |
1920 | if (TYPE_FN_FIELD_STUB (f, j)) | |
bd5635a1 RP |
1921 | { |
1922 | /* Build something we can demangle. */ | |
4341615d FF |
1923 | mangled_name = gdb_mangle_name (type, i, j); |
1924 | demangled_name = | |
8f793aa5 FF |
1925 | cplus_demangle (mangled_name, |
1926 | DMGL_ANSI | DMGL_PARAMS); | |
4341615d | 1927 | if (demangled_name == NULL) |
24b2fbdc | 1928 | fprintf_filtered (stream, "<badly mangled name %s>", |
bd5635a1 RP |
1929 | mangled_name); |
1930 | else | |
1931 | { | |
24b2fbdc | 1932 | fprintf_filtered (stream, "%s", |
bd5635a1 RP |
1933 | strchr (demangled_name, ':') + 2); |
1934 | free (demangled_name); | |
1935 | } | |
1936 | free (mangled_name); | |
1937 | } | |
1938 | else if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_' | |
1939 | && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == CPLUS_MARKER) | |
1940 | type_print_method_args | |
1941 | (TYPE_FN_FIELD_ARGS (f, j) + 1, "~", | |
24b2fbdc | 1942 | method_name, 0, stream); |
bd5635a1 RP |
1943 | else |
1944 | type_print_method_args | |
1945 | (TYPE_FN_FIELD_ARGS (f, j), "", | |
24b2fbdc | 1946 | method_name, |
bd5635a1 RP |
1947 | TYPE_FN_FIELD_STATIC_P (f, j), stream); |
1948 | ||
1949 | fprintf_filtered (stream, ";\n"); | |
1950 | } | |
1951 | } | |
1952 | ||
9e4667f6 | 1953 | fprintfi_filtered (level, stream, "}"); |
bd5635a1 RP |
1954 | } |
1955 | break; | |
1956 | ||
1957 | case TYPE_CODE_ENUM: | |
1958 | fprintf_filtered (stream, "enum "); | |
1959 | if (name = type_name_no_tag (type)) | |
1960 | { | |
1961 | fputs_filtered (name, stream); | |
1962 | fputs_filtered (" ", stream); | |
1963 | } | |
8ffd75c8 | 1964 | wrap_here (" "); |
bd5635a1 RP |
1965 | if (show < 0) |
1966 | fprintf_filtered (stream, "{...}"); | |
1967 | else | |
1968 | { | |
1969 | fprintf_filtered (stream, "{"); | |
1970 | len = TYPE_NFIELDS (type); | |
1971 | lastval = 0; | |
1972 | for (i = 0; i < len; i++) | |
1973 | { | |
1974 | QUIT; | |
1975 | if (i) fprintf_filtered (stream, ", "); | |
8ffd75c8 | 1976 | wrap_here (" "); |
bd5635a1 RP |
1977 | fputs_filtered (TYPE_FIELD_NAME (type, i), stream); |
1978 | if (lastval != TYPE_FIELD_BITPOS (type, i)) | |
1979 | { | |
1980 | fprintf_filtered (stream, " = %d", TYPE_FIELD_BITPOS (type, i)); | |
1981 | lastval = TYPE_FIELD_BITPOS (type, i); | |
1982 | } | |
1983 | lastval++; | |
1984 | } | |
1985 | fprintf_filtered (stream, "}"); | |
1986 | } | |
1987 | break; | |
1988 | ||
bd5635a1 RP |
1989 | case TYPE_CODE_VOID: |
1990 | fprintf_filtered (stream, "void"); | |
1991 | break; | |
1992 | ||
e2aab031 FF |
1993 | case TYPE_CODE_UNDEF: |
1994 | fprintf_filtered (stream, "struct <unknown>"); | |
bd5635a1 RP |
1995 | break; |
1996 | ||
1997 | case TYPE_CODE_ERROR: | |
1998 | fprintf_filtered (stream, "<unknown type>"); | |
1999 | break; | |
2000 | ||
e2aab031 FF |
2001 | case TYPE_CODE_RANGE: |
2002 | /* This should not occur */ | |
2003 | fprintf_filtered (stream, "<range type>"); | |
2004 | break; | |
2005 | ||
bd5635a1 | 2006 | default: |
4ace50a5 FF |
2007 | /* Handle types not explicitly handled by the other cases, |
2008 | such as fundamental types. For these, just print whatever | |
2009 | the type name is, as recorded in the type itself. If there | |
2010 | is no type name, then complain. */ | |
2011 | if (TYPE_NAME (type) != NULL) | |
2012 | { | |
2013 | fputs_filtered (TYPE_NAME (type), stream); | |
2014 | } | |
2015 | else | |
2016 | { | |
2017 | error ("Invalid type code (%d) in symbol table.", TYPE_CODE (type)); | |
2018 | } | |
2019 | break; | |
bd5635a1 RP |
2020 | } |
2021 | } | |
2022 | \f | |
e1ce8aa5 | 2023 | #if 0 |
bd5635a1 RP |
2024 | /* Validate an input or output radix setting, and make sure the user |
2025 | knows what they really did here. Radix setting is confusing, e.g. | |
2026 | setting the input radix to "10" never changes it! */ | |
2027 | ||
e1ce8aa5 | 2028 | /* ARGSUSED */ |
bd5635a1 RP |
2029 | static void |
2030 | set_input_radix (args, from_tty, c) | |
2031 | char *args; | |
2032 | int from_tty; | |
2033 | struct cmd_list_element *c; | |
2034 | { | |
2035 | unsigned radix = *(unsigned *)c->var; | |
2036 | ||
2037 | if (from_tty) | |
2038 | printf_filtered ("Input radix set to decimal %d, hex %x, octal %o\n", | |
2039 | radix, radix, radix); | |
2040 | } | |
e1ce8aa5 | 2041 | #endif |
bd5635a1 | 2042 | |
e1ce8aa5 | 2043 | /* ARGSUSED */ |
bd5635a1 RP |
2044 | static void |
2045 | set_output_radix (args, from_tty, c) | |
2046 | char *args; | |
2047 | int from_tty; | |
2048 | struct cmd_list_element *c; | |
2049 | { | |
2050 | unsigned radix = *(unsigned *)c->var; | |
2051 | ||
2052 | if (from_tty) | |
2053 | printf_filtered ("Output radix set to decimal %d, hex %x, octal %o\n", | |
2054 | radix, radix, radix); | |
2055 | ||
2056 | /* FIXME, we really should be able to validate the setting BEFORE | |
2057 | it takes effect. */ | |
2058 | switch (radix) | |
2059 | { | |
2060 | case 16: | |
2061 | output_format = 'x'; | |
2062 | break; | |
2063 | case 10: | |
2064 | output_format = 0; | |
2065 | break; | |
2066 | case 8: | |
2067 | output_format = 'o'; /* octal */ | |
2068 | break; | |
2069 | default: | |
2070 | output_format = 0; | |
2071 | error ("Unsupported radix ``decimal %d''; using decimal output", | |
2072 | radix); | |
2073 | } | |
2074 | } | |
2075 | ||
2076 | /* Both at once */ | |
2077 | static void | |
2078 | set_radix (arg, from_tty, c) | |
2079 | char *arg; | |
2080 | int from_tty; | |
2081 | struct cmd_list_element *c; | |
2082 | { | |
2083 | unsigned radix = *(unsigned *)c->var; | |
2084 | ||
2085 | if (from_tty) | |
2086 | printf_filtered ("Radix set to decimal %d, hex %x, octal %o\n", | |
2087 | radix, radix, radix); | |
2088 | ||
2089 | input_radix = radix; | |
2090 | output_radix = radix; | |
2091 | ||
2092 | set_output_radix (arg, 0, c); | |
2093 | } | |
2094 | \f | |
f266e564 JK |
2095 | /*ARGSUSED*/ |
2096 | static void | |
2097 | set_print (arg, from_tty) | |
2098 | char *arg; | |
2099 | int from_tty; | |
2100 | { | |
2101 | printf ( | |
2102 | "\"set print\" must be followed by the name of a print subcommand.\n"); | |
2103 | help_list (setprintlist, "set print ", -1, stdout); | |
2104 | } | |
2105 | ||
2106 | /*ARGSUSED*/ | |
2107 | static void | |
2108 | show_print (args, from_tty) | |
2109 | char *args; | |
2110 | int from_tty; | |
2111 | { | |
2112 | cmd_show_list (showprintlist, from_tty, ""); | |
2113 | } | |
2114 | \f | |
bd5635a1 RP |
2115 | void |
2116 | _initialize_valprint () | |
2117 | { | |
2118 | struct cmd_list_element *c; | |
2119 | ||
f266e564 JK |
2120 | add_prefix_cmd ("print", no_class, set_print, |
2121 | "Generic command for setting how things print.", | |
2122 | &setprintlist, "set print ", 0, &setlist); | |
36b9d39c JG |
2123 | add_alias_cmd ("p", "print", no_class, 1, &setlist); |
2124 | add_alias_cmd ("pr", "print", no_class, 1, &setlist); /* prefer set print | |
2125 | to set prompt */ | |
f266e564 JK |
2126 | add_prefix_cmd ("print", no_class, show_print, |
2127 | "Generic command for showing print settings.", | |
2128 | &showprintlist, "show print ", 0, &showlist); | |
36b9d39c JG |
2129 | add_alias_cmd ("p", "print", no_class, 1, &showlist); |
2130 | add_alias_cmd ("pr", "print", no_class, 1, &showlist); | |
f266e564 | 2131 | |
bd5635a1 | 2132 | add_show_from_set |
f266e564 | 2133 | (add_set_cmd ("elements", no_class, var_uinteger, (char *)&print_max, |
bd5635a1 | 2134 | "Set limit on string chars or array elements to print.\n\ |
f266e564 JK |
2135 | \"set print elements 0\" causes there to be no limit.", |
2136 | &setprintlist), | |
2137 | &showprintlist); | |
bd5635a1 RP |
2138 | |
2139 | add_show_from_set | |
f266e564 | 2140 | (add_set_cmd ("pretty", class_support, var_boolean, (char *)&prettyprint, |
bd5635a1 | 2141 | "Set prettyprinting of structures.", |
f266e564 JK |
2142 | &setprintlist), |
2143 | &showprintlist); | |
bd5635a1 RP |
2144 | |
2145 | add_show_from_set | |
f266e564 | 2146 | (add_set_cmd ("union", class_support, var_boolean, (char *)&unionprint, |
bd5635a1 | 2147 | "Set printing of unions interior to structures.", |
f266e564 JK |
2148 | &setprintlist), |
2149 | &showprintlist); | |
bd5635a1 RP |
2150 | |
2151 | add_show_from_set | |
f266e564 | 2152 | (add_set_cmd ("vtbl", class_support, var_boolean, (char *)&vtblprint, |
bd5635a1 | 2153 | "Set printing of C++ virtual function tables.", |
f266e564 JK |
2154 | &setprintlist), |
2155 | &showprintlist); | |
bd5635a1 RP |
2156 | |
2157 | add_show_from_set | |
f266e564 | 2158 | (add_set_cmd ("array", class_support, var_boolean, (char *)&arrayprint, |
bd5635a1 | 2159 | "Set prettyprinting of arrays.", |
f266e564 JK |
2160 | &setprintlist), |
2161 | &showprintlist); | |
bd5635a1 | 2162 | |
0dce3774 JK |
2163 | add_show_from_set |
2164 | (add_set_cmd ("object", class_support, var_boolean, (char *)&objectprint, | |
2165 | "Set printing of object's derived type based on vtable info.", | |
2166 | &setprintlist), | |
2167 | &showprintlist); | |
2168 | ||
bd5635a1 | 2169 | add_show_from_set |
f266e564 | 2170 | (add_set_cmd ("address", class_support, var_boolean, (char *)&addressprint, |
bd5635a1 | 2171 | "Set printing of addresses.", |
f266e564 JK |
2172 | &setprintlist), |
2173 | &showprintlist); | |
bd5635a1 RP |
2174 | |
2175 | #if 0 | |
2176 | /* The "show radix" cmd isn't good enough to show two separate values. | |
2177 | The rest of the code works, but the show part is confusing, so don't | |
2178 | let them be set separately 'til we work out "show". */ | |
2179 | c = add_set_cmd ("input-radix", class_support, var_uinteger, | |
2180 | (char *)&input_radix, | |
2181 | "Set default input radix for entering numbers.", | |
2182 | &setlist); | |
2183 | add_show_from_set (c, &showlist); | |
2184 | c->function = set_input_radix; | |
2185 | ||
2186 | c = add_set_cmd ("output-radix", class_support, var_uinteger, | |
2187 | (char *)&output_radix, | |
2188 | "Set default output radix for printing of values.", | |
2189 | &setlist); | |
2190 | add_show_from_set (c, &showlist); | |
2191 | c->function = set_output_radix; | |
2192 | #endif | |
2193 | ||
2194 | c = add_set_cmd ("radix", class_support, var_uinteger, | |
2195 | (char *)&output_radix, | |
2196 | "Set default input and output number radix.", | |
2197 | &setlist); | |
2198 | add_show_from_set (c, &showlist); | |
2cd99985 | 2199 | c->function.sfunc = set_radix; |
bd5635a1 RP |
2200 | |
2201 | /* Give people the defaults which they are used to. */ | |
2202 | prettyprint = 0; | |
2203 | unionprint = 1; | |
2204 | vtblprint = 0; | |
2205 | arrayprint = 0; | |
2206 | addressprint = 1; | |
0dce3774 | 2207 | objectprint = 0; |
bd5635a1 RP |
2208 | |
2209 | print_max = 200; | |
2210 | ||
bd5635a1 RP |
2211 | obstack_begin (&dont_print_obstack, 32 * sizeof (struct type *)); |
2212 | } |