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, "{ "))
524 if (! append_type (info, "/* undefined */"))
530 for (i = 0; names[i] != NULL; i++)
534 if (! append_type (info, ", "))
538 if (! append_type (info, names[i]))
541 if (values[i] != val)
545 print_vma (values[i], ab, false, false);
546 if (! append_type (info, " = ")
547 || ! append_type (info, ab))
556 return append_type (info, " }");
559 /* Turn the top type on the stack into a pointer. */
565 struct pr_handle *info = (struct pr_handle *) p;
567 assert (info->stack != NULL);
569 return substitute_type (info, "*|");
572 /* Turn the top type on the stack into a function returning that type. */
578 struct pr_handle *info = (struct pr_handle *) p;
580 assert (info->stack != NULL);
582 return substitute_type (info, "(|) ()");
585 /* Turn the top type on the stack into a reference to that type. */
588 pr_reference_type (p)
591 struct pr_handle *info = (struct pr_handle *) p;
593 assert (info->stack != NULL);
595 return substitute_type (info, "&|");
598 /* Make a range type. */
601 pr_range_type (p, lower, upper)
603 bfd_signed_vma lower;
604 bfd_signed_vma upper;
606 struct pr_handle *info = (struct pr_handle *) p;
607 char abl[20], abu[20];
609 assert (info->stack != NULL);
611 if (! substitute_type (info, ""))
614 print_vma (lower, abl, false, false);
615 print_vma (upper, abu, false, false);
617 return (prepend_type (info, "range (")
618 && append_type (info, "):")
619 && append_type (info, abl)
620 && append_type (info, ":")
621 && append_type (info, abu));
624 /* Make an array type. */
628 pr_array_type (p, lower, upper, stringp)
630 bfd_signed_vma lower;
631 bfd_signed_vma upper;
634 struct pr_handle *info = (struct pr_handle *) p;
636 char abl[20], abu[20], ab[50];
638 range_type = pop_type (info);
639 if (range_type == NULL)
648 print_vma (upper + 1, abu, false, false);
649 sprintf (ab, "|[%s]", abu);
654 print_vma (lower, abl, false, false);
655 print_vma (upper, abu, false, false);
656 sprintf (ab, "|[%s:%s]", abl, abu);
659 if (! substitute_type (info, ab))
662 if (strcmp (range_type, "int") != 0)
664 if (! append_type (info, ":")
665 || ! append_type (info, range_type))
671 if (! append_type (info, " /* string */"))
678 /* Make a set type. */
682 pr_set_type (p, bitstringp)
686 struct pr_handle *info = (struct pr_handle *) p;
688 if (! substitute_type (info, ""))
691 if (! prepend_type (info, "set { ")
692 || ! append_type (info, " }"))
697 if (! append_type (info, "/* bitstring */"))
704 /* Make an offset type. */
710 struct pr_handle *info = (struct pr_handle *) p;
713 if (! substitute_type (info, ""))
720 return (substitute_type (info, "")
721 && prepend_type (info, " ")
722 && prepend_type (info, t)
723 && append_type (info, "::|"));
726 /* Make a method type. */
729 pr_method_type (p, domain, argcount)
734 struct pr_handle *info = (struct pr_handle *) p;
746 if (! substitute_type (info, ""))
748 domain_type = pop_type (info);
749 if (domain_type == NULL)
751 if (strncmp (domain_type, "class ", sizeof "class " - 1) == 0
752 && strchr (domain_type + sizeof "class " - 1, ' ') == NULL)
753 domain_type += sizeof "class " - 1;
754 else if (strncmp (domain_type, "union class ",
755 sizeof "union class ") == 0
756 && (strchr (domain_type + sizeof "union class " - 1, ' ')
758 domain_type += sizeof "union class " - 1;
759 len += strlen (domain_type);
771 arg_types = (char **) xmalloc (argcount * sizeof *arg_types);
772 for (i = argcount - 1; i >= 0; i--)
774 if (! substitute_type (info, ""))
776 arg_types[i] = pop_type (info);
777 if (arg_types[i] == NULL)
779 len += strlen (arg_types[i]) + 2;
783 /* Now the return type is on the top of the stack. */
785 s = (char *) xmalloc (len);
789 strcpy (s, domain_type);
793 strcat (s, "/* unknown */");
798 for (i = 0; i < argcount; i++)
802 strcat (s, arg_types[i]);
808 if (! substitute_type (info, s))
816 /* Make a const qualified type. */
822 struct pr_handle *info = (struct pr_handle *) p;
824 return substitute_type (info, "const |");
827 /* Make a volatile qualified type. */
833 struct pr_handle *info = (struct pr_handle *) p;
835 return substitute_type (info, "volatile |");
838 /* Start accumulating a struct type. */
841 pr_start_struct_type (p, tag, structp, size)
847 struct pr_handle *info = (struct pr_handle *) p;
852 if (! push_type (info, structp ? "struct " : "union "))
856 if (! append_type (info, tag)
857 || ! append_type (info, " "))
861 sprintf (ab, "{ /* size %u */\n", size);
864 if (! append_type (info, ab))
866 info->stack->visibility = DEBUG_VISIBILITY_PUBLIC;
867 return indent_type (info);
870 /* Output the visibility of a field in a struct. */
873 pr_fix_visibility (info, visibility)
874 struct pr_handle *info;
875 enum debug_visibility visibility;
878 struct pr_stack *top;
882 assert (info->stack != NULL && info->stack->next != NULL);
884 if (info->stack->next->visibility == visibility)
887 assert (info->stack->next->visibility != DEBUG_VISIBILITY_IGNORE);
891 case DEBUG_VISIBILITY_PUBLIC:
894 case DEBUG_VISIBILITY_PRIVATE:
897 case DEBUG_VISIBILITY_PROTECTED:
905 /* Trim off a trailing space in the struct string, to make the
906 output look a bit better, then stick on the visibility string.
907 Pop the stack temporarily to make the string manipulation
911 info->stack = top->next;
913 t = info->stack->type;
915 assert (t[len - 1] == ' ');
918 if (! append_type (info, s)
919 || ! append_type (info, ":\n")
920 || ! indent_type (info))
923 info->stack->visibility = visibility;
930 /* Add a field to a struct type. */
933 pr_struct_field (p, name, bitpos, bitsize, visibility)
938 enum debug_visibility visibility;
940 struct pr_handle *info = (struct pr_handle *) p;
943 if (! pr_fix_visibility (info, visibility))
946 if (! substitute_type (info, name))
949 if (! append_type (info, "; /* "))
954 print_vma (bitsize, ab, true, false);
955 if (! append_type (info, "bitsize ")
956 || ! append_type (info, ab)
957 || ! append_type (info, ", "))
961 print_vma (bitpos, ab, true, false);
962 if (! append_type (info, "bitpos ")
963 || ! append_type (info, ab)
964 || ! append_type (info, " */\n")
965 || ! indent_type (info))
968 return append_type (info, pop_type (info));
971 /* Finish a struct type. */
974 pr_end_struct_type (p)
977 struct pr_handle *info = (struct pr_handle *) p;
980 assert (info->stack != NULL);
981 assert (info->indent >= 2);
985 /* Change the trailing indentation to have a close brace. */
986 s = info->stack->type + strlen (info->stack->type) - 2;
987 assert (strcmp (s, " ") == 0);
995 /* Start a class type. */
998 pr_start_class_type (p, tag, structp, size, vptr, ownvptr)
1006 struct pr_handle *info = (struct pr_handle *) p;
1011 if (vptr && ! ownvptr)
1013 tv = pop_type (info);
1018 if (! push_type (info, structp ? "class " : "union class "))
1022 if (! append_type (info, tag)
1023 || ! append_type (info, " "))
1026 if (! append_type (info, "{"))
1028 if (size != 0 || vptr || ownvptr)
1030 if (! append_type (info, " /*"))
1037 sprintf (ab, "%u", size);
1038 if (! append_type (info, " size ")
1039 || ! append_type (info, ab))
1045 if (! append_type (info, " vtable "))
1049 if (! append_type (info, "self "))
1054 if (! append_type (info, tv)
1055 || ! append_type (info, " "))
1060 if (! append_type (info, " */"))
1064 info->stack->visibility = DEBUG_VISIBILITY_PRIVATE;
1066 return (append_type (info, "\n")
1067 && indent_type (info));
1070 /* Add a static member to a class. */
1073 pr_class_static_member (p, name, physname, visibility)
1076 const char *physname;
1077 enum debug_visibility visibility;
1079 struct pr_handle *info = (struct pr_handle *) p;
1081 if (! pr_fix_visibility (info, visibility))
1084 if (! substitute_type (info, name))
1087 return (prepend_type (info, "static ")
1088 && append_type (info, "; /* physname ")
1089 && append_type (info, physname)
1090 && append_type (info, " */\n")
1091 && indent_type (info)
1092 && append_type (info, pop_type (info)));
1095 /* Add a base class to a class. */
1098 pr_class_baseclass (p, bitpos, virtual, visibility)
1102 enum debug_visibility visibility;
1104 struct pr_handle *info = (struct pr_handle *) p;
1110 assert (info->stack != NULL && info->stack->next != NULL);
1112 if (! substitute_type (info, ""))
1115 t = pop_type (info);
1119 if (strncmp (t, "class ", sizeof "class " - 1) == 0)
1120 t += sizeof "class " - 1;
1122 /* Push it back on to take advantage of the prepend_type and
1123 append_type routines. */
1124 if (! push_type (info, t))
1129 if (! prepend_type (info, "virtual "))
1135 case DEBUG_VISIBILITY_PUBLIC:
1138 case DEBUG_VISIBILITY_PROTECTED:
1139 prefix = "protected ";
1141 case DEBUG_VISIBILITY_PRIVATE:
1142 prefix = "private ";
1145 prefix = "/* unknown visibility */ ";
1149 if (! prepend_type (info, prefix))
1154 print_vma (bitpos, ab, true, false);
1155 if (! append_type (info, " /* bitpos ")
1156 || ! append_type (info, ab)
1157 || ! append_type (info, " */"))
1161 /* Now the top of the stack is something like "public A / * bitpos
1162 10 * /". The next element on the stack is something like "class
1163 xx { / * size 8 * /\n...". We want to substitute the top of the
1164 stack in before the {. */
1165 s = strchr (info->stack->next->type, '{');
1169 /* If there is already a ':', then we already have a baseclass, and
1170 we must append this one after a comma. */
1171 for (l = info->stack->next->type; l != s; l++)
1174 if (! prepend_type (info, l == s ? " : " : ", "))
1177 t = pop_type (info);
1181 n = (char *) xmalloc (strlen (info->stack->type) + strlen (t) + 1);
1182 memcpy (n, info->stack->type, s - info->stack->type);
1183 strcpy (n + (s - info->stack->type), t);
1186 free (info->stack->type);
1187 info->stack->type = n;
1194 /* Start adding a method to a class. */
1197 pr_class_start_method (p, name)
1201 struct pr_handle *info = (struct pr_handle *) p;
1203 if (! push_type (info, ""))
1205 info->stack->method = name;
1209 /* Add a variant to a method. */
1212 pr_class_method_variant (p, argtypes, visibility, constp, volatilep, voffset,
1215 const char *argtypes;
1216 enum debug_visibility visibility;
1222 struct pr_handle *info = (struct pr_handle *) p;
1226 assert (info->stack != NULL);
1227 assert (info->stack->next != NULL);
1229 /* Put the const and volatile qualifiers on the type. */
1232 if (! prepend_type (info, "volatile "))
1237 if (! prepend_type (info, "const "))
1241 /* Stick the name of the method into its type. */
1242 if (! substitute_type (info,
1244 ? info->stack->next->next->method
1245 : info->stack->next->method)))
1249 method_type = pop_type (info);
1250 if (method_type == NULL)
1253 /* Pull off the context type if there is one. */
1255 context_type = NULL;
1258 context_type = pop_type (info);
1259 if (context_type == NULL)
1263 /* Now the top of the stack is the holder for the method, and the
1264 second element on the stack is the class. */
1266 if (! pr_fix_visibility (info, visibility))
1269 if (! append_type (info, method_type)
1270 || ! append_type (info, " /* ")
1271 || ! append_type (info, argtypes))
1273 if (context || voffset != 0)
1279 if (! append_type (info, "context ")
1280 || ! append_type (info, context_type)
1281 || ! append_type (info, " "))
1284 print_vma (voffset, ab, true, false);
1285 if (! append_type (info, "voffset ")
1286 || ! append_type (info, ab))
1290 return (append_type (info, " */;\n")
1291 && indent_type (info));
1294 /* Add a static variant to a method. */
1297 pr_class_static_method_variant (p, argtypes, visibility, constp, volatilep)
1299 const char *argtypes;
1300 enum debug_visibility visibility;
1304 struct pr_handle *info = (struct pr_handle *) p;
1307 assert (info->stack != NULL);
1308 assert (info->stack->next != NULL);
1309 assert (info->stack->next->method != NULL);
1311 /* Put the const and volatile qualifiers on the type. */
1314 if (! prepend_type (info, "volatile "))
1319 if (! prepend_type (info, "const "))
1323 /* Mark it as static. */
1324 if (! prepend_type (info, "static "))
1327 /* Stick the name of the method into its type. */
1328 if (! substitute_type (info, info->stack->next->method))
1332 method_type = pop_type (info);
1333 if (method_type == NULL)
1336 /* Now the top of the stack is the holder for the method, and the
1337 second element on the stack is the class. */
1339 if (! pr_fix_visibility (info, visibility))
1342 return (append_type (info, method_type)
1343 && append_type (info, " /* ")
1344 && append_type (info, argtypes)
1345 && append_type (info, " */;\n")
1346 && indent_type (info));
1349 /* Finish up a method. */
1352 pr_class_end_method (p)
1355 struct pr_handle *info = (struct pr_handle *) p;
1357 /* The method variants have been appended to the string on top of
1358 the stack with the correct indentation. We just need the append
1359 the string on top of the stack to the class string that is second
1361 return append_type (info, pop_type (info));
1364 /* Finish up a class. */
1367 pr_end_class_type (p)
1370 return pr_end_struct_type (p);
1373 /* Push a type on the stack using a typedef name. */
1376 pr_typedef_type (p, name)
1380 struct pr_handle *info = (struct pr_handle *) p;
1382 return push_type (info, name);
1385 /* Push a type on the stack using a tag name. */
1388 pr_tag_type (p, name, kind)
1391 enum debug_type_kind kind;
1393 struct pr_handle *info = (struct pr_handle *) p;
1398 case DEBUG_KIND_STRUCT:
1401 case DEBUG_KIND_UNION:
1404 case DEBUG_KIND_ENUM:
1407 case DEBUG_KIND_CLASS:
1410 case DEBUG_KIND_UNION_CLASS:
1418 return (push_type (info, t)
1419 && append_type (info, name));
1422 /* Output a typedef. */
1429 struct pr_handle *info = (struct pr_handle *) p;
1432 if (! substitute_type (info, name))
1435 s = pop_type (info);
1440 fprintf (info->f, "typedef %s;\n", s);
1447 /* Output a tag. The tag should already be in the string on the
1448 stack, so all we have to do here is print it out. */
1456 struct pr_handle *info = (struct pr_handle *) p;
1459 t = pop_type (info);
1464 fprintf (info->f, "%s;\n", t);
1471 /* Output an integer constant. */
1474 pr_int_constant (p, name, val)
1479 struct pr_handle *info = (struct pr_handle *) info;
1483 print_vma (val, ab, false, false);
1484 fprintf (info->f, "const int %s = %s;\n", name, ab);
1488 /* Output a floating point constant. */
1491 pr_float_constant (p, name, val)
1496 struct pr_handle *info = (struct pr_handle *) info;
1499 fprintf (info->f, "const double %s = %g;\n", name, val);
1503 /* Output a typed constant. */
1506 pr_typed_constant (p, name, val)
1511 struct pr_handle *info = (struct pr_handle *) p;
1515 t = pop_type (info);
1520 print_vma (val, ab, false, false);
1521 fprintf (info->f, "const %s %s = %s;\n", t, name, ab);
1528 /* Output a variable. */
1531 pr_variable (p, name, kind, val)
1534 enum debug_var_kind kind;
1537 struct pr_handle *info = (struct pr_handle *) p;
1541 if (! substitute_type (info, name))
1544 t = pop_type (info);
1552 case DEBUG_LOCAL_STATIC:
1553 fprintf (info->f, "static ");
1555 case DEBUG_REGISTER:
1556 fprintf (info->f, "register ");
1561 print_vma (val, ab, true, true);
1562 fprintf (info->f, "%s /* %s */;\n", t, ab);
1569 /* Start outputting a function. */
1572 pr_start_function (p, name, global)
1577 struct pr_handle *info = (struct pr_handle *) p;
1580 if (! substitute_type (info, name))
1583 t = pop_type (info);
1589 fprintf (info->f, "static ");
1590 fprintf (info->f, "%s (", t);
1592 info->parameter = 1;
1597 /* Output a function parameter. */
1600 pr_function_parameter (p, name, kind, val)
1603 enum debug_parm_kind kind;
1606 struct pr_handle *info = (struct pr_handle *) p;
1610 if (kind == DEBUG_PARM_REFERENCE
1611 || kind == DEBUG_PARM_REF_REG)
1613 if (! pr_reference_type (p))
1617 if (! substitute_type (info, name))
1620 t = pop_type (info);
1624 if (info->parameter != 1)
1625 fprintf (info->f, ", ");
1627 if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG)
1628 fprintf (info->f, "register ");
1630 print_vma (val, ab, true, true);
1631 fprintf (info->f, "%s /* %s */", t, ab);
1640 /* Start writing out a block. */
1643 pr_start_block (p, addr)
1647 struct pr_handle *info = (struct pr_handle *) p;
1650 if (info->parameter > 0)
1652 fprintf (info->f, ")\n");
1653 info->parameter = 0;
1657 print_vma (addr, ab, true, true);
1658 fprintf (info->f, "{ /* %s */\n", ab);
1665 /* Write out line number information. */
1668 pr_lineno (p, filename, lineno, addr)
1670 const char *filename;
1671 unsigned long lineno;
1674 struct pr_handle *info = (struct pr_handle *) p;
1678 print_vma (addr, ab, true, true);
1679 fprintf (info->f, "/* file %s line %lu addr %s */\n", filename, lineno, ab);
1684 /* Finish writing out a block. */
1687 pr_end_block (p, addr)
1691 struct pr_handle *info = (struct pr_handle *) p;
1697 print_vma (addr, ab, true, true);
1698 fprintf (info->f, "} /* %s */\n", ab);
1703 /* Finish writing out a function. */