1 /* prdbg.c -- Print out generic debugging information.
2 Copyright (C) 1995, 1996 Free Software Foundation, Inc.
3 Written by Ian Lance Taylor <ian@cygnus.com>.
5 This file is part of GNU Binutils.
7 This program is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 2 of the License, or
10 (at your option) any later version.
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with this program; if not, write to the Free Software
19 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
22 /* This file prints out the generic debugging information, by
23 supplying a set of routines to debug_write. */
30 #include "libiberty.h"
34 /* This is the structure we use as a handle for these routines. */
38 /* File to print information to. */
40 /* Current indentation level. */
43 struct pr_stack *stack;
44 /* Parameter number we are about to output. */
52 /* Next element on the stack. */
53 struct pr_stack *next;
56 /* Current visibility of fields if this is a class. */
57 enum debug_visibility visibility;
58 /* Name of the current method we are handling. */
62 static void indent PARAMS ((struct pr_handle *));
63 static boolean push_type PARAMS ((struct pr_handle *, const char *));
64 static boolean prepend_type PARAMS ((struct pr_handle *, const char *));
65 static boolean append_type PARAMS ((struct pr_handle *, const char *));
66 static boolean substitute_type PARAMS ((struct pr_handle *, const char *));
67 static boolean indent_type PARAMS ((struct pr_handle *));
68 static char *pop_type PARAMS ((struct pr_handle *));
69 static void print_vma PARAMS ((bfd_vma, char *, boolean, boolean));
70 static boolean pr_fix_visibility
71 PARAMS ((struct pr_handle *, enum debug_visibility));
73 static boolean pr_start_compilation_unit PARAMS ((PTR, const char *));
74 static boolean pr_start_source PARAMS ((PTR, const char *));
75 static boolean pr_empty_type PARAMS ((PTR));
76 static boolean pr_void_type PARAMS ((PTR));
77 static boolean pr_int_type PARAMS ((PTR, unsigned int, boolean));
78 static boolean pr_float_type PARAMS ((PTR, unsigned int));
79 static boolean pr_complex_type PARAMS ((PTR, unsigned int));
80 static boolean pr_bool_type PARAMS ((PTR, unsigned int));
81 static boolean pr_enum_type
82 PARAMS ((PTR, const char *, const char **, bfd_signed_vma *));
83 static boolean pr_pointer_type PARAMS ((PTR));
84 static boolean pr_function_type PARAMS ((PTR));
85 static boolean pr_reference_type PARAMS ((PTR));
86 static boolean pr_range_type PARAMS ((PTR, bfd_signed_vma, bfd_signed_vma));
87 static boolean pr_array_type
88 PARAMS ((PTR, bfd_signed_vma, bfd_signed_vma, boolean));
89 static boolean pr_set_type PARAMS ((PTR, boolean));
90 static boolean pr_offset_type PARAMS ((PTR));
91 static boolean pr_method_type PARAMS ((PTR, boolean, int));
92 static boolean pr_const_type PARAMS ((PTR));
93 static boolean pr_volatile_type PARAMS ((PTR));
94 static boolean pr_start_struct_type
95 PARAMS ((PTR, const char *, boolean, unsigned int));
96 static boolean pr_struct_field
97 PARAMS ((PTR, const char *, bfd_vma, bfd_vma, enum debug_visibility));
98 static boolean pr_end_struct_type PARAMS ((PTR));
99 static boolean pr_start_class_type
100 PARAMS ((PTR, const char *, boolean, unsigned int, boolean, boolean));
101 static boolean pr_class_static_member
102 PARAMS ((PTR, const char *, const char *, enum debug_visibility));
103 static boolean pr_class_baseclass
104 PARAMS ((PTR, bfd_vma, boolean, enum debug_visibility));
105 static boolean pr_class_start_method PARAMS ((PTR, const char *));
106 static boolean pr_class_method_variant
107 PARAMS ((PTR, const char *, enum debug_visibility, boolean, boolean,
109 static boolean pr_class_static_method_variant
110 PARAMS ((PTR, const char *, enum debug_visibility, boolean, boolean));
111 static boolean pr_class_end_method PARAMS ((PTR));
112 static boolean pr_end_class_type PARAMS ((PTR));
113 static boolean pr_typedef_type PARAMS ((PTR, const char *));
114 static boolean pr_tag_type PARAMS ((PTR, const char *, enum debug_type_kind));
115 static boolean pr_typdef PARAMS ((PTR, const char *));
116 static boolean pr_tag PARAMS ((PTR, const char *));
117 static boolean pr_int_constant PARAMS ((PTR, const char *, bfd_vma));
118 static boolean pr_float_constant PARAMS ((PTR, const char *, double));
119 static boolean pr_typed_constant PARAMS ((PTR, const char *, bfd_vma));
120 static boolean pr_variable
121 PARAMS ((PTR, const char *, enum debug_var_kind, bfd_vma));
122 static boolean pr_start_function PARAMS ((PTR, const char *, boolean));
123 static boolean pr_function_parameter
124 PARAMS ((PTR, const char *, enum debug_parm_kind, bfd_vma));
125 static boolean pr_start_block PARAMS ((PTR, bfd_vma));
126 static boolean pr_end_block PARAMS ((PTR, bfd_vma));
127 static boolean pr_end_function PARAMS ((PTR));
128 static boolean pr_lineno PARAMS ((PTR, const char *, unsigned long, bfd_vma));
130 static const struct debug_write_fns pr_fns =
132 pr_start_compilation_unit,
151 pr_start_struct_type,
155 pr_class_static_member,
157 pr_class_start_method,
158 pr_class_method_variant,
159 pr_class_static_method_variant,
171 pr_function_parameter,
178 /* Print out the generic debugging information recorded in dhandle. */
181 print_debugging_info (f, dhandle)
185 struct pr_handle info;
192 return debug_write (dhandle, &pr_fns, (PTR) &info);
195 /* Indent to the current indentation level. */
199 struct pr_handle *info;
203 for (i = 0; i < info->indent; i++)
207 /* Push a type on the type stack. */
210 push_type (info, type)
211 struct pr_handle *info;
219 n = (struct pr_stack *) xmalloc (sizeof *n);
220 memset (n, 0, sizeof *n);
222 n->type = xstrdup (type);
223 n->visibility = DEBUG_VISIBILITY_IGNORE;
225 n->next = info->stack;
231 /* Prepend a string onto the type on the top of the type stack. */
234 prepend_type (info, s)
235 struct pr_handle *info;
240 assert (info->stack != NULL);
242 n = (char *) xmalloc (strlen (s) + strlen (info->stack->type) + 1);
243 sprintf (n, "%s%s", s, info->stack->type);
244 free (info->stack->type);
245 info->stack->type = n;
250 /* Append a string to the type on the top of the type stack. */
253 append_type (info, s)
254 struct pr_handle *info;
262 assert (info->stack != NULL);
264 len = strlen (info->stack->type);
265 info->stack->type = (char *) xrealloc (info->stack->type,
266 len + strlen (s) + 1);
267 strcpy (info->stack->type + len, s);
272 /* We use an underscore to indicate where the name should go in a type
273 string. This function substitutes a string for the underscore. If
274 there is no underscore, the name follows the type. */
277 substitute_type (info, s)
278 struct pr_handle *info;
283 assert (info->stack != NULL);
285 u = strchr (info->stack->type, '|');
290 n = (char *) xmalloc (strlen (info->stack->type) + strlen (s));
292 memcpy (n, info->stack->type, u - info->stack->type);
293 strcpy (n + (u - info->stack->type), s);
296 free (info->stack->type);
297 info->stack->type = n;
302 if (strchr (s, '|') != NULL
303 && (strchr (info->stack->type, '{') != NULL
304 || strchr (info->stack->type, '(') != NULL))
306 if (! prepend_type (info, "(")
307 || ! append_type (info, ")"))
314 return (append_type (info, " ")
315 && append_type (info, s));
318 /* Indent the type at the top of the stack by appending spaces. */
322 struct pr_handle *info;
326 for (i = 0; i < info->indent; i++)
328 if (! append_type (info, " "))
335 /* Pop a type from the type stack. */
339 struct pr_handle *info;
344 assert (info->stack != NULL);
347 info->stack = o->next;
354 /* Print a VMA value into a string. */
357 print_vma (vma, buf, unsignedp, hexp)
363 if (sizeof (vma) <= sizeof (unsigned long))
366 sprintf (buf, "0x%lx", (unsigned long) vma);
368 sprintf (buf, "%lu", (unsigned long) vma);
370 sprintf (buf, "%ld", (long) vma);
376 sprintf_vma (buf + 2, vma);
380 /* Start a new compilation unit. */
383 pr_start_compilation_unit (p, filename)
385 const char *filename;
387 struct pr_handle *info = (struct pr_handle *) p;
389 assert (info->indent == 0);
391 fprintf (info->f, "%s:\n", filename);
396 /* Start a source file within a compilation unit. */
399 pr_start_source (p, filename)
401 const char *filename;
403 struct pr_handle *info = (struct pr_handle *) p;
405 assert (info->indent == 0);
407 fprintf (info->f, " %s:\n", filename);
412 /* Push an empty type onto the type stack. */
418 struct pr_handle *info = (struct pr_handle *) p;
420 return push_type (info, "<undefined>");
423 /* Push a void type onto the type stack. */
429 struct pr_handle *info = (struct pr_handle *) p;
431 return push_type (info, "void");
434 /* Push an integer type onto the type stack. */
437 pr_int_type (p, size, unsignedp)
442 struct pr_handle *info = (struct pr_handle *) p;
445 sprintf (ab, "%sint%d", unsignedp ? "u" : "", size * 8);
446 return push_type (info, ab);
449 /* Push a floating type onto the type stack. */
452 pr_float_type (p, size)
456 struct pr_handle *info = (struct pr_handle *) p;
460 return push_type (info, "float");
462 return push_type (info, "double");
464 sprintf (ab, "float%d", size * 8);
465 return push_type (info, ab);
468 /* Push a complex type onto the type stack. */
471 pr_complex_type (p, size)
475 struct pr_handle *info = (struct pr_handle *) p;
477 if (! pr_float_type (p, size))
480 return prepend_type (info, "complex ");
483 /* Push a boolean type onto the type stack. */
486 pr_bool_type (p, size)
490 struct pr_handle *info = (struct pr_handle *) p;
493 sprintf (ab, "bool%d", size * 8);
495 return push_type (info, ab);
498 /* Push an enum type onto the type stack. */
501 pr_enum_type (p, tag, names, values)
505 bfd_signed_vma *values;
507 struct pr_handle *info = (struct pr_handle *) p;
511 if (! push_type (info, "enum "))
515 if (! append_type (info, tag)
516 || ! append_type (info, " "))
519 if (! append_type (info, "{ "))
523 for (i = 0; names[i] != NULL; i++)
527 if (! append_type (info, ", "))
531 if (! append_type (info, names[i]))
534 if (values[i] != val)
538 print_vma (values[i], ab, false, false);
539 if (! append_type (info, " = ")
540 || ! append_type (info, ab))
548 return append_type (info, " }");
551 /* Turn the top type on the stack into a pointer. */
557 struct pr_handle *info = (struct pr_handle *) p;
559 assert (info->stack != NULL);
561 return substitute_type (info, "*|");
564 /* Turn the top type on the stack into a function returning that type. */
570 struct pr_handle *info = (struct pr_handle *) p;
572 assert (info->stack != NULL);
574 return substitute_type (info, "(|) ()");
577 /* Turn the top type on the stack into a reference to that type. */
580 pr_reference_type (p)
583 struct pr_handle *info = (struct pr_handle *) p;
585 assert (info->stack != NULL);
587 return substitute_type (info, "&|");
590 /* Make a range type. */
593 pr_range_type (p, lower, upper)
595 bfd_signed_vma lower;
596 bfd_signed_vma upper;
598 struct pr_handle *info = (struct pr_handle *) p;
599 char abl[20], abu[20];
601 assert (info->stack != NULL);
603 if (! substitute_type (info, ""))
606 print_vma (lower, abl, false, false);
607 print_vma (upper, abu, false, false);
609 return (prepend_type (info, "range (")
610 && append_type (info, "):")
611 && append_type (info, abl)
612 && append_type (info, ":")
613 && append_type (info, abu));
616 /* Make an array type. */
620 pr_array_type (p, lower, upper, stringp)
622 bfd_signed_vma lower;
623 bfd_signed_vma upper;
626 struct pr_handle *info = (struct pr_handle *) p;
628 char abl[20], abu[20], ab[50];
630 range_type = pop_type (info);
631 if (range_type == NULL)
640 print_vma (upper + 1, abu, false, false);
641 sprintf (ab, "|[%s]", abu);
646 print_vma (lower, abl, false, false);
647 print_vma (upper, abu, false, false);
648 sprintf (ab, "|[%s:%s]", abl, abu);
651 if (! substitute_type (info, ab))
654 if (strcmp (range_type, "int") != 0)
656 if (! append_type (info, ":")
657 || ! append_type (info, range_type))
663 if (! append_type (info, " /* string */"))
670 /* Make a set type. */
674 pr_set_type (p, bitstringp)
678 struct pr_handle *info = (struct pr_handle *) p;
680 if (! substitute_type (info, ""))
683 if (! prepend_type (info, "set { ")
684 || ! append_type (info, " }"))
689 if (! append_type (info, "/* bitstring */"))
696 /* Make an offset type. */
702 struct pr_handle *info = (struct pr_handle *) p;
705 if (! substitute_type (info, ""))
712 return (substitute_type (info, "")
713 && prepend_type (info, " ")
714 && prepend_type (info, t)
715 && append_type (info, "::|"));
718 /* Make a method type. */
721 pr_method_type (p, domain, argcount)
726 struct pr_handle *info = (struct pr_handle *) p;
738 if (! substitute_type (info, ""))
740 domain_type = pop_type (info);
741 if (domain_type == NULL)
743 if (strncmp (domain_type, "class ", sizeof "class " - 1) == 0
744 && strchr (domain_type + sizeof "class " - 1, ' ') == NULL)
745 domain_type += sizeof "class " - 1;
746 else if (strncmp (domain_type, "union class ",
747 sizeof "union class ") == 0
748 && (strchr (domain_type + sizeof "union class " - 1, ' ')
750 domain_type += sizeof "union class " - 1;
751 len += strlen (domain_type);
763 arg_types = (char **) xmalloc (argcount * sizeof *arg_types);
764 for (i = argcount - 1; i >= 0; i--)
766 if (! substitute_type (info, ""))
768 arg_types[i] = pop_type (info);
769 if (arg_types[i] == NULL)
771 len += strlen (arg_types[i]) + 2;
775 /* Now the return type is on the top of the stack. */
777 s = (char *) xmalloc (len);
781 strcpy (s, domain_type);
785 strcat (s, "/* unknown */");
790 for (i = 0; i < argcount; i++)
794 strcat (s, arg_types[i]);
800 if (! substitute_type (info, s))
808 /* Make a const qualified type. */
814 struct pr_handle *info = (struct pr_handle *) p;
816 return substitute_type (info, "const |");
819 /* Make a volatile qualified type. */
825 struct pr_handle *info = (struct pr_handle *) p;
827 return substitute_type (info, "volatile |");
830 /* Start accumulating a struct type. */
833 pr_start_struct_type (p, tag, structp, size)
839 struct pr_handle *info = (struct pr_handle *) p;
844 if (! push_type (info, structp ? "struct " : "union "))
848 if (! append_type (info, tag)
849 || ! append_type (info, " "))
853 sprintf (ab, "{ /* size %u */\n", size);
856 if (! append_type (info, ab))
858 info->stack->visibility = DEBUG_VISIBILITY_PUBLIC;
859 return indent_type (info);
862 /* Output the visibility of a field in a struct. */
865 pr_fix_visibility (info, visibility)
866 struct pr_handle *info;
867 enum debug_visibility visibility;
870 struct pr_stack *top;
874 assert (info->stack != NULL && info->stack->next != NULL);
876 if (info->stack->next->visibility == visibility)
879 assert (info->stack->next->visibility != DEBUG_VISIBILITY_IGNORE);
883 case DEBUG_VISIBILITY_PUBLIC:
886 case DEBUG_VISIBILITY_PRIVATE:
889 case DEBUG_VISIBILITY_PROTECTED:
897 /* Trim off a trailing space in the struct string, to make the
898 output look a bit better, then stick on the visibility string.
899 Pop the stack temporarily to make the string manipulation
903 info->stack = top->next;
905 t = info->stack->type;
907 assert (t[len - 1] == ' ');
910 if (! append_type (info, s)
911 || ! append_type (info, ":\n")
912 || ! indent_type (info))
915 info->stack->visibility = visibility;
922 /* Add a field to a struct type. */
925 pr_struct_field (p, name, bitpos, bitsize, visibility)
930 enum debug_visibility visibility;
932 struct pr_handle *info = (struct pr_handle *) p;
935 if (! pr_fix_visibility (info, visibility))
938 if (! substitute_type (info, name))
941 if (! append_type (info, "; /* "))
946 print_vma (bitsize, ab, true, false);
947 if (! append_type (info, "bitsize ")
948 || ! append_type (info, ab)
949 || ! append_type (info, ", "))
953 print_vma (bitpos, ab, true, false);
954 if (! append_type (info, "bitpos ")
955 || ! append_type (info, ab)
956 || ! append_type (info, " */\n")
957 || ! indent_type (info))
960 return append_type (info, pop_type (info));
963 /* Finish a struct type. */
966 pr_end_struct_type (p)
969 struct pr_handle *info = (struct pr_handle *) p;
972 assert (info->stack != NULL);
973 assert (info->indent >= 2);
977 /* Change the trailing indentation to have a close brace. */
978 s = info->stack->type + strlen (info->stack->type) - 2;
979 assert (strcmp (s, " ") == 0);
987 /* Start a class type. */
990 pr_start_class_type (p, tag, structp, size, vptr, ownvptr)
998 struct pr_handle *info = (struct pr_handle *) p;
1003 if (vptr && ! ownvptr)
1005 tv = pop_type (info);
1010 if (! push_type (info, structp ? "class " : "union class "))
1014 if (! append_type (info, tag)
1015 || ! append_type (info, " "))
1018 if (! append_type (info, "{"))
1020 if (size != 0 || vptr || ownvptr)
1022 if (! append_type (info, " /*"))
1029 sprintf (ab, "%u", size);
1030 if (! append_type (info, " size ")
1031 || ! append_type (info, ab))
1037 if (! append_type (info, " vtable "))
1041 if (! append_type (info, "self "))
1046 if (! append_type (info, tv)
1047 || ! append_type (info, " "))
1052 if (! append_type (info, " */"))
1056 info->stack->visibility = DEBUG_VISIBILITY_PRIVATE;
1058 return (append_type (info, "\n")
1059 && indent_type (info));
1062 /* Add a static member to a class. */
1065 pr_class_static_member (p, name, physname, visibility)
1068 const char *physname;
1069 enum debug_visibility visibility;
1071 struct pr_handle *info = (struct pr_handle *) p;
1073 if (! pr_fix_visibility (info, visibility))
1076 if (! substitute_type (info, name))
1079 return (prepend_type (info, "static ")
1080 && append_type (info, "; /* physname ")
1081 && append_type (info, physname)
1082 && append_type (info, " */\n")
1083 && indent_type (info)
1084 && append_type (info, pop_type (info)));
1087 /* Add a base class to a class. */
1090 pr_class_baseclass (p, bitpos, virtual, visibility)
1094 enum debug_visibility visibility;
1096 struct pr_handle *info = (struct pr_handle *) p;
1102 assert (info->stack != NULL && info->stack->next != NULL);
1104 if (! substitute_type (info, ""))
1107 t = pop_type (info);
1111 if (strncmp (t, "class ", sizeof "class " - 1) == 0)
1112 t += sizeof "class " - 1;
1114 /* Push it back on to take advantage of the prepend_type and
1115 append_type routines. */
1116 if (! push_type (info, t))
1121 if (! prepend_type (info, "virtual "))
1127 case DEBUG_VISIBILITY_PUBLIC:
1130 case DEBUG_VISIBILITY_PROTECTED:
1131 prefix = "protected ";
1133 case DEBUG_VISIBILITY_PRIVATE:
1134 prefix = "private ";
1137 prefix = "/* unknown visibility */ ";
1141 if (! prepend_type (info, prefix))
1146 print_vma (bitpos, ab, true, false);
1147 if (! append_type (info, " /* bitpos ")
1148 || ! append_type (info, ab)
1149 || ! append_type (info, " */"))
1153 /* Now the top of the stack is something like "public A / * bitpos
1154 10 * /". The next element on the stack is something like "class
1155 xx { / * size 8 * /\n...". We want to substitute the top of the
1156 stack in before the {. */
1157 s = strchr (info->stack->next->type, '{');
1161 /* If there is already a ':', then we already have a baseclass, and
1162 we must append this one after a comma. */
1163 for (l = info->stack->next->type; l != s; l++)
1166 if (! prepend_type (info, l == s ? " : " : ", "))
1169 t = pop_type (info);
1173 n = (char *) xmalloc (strlen (info->stack->type) + strlen (t) + 1);
1174 memcpy (n, info->stack->type, s - info->stack->type);
1175 strcpy (n + (s - info->stack->type), t);
1178 free (info->stack->type);
1179 info->stack->type = n;
1186 /* Start adding a method to a class. */
1189 pr_class_start_method (p, name)
1193 struct pr_handle *info = (struct pr_handle *) p;
1195 if (! push_type (info, ""))
1197 info->stack->method = name;
1201 /* Add a variant to a method. */
1204 pr_class_method_variant (p, argtypes, visibility, constp, volatilep, voffset,
1207 const char *argtypes;
1208 enum debug_visibility visibility;
1214 struct pr_handle *info = (struct pr_handle *) p;
1218 assert (info->stack != NULL);
1219 assert (info->stack->next != NULL);
1221 /* Put the const and volatile qualifiers on the type. */
1224 if (! prepend_type (info, "volatile "))
1229 if (! prepend_type (info, "const "))
1233 /* Stick the name of the method into its type. */
1234 if (! substitute_type (info,
1236 ? info->stack->next->next->method
1237 : info->stack->next->method)))
1241 method_type = pop_type (info);
1242 if (method_type == NULL)
1245 /* Pull off the context type if there is one. */
1247 context_type = NULL;
1250 context_type = pop_type (info);
1251 if (context_type == NULL)
1255 /* Now the top of the stack is the holder for the method, and the
1256 second element on the stack is the class. */
1258 if (! pr_fix_visibility (info, visibility))
1261 if (! append_type (info, method_type)
1262 || ! append_type (info, " /* ")
1263 || ! append_type (info, argtypes))
1265 if (context || voffset != 0)
1271 if (! append_type (info, "context ")
1272 || ! append_type (info, context_type)
1273 || ! append_type (info, " "))
1276 print_vma (voffset, ab, true, false);
1277 if (! append_type (info, "voffset ")
1278 || ! append_type (info, ab))
1282 return (append_type (info, " */;\n")
1283 && indent_type (info));
1286 /* Add a static variant to a method. */
1289 pr_class_static_method_variant (p, argtypes, visibility, constp, volatilep)
1291 const char *argtypes;
1292 enum debug_visibility visibility;
1296 struct pr_handle *info = (struct pr_handle *) p;
1299 assert (info->stack != NULL);
1300 assert (info->stack->next != NULL);
1301 assert (info->stack->next->method != NULL);
1303 /* Put the const and volatile qualifiers on the type. */
1306 if (! prepend_type (info, "volatile "))
1311 if (! prepend_type (info, "const "))
1315 /* Mark it as static. */
1316 if (! prepend_type (info, "static "))
1319 /* Stick the name of the method into its type. */
1320 if (! substitute_type (info, info->stack->next->method))
1324 method_type = pop_type (info);
1325 if (method_type == NULL)
1328 /* Now the top of the stack is the holder for the method, and the
1329 second element on the stack is the class. */
1331 if (! pr_fix_visibility (info, visibility))
1334 return (append_type (info, method_type)
1335 && append_type (info, " /* ")
1336 && append_type (info, argtypes)
1337 && append_type (info, " */;\n")
1338 && indent_type (info));
1341 /* Finish up a method. */
1344 pr_class_end_method (p)
1347 struct pr_handle *info = (struct pr_handle *) p;
1349 /* The method variants have been appended to the string on top of
1350 the stack with the correct indentation. We just need the append
1351 the string on top of the stack to the class string that is second
1353 return append_type (info, pop_type (info));
1356 /* Finish up a class. */
1359 pr_end_class_type (p)
1362 return pr_end_struct_type (p);
1365 /* Push a type on the stack using a typedef name. */
1368 pr_typedef_type (p, name)
1372 struct pr_handle *info = (struct pr_handle *) p;
1374 return push_type (info, name);
1377 /* Push a type on the stack using a tag name. */
1380 pr_tag_type (p, name, kind)
1383 enum debug_type_kind kind;
1385 struct pr_handle *info = (struct pr_handle *) p;
1390 case DEBUG_KIND_STRUCT:
1393 case DEBUG_KIND_UNION:
1396 case DEBUG_KIND_ENUM:
1399 case DEBUG_KIND_CLASS:
1402 case DEBUG_KIND_UNION_CLASS:
1410 return (push_type (info, t)
1411 && append_type (info, name));
1414 /* Output a typedef. */
1421 struct pr_handle *info = (struct pr_handle *) p;
1424 if (! substitute_type (info, name))
1427 s = pop_type (info);
1432 fprintf (info->f, "typedef %s;\n", s);
1439 /* Output a tag. The tag should already be in the string on the
1440 stack, so all we have to do here is print it out. */
1448 struct pr_handle *info = (struct pr_handle *) p;
1451 t = pop_type (info);
1456 fprintf (info->f, "%s;\n", t);
1463 /* Output an integer constant. */
1466 pr_int_constant (p, name, val)
1471 struct pr_handle *info = (struct pr_handle *) info;
1475 print_vma (val, ab, false, false);
1476 fprintf (info->f, "const int %s = %s;\n", name, ab);
1480 /* Output a floating point constant. */
1483 pr_float_constant (p, name, val)
1488 struct pr_handle *info = (struct pr_handle *) info;
1491 fprintf (info->f, "const double %s = %g;\n", name, val);
1495 /* Output a typed constant. */
1498 pr_typed_constant (p, name, val)
1503 struct pr_handle *info = (struct pr_handle *) p;
1507 t = pop_type (info);
1512 print_vma (val, ab, false, false);
1513 fprintf (info->f, "const %s %s = %s;\n", t, name, ab);
1520 /* Output a variable. */
1523 pr_variable (p, name, kind, val)
1526 enum debug_var_kind kind;
1529 struct pr_handle *info = (struct pr_handle *) p;
1533 if (! substitute_type (info, name))
1536 t = pop_type (info);
1544 case DEBUG_LOCAL_STATIC:
1545 fprintf (info->f, "static ");
1547 case DEBUG_REGISTER:
1548 fprintf (info->f, "register ");
1553 print_vma (val, ab, true, true);
1554 fprintf (info->f, "%s /* %s */;\n", t, ab);
1561 /* Start outputting a function. */
1564 pr_start_function (p, name, global)
1569 struct pr_handle *info = (struct pr_handle *) p;
1572 if (! substitute_type (info, name))
1575 t = pop_type (info);
1581 fprintf (info->f, "static ");
1582 fprintf (info->f, "%s (", t);
1584 info->parameter = 1;
1589 /* Output a function parameter. */
1592 pr_function_parameter (p, name, kind, val)
1595 enum debug_parm_kind kind;
1598 struct pr_handle *info = (struct pr_handle *) p;
1602 if (kind == DEBUG_PARM_REFERENCE
1603 || kind == DEBUG_PARM_REF_REG)
1605 if (! pr_reference_type (p))
1609 if (! substitute_type (info, name))
1612 t = pop_type (info);
1616 if (info->parameter != 1)
1617 fprintf (info->f, ", ");
1619 if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG)
1620 fprintf (info->f, "register ");
1622 print_vma (val, ab, true, true);
1623 fprintf (info->f, "%s /* %s */", t, ab);
1632 /* Start writing out a block. */
1635 pr_start_block (p, addr)
1639 struct pr_handle *info = (struct pr_handle *) p;
1642 if (info->parameter > 0)
1644 fprintf (info->f, ")\n");
1645 info->parameter = 0;
1649 print_vma (addr, ab, true, true);
1650 fprintf (info->f, "{ /* %s */\n", ab);
1657 /* Write out line number information. */
1660 pr_lineno (p, filename, lineno, addr)
1662 const char *filename;
1663 unsigned long lineno;
1666 struct pr_handle *info = (struct pr_handle *) p;
1670 print_vma (addr, ab, true, true);
1671 fprintf (info->f, "/* file %s line %lu addr %s */\n", filename, lineno, ab);
1676 /* Finish writing out a block. */
1679 pr_end_block (p, addr)
1683 struct pr_handle *info = (struct pr_handle *) p;
1689 print_vma (addr, ab, true, true);
1690 fprintf (info->f, "} /* %s */\n", ab);
1695 /* Finish writing out a function. */