|
|
1.1 root 1: /* Print values for GNU debugger gdb.
2: Copyright (C) 1986 Free Software Foundation, Inc.
3:
4: GDB is distributed in the hope that it will be useful, but WITHOUT ANY
5: WARRANTY. No author or distributor accepts responsibility to anyone
6: for the consequences of using it or for whether it serves any
7: particular purpose or works at all, unless he says so in writing.
8: Refer to the GDB General Public License for full details.
9:
10: Everyone is granted permission to copy, modify and redistribute GDB,
11: but only under the conditions described in the GDB General Public
12: License. A copy of this license is supposed to have been given to you
13: along with GDB so you can know your rights and responsibilities. It
14: should be in a file named COPYING. Among other things, the copyright
15: notice and this notice must be preserved on all copies.
16:
17: In other words, go ahead and share GDB, but don't try to stop
18: anyone else from sharing it farther. Help stamp out software hoarding!
19: */
20:
21: #include <stdio.h>
22: #include "defs.h"
23: #include "initialize.h"
24: #include "symtab.h"
25: #include "value.h"
26:
27: /* Maximum number of chars to print for a string pointer value
28: or vector contents. */
29:
30: static int print_max;
31:
32: static void type_print_varspec_suffix ();
33: static void type_print_varspec_prefix ();
34: static void type_print_base ();
1.1.1.3 root 35: static void type_print_method_args ();
1.1 root 36:
37: START_FILE
38:
39: char **unsigned_type_table;
40: char **signed_type_table;
41: char **float_type_table;
42:
43: /* Print the value VAL in C-ish syntax on stream STREAM.
44: If the object printed is a string pointer, returns
45: the number of string bytes printed. */
46:
47: value_print (val, stream)
48: value val;
49: FILE *stream;
50: {
51: register int i, n, typelen;
52:
53: /* A "repeated" value really contains several values in a row.
54: They are made by the @ operator.
55: Print such values as if they were arrays. */
56:
57: if (VALUE_REPEATED (val))
58: {
59: n = VALUE_REPETITIONS (val);
60: typelen = TYPE_LENGTH (VALUE_TYPE (val));
61: fputc ('{', stream);
62: /* Print arrays of characters using string syntax. */
63: if (VALUE_TYPE (val) == builtin_type_char
64: || VALUE_TYPE (val) == builtin_type_unsigned_char)
65: {
66: fputc ('"', stream);
67: for (i = 0; i < n && i < print_max; i++)
68: {
69: QUIT;
70: printchar (VALUE_CONTENTS (val)[i], stream);
71: }
72: if (i < n)
73: fprintf (stream, "...");
74: fputc ('"', stream);
75: }
76: else
77: {
78: for (i = 0; i < n && i < print_max; i++)
79: {
80: if (i)
81: fprintf (stream, ", ");
82: val_print (VALUE_TYPE (val), VALUE_CONTENTS (val) + typelen * i,
83: VALUE_ADDRESS (val) + typelen * i, stream);
84: }
85: if (i < n)
86: fprintf (stream, "...");
87: }
88: fputc ('}', stream);
89: }
90: else
91: {
1.1.1.3 root 92: /* If it is a pointer, indicate what it points to.
93:
94: C++: if it is a member pointer, we will take care
95: of that when we print it. */
1.1 root 96: if (TYPE_CODE (VALUE_TYPE (val)) == TYPE_CODE_PTR)
97: {
98: fprintf (stream, "(");
99: type_print (VALUE_TYPE (val), "", stream, -1);
100: fprintf (stream, ") ");
101: }
102: return val_print (VALUE_TYPE (val), VALUE_CONTENTS (val),
103: VALUE_ADDRESS (val), stream);
104: }
105: }
106:
107: /* Print on STREAM data stored in debugger at address VALADDR
108: according to the format of type TYPE.
109: ADDRESS is the location in the inferior that the data
110: is supposed to have come from.
111:
112: If the data are a string pointer, returns the number of
113: sting characters printed. */
114:
115: int
116: val_print (type, valaddr, address, stream)
117: struct type *type;
118: char *valaddr;
119: CORE_ADDR address;
120: FILE *stream;
121: {
122: register int i;
123: int len;
124: struct type *elttype;
125: int eltlen;
126: int val;
127: unsigned char c;
128:
129: QUIT;
130:
131: switch (TYPE_CODE (type))
132: {
133: case TYPE_CODE_ARRAY:
134: if (TYPE_LENGTH (type) >= 0)
135: {
136: elttype = TYPE_TARGET_TYPE (type);
137: eltlen = TYPE_LENGTH (elttype);
138: len = TYPE_LENGTH (type) / eltlen;
139: fprintf (stream, "{");
140: /* For an array of chars, print with string syntax. */
141: if (elttype == builtin_type_char
142: || elttype == builtin_type_unsigned_char)
143: {
144: fputc ('"', stream);
145: for (i = 0; i < len && i < print_max; i++)
146: {
147: QUIT;
148: printchar (valaddr[i], stream);
149: }
150: if (i < len)
151: fprintf (stream, "...");
152: fputc ('"', stream);
153: }
154: else
155: {
156: for (i = 0; i < len && i < print_max; i++)
157: {
158: if (i) fprintf (stream, ", ");
159: val_print (elttype, valaddr + i * eltlen,
160: 0, stream);
161: }
162: if (i < len)
163: fprintf (stream, "...");
164: }
165: fprintf (stream, "}");
166: break;
167: }
168: /* Array of unspecified length: treat like pointer. */
169:
170: case TYPE_CODE_PTR:
1.1.1.4 root 171: if (TYPE_CODE (TYPE_TARGET_TYPE (type)) == TYPE_CODE_MEMBER)
172: {
173: struct type *domain = TYPE_DOMAIN_TYPE (TYPE_TARGET_TYPE (type));
174: struct type *target = TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (type));
175: struct fn_field *f;
176: int j, len2;
177: char *kind = "";
1.1 root 178:
1.1.1.4 root 179: val = unpack_long (builtin_type_int, valaddr);
180: if (TYPE_CODE (target) == TYPE_CODE_FUNC)
181: {
182: if (val < 128)
183: {
184: len = TYPE_NFN_FIELDS (domain);
185: for (i = 0; i < len; i++)
186: {
187: f = TYPE_FN_FIELDLIST1 (domain, i);
188: len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
189:
190: for (j = 0; j < len2; j++)
191: {
192: QUIT;
193: if (TYPE_FN_FIELD_VOFFSET (f, j) == val)
194: {
195: kind = "virtual";
196: goto common;
197: }
198: }
199: }
200: }
201: else
202: {
203: struct symbol *sym = find_pc_function (val);
204: if (sym == 0)
205: error ("invalid pointer to member function");
206: len = TYPE_NFN_FIELDS (domain);
207: for (i = 0; i < len; i++)
208: {
209: f = TYPE_FN_FIELDLIST1 (domain, i);
210: len2 = TYPE_FN_FIELDLIST_LENGTH (domain, i);
211:
212: for (j = 0; j < len2; j++)
213: {
214: QUIT;
215: if (!strcmp (SYMBOL_NAME (sym), TYPE_FN_FIELD_PHYSNAME (f, j)))
1.1.1.3 root 216: goto common;
1.1.1.4 root 217: }
218: }
219: }
220: common:
221: if (i < len)
222: {
1.1.1.5 ! root 223: fputc ('&', stream);
1.1.1.4 root 224: type_print_varspec_prefix (TYPE_FN_FIELD_TYPE (f, j), stream, 0, 0);
225: fprintf (stream, kind);
226: if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
227: && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$')
228: type_print_method_args
229: (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
230: TYPE_FN_FIELDLIST_NAME (domain, i), stream);
231: else
232: type_print_method_args
233: (TYPE_FN_FIELD_ARGS (f, j), "",
234: TYPE_FN_FIELDLIST_NAME (domain, i), stream);
1.1.1.3 root 235: break;
1.1.1.4 root 236: }
237: }
238: else
239: {
240: /* VAL is a byte offset into the structure type DOMAIN.
241: Find the name of the field for that offset and
242: print it. */
243: int extra = 0;
244: int bits = 0;
245: len = TYPE_NFIELDS (domain);
246: val <<= 3; /* @@ Make VAL into bit offset */
247: for (i = 0; i < len; i++)
248: {
249: int bitpos = TYPE_FIELD_BITPOS (domain, i);
250: QUIT;
251: if (val == bitpos)
1.1.1.3 root 252: break;
1.1.1.4 root 253: if (val < bitpos && i > 0)
254: {
255: int ptrsize = (TYPE_LENGTH (builtin_type_char) * TYPE_LENGTH (target));
256: /* Somehow pointing into a field. */
257: i -= 1;
258: extra = (val - TYPE_FIELD_BITPOS (domain, i));
259: if (extra & 0x3)
260: bits = 1;
261: else
262: extra >>= 3;
263: break;
264: }
265: }
266: if (i < len)
267: {
1.1.1.5 ! root 268: fputc ('&', stream);
1.1.1.4 root 269: type_print_base (domain, stream, 0, 0);
270: fprintf (stream, "::");
271: fprintf (stream, "%s", TYPE_FIELD_NAME (domain, i));
272: if (extra)
273: fprintf (stream, " + %d bytes", extra);
274: if (bits)
275: fprintf (stream, " (offset in bits)");
276: break;
277: }
278: }
279: fputc ('(', stream);
280: type_print (type, "", stream, -1);
281: fprintf (stream, ") %d", val >> 3);
282: }
283: else
284: {
285: fprintf (stream, "0x%x", * (int *) valaddr);
286: /* For a pointer to char or unsigned char,
287: also print the string pointed to, unless pointer is null. */
288: if ((TYPE_TARGET_TYPE (type) == builtin_type_char
289: || TYPE_TARGET_TYPE (type) == builtin_type_unsigned_char)
290: && unpack_long (type, valaddr) != 0)
291: {
292: fputc (' ', stream);
293: fputc ('"', stream);
294: for (i = 0; i < print_max; i++)
295: {
296: QUIT;
297: read_memory (unpack_long (type, valaddr) + i, &c, 1);
298: if (c == 0)
299: break;
300: printchar (c, stream);
301: }
302: fputc ('"', stream);
303: if (i == print_max)
304: fprintf (stream, "...");
305: fflush (stream);
306: /* Return number of characters printed, plus one for the
307: terminating null if we have "reached the end". */
308: return i + (i != print_max);
309: }
310: }
311: break;
312:
313: case TYPE_CODE_MEMBER:
314: error ("not implemented: member type in val_print");
315: break;
1.1.1.3 root 316:
317: case TYPE_CODE_REF:
318: fprintf (stream, "(0x%x &) = ", * (int *) valaddr);
319: /* De-reference the reference. */
320: if (TYPE_CODE (TYPE_TARGET_TYPE (type)) != TYPE_CODE_UNDEF)
321: {
322: value val = value_at (TYPE_TARGET_TYPE (type), * (int *)valaddr);
323: val_print (VALUE_TYPE (val), VALUE_CONTENTS (val),
324: VALUE_ADDRESS (val), stream);
325: }
326: else
327: fprintf (stream, "???");
328: break;
329:
1.1 root 330: case TYPE_CODE_STRUCT:
331: case TYPE_CODE_UNION:
332: fprintf (stream, "{");
333: len = TYPE_NFIELDS (type);
1.1.1.3 root 334: if (TYPE_BASECLASS (type))
335: {
336: i = 1;
337: fprintf (stream, "<%s> = ", TYPE_NAME (TYPE_BASECLASS (type)));
338: val_print (TYPE_FIELD_TYPE (type, 0),
339: valaddr + TYPE_FIELD_BITPOS (type, 0) / 8,
340: 0, stream);
341:
342: }
343: else i = 0;
344: for (; i < len; i++)
1.1 root 345: {
346: if (i) fprintf (stream, ", ");
347: fprintf (stream, "%s = ", TYPE_FIELD_NAME (type, i));
1.1.1.3 root 348: /* check if static field */
349: if (TYPE_FIELD_STATIC (type, i))
350: {
351: value v;
352:
353: v = value_static_field (type, TYPE_FIELD_NAME (type, i), i);
354: val_print (TYPE_FIELD_TYPE (type, i),
355: VALUE_CONTENTS (v), 0, stream);
356: }
357: else if (TYPE_FIELD_PACKED (type, i))
1.1 root 358: {
359: val = unpack_field_as_long (type, valaddr, i);
360: val_print (TYPE_FIELD_TYPE (type, i), &val, 0, stream);
361: }
362: else
1.1.1.3 root 363: {
364: val_print (TYPE_FIELD_TYPE (type, i),
365: valaddr + TYPE_FIELD_BITPOS (type, i) / 8,
366: 0, stream);
367: }
1.1 root 368: }
369: fprintf (stream, "}");
370: break;
371:
372: case TYPE_CODE_ENUM:
373: len = TYPE_NFIELDS (type);
374: val = unpack_long (builtin_type_int, valaddr);
375: for (i = 0; i < len; i++)
376: {
377: QUIT;
378: if (val == TYPE_FIELD_VALUE (type, i))
379: break;
380: }
381: if (i < len)
382: fprintf (stream, "%s", TYPE_FIELD_NAME (type, i));
383: else
384: fprintf (stream, "%d", val);
385: break;
386:
387: case TYPE_CODE_FUNC:
388: fprintf (stream, "{");
389: type_print (type, "", stream, -1);
390: fprintf (stream, "} ");
391: fprintf (stream, "0x%x", address);
392: break;
393:
394: case TYPE_CODE_INT:
395: fprintf (stream,
396: TYPE_UNSIGNED (type) ? "%u" : "%d",
397: unpack_long (type, valaddr));
398: if (type == builtin_type_char
399: || type == builtin_type_unsigned_char)
400: {
401: fprintf (stream, " '");
402: printchar (unpack_long (type, valaddr), stream);
403: fputc ('\'', stream);
404: }
405: break;
406:
407: case TYPE_CODE_FLT:
1.1.1.2 root 408: #ifdef IEEE_FLOAT
409: if (is_nan (unpack_double (type, valaddr)))
410: {
411: fprintf (stream, "Nan");
412: break;
413: }
414: #endif
1.1 root 415: fprintf (stream, "%g", unpack_double (type, valaddr));
416: break;
417:
418: case TYPE_CODE_VOID:
419: fprintf (stream, "void");
420: break;
421:
422: default:
423: error ("Invalid type code in symbol table.");
424: }
425: fflush (stream);
426: }
427:
1.1.1.2 root 428: #ifdef IEEE_FLOAT
429:
430: union ieee {
431: int i[2];
432: double d;
433: };
434:
435: /* Nonzero if ARG (a double) is a NAN. */
436:
437: int
438: is_nan (arg)
439: union ieee arg;
440: {
441: int lowhalf, highhalf;
442: union { int i; char c; } test;
443:
444: /* Separate the high and low words of the double.
445: Distinguish big and little-endian machines. */
446: test.i = 1;
447: if (test.c != 1)
448: /* Big-endian machine */
449: lowhalf = arg.i[1], highhalf = arg.i[0];
450: else
451: lowhalf = arg.i[0], highhalf = arg.i[1];
452:
453: /* Nan: exponent is the maximum possible, and fraction is nonzero. */
454: return (((highhalf>>20) & 0x7ff) == 0x7ff
455: &&
456: ! ((highhalf & 0xfffff == 0) && (lowhalf == 0)));
457: }
458: #endif
459:
1.1 root 460: /* Print a description of a type TYPE
461: in the form of a declaration of a variable named VARSTRING.
462: Output goes to STREAM (via stdio).
463: If SHOW is positive, we show the contents of the outermost level
464: of structure even if there is a type name that could be used instead.
465: If SHOW is negative, we never show the details of elements' types. */
466:
467: type_print (type, varstring, stream, show)
468: struct type *type;
469: char *varstring;
470: FILE *stream;
471: int show;
472: {
473: type_print_1 (type, varstring, stream, show, 0);
474: }
475:
476: /* LEVEL is the depth to indent lines by. */
477:
478: type_print_1 (type, varstring, stream, show, level)
479: struct type *type;
480: char *varstring;
481: FILE *stream;
482: int show;
483: int level;
484: {
485: register enum type_code code;
486: type_print_base (type, stream, show, level);
487: code = TYPE_CODE (type);
488: if ((varstring && *varstring)
489: ||
490: /* Need a space if going to print stars or brackets;
491: but not if we will print just a type name. */
492: ((show > 0 || TYPE_NAME (type) == 0)
493: &&
494: (code == TYPE_CODE_PTR || code == TYPE_CODE_FUNC
1.1.1.3 root 495: || code == TYPE_CODE_ARRAY
1.1.1.4 root 496: || code == TYPE_CODE_MEMBER
1.1.1.3 root 497: || code == TYPE_CODE_REF)))
1.1 root 498: fprintf (stream, " ");
499: type_print_varspec_prefix (type, stream, show, 0);
500: fprintf (stream, "%s", varstring);
501: type_print_varspec_suffix (type, stream, show, 0);
502: }
503:
1.1.1.3 root 504: /* Print the method arguments ARGS to the file STREAM. */
505: static void
506: type_print_method_args (args, prefix, varstring, stream)
507: struct type **args;
508: char *prefix, *varstring;
509: FILE *stream;
510: {
511: int i;
512:
513: fprintf (stream, " %s%s (", prefix, varstring);
514: if (args[1] && args[1]->code != TYPE_CODE_VOID)
515: {
516: i = 1; /* skip the class variable */
517: while (1)
518: {
519: type_print (args[i++], "", stream, 0);
1.1.1.5 ! root 520: if (!args[i])
! 521: {
! 522: fprintf (stream, " ...");
! 523: break;
! 524: }
! 525: else if (args[i]->code != TYPE_CODE_VOID)
1.1.1.3 root 526: {
527: fprintf (stream, ", ");
528: }
529: else break;
530: }
531: }
532: fprintf (stream, ")");
533: }
534:
1.1 root 535: /* Print any asterisks or open-parentheses needed before the
536: variable name (to describe its type).
537:
538: On outermost call, pass 0 for PASSED_A_PTR.
539: On outermost call, SHOW > 0 means should ignore
540: any typename for TYPE and show its details.
541: SHOW is always zero on recursive calls. */
542:
543: static void
544: type_print_varspec_prefix (type, stream, show, passed_a_ptr)
545: struct type *type;
546: FILE *stream;
547: int show;
548: int passed_a_ptr;
549: {
550: if (TYPE_NAME (type) && show <= 0)
551: return;
552:
553: QUIT;
554:
555: switch (TYPE_CODE (type))
556: {
557: case TYPE_CODE_PTR:
558: type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
559: fputc ('*', stream);
560: break;
561:
1.1.1.4 root 562: case TYPE_CODE_MEMBER:
1.1.1.5 ! root 563: type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
! 564: passed_a_ptr);
! 565: fputc (' ', stream);
1.1.1.4 root 566: type_print_base (TYPE_DOMAIN_TYPE (type), stream, 0,
567: passed_a_ptr);
568: fprintf (stream, "::");
1.1.1.3 root 569: break;
570:
571: case TYPE_CODE_REF:
572: type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0, 1);
573: fputc ('&', stream);
574: break;
575:
1.1 root 576: case TYPE_CODE_FUNC:
1.1.1.3 root 577: type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
578: passed_a_ptr);
1.1 root 579: if (passed_a_ptr)
580: fputc ('(', stream);
581: break;
1.1.1.3 root 582:
583: case TYPE_CODE_ARRAY:
584: type_print_varspec_prefix (TYPE_TARGET_TYPE (type), stream, 0,
585: passed_a_ptr);
1.1 root 586: }
587: }
588:
589: /* Print any array sizes, function arguments or close parentheses
590: needed after the variable name (to describe its type).
591: Args work like type_print_varspec_prefix. */
592:
593: static void
594: type_print_varspec_suffix (type, stream, show, passed_a_ptr)
595: struct type *type;
596: FILE *stream;
597: int show;
598: int passed_a_ptr;
599: {
600: if (TYPE_NAME (type) && show <= 0)
601: return;
602:
603: QUIT;
604:
605: switch (TYPE_CODE (type))
606: {
607: case TYPE_CODE_ARRAY:
1.1.1.3 root 608: type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
609: passed_a_ptr);
1.1 root 610: fprintf (stream, "[");
611: if (TYPE_LENGTH (type) >= 0)
612: fprintf (stream, "%d",
613: TYPE_LENGTH (type) / TYPE_LENGTH (TYPE_TARGET_TYPE (type)));
614: fprintf (stream, "]");
615: break;
616:
1.1.1.4 root 617: case TYPE_CODE_MEMBER:
1.1.1.3 root 618: if (passed_a_ptr)
619: fputc (')', stream);
1.1.1.4 root 620: type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 0);
621: break;
622:
1.1 root 623: case TYPE_CODE_PTR:
1.1.1.3 root 624: case TYPE_CODE_REF:
1.1 root 625: type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0, 1);
626: break;
627:
628: case TYPE_CODE_FUNC:
1.1.1.3 root 629: type_print_varspec_suffix (TYPE_TARGET_TYPE (type), stream, 0,
630: passed_a_ptr);
1.1 root 631: if (passed_a_ptr)
632: fprintf (stream, ")");
633: fprintf (stream, "()");
634: break;
635: }
636: }
637:
638: /* Print the name of the type (or the ultimate pointer target,
639: function value or array element), or the description of a
640: structure or union.
641:
642: SHOW nonzero means don't print this type as just its name;
643: show its real definition even if it has a name.
644: SHOW zero means print just typename or struct tag if there is one
645: SHOW negative means abbreviate structure elements.
646: SHOW is decremented for printing of structure elements.
647:
648: LEVEL is the depth to indent by.
649: We increase it for some recursive calls. */
650:
651: static void
652: type_print_base (type, stream, show, level)
653: struct type *type;
654: FILE *stream;
655: int show;
656: int level;
657: {
658: char *name;
659: register int i;
660: register int len;
661: register int lastval;
662:
663: QUIT;
664:
665: if (TYPE_NAME (type) && show <= 0)
666: {
667: fprintf (stream, TYPE_NAME (type));
668: return;
669: }
670:
671: switch (TYPE_CODE (type))
672: {
673: case TYPE_CODE_ARRAY:
674: case TYPE_CODE_PTR:
1.1.1.4 root 675: case TYPE_CODE_MEMBER:
1.1.1.3 root 676: case TYPE_CODE_REF:
1.1 root 677: case TYPE_CODE_FUNC:
678: type_print_base (TYPE_TARGET_TYPE (type), stream, show, level);
679: break;
680:
681: case TYPE_CODE_STRUCT:
682: fprintf (stream, "struct ");
683: goto struct_union;
684:
685: case TYPE_CODE_UNION:
686: fprintf (stream, "union ");
687: struct_union:
688: if (TYPE_NAME (type) && (name = TYPE_NAME (type)))
689: {
690: while (*name != ' ') name++;
691: fprintf (stream, "%s ", name + 1);
692: }
693: if (show < 0)
694: fprintf (stream, "{...}");
695: else
696: {
1.1.1.3 root 697: struct type *basetype, *dtype;
698:
699: dtype = type;
700: basetype = TYPE_BASECLASS (type);
701: while (basetype)
702: {
703: if (TYPE_NAME (basetype) && (name = TYPE_NAME (basetype)))
704: {
705: while (*name != ' ') name++;
706: fprintf (stream, ": %s %s ",
707: TYPE_VIA_PUBLIC (dtype) ? "public" : "private",
708: name + 1);
709: }
710: dtype = basetype;
711: basetype = TYPE_BASECLASS (basetype);
712: }
1.1 root 713: fprintf (stream, "{");
714: len = TYPE_NFIELDS (type);
1.1.1.3 root 715: if (len) fprintf (stream, "\n");
716: else fprintf (stream, "<no data fields>\n");
717:
718: /* If there is a base class for this type,
719: do not print the field that it occupies. */
720: for (i = !! TYPE_BASECLASS (type); i < len; i++)
1.1 root 721: {
722: QUIT;
1.1.1.3 root 723: /* Don't print out virtual function table. */
724: if (! strncmp (TYPE_FIELD_NAME (type, i),
725: "_vptr$", 6))
726: continue;
1.1.1.2 root 727:
1.1.1.3 root 728: print_spaces (level + 4, stream);
729: if (TYPE_FIELD_STATIC (type, i))
1.1.1.2 root 730: {
1.1.1.3 root 731: fprintf (stream, "static ");
1.1.1.2 root 732: }
1.1 root 733: type_print_1 (TYPE_FIELD_TYPE (type, i),
734: TYPE_FIELD_NAME (type, i),
735: stream, show - 1, level + 4);
1.1.1.3 root 736: if (!TYPE_FIELD_STATIC (type, i)
737: && TYPE_FIELD_PACKED (type, i))
738: {
739: /* ??? don't know what to put here ??? */;
740: }
741: fprintf (stream, ";\n");
742: }
1.1.1.2 root 743:
1.1.1.3 root 744: /* C++: print out the methods */
745: len = TYPE_NFN_FIELDS (type);
746: if (len) fprintf (stream, "\n");
747: for (i = 0; i < len; i++)
748: {
749: struct fn_field *f = TYPE_FN_FIELDLIST1 (type, i);
750: int j, len2 = TYPE_FN_FIELDLIST_LENGTH (type, i);
1.1.1.2 root 751:
1.1.1.3 root 752: for (j = 0; j < len2; j++)
753: {
754: QUIT;
755: print_spaces (level + 4, stream);
756: if (TYPE_FN_FIELD_VIRTUAL_P (f, j))
757: fprintf (stream, "virtual ");
1.1.1.5 ! root 758: type_print (TYPE_TARGET_TYPE (TYPE_TARGET_TYPE (TYPE_FN_FIELD_TYPE (f, j))), "", stream, 0);
1.1.1.3 root 759: if (TYPE_FN_FIELD_PHYSNAME (f, j)[0] == '_'
760: && TYPE_FN_FIELD_PHYSNAME (f, j)[1] == '$')
761: type_print_method_args
762: (TYPE_FN_FIELD_ARGS (f, j) + 1, "~",
763: TYPE_FN_FIELDLIST_NAME (type, i), stream);
764: else
765: type_print_method_args
766: (TYPE_FN_FIELD_ARGS (f, j), "",
767: TYPE_FN_FIELDLIST_NAME (type, i), stream);
1.1.1.2 root 768:
1.1.1.3 root 769: fprintf (stream, ";\n");
770: }
771: if (len2) fprintf (stream, "\n");
1.1 root 772: }
1.1.1.3 root 773:
1.1 root 774: print_spaces (level, stream);
775: fputc ('}', stream);
776: }
777: break;
778:
779: case TYPE_CODE_ENUM:
780: fprintf (stream, "enum ");
781: if (TYPE_NAME (type))
782: {
783: name = TYPE_NAME (type);
784: while (*name != ' ') name++;
785: fprintf (stream, "%s ", name + 1);
786: }
787: if (show < 0)
788: fprintf (stream, "{...}");
789: else
790: {
791: fprintf (stream, "{");
792: len = TYPE_NFIELDS (type);
793: lastval = 0;
794: for (i = 0; i < len; i++)
795: {
796: QUIT;
797: if (i) fprintf (stream, ", ");
798: fprintf (stream, "%s", TYPE_FIELD_NAME (type, i));
799: if (lastval != TYPE_FIELD_VALUE (type, i))
800: {
801: fprintf (stream, " : %d", TYPE_FIELD_VALUE (type, i));
802: lastval = TYPE_FIELD_VALUE (type, i);
803: }
804: lastval++;
805: }
806: fprintf (stream, "}");
807: }
808: break;
809:
810: case TYPE_CODE_INT:
811: if (TYPE_UNSIGNED (type))
812: name = unsigned_type_table[TYPE_LENGTH (type)];
813: else
814: name = signed_type_table[TYPE_LENGTH (type)];
815: fprintf (stream, "%s", name);
816: break;
817:
818: case TYPE_CODE_FLT:
819: name = float_type_table[TYPE_LENGTH (type)];
820: fprintf (stream, "%s", name);
821: break;
822:
823: case TYPE_CODE_VOID:
824: fprintf (stream, "void");
825: break;
826:
827: case 0:
828: fprintf (stream, "struct unknown");
829: break;
830:
831: default:
832: error ("Invalid type code in symbol table.");
833: }
834: }
835:
836: static void
837: set_maximum_command (arg)
838: char *arg;
839: {
840: if (!arg) error_no_arg ("value for maximum elements to print");
841: print_max = atoi (arg);
842: }
843:
844: static
845: initialize ()
846: {
847: add_com ("set-maximum", class_vars, set_maximum_command,
848: "Set NUMBER as limit on string chars or array elements to print.");
849:
850: print_max = 200;
851:
852: unsigned_type_table
853: = (char **) xmalloc ((1 + sizeof (unsigned long)) * sizeof (char *));
854: bzero (unsigned_type_table, (1 + sizeof (unsigned long)));
855: unsigned_type_table[sizeof (unsigned char)] = "unsigned char";
856: unsigned_type_table[sizeof (unsigned short)] = "unsigned short";
857: unsigned_type_table[sizeof (unsigned long)] = "unsigned long";
858: unsigned_type_table[sizeof (unsigned int)] = "unsigned int";
859:
860: signed_type_table
861: = (char **) xmalloc ((1 + sizeof (long)) * sizeof (char *));
862: bzero (signed_type_table, (1 + sizeof (long)));
863: signed_type_table[sizeof (char)] = "char";
864: signed_type_table[sizeof (short)] = "short";
865: signed_type_table[sizeof (long)] = "long";
866: signed_type_table[sizeof (int)] = "int";
867:
868: float_type_table
869: = (char **) xmalloc ((1 + sizeof (double)) * sizeof (char *));
870: bzero (float_type_table, (1 + sizeof (double)));
871: float_type_table[sizeof (float)] = "float";
872: float_type_table[sizeof (double)] = "double";
873: }
874:
875: END_FILE
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.