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_ellipsis_type PARAMS ((PTR));
76 static boolean pr_empty_type PARAMS ((PTR));
77 static boolean pr_void_type PARAMS ((PTR));
78 static boolean pr_int_type PARAMS ((PTR, unsigned int, boolean));
79 static boolean pr_float_type PARAMS ((PTR, unsigned int));
80 static boolean pr_complex_type PARAMS ((PTR, unsigned int));
81 static boolean pr_bool_type PARAMS ((PTR, unsigned int));
82 static boolean pr_enum_type
83 PARAMS ((PTR, const char *, const char **, bfd_signed_vma *));
84 static boolean pr_pointer_type PARAMS ((PTR));
85 static boolean pr_function_type PARAMS ((PTR));
86 static boolean pr_reference_type PARAMS ((PTR));
87 static boolean pr_range_type PARAMS ((PTR, bfd_signed_vma, bfd_signed_vma));
88 static boolean pr_array_type
89 PARAMS ((PTR, bfd_signed_vma, bfd_signed_vma, boolean));
90 static boolean pr_set_type PARAMS ((PTR, boolean));
91 static boolean pr_offset_type PARAMS ((PTR));
92 static boolean pr_method_type PARAMS ((PTR, boolean, int));
93 static boolean pr_const_type PARAMS ((PTR));
94 static boolean pr_volatile_type PARAMS ((PTR));
95 static boolean pr_start_struct_type
96 PARAMS ((PTR, const char *, unsigned int, boolean, unsigned int));
97 static boolean pr_struct_field
98 PARAMS ((PTR, const char *, bfd_vma, bfd_vma, enum debug_visibility));
99 static boolean pr_end_struct_type PARAMS ((PTR));
100 static boolean pr_start_class_type
101 PARAMS ((PTR, const char *, unsigned int, boolean, unsigned int, boolean,
103 static boolean pr_class_static_member
104 PARAMS ((PTR, const char *, const char *, enum debug_visibility));
105 static boolean pr_class_baseclass
106 PARAMS ((PTR, bfd_vma, boolean, enum debug_visibility));
107 static boolean pr_class_start_method PARAMS ((PTR, const char *));
108 static boolean pr_class_method_variant
109 PARAMS ((PTR, const char *, enum debug_visibility, boolean, boolean,
111 static boolean pr_class_static_method_variant
112 PARAMS ((PTR, const char *, enum debug_visibility, boolean, boolean));
113 static boolean pr_class_end_method PARAMS ((PTR));
114 static boolean pr_end_class_type PARAMS ((PTR));
115 static boolean pr_typedef_type PARAMS ((PTR, const char *));
116 static boolean pr_tag_type
117 PARAMS ((PTR, const char *, unsigned int, enum debug_type_kind));
118 static boolean pr_typdef PARAMS ((PTR, const char *));
119 static boolean pr_tag PARAMS ((PTR, const char *));
120 static boolean pr_int_constant PARAMS ((PTR, const char *, bfd_vma));
121 static boolean pr_float_constant PARAMS ((PTR, const char *, double));
122 static boolean pr_typed_constant PARAMS ((PTR, const char *, bfd_vma));
123 static boolean pr_variable
124 PARAMS ((PTR, const char *, enum debug_var_kind, bfd_vma));
125 static boolean pr_start_function PARAMS ((PTR, const char *, boolean));
126 static boolean pr_function_parameter
127 PARAMS ((PTR, const char *, enum debug_parm_kind, bfd_vma));
128 static boolean pr_start_block PARAMS ((PTR, bfd_vma));
129 static boolean pr_end_block PARAMS ((PTR, bfd_vma));
130 static boolean pr_end_function PARAMS ((PTR));
131 static boolean pr_lineno PARAMS ((PTR, const char *, unsigned long, bfd_vma));
133 static const struct debug_write_fns pr_fns =
135 pr_start_compilation_unit,
155 pr_start_struct_type,
159 pr_class_static_member,
161 pr_class_start_method,
162 pr_class_method_variant,
163 pr_class_static_method_variant,
175 pr_function_parameter,
182 /* Print out the generic debugging information recorded in dhandle. */
185 print_debugging_info (f, dhandle)
189 struct pr_handle info;
196 return debug_write (dhandle, &pr_fns, (PTR) &info);
199 /* Indent to the current indentation level. */
203 struct pr_handle *info;
207 for (i = 0; i < info->indent; i++)
211 /* Push a type on the type stack. */
214 push_type (info, type)
215 struct pr_handle *info;
223 n = (struct pr_stack *) xmalloc (sizeof *n);
224 memset (n, 0, sizeof *n);
226 n->type = xstrdup (type);
227 n->visibility = DEBUG_VISIBILITY_IGNORE;
229 n->next = info->stack;
235 /* Prepend a string onto the type on the top of the type stack. */
238 prepend_type (info, s)
239 struct pr_handle *info;
244 assert (info->stack != NULL);
246 n = (char *) xmalloc (strlen (s) + strlen (info->stack->type) + 1);
247 sprintf (n, "%s%s", s, info->stack->type);
248 free (info->stack->type);
249 info->stack->type = n;
254 /* Append a string to the type on the top of the type stack. */
257 append_type (info, s)
258 struct pr_handle *info;
266 assert (info->stack != NULL);
268 len = strlen (info->stack->type);
269 info->stack->type = (char *) xrealloc (info->stack->type,
270 len + strlen (s) + 1);
271 strcpy (info->stack->type + len, s);
276 /* We use an underscore to indicate where the name should go in a type
277 string. This function substitutes a string for the underscore. If
278 there is no underscore, the name follows the type. */
281 substitute_type (info, s)
282 struct pr_handle *info;
287 assert (info->stack != NULL);
289 u = strchr (info->stack->type, '|');
294 n = (char *) xmalloc (strlen (info->stack->type) + strlen (s));
296 memcpy (n, info->stack->type, u - info->stack->type);
297 strcpy (n + (u - info->stack->type), s);
300 free (info->stack->type);
301 info->stack->type = n;
306 if (strchr (s, '|') != NULL
307 && (strchr (info->stack->type, '{') != NULL
308 || strchr (info->stack->type, '(') != NULL))
310 if (! prepend_type (info, "(")
311 || ! append_type (info, ")"))
318 return (append_type (info, " ")
319 && append_type (info, s));
322 /* Indent the type at the top of the stack by appending spaces. */
326 struct pr_handle *info;
330 for (i = 0; i < info->indent; i++)
332 if (! append_type (info, " "))
339 /* Pop a type from the type stack. */
343 struct pr_handle *info;
348 assert (info->stack != NULL);
351 info->stack = o->next;
358 /* Print a VMA value into a string. */
361 print_vma (vma, buf, unsignedp, hexp)
367 if (sizeof (vma) <= sizeof (unsigned long))
370 sprintf (buf, "0x%lx", (unsigned long) vma);
372 sprintf (buf, "%lu", (unsigned long) vma);
374 sprintf (buf, "%ld", (long) vma);
380 sprintf_vma (buf + 2, vma);
384 /* Start a new compilation unit. */
387 pr_start_compilation_unit (p, filename)
389 const char *filename;
391 struct pr_handle *info = (struct pr_handle *) p;
393 assert (info->indent == 0);
395 fprintf (info->f, "%s:\n", filename);
400 /* Start a source file within a compilation unit. */
403 pr_start_source (p, filename)
405 const char *filename;
407 struct pr_handle *info = (struct pr_handle *) p;
409 assert (info->indent == 0);
411 fprintf (info->f, " %s:\n", filename);
416 /* Push an ellipsis type onto the type stack. */
422 struct pr_handle *info = (struct pr_handle *) p;
424 return push_type (info, "...");
427 /* Push an empty type onto the type stack. */
433 struct pr_handle *info = (struct pr_handle *) p;
435 return push_type (info, "<undefined>");
438 /* Push a void type onto the type stack. */
444 struct pr_handle *info = (struct pr_handle *) p;
446 return push_type (info, "void");
449 /* Push an integer type onto the type stack. */
452 pr_int_type (p, size, unsignedp)
457 struct pr_handle *info = (struct pr_handle *) p;
460 sprintf (ab, "%sint%d", unsignedp ? "u" : "", size * 8);
461 return push_type (info, ab);
464 /* Push a floating type onto the type stack. */
467 pr_float_type (p, size)
471 struct pr_handle *info = (struct pr_handle *) p;
475 return push_type (info, "float");
477 return push_type (info, "double");
479 sprintf (ab, "float%d", size * 8);
480 return push_type (info, ab);
483 /* Push a complex type onto the type stack. */
486 pr_complex_type (p, size)
490 struct pr_handle *info = (struct pr_handle *) p;
492 if (! pr_float_type (p, size))
495 return prepend_type (info, "complex ");
498 /* Push a boolean type onto the type stack. */
501 pr_bool_type (p, size)
505 struct pr_handle *info = (struct pr_handle *) p;
508 sprintf (ab, "bool%d", size * 8);
510 return push_type (info, ab);
513 /* Push an enum type onto the type stack. */
516 pr_enum_type (p, tag, names, values)
520 bfd_signed_vma *values;
522 struct pr_handle *info = (struct pr_handle *) p;
526 if (! push_type (info, "enum "))
530 if (! append_type (info, tag)
531 || ! append_type (info, " "))
534 if (! append_type (info, "{ "))
539 if (! append_type (info, "/* undefined */"))
545 for (i = 0; names[i] != NULL; i++)
549 if (! append_type (info, ", "))
553 if (! append_type (info, names[i]))
556 if (values[i] != val)
560 print_vma (values[i], ab, false, false);
561 if (! append_type (info, " = ")
562 || ! append_type (info, ab))
571 return append_type (info, " }");
574 /* Turn the top type on the stack into a pointer. */
580 struct pr_handle *info = (struct pr_handle *) p;
583 assert (info->stack != NULL);
585 s = strchr (info->stack->type, '|');
586 if (s != NULL && s[1] == '[')
587 return substitute_type (info, "(*|)");
588 return substitute_type (info, "*|");
591 /* Turn the top type on the stack into a function returning that type. */
597 struct pr_handle *info = (struct pr_handle *) p;
599 assert (info->stack != NULL);
601 return substitute_type (info, "(|) ()");
604 /* Turn the top type on the stack into a reference to that type. */
607 pr_reference_type (p)
610 struct pr_handle *info = (struct pr_handle *) p;
612 assert (info->stack != NULL);
614 return substitute_type (info, "&|");
617 /* Make a range type. */
620 pr_range_type (p, lower, upper)
622 bfd_signed_vma lower;
623 bfd_signed_vma upper;
625 struct pr_handle *info = (struct pr_handle *) p;
626 char abl[20], abu[20];
628 assert (info->stack != NULL);
630 if (! substitute_type (info, ""))
633 print_vma (lower, abl, false, false);
634 print_vma (upper, abu, false, false);
636 return (prepend_type (info, "range (")
637 && append_type (info, "):")
638 && append_type (info, abl)
639 && append_type (info, ":")
640 && append_type (info, abu));
643 /* Make an array type. */
647 pr_array_type (p, lower, upper, stringp)
649 bfd_signed_vma lower;
650 bfd_signed_vma upper;
653 struct pr_handle *info = (struct pr_handle *) p;
655 char abl[20], abu[20], ab[50];
657 range_type = pop_type (info);
658 if (range_type == NULL)
667 print_vma (upper + 1, abu, false, false);
668 sprintf (ab, "|[%s]", abu);
673 print_vma (lower, abl, false, false);
674 print_vma (upper, abu, false, false);
675 sprintf (ab, "|[%s:%s]", abl, abu);
678 if (! substitute_type (info, ab))
681 if (strcmp (range_type, "int") != 0)
683 if (! append_type (info, ":")
684 || ! append_type (info, range_type))
690 if (! append_type (info, " /* string */"))
697 /* Make a set type. */
701 pr_set_type (p, bitstringp)
705 struct pr_handle *info = (struct pr_handle *) p;
707 if (! substitute_type (info, ""))
710 if (! prepend_type (info, "set { ")
711 || ! append_type (info, " }"))
716 if (! append_type (info, "/* bitstring */"))
723 /* Make an offset type. */
729 struct pr_handle *info = (struct pr_handle *) p;
732 if (! substitute_type (info, ""))
739 return (substitute_type (info, "")
740 && prepend_type (info, " ")
741 && prepend_type (info, t)
742 && append_type (info, "::|"));
745 /* Make a method type. */
748 pr_method_type (p, domain, argcount)
753 struct pr_handle *info = (struct pr_handle *) p;
765 if (! substitute_type (info, ""))
767 domain_type = pop_type (info);
768 if (domain_type == NULL)
770 if (strncmp (domain_type, "class ", sizeof "class " - 1) == 0
771 && strchr (domain_type + sizeof "class " - 1, ' ') == NULL)
772 domain_type += sizeof "class " - 1;
773 else if (strncmp (domain_type, "union class ",
774 sizeof "union class ") == 0
775 && (strchr (domain_type + sizeof "union class " - 1, ' ')
777 domain_type += sizeof "union class " - 1;
778 len += strlen (domain_type);
790 arg_types = (char **) xmalloc (argcount * sizeof *arg_types);
791 for (i = argcount - 1; i >= 0; i--)
793 if (! substitute_type (info, ""))
795 arg_types[i] = pop_type (info);
796 if (arg_types[i] == NULL)
798 len += strlen (arg_types[i]) + 2;
802 /* Now the return type is on the top of the stack. */
804 s = (char *) xmalloc (len);
808 strcpy (s, domain_type);
812 strcat (s, "/* unknown */");
817 for (i = 0; i < argcount; i++)
821 strcat (s, arg_types[i]);
827 if (! substitute_type (info, s))
835 /* Make a const qualified type. */
841 struct pr_handle *info = (struct pr_handle *) p;
843 return substitute_type (info, "const |");
846 /* Make a volatile qualified type. */
852 struct pr_handle *info = (struct pr_handle *) p;
854 return substitute_type (info, "volatile |");
857 /* Start accumulating a struct type. */
860 pr_start_struct_type (p, tag, id, structp, size)
867 struct pr_handle *info = (struct pr_handle *) p;
872 if (! push_type (info, structp ? "struct " : "union "))
876 if (! append_type (info, tag))
883 sprintf (idbuf, "%%anon%u", id);
884 if (! append_type (info, idbuf))
889 sprintf (ab, " { /* size %u */\n", size);
892 if (! append_type (info, ab))
894 info->stack->visibility = DEBUG_VISIBILITY_PUBLIC;
895 return indent_type (info);
898 /* Output the visibility of a field in a struct. */
901 pr_fix_visibility (info, visibility)
902 struct pr_handle *info;
903 enum debug_visibility visibility;
909 assert (info->stack != NULL);
911 if (info->stack->visibility == visibility)
914 assert (info->stack->visibility != DEBUG_VISIBILITY_IGNORE);
918 case DEBUG_VISIBILITY_PUBLIC:
921 case DEBUG_VISIBILITY_PRIVATE:
924 case DEBUG_VISIBILITY_PROTECTED:
932 /* Trim off a trailing space in the struct string, to make the
933 output look a bit better, then stick on the visibility string. */
935 t = info->stack->type;
937 assert (t[len - 1] == ' ');
940 if (! append_type (info, s)
941 || ! append_type (info, ":\n")
942 || ! indent_type (info))
945 info->stack->visibility = visibility;
950 /* Add a field to a struct type. */
953 pr_struct_field (p, name, bitpos, bitsize, visibility)
958 enum debug_visibility visibility;
960 struct pr_handle *info = (struct pr_handle *) p;
964 if (! substitute_type (info, name))
967 if (! append_type (info, "; /* "))
972 print_vma (bitsize, ab, true, false);
973 if (! append_type (info, "bitsize ")
974 || ! append_type (info, ab)
975 || ! append_type (info, ", "))
979 print_vma (bitpos, ab, true, false);
980 if (! append_type (info, "bitpos ")
981 || ! append_type (info, ab)
982 || ! append_type (info, " */\n")
983 || ! indent_type (info))
990 if (! pr_fix_visibility (info, visibility))
993 return append_type (info, t);
996 /* Finish a struct type. */
999 pr_end_struct_type (p)
1002 struct pr_handle *info = (struct pr_handle *) p;
1005 assert (info->stack != NULL);
1006 assert (info->indent >= 2);
1010 /* Change the trailing indentation to have a close brace. */
1011 s = info->stack->type + strlen (info->stack->type) - 2;
1012 assert (strcmp (s, " ") == 0);
1020 /* Start a class type. */
1023 pr_start_class_type (p, tag, id, structp, size, vptr, ownvptr)
1032 struct pr_handle *info = (struct pr_handle *) p;
1037 if (vptr && ! ownvptr)
1039 tv = pop_type (info);
1044 if (! push_type (info, structp ? "class " : "union class "))
1048 if (! append_type (info, tag))
1055 sprintf (idbuf, "%%anon%u", id);
1056 if (! append_type (info, idbuf))
1060 if (! append_type (info, " {"))
1062 if (size != 0 || vptr || ownvptr)
1064 if (! append_type (info, " /*"))
1071 sprintf (ab, "%u", size);
1072 if (! append_type (info, " size ")
1073 || ! append_type (info, ab))
1079 if (! append_type (info, " vtable "))
1083 if (! append_type (info, "self "))
1088 if (! append_type (info, tv)
1089 || ! append_type (info, " "))
1094 if (! append_type (info, " */"))
1098 info->stack->visibility = DEBUG_VISIBILITY_PRIVATE;
1100 return (append_type (info, "\n")
1101 && indent_type (info));
1104 /* Add a static member to a class. */
1107 pr_class_static_member (p, name, physname, visibility)
1110 const char *physname;
1111 enum debug_visibility visibility;
1113 struct pr_handle *info = (struct pr_handle *) p;
1116 if (! substitute_type (info, name))
1119 if (! prepend_type (info, "static ")
1120 || ! append_type (info, "; /* ")
1121 || ! append_type (info, physname)
1122 || ! append_type (info, " */\n")
1123 || ! indent_type (info))
1126 t = pop_type (info);
1130 if (! pr_fix_visibility (info, visibility))
1133 return append_type (info, t);
1136 /* Add a base class to a class. */
1139 pr_class_baseclass (p, bitpos, virtual, visibility)
1143 enum debug_visibility visibility;
1145 struct pr_handle *info = (struct pr_handle *) p;
1151 assert (info->stack != NULL && info->stack->next != NULL);
1153 if (! substitute_type (info, ""))
1156 t = pop_type (info);
1160 if (strncmp (t, "class ", sizeof "class " - 1) == 0)
1161 t += sizeof "class " - 1;
1163 /* Push it back on to take advantage of the prepend_type and
1164 append_type routines. */
1165 if (! push_type (info, t))
1170 if (! prepend_type (info, "virtual "))
1176 case DEBUG_VISIBILITY_PUBLIC:
1179 case DEBUG_VISIBILITY_PROTECTED:
1180 prefix = "protected ";
1182 case DEBUG_VISIBILITY_PRIVATE:
1183 prefix = "private ";
1186 prefix = "/* unknown visibility */ ";
1190 if (! prepend_type (info, prefix))
1195 print_vma (bitpos, ab, true, false);
1196 if (! append_type (info, " /* bitpos ")
1197 || ! append_type (info, ab)
1198 || ! append_type (info, " */"))
1202 /* Now the top of the stack is something like "public A / * bitpos
1203 10 * /". The next element on the stack is something like "class
1204 xx { / * size 8 * /\n...". We want to substitute the top of the
1205 stack in before the {. */
1206 s = strchr (info->stack->next->type, '{');
1210 /* If there is already a ':', then we already have a baseclass, and
1211 we must append this one after a comma. */
1212 for (l = info->stack->next->type; l != s; l++)
1215 if (! prepend_type (info, l == s ? " : " : ", "))
1218 t = pop_type (info);
1222 n = (char *) xmalloc (strlen (info->stack->type) + strlen (t) + 1);
1223 memcpy (n, info->stack->type, s - info->stack->type);
1224 strcpy (n + (s - info->stack->type), t);
1227 free (info->stack->type);
1228 info->stack->type = n;
1235 /* Start adding a method to a class. */
1238 pr_class_start_method (p, name)
1242 struct pr_handle *info = (struct pr_handle *) p;
1244 assert (info->stack != NULL);
1245 info->stack->method = name;
1249 /* Add a variant to a method. */
1252 pr_class_method_variant (p, physname, visibility, constp, volatilep, voffset,
1255 const char *physname;
1256 enum debug_visibility visibility;
1262 struct pr_handle *info = (struct pr_handle *) p;
1266 assert (info->stack != NULL);
1267 assert (info->stack->next != NULL);
1269 /* Put the const and volatile qualifiers on the type. */
1272 if (! append_type (info, " volatile"))
1277 if (! append_type (info, " const"))
1281 /* Stick the name of the method into its type. */
1282 if (! substitute_type (info,
1284 ? info->stack->next->next->method
1285 : info->stack->next->method)))
1289 method_type = pop_type (info);
1290 if (method_type == NULL)
1293 /* Pull off the context type if there is one. */
1295 context_type = NULL;
1298 context_type = pop_type (info);
1299 if (context_type == NULL)
1303 /* Now the top of the stack is the class. */
1305 if (! pr_fix_visibility (info, visibility))
1308 if (! append_type (info, method_type)
1309 || ! append_type (info, " /* ")
1310 || ! append_type (info, physname)
1311 || ! append_type (info, " "))
1313 if (context || voffset != 0)
1319 if (! append_type (info, "context ")
1320 || ! append_type (info, context_type)
1321 || ! append_type (info, " "))
1324 print_vma (voffset, ab, true, false);
1325 if (! append_type (info, "voffset ")
1326 || ! append_type (info, ab))
1330 return (append_type (info, " */;\n")
1331 && indent_type (info));
1334 /* Add a static variant to a method. */
1337 pr_class_static_method_variant (p, physname, visibility, constp, volatilep)
1339 const char *physname;
1340 enum debug_visibility visibility;
1344 struct pr_handle *info = (struct pr_handle *) p;
1347 assert (info->stack != NULL);
1348 assert (info->stack->next != NULL);
1349 assert (info->stack->next->method != NULL);
1351 /* Put the const and volatile qualifiers on the type. */
1354 if (! append_type (info, " volatile"))
1359 if (! append_type (info, " const"))
1363 /* Mark it as static. */
1364 if (! prepend_type (info, "static "))
1367 /* Stick the name of the method into its type. */
1368 if (! substitute_type (info, info->stack->next->method))
1372 method_type = pop_type (info);
1373 if (method_type == NULL)
1376 /* Now the top of the stack is the class. */
1378 if (! pr_fix_visibility (info, visibility))
1381 return (append_type (info, method_type)
1382 && append_type (info, " /* ")
1383 && append_type (info, physname)
1384 && append_type (info, " */;\n")
1385 && indent_type (info));
1388 /* Finish up a method. */
1391 pr_class_end_method (p)
1394 struct pr_handle *info = (struct pr_handle *) p;
1396 info->stack->method = NULL;
1400 /* Finish up a class. */
1403 pr_end_class_type (p)
1406 return pr_end_struct_type (p);
1409 /* Push a type on the stack using a typedef name. */
1412 pr_typedef_type (p, name)
1416 struct pr_handle *info = (struct pr_handle *) p;
1418 return push_type (info, name);
1421 /* Push a type on the stack using a tag name. */
1424 pr_tag_type (p, name, id, kind)
1428 enum debug_type_kind kind;
1430 struct pr_handle *info = (struct pr_handle *) p;
1431 const char *t, *tag;
1436 case DEBUG_KIND_STRUCT:
1439 case DEBUG_KIND_UNION:
1442 case DEBUG_KIND_ENUM:
1445 case DEBUG_KIND_CLASS:
1448 case DEBUG_KIND_UNION_CLASS:
1456 if (! push_type (info, t))
1462 sprintf (idbuf, "%%anon%u", id);
1466 return append_type (info, tag);
1469 /* Output a typedef. */
1476 struct pr_handle *info = (struct pr_handle *) p;
1479 if (! substitute_type (info, name))
1482 s = pop_type (info);
1487 fprintf (info->f, "typedef %s;\n", s);
1494 /* Output a tag. The tag should already be in the string on the
1495 stack, so all we have to do here is print it out. */
1503 struct pr_handle *info = (struct pr_handle *) p;
1506 t = pop_type (info);
1511 fprintf (info->f, "%s;\n", t);
1518 /* Output an integer constant. */
1521 pr_int_constant (p, name, val)
1526 struct pr_handle *info = (struct pr_handle *) info;
1530 print_vma (val, ab, false, false);
1531 fprintf (info->f, "const int %s = %s;\n", name, ab);
1535 /* Output a floating point constant. */
1538 pr_float_constant (p, name, val)
1543 struct pr_handle *info = (struct pr_handle *) info;
1546 fprintf (info->f, "const double %s = %g;\n", name, val);
1550 /* Output a typed constant. */
1553 pr_typed_constant (p, name, val)
1558 struct pr_handle *info = (struct pr_handle *) p;
1562 t = pop_type (info);
1567 print_vma (val, ab, false, false);
1568 fprintf (info->f, "const %s %s = %s;\n", t, name, ab);
1575 /* Output a variable. */
1578 pr_variable (p, name, kind, val)
1581 enum debug_var_kind kind;
1584 struct pr_handle *info = (struct pr_handle *) p;
1588 if (! substitute_type (info, name))
1591 t = pop_type (info);
1599 case DEBUG_LOCAL_STATIC:
1600 fprintf (info->f, "static ");
1602 case DEBUG_REGISTER:
1603 fprintf (info->f, "register ");
1608 print_vma (val, ab, true, true);
1609 fprintf (info->f, "%s /* %s */;\n", t, ab);
1616 /* Start outputting a function. */
1619 pr_start_function (p, name, global)
1624 struct pr_handle *info = (struct pr_handle *) p;
1627 if (! substitute_type (info, name))
1630 t = pop_type (info);
1636 fprintf (info->f, "static ");
1637 fprintf (info->f, "%s (", t);
1639 info->parameter = 1;
1644 /* Output a function parameter. */
1647 pr_function_parameter (p, name, kind, val)
1650 enum debug_parm_kind kind;
1653 struct pr_handle *info = (struct pr_handle *) p;
1657 if (kind == DEBUG_PARM_REFERENCE
1658 || kind == DEBUG_PARM_REF_REG)
1660 if (! pr_reference_type (p))
1664 if (! substitute_type (info, name))
1667 t = pop_type (info);
1671 if (info->parameter != 1)
1672 fprintf (info->f, ", ");
1674 if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG)
1675 fprintf (info->f, "register ");
1677 print_vma (val, ab, true, true);
1678 fprintf (info->f, "%s /* %s */", t, ab);
1687 /* Start writing out a block. */
1690 pr_start_block (p, addr)
1694 struct pr_handle *info = (struct pr_handle *) p;
1697 if (info->parameter > 0)
1699 fprintf (info->f, ")\n");
1700 info->parameter = 0;
1704 print_vma (addr, ab, true, true);
1705 fprintf (info->f, "{ /* %s */\n", ab);
1712 /* Write out line number information. */
1715 pr_lineno (p, filename, lineno, addr)
1717 const char *filename;
1718 unsigned long lineno;
1721 struct pr_handle *info = (struct pr_handle *) p;
1725 print_vma (addr, ab, true, true);
1726 fprintf (info->f, "/* file %s line %lu addr %s */\n", filename, lineno, ab);
1731 /* Finish writing out a block. */
1734 pr_end_block (p, addr)
1738 struct pr_handle *info = (struct pr_handle *) p;
1744 print_vma (addr, ab, true, true);
1745 fprintf (info->f, "} /* %s */\n", ab);
1750 /* Finish writing out a function. */