daily update
[binutils.git] / binutils / prdbg.c
blob098bd58c3d4337f7acdbab59151cd7d536bb9f8d
1 /* prdbg.c -- Print out generic debugging information.
2 Copyright 1995, 1996, 1999, 2002, 2003, 2004, 2006, 2007
3 Free Software Foundation, Inc.
4 Written by Ian Lance Taylor <ian@cygnus.com>.
5 Tags style generation written by Salvador E. Tropea <set@computer.org>.
7 This file is part of GNU Binutils.
9 This program is free software; you can redistribute it and/or modify
10 it under the terms of the GNU General Public License as published by
11 the Free Software Foundation; either version 3 of the License, or
12 (at your option) any later version.
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 GNU General Public License for more details.
19 You should have received a copy of the GNU General Public License
20 along with this program; if not, write to the Free Software
21 Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
22 02110-1301, USA. */
24 /* This file prints out the generic debugging information, by
25 supplying a set of routines to debug_write. */
27 #include "sysdep.h"
28 #include <assert.h>
29 #include "bfd.h"
30 #include "libiberty.h"
31 #include "demangle.h"
32 #include "debug.h"
33 #include "budbg.h"
35 /* This is the structure we use as a handle for these routines. */
37 struct pr_handle
39 /* File to print information to. */
40 FILE *f;
41 /* Current indentation level. */
42 unsigned int indent;
43 /* Type stack. */
44 struct pr_stack *stack;
45 /* Parameter number we are about to output. */
46 int parameter;
47 /* The following are used only by the tags code (tg_). */
48 /* Name of the file we are using. */
49 char *filename;
50 /* The BFD. */
51 bfd *abfd;
52 /* The symbols table for this BFD. */
53 asymbol **syms;
54 /* Pointer to a function to demangle symbols. */
55 char *(*demangler) (bfd *, const char *, int);
58 /* The type stack. */
60 struct pr_stack
62 /* Next element on the stack. */
63 struct pr_stack *next;
64 /* This element. */
65 char *type;
66 /* Current visibility of fields if this is a class. */
67 enum debug_visibility visibility;
68 /* Name of the current method we are handling. */
69 const char *method;
70 /* The following are used only by the tags code (tg_). */
71 /* Type for the container (struct, union, class, union class). */
72 const char *flavor;
73 /* A comma separated list of parent classes. */
74 char *parents;
75 /* How many parents contains parents. */
76 int num_parents;
79 static void indent (struct pr_handle *);
80 static bfd_boolean push_type (struct pr_handle *, const char *);
81 static bfd_boolean prepend_type (struct pr_handle *, const char *);
82 static bfd_boolean append_type (struct pr_handle *, const char *);
83 static bfd_boolean substitute_type (struct pr_handle *, const char *);
84 static bfd_boolean indent_type (struct pr_handle *);
85 static char *pop_type (struct pr_handle *);
86 static void print_vma (bfd_vma, char *, bfd_boolean, bfd_boolean);
87 static bfd_boolean pr_fix_visibility
88 (struct pr_handle *, enum debug_visibility);
89 static bfd_boolean pr_start_compilation_unit (void *, const char *);
90 static bfd_boolean pr_start_source (void *, const char *);
91 static bfd_boolean pr_empty_type (void *);
92 static bfd_boolean pr_void_type (void *);
93 static bfd_boolean pr_int_type (void *, unsigned int, bfd_boolean);
94 static bfd_boolean pr_float_type (void *, unsigned int);
95 static bfd_boolean pr_complex_type (void *, unsigned int);
96 static bfd_boolean pr_bool_type (void *, unsigned int);
97 static bfd_boolean pr_enum_type
98 (void *, const char *, const char **, bfd_signed_vma *);
99 static bfd_boolean pr_pointer_type (void *);
100 static bfd_boolean pr_function_type (void *, int, bfd_boolean);
101 static bfd_boolean pr_reference_type (void *);
102 static bfd_boolean pr_range_type (void *, bfd_signed_vma, bfd_signed_vma);
103 static bfd_boolean pr_array_type
104 (void *, bfd_signed_vma, bfd_signed_vma, bfd_boolean);
105 static bfd_boolean pr_set_type (void *, bfd_boolean);
106 static bfd_boolean pr_offset_type (void *);
107 static bfd_boolean pr_method_type (void *, bfd_boolean, int, bfd_boolean);
108 static bfd_boolean pr_const_type (void *);
109 static bfd_boolean pr_volatile_type (void *);
110 static bfd_boolean pr_start_struct_type
111 (void *, const char *, unsigned int, bfd_boolean, unsigned int);
112 static bfd_boolean pr_struct_field
113 (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility);
114 static bfd_boolean pr_end_struct_type (void *);
115 static bfd_boolean pr_start_class_type
116 (void *, const char *, unsigned int, bfd_boolean, unsigned int,
117 bfd_boolean, bfd_boolean);
118 static bfd_boolean pr_class_static_member
119 (void *, const char *, const char *, enum debug_visibility);
120 static bfd_boolean pr_class_baseclass
121 (void *, bfd_vma, bfd_boolean, enum debug_visibility);
122 static bfd_boolean pr_class_start_method (void *, const char *);
123 static bfd_boolean pr_class_method_variant
124 (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean,
125 bfd_vma, bfd_boolean);
126 static bfd_boolean pr_class_static_method_variant
127 (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean);
128 static bfd_boolean pr_class_end_method (void *);
129 static bfd_boolean pr_end_class_type (void *);
130 static bfd_boolean pr_typedef_type (void *, const char *);
131 static bfd_boolean pr_tag_type
132 (void *, const char *, unsigned int, enum debug_type_kind);
133 static bfd_boolean pr_typdef (void *, const char *);
134 static bfd_boolean pr_tag (void *, const char *);
135 static bfd_boolean pr_int_constant (void *, const char *, bfd_vma);
136 static bfd_boolean pr_float_constant (void *, const char *, double);
137 static bfd_boolean pr_typed_constant (void *, const char *, bfd_vma);
138 static bfd_boolean pr_variable
139 (void *, const char *, enum debug_var_kind, bfd_vma);
140 static bfd_boolean pr_start_function (void *, const char *, bfd_boolean);
141 static bfd_boolean pr_function_parameter
142 (void *, const char *, enum debug_parm_kind, bfd_vma);
143 static bfd_boolean pr_start_block (void *, bfd_vma);
144 static bfd_boolean pr_end_block (void *, bfd_vma);
145 static bfd_boolean pr_end_function (void *);
146 static bfd_boolean pr_lineno (void *, const char *, unsigned long, bfd_vma);
147 static bfd_boolean append_parent (struct pr_handle *, const char *);
148 /* Only used by tg_ code. */
149 static bfd_boolean tg_fix_visibility
150 (struct pr_handle *, enum debug_visibility);
151 static void find_address_in_section (bfd *, asection *, void *);
152 static void translate_addresses (bfd *, char *, FILE *, asymbol **);
153 static const char *visibility_name (enum debug_visibility);
154 /* Tags style replacements. */
155 static bfd_boolean tg_start_compilation_unit (void *, const char *);
156 static bfd_boolean tg_start_source (void *, const char *);
157 static bfd_boolean tg_enum_type
158 (void *, const char *, const char **, bfd_signed_vma *);
159 static bfd_boolean tg_start_struct_type
160 (void *, const char *, unsigned int, bfd_boolean, unsigned int);
161 static bfd_boolean pr_struct_field
162 (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility);
163 static bfd_boolean tg_struct_field
164 (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility);
165 static bfd_boolean tg_struct_field
166 (void *, const char *, bfd_vma, bfd_vma, enum debug_visibility);
167 static bfd_boolean tg_end_struct_type (void *);
168 static bfd_boolean tg_start_class_type
169 (void *, const char *, unsigned int, bfd_boolean, unsigned int, bfd_boolean, bfd_boolean);
170 static bfd_boolean tg_class_static_member
171 (void *, const char *, const char *, enum debug_visibility);
172 static bfd_boolean tg_class_baseclass
173 (void *, bfd_vma, bfd_boolean, enum debug_visibility);
174 static bfd_boolean tg_class_method_variant
175 (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, bfd_vma, bfd_boolean);
176 static bfd_boolean tg_class_static_method_variant
177 (void *, const char *, enum debug_visibility, bfd_boolean, bfd_boolean);
178 static bfd_boolean tg_end_class_type (void *);
179 static bfd_boolean tg_tag_type
180 (void *, const char *, unsigned int, enum debug_type_kind);
181 static bfd_boolean tg_typdef (void *, const char *);
182 static bfd_boolean tg_tag (void *, const char *);
183 static bfd_boolean tg_int_constant (void *, const char *, bfd_vma);
184 static bfd_boolean tg_float_constant (void *, const char *, double);
185 static bfd_boolean tg_typed_constant (void *, const char *, bfd_vma);
186 static bfd_boolean tg_variable
187 (void *, const char *, enum debug_var_kind, bfd_vma);
188 static bfd_boolean tg_start_function (void *, const char *, bfd_boolean);
189 static bfd_boolean tg_function_parameter
190 (void *, const char *, enum debug_parm_kind, bfd_vma);
191 static bfd_boolean tg_start_block (void *, bfd_vma);
192 static bfd_boolean tg_end_block (void *, bfd_vma);
193 static bfd_boolean tg_lineno (void *, const char *, unsigned long, bfd_vma);
195 static const struct debug_write_fns pr_fns =
197 pr_start_compilation_unit,
198 pr_start_source,
199 pr_empty_type,
200 pr_void_type,
201 pr_int_type,
202 pr_float_type,
203 pr_complex_type,
204 pr_bool_type,
205 pr_enum_type,
206 pr_pointer_type,
207 pr_function_type,
208 pr_reference_type,
209 pr_range_type,
210 pr_array_type,
211 pr_set_type,
212 pr_offset_type,
213 pr_method_type,
214 pr_const_type,
215 pr_volatile_type,
216 pr_start_struct_type,
217 pr_struct_field,
218 pr_end_struct_type,
219 pr_start_class_type,
220 pr_class_static_member,
221 pr_class_baseclass,
222 pr_class_start_method,
223 pr_class_method_variant,
224 pr_class_static_method_variant,
225 pr_class_end_method,
226 pr_end_class_type,
227 pr_typedef_type,
228 pr_tag_type,
229 pr_typdef,
230 pr_tag,
231 pr_int_constant,
232 pr_float_constant,
233 pr_typed_constant,
234 pr_variable,
235 pr_start_function,
236 pr_function_parameter,
237 pr_start_block,
238 pr_end_block,
239 pr_end_function,
240 pr_lineno
243 static const struct debug_write_fns tg_fns =
245 tg_start_compilation_unit,
246 tg_start_source,
247 pr_empty_type, /* Same, push_type. */
248 pr_void_type, /* Same, push_type. */
249 pr_int_type, /* Same, push_type. */
250 pr_float_type, /* Same, push_type. */
251 pr_complex_type, /* Same, push_type. */
252 pr_bool_type, /* Same, push_type. */
253 tg_enum_type,
254 pr_pointer_type, /* Same, changes to pointer. */
255 pr_function_type, /* Same, push_type. */
256 pr_reference_type, /* Same, changes to reference. */
257 pr_range_type, /* FIXME: What's that?. */
258 pr_array_type, /* Same, push_type. */
259 pr_set_type, /* FIXME: What's that?. */
260 pr_offset_type, /* FIXME: What's that?. */
261 pr_method_type, /* Same. */
262 pr_const_type, /* Same, changes to const. */
263 pr_volatile_type, /* Same, changes to volatile. */
264 tg_start_struct_type,
265 tg_struct_field,
266 tg_end_struct_type,
267 tg_start_class_type,
268 tg_class_static_member,
269 tg_class_baseclass,
270 pr_class_start_method, /* Same, remembers that's a method. */
271 tg_class_method_variant,
272 tg_class_static_method_variant,
273 pr_class_end_method, /* Same, forgets that's a method. */
274 tg_end_class_type,
275 pr_typedef_type, /* Same, just push type. */
276 tg_tag_type,
277 tg_typdef,
278 tg_tag,
279 tg_int_constant, /* Untested. */
280 tg_float_constant, /* Untested. */
281 tg_typed_constant, /* Untested. */
282 tg_variable,
283 tg_start_function,
284 tg_function_parameter,
285 tg_start_block,
286 tg_end_block,
287 pr_end_function, /* Same, does nothing. */
288 tg_lineno
291 /* Print out the generic debugging information recorded in dhandle. */
293 bfd_boolean
294 print_debugging_info (FILE *f, void *dhandle, bfd *abfd, asymbol **syms,
295 void *demangler, bfd_boolean as_tags)
297 struct pr_handle info;
299 info.f = f;
300 info.indent = 0;
301 info.stack = NULL;
302 info.parameter = 0;
303 info.filename = NULL;
304 info.abfd = abfd;
305 info.syms = syms;
306 info.demangler = demangler;
308 if (as_tags)
310 fputs ("!_TAG_FILE_FORMAT\t2\t/extended format/\n", f);
311 fputs ("!_TAG_FILE_SORTED\t0\t/0=unsorted, 1=sorted/\n", f);
312 fputs ("!_TAG_PROGRAM_AUTHOR\tIan Lance Taylor, Salvador E. Tropea and others\t//\n", f);
313 fputs ("!_TAG_PROGRAM_NAME\tobjdump\t/From GNU binutils/\n", f);
316 return as_tags ? debug_write (dhandle, &tg_fns, (void *) & info)
317 : debug_write (dhandle, &pr_fns, (void *) & info);
320 /* Indent to the current indentation level. */
322 static void
323 indent (struct pr_handle *info)
325 unsigned int i;
327 for (i = 0; i < info->indent; i++)
328 putc (' ', info->f);
331 /* Push a type on the type stack. */
333 static bfd_boolean
334 push_type (struct pr_handle *info, const char *type)
336 struct pr_stack *n;
338 if (type == NULL)
339 return FALSE;
341 n = (struct pr_stack *) xmalloc (sizeof *n);
342 memset (n, 0, sizeof *n);
344 n->type = xstrdup (type);
345 n->visibility = DEBUG_VISIBILITY_IGNORE;
346 n->method = NULL;
347 n->next = info->stack;
348 info->stack = n;
350 return TRUE;
353 /* Prepend a string onto the type on the top of the type stack. */
355 static bfd_boolean
356 prepend_type (struct pr_handle *info, const char *s)
358 char *n;
360 assert (info->stack != NULL);
362 n = (char *) xmalloc (strlen (s) + strlen (info->stack->type) + 1);
363 sprintf (n, "%s%s", s, info->stack->type);
364 free (info->stack->type);
365 info->stack->type = n;
367 return TRUE;
370 /* Append a string to the type on the top of the type stack. */
372 static bfd_boolean
373 append_type (struct pr_handle *info, const char *s)
375 unsigned int len;
377 if (s == NULL)
378 return FALSE;
380 assert (info->stack != NULL);
382 len = strlen (info->stack->type);
383 info->stack->type = (char *) xrealloc (info->stack->type,
384 len + strlen (s) + 1);
385 strcpy (info->stack->type + len, s);
387 return TRUE;
390 /* Append a string to the parents on the top of the type stack. */
392 static bfd_boolean
393 append_parent (struct pr_handle *info, const char *s)
395 unsigned int len;
397 if (s == NULL)
398 return FALSE;
400 assert (info->stack != NULL);
402 len = info->stack->parents ? strlen (info->stack->parents) : 0;
403 info->stack->parents = (char *) xrealloc (info->stack->parents,
404 len + strlen (s) + 1);
405 strcpy (info->stack->parents + len, s);
407 return TRUE;
410 /* We use an underscore to indicate where the name should go in a type
411 string. This function substitutes a string for the underscore. If
412 there is no underscore, the name follows the type. */
414 static bfd_boolean
415 substitute_type (struct pr_handle *info, const char *s)
417 char *u;
419 assert (info->stack != NULL);
421 u = strchr (info->stack->type, '|');
422 if (u != NULL)
424 char *n;
426 n = (char *) xmalloc (strlen (info->stack->type) + strlen (s));
428 memcpy (n, info->stack->type, u - info->stack->type);
429 strcpy (n + (u - info->stack->type), s);
430 strcat (n, u + 1);
432 free (info->stack->type);
433 info->stack->type = n;
435 return TRUE;
438 if (strchr (s, '|') != NULL
439 && (strchr (info->stack->type, '{') != NULL
440 || strchr (info->stack->type, '(') != NULL))
442 if (! prepend_type (info, "(")
443 || ! append_type (info, ")"))
444 return FALSE;
447 if (*s == '\0')
448 return TRUE;
450 return (append_type (info, " ")
451 && append_type (info, s));
454 /* Indent the type at the top of the stack by appending spaces. */
456 static bfd_boolean
457 indent_type (struct pr_handle *info)
459 unsigned int i;
461 for (i = 0; i < info->indent; i++)
463 if (! append_type (info, " "))
464 return FALSE;
467 return TRUE;
470 /* Pop a type from the type stack. */
472 static char *
473 pop_type (struct pr_handle *info)
475 struct pr_stack *o;
476 char *ret;
478 assert (info->stack != NULL);
480 o = info->stack;
481 info->stack = o->next;
482 ret = o->type;
483 free (o);
485 return ret;
488 /* Print a VMA value into a string. */
490 static void
491 print_vma (bfd_vma vma, char *buf, bfd_boolean unsignedp, bfd_boolean hexp)
493 if (sizeof (vma) <= sizeof (unsigned long))
495 if (hexp)
496 sprintf (buf, "0x%lx", (unsigned long) vma);
497 else if (unsignedp)
498 sprintf (buf, "%lu", (unsigned long) vma);
499 else
500 sprintf (buf, "%ld", (long) vma);
502 else
504 buf[0] = '0';
505 buf[1] = 'x';
506 sprintf_vma (buf + 2, vma);
510 /* Start a new compilation unit. */
512 static bfd_boolean
513 pr_start_compilation_unit (void *p, const char *filename)
515 struct pr_handle *info = (struct pr_handle *) p;
517 assert (info->indent == 0);
519 fprintf (info->f, "%s:\n", filename);
521 return TRUE;
524 /* Start a source file within a compilation unit. */
526 static bfd_boolean
527 pr_start_source (void *p, const char *filename)
529 struct pr_handle *info = (struct pr_handle *) p;
531 assert (info->indent == 0);
533 fprintf (info->f, " %s:\n", filename);
535 return TRUE;
538 /* Push an empty type onto the type stack. */
540 static bfd_boolean
541 pr_empty_type (void *p)
543 struct pr_handle *info = (struct pr_handle *) p;
545 return push_type (info, "<undefined>");
548 /* Push a void type onto the type stack. */
550 static bfd_boolean
551 pr_void_type (void *p)
553 struct pr_handle *info = (struct pr_handle *) p;
555 return push_type (info, "void");
558 /* Push an integer type onto the type stack. */
560 static bfd_boolean
561 pr_int_type (void *p, unsigned int size, bfd_boolean unsignedp)
563 struct pr_handle *info = (struct pr_handle *) p;
564 char ab[10];
566 sprintf (ab, "%sint%d", unsignedp ? "u" : "", size * 8);
567 return push_type (info, ab);
570 /* Push a floating type onto the type stack. */
572 static bfd_boolean
573 pr_float_type (void *p, unsigned int size)
575 struct pr_handle *info = (struct pr_handle *) p;
576 char ab[10];
578 if (size == 4)
579 return push_type (info, "float");
580 else if (size == 8)
581 return push_type (info, "double");
583 sprintf (ab, "float%d", size * 8);
584 return push_type (info, ab);
587 /* Push a complex type onto the type stack. */
589 static bfd_boolean
590 pr_complex_type (void *p, unsigned int size)
592 struct pr_handle *info = (struct pr_handle *) p;
594 if (! pr_float_type (p, size))
595 return FALSE;
597 return prepend_type (info, "complex ");
600 /* Push a bfd_boolean type onto the type stack. */
602 static bfd_boolean
603 pr_bool_type (void *p, unsigned int size)
605 struct pr_handle *info = (struct pr_handle *) p;
606 char ab[10];
608 sprintf (ab, "bool%d", size * 8);
610 return push_type (info, ab);
613 /* Push an enum type onto the type stack. */
615 static bfd_boolean
616 pr_enum_type (void *p, const char *tag, const char **names,
617 bfd_signed_vma *values)
619 struct pr_handle *info = (struct pr_handle *) p;
620 unsigned int i;
621 bfd_signed_vma val;
623 if (! push_type (info, "enum "))
624 return FALSE;
625 if (tag != NULL)
627 if (! append_type (info, tag)
628 || ! append_type (info, " "))
629 return FALSE;
631 if (! append_type (info, "{ "))
632 return FALSE;
634 if (names == NULL)
636 if (! append_type (info, "/* undefined */"))
637 return FALSE;
639 else
641 val = 0;
642 for (i = 0; names[i] != NULL; i++)
644 if (i > 0)
646 if (! append_type (info, ", "))
647 return FALSE;
650 if (! append_type (info, names[i]))
651 return FALSE;
653 if (values[i] != val)
655 char ab[20];
657 print_vma (values[i], ab, FALSE, FALSE);
658 if (! append_type (info, " = ")
659 || ! append_type (info, ab))
660 return FALSE;
661 val = values[i];
664 ++val;
668 return append_type (info, " }");
671 /* Turn the top type on the stack into a pointer. */
673 static bfd_boolean
674 pr_pointer_type (void *p)
676 struct pr_handle *info = (struct pr_handle *) p;
677 char *s;
679 assert (info->stack != NULL);
681 s = strchr (info->stack->type, '|');
682 if (s != NULL && s[1] == '[')
683 return substitute_type (info, "(*|)");
684 return substitute_type (info, "*|");
687 /* Turn the top type on the stack into a function returning that type. */
689 static bfd_boolean
690 pr_function_type (void *p, int argcount, bfd_boolean varargs)
692 struct pr_handle *info = (struct pr_handle *) p;
693 char **arg_types;
694 unsigned int len;
695 char *s;
697 assert (info->stack != NULL);
699 len = 10;
701 if (argcount <= 0)
703 arg_types = NULL;
704 len += 15;
706 else
708 int i;
710 arg_types = (char **) xmalloc (argcount * sizeof *arg_types);
711 for (i = argcount - 1; i >= 0; i--)
713 if (! substitute_type (info, ""))
714 return FALSE;
715 arg_types[i] = pop_type (info);
716 if (arg_types[i] == NULL)
717 return FALSE;
718 len += strlen (arg_types[i]) + 2;
720 if (varargs)
721 len += 5;
724 /* Now the return type is on the top of the stack. */
726 s = xmalloc (len);
727 LITSTRCPY (s, "(|) (");
729 if (argcount < 0)
730 strcat (s, "/* unknown */");
731 else
733 int i;
735 for (i = 0; i < argcount; i++)
737 if (i > 0)
738 strcat (s, ", ");
739 strcat (s, arg_types[i]);
741 if (varargs)
743 if (i > 0)
744 strcat (s, ", ");
745 strcat (s, "...");
747 if (argcount > 0)
748 free (arg_types);
751 strcat (s, ")");
753 if (! substitute_type (info, s))
754 return FALSE;
756 free (s);
758 return TRUE;
761 /* Turn the top type on the stack into a reference to that type. */
763 static bfd_boolean
764 pr_reference_type (void *p)
766 struct pr_handle *info = (struct pr_handle *) p;
768 assert (info->stack != NULL);
770 return substitute_type (info, "&|");
773 /* Make a range type. */
775 static bfd_boolean
776 pr_range_type (void *p, bfd_signed_vma lower, bfd_signed_vma upper)
778 struct pr_handle *info = (struct pr_handle *) p;
779 char abl[20], abu[20];
781 assert (info->stack != NULL);
783 if (! substitute_type (info, ""))
784 return FALSE;
786 print_vma (lower, abl, FALSE, FALSE);
787 print_vma (upper, abu, FALSE, FALSE);
789 return (prepend_type (info, "range (")
790 && append_type (info, "):")
791 && append_type (info, abl)
792 && append_type (info, ":")
793 && append_type (info, abu));
796 /* Make an array type. */
798 static bfd_boolean
799 pr_array_type (void *p, bfd_signed_vma lower, bfd_signed_vma upper,
800 bfd_boolean stringp)
802 struct pr_handle *info = (struct pr_handle *) p;
803 char *range_type;
804 char abl[20], abu[20], ab[50];
806 range_type = pop_type (info);
807 if (range_type == NULL)
808 return FALSE;
810 if (lower == 0)
812 if (upper == -1)
813 sprintf (ab, "|[]");
814 else
816 print_vma (upper + 1, abu, FALSE, FALSE);
817 sprintf (ab, "|[%s]", abu);
820 else
822 print_vma (lower, abl, FALSE, FALSE);
823 print_vma (upper, abu, FALSE, FALSE);
824 sprintf (ab, "|[%s:%s]", abl, abu);
827 if (! substitute_type (info, ab))
828 return FALSE;
830 if (strcmp (range_type, "int") != 0)
832 if (! append_type (info, ":")
833 || ! append_type (info, range_type))
834 return FALSE;
837 if (stringp)
839 if (! append_type (info, " /* string */"))
840 return FALSE;
843 return TRUE;
846 /* Make a set type. */
848 static bfd_boolean
849 pr_set_type (void *p, bfd_boolean bitstringp)
851 struct pr_handle *info = (struct pr_handle *) p;
853 if (! substitute_type (info, ""))
854 return FALSE;
856 if (! prepend_type (info, "set { ")
857 || ! append_type (info, " }"))
858 return FALSE;
860 if (bitstringp)
862 if (! append_type (info, "/* bitstring */"))
863 return FALSE;
866 return TRUE;
869 /* Make an offset type. */
871 static bfd_boolean
872 pr_offset_type (void *p)
874 struct pr_handle *info = (struct pr_handle *) p;
875 char *t;
877 if (! substitute_type (info, ""))
878 return FALSE;
880 t = pop_type (info);
881 if (t == NULL)
882 return FALSE;
884 return (substitute_type (info, "")
885 && prepend_type (info, " ")
886 && prepend_type (info, t)
887 && append_type (info, "::|"));
890 /* Make a method type. */
892 static bfd_boolean
893 pr_method_type (void *p, bfd_boolean domain, int argcount, bfd_boolean varargs)
895 struct pr_handle *info = (struct pr_handle *) p;
896 unsigned int len;
897 char *domain_type;
898 char **arg_types;
899 char *s;
901 len = 10;
903 if (! domain)
904 domain_type = NULL;
905 else
907 if (! substitute_type (info, ""))
908 return FALSE;
909 domain_type = pop_type (info);
910 if (domain_type == NULL)
911 return FALSE;
912 if (CONST_STRNEQ (domain_type, "class ")
913 && strchr (domain_type + sizeof "class " - 1, ' ') == NULL)
914 domain_type += sizeof "class " - 1;
915 else if (CONST_STRNEQ (domain_type, "union class ")
916 && (strchr (domain_type + sizeof "union class " - 1, ' ')
917 == NULL))
918 domain_type += sizeof "union class " - 1;
919 len += strlen (domain_type);
922 if (argcount <= 0)
924 arg_types = NULL;
925 len += 15;
927 else
929 int i;
931 arg_types = (char **) xmalloc (argcount * sizeof *arg_types);
932 for (i = argcount - 1; i >= 0; i--)
934 if (! substitute_type (info, ""))
935 return FALSE;
936 arg_types[i] = pop_type (info);
937 if (arg_types[i] == NULL)
938 return FALSE;
939 len += strlen (arg_types[i]) + 2;
941 if (varargs)
942 len += 5;
945 /* Now the return type is on the top of the stack. */
947 s = (char *) xmalloc (len);
948 if (! domain)
949 *s = '\0';
950 else
951 strcpy (s, domain_type);
952 strcat (s, "::| (");
954 if (argcount < 0)
955 strcat (s, "/* unknown */");
956 else
958 int i;
960 for (i = 0; i < argcount; i++)
962 if (i > 0)
963 strcat (s, ", ");
964 strcat (s, arg_types[i]);
966 if (varargs)
968 if (i > 0)
969 strcat (s, ", ");
970 strcat (s, "...");
972 if (argcount > 0)
973 free (arg_types);
976 strcat (s, ")");
978 if (! substitute_type (info, s))
979 return FALSE;
981 free (s);
983 return TRUE;
986 /* Make a const qualified type. */
988 static bfd_boolean
989 pr_const_type (void *p)
991 struct pr_handle *info = (struct pr_handle *) p;
993 return substitute_type (info, "const |");
996 /* Make a volatile qualified type. */
998 static bfd_boolean
999 pr_volatile_type (void *p)
1001 struct pr_handle *info = (struct pr_handle *) p;
1003 return substitute_type (info, "volatile |");
1006 /* Start accumulating a struct type. */
1008 static bfd_boolean
1009 pr_start_struct_type (void *p, const char *tag, unsigned int id,
1010 bfd_boolean structp, unsigned int size)
1012 struct pr_handle *info = (struct pr_handle *) p;
1014 info->indent += 2;
1016 if (! push_type (info, structp ? "struct " : "union "))
1017 return FALSE;
1018 if (tag != NULL)
1020 if (! append_type (info, tag))
1021 return FALSE;
1023 else
1025 char idbuf[20];
1027 sprintf (idbuf, "%%anon%u", id);
1028 if (! append_type (info, idbuf))
1029 return FALSE;
1032 if (! append_type (info, " {"))
1033 return FALSE;
1034 if (size != 0 || tag != NULL)
1036 char ab[30];
1038 if (! append_type (info, " /*"))
1039 return FALSE;
1041 if (size != 0)
1043 sprintf (ab, " size %u", size);
1044 if (! append_type (info, ab))
1045 return FALSE;
1047 if (tag != NULL)
1049 sprintf (ab, " id %u", id);
1050 if (! append_type (info, ab))
1051 return FALSE;
1053 if (! append_type (info, " */"))
1054 return FALSE;
1056 if (! append_type (info, "\n"))
1057 return FALSE;
1059 info->stack->visibility = DEBUG_VISIBILITY_PUBLIC;
1061 return indent_type (info);
1064 /* Output the visibility of a field in a struct. */
1066 static bfd_boolean
1067 pr_fix_visibility (struct pr_handle *info, enum debug_visibility visibility)
1069 const char *s = NULL;
1070 char *t;
1071 unsigned int len;
1073 assert (info->stack != NULL);
1075 if (info->stack->visibility == visibility)
1076 return TRUE;
1078 switch (visibility)
1080 case DEBUG_VISIBILITY_PUBLIC:
1081 s = "public";
1082 break;
1083 case DEBUG_VISIBILITY_PRIVATE:
1084 s = "private";
1085 break;
1086 case DEBUG_VISIBILITY_PROTECTED:
1087 s = "protected";
1088 break;
1089 case DEBUG_VISIBILITY_IGNORE:
1090 s = "/* ignore */";
1091 break;
1092 default:
1093 abort ();
1094 return FALSE;
1097 /* Trim off a trailing space in the struct string, to make the
1098 output look a bit better, then stick on the visibility string. */
1100 t = info->stack->type;
1101 len = strlen (t);
1102 assert (t[len - 1] == ' ');
1103 t[len - 1] = '\0';
1105 if (! append_type (info, s)
1106 || ! append_type (info, ":\n")
1107 || ! indent_type (info))
1108 return FALSE;
1110 info->stack->visibility = visibility;
1112 return TRUE;
1115 /* Add a field to a struct type. */
1117 static bfd_boolean
1118 pr_struct_field (void *p, const char *name, bfd_vma bitpos, bfd_vma bitsize,
1119 enum debug_visibility visibility)
1121 struct pr_handle *info = (struct pr_handle *) p;
1122 char ab[20];
1123 char *t;
1125 if (! substitute_type (info, name))
1126 return FALSE;
1128 if (! append_type (info, "; /* "))
1129 return FALSE;
1131 if (bitsize != 0)
1133 print_vma (bitsize, ab, TRUE, FALSE);
1134 if (! append_type (info, "bitsize ")
1135 || ! append_type (info, ab)
1136 || ! append_type (info, ", "))
1137 return FALSE;
1140 print_vma (bitpos, ab, TRUE, FALSE);
1141 if (! append_type (info, "bitpos ")
1142 || ! append_type (info, ab)
1143 || ! append_type (info, " */\n")
1144 || ! indent_type (info))
1145 return FALSE;
1147 t = pop_type (info);
1148 if (t == NULL)
1149 return FALSE;
1151 if (! pr_fix_visibility (info, visibility))
1152 return FALSE;
1154 return append_type (info, t);
1157 /* Finish a struct type. */
1159 static bfd_boolean
1160 pr_end_struct_type (void *p)
1162 struct pr_handle *info = (struct pr_handle *) p;
1163 char *s;
1165 assert (info->stack != NULL);
1166 assert (info->indent >= 2);
1168 info->indent -= 2;
1170 /* Change the trailing indentation to have a close brace. */
1171 s = info->stack->type + strlen (info->stack->type) - 2;
1172 assert (s[0] == ' ' && s[1] == ' ' && s[2] == '\0');
1174 *s++ = '}';
1175 *s = '\0';
1177 return TRUE;
1180 /* Start a class type. */
1182 static bfd_boolean
1183 pr_start_class_type (void *p, const char *tag, unsigned int id,
1184 bfd_boolean structp, unsigned int size,
1185 bfd_boolean vptr, bfd_boolean ownvptr)
1187 struct pr_handle *info = (struct pr_handle *) p;
1188 char *tv = NULL;
1190 info->indent += 2;
1192 if (vptr && ! ownvptr)
1194 tv = pop_type (info);
1195 if (tv == NULL)
1196 return FALSE;
1199 if (! push_type (info, structp ? "class " : "union class "))
1200 return FALSE;
1201 if (tag != NULL)
1203 if (! append_type (info, tag))
1204 return FALSE;
1206 else
1208 char idbuf[20];
1210 sprintf (idbuf, "%%anon%u", id);
1211 if (! append_type (info, idbuf))
1212 return FALSE;
1215 if (! append_type (info, " {"))
1216 return FALSE;
1217 if (size != 0 || vptr || ownvptr || tag != NULL)
1219 if (! append_type (info, " /*"))
1220 return FALSE;
1222 if (size != 0)
1224 char ab[20];
1226 sprintf (ab, "%u", size);
1227 if (! append_type (info, " size ")
1228 || ! append_type (info, ab))
1229 return FALSE;
1232 if (vptr)
1234 if (! append_type (info, " vtable "))
1235 return FALSE;
1236 if (ownvptr)
1238 if (! append_type (info, "self "))
1239 return FALSE;
1241 else
1243 if (! append_type (info, tv)
1244 || ! append_type (info, " "))
1245 return FALSE;
1249 if (tag != NULL)
1251 char ab[30];
1253 sprintf (ab, " id %u", id);
1254 if (! append_type (info, ab))
1255 return FALSE;
1258 if (! append_type (info, " */"))
1259 return FALSE;
1262 info->stack->visibility = DEBUG_VISIBILITY_PRIVATE;
1264 return (append_type (info, "\n")
1265 && indent_type (info));
1268 /* Add a static member to a class. */
1270 static bfd_boolean
1271 pr_class_static_member (void *p, const char *name, const char *physname,
1272 enum debug_visibility visibility)
1274 struct pr_handle *info = (struct pr_handle *) p;
1275 char *t;
1277 if (! substitute_type (info, name))
1278 return FALSE;
1280 if (! prepend_type (info, "static ")
1281 || ! append_type (info, "; /* ")
1282 || ! append_type (info, physname)
1283 || ! append_type (info, " */\n")
1284 || ! indent_type (info))
1285 return FALSE;
1287 t = pop_type (info);
1288 if (t == NULL)
1289 return FALSE;
1291 if (! pr_fix_visibility (info, visibility))
1292 return FALSE;
1294 return append_type (info, t);
1297 /* Add a base class to a class. */
1299 static bfd_boolean
1300 pr_class_baseclass (void *p, bfd_vma bitpos, bfd_boolean virtual,
1301 enum debug_visibility visibility)
1303 struct pr_handle *info = (struct pr_handle *) p;
1304 char *t;
1305 const char *prefix;
1306 char ab[20];
1307 char *s, *l, *n;
1309 assert (info->stack != NULL && info->stack->next != NULL);
1311 if (! substitute_type (info, ""))
1312 return FALSE;
1314 t = pop_type (info);
1315 if (t == NULL)
1316 return FALSE;
1318 if (CONST_STRNEQ (t, "class "))
1319 t += sizeof "class " - 1;
1321 /* Push it back on to take advantage of the prepend_type and
1322 append_type routines. */
1323 if (! push_type (info, t))
1324 return FALSE;
1326 if (virtual)
1328 if (! prepend_type (info, "virtual "))
1329 return FALSE;
1332 switch (visibility)
1334 case DEBUG_VISIBILITY_PUBLIC:
1335 prefix = "public ";
1336 break;
1337 case DEBUG_VISIBILITY_PROTECTED:
1338 prefix = "protected ";
1339 break;
1340 case DEBUG_VISIBILITY_PRIVATE:
1341 prefix = "private ";
1342 break;
1343 default:
1344 prefix = "/* unknown visibility */ ";
1345 break;
1348 if (! prepend_type (info, prefix))
1349 return FALSE;
1351 if (bitpos != 0)
1353 print_vma (bitpos, ab, TRUE, FALSE);
1354 if (! append_type (info, " /* bitpos ")
1355 || ! append_type (info, ab)
1356 || ! append_type (info, " */"))
1357 return FALSE;
1360 /* Now the top of the stack is something like "public A / * bitpos
1361 10 * /". The next element on the stack is something like "class
1362 xx { / * size 8 * /\n...". We want to substitute the top of the
1363 stack in before the {. */
1364 s = strchr (info->stack->next->type, '{');
1365 assert (s != NULL);
1366 --s;
1368 /* If there is already a ':', then we already have a baseclass, and
1369 we must append this one after a comma. */
1370 for (l = info->stack->next->type; l != s; l++)
1371 if (*l == ':')
1372 break;
1373 if (! prepend_type (info, l == s ? " : " : ", "))
1374 return FALSE;
1376 t = pop_type (info);
1377 if (t == NULL)
1378 return FALSE;
1380 n = (char *) xmalloc (strlen (info->stack->type) + strlen (t) + 1);
1381 memcpy (n, info->stack->type, s - info->stack->type);
1382 strcpy (n + (s - info->stack->type), t);
1383 strcat (n, s);
1385 free (info->stack->type);
1386 info->stack->type = n;
1388 free (t);
1390 return TRUE;
1393 /* Start adding a method to a class. */
1395 static bfd_boolean
1396 pr_class_start_method (void *p, const char *name)
1398 struct pr_handle *info = (struct pr_handle *) p;
1400 assert (info->stack != NULL);
1401 info->stack->method = name;
1402 return TRUE;
1405 /* Add a variant to a method. */
1407 static bfd_boolean
1408 pr_class_method_variant (void *p, const char *physname,
1409 enum debug_visibility visibility,
1410 bfd_boolean constp, bfd_boolean volatilep,
1411 bfd_vma voffset, bfd_boolean context)
1413 struct pr_handle *info = (struct pr_handle *) p;
1414 char *method_type;
1415 char *context_type;
1417 assert (info->stack != NULL);
1418 assert (info->stack->next != NULL);
1420 /* Put the const and volatile qualifiers on the type. */
1421 if (volatilep)
1423 if (! append_type (info, " volatile"))
1424 return FALSE;
1426 if (constp)
1428 if (! append_type (info, " const"))
1429 return FALSE;
1432 /* Stick the name of the method into its type. */
1433 if (! substitute_type (info,
1434 (context
1435 ? info->stack->next->next->method
1436 : info->stack->next->method)))
1437 return FALSE;
1439 /* Get the type. */
1440 method_type = pop_type (info);
1441 if (method_type == NULL)
1442 return FALSE;
1444 /* Pull off the context type if there is one. */
1445 if (! context)
1446 context_type = NULL;
1447 else
1449 context_type = pop_type (info);
1450 if (context_type == NULL)
1451 return FALSE;
1454 /* Now the top of the stack is the class. */
1456 if (! pr_fix_visibility (info, visibility))
1457 return FALSE;
1459 if (! append_type (info, method_type)
1460 || ! append_type (info, " /* ")
1461 || ! append_type (info, physname)
1462 || ! append_type (info, " "))
1463 return FALSE;
1464 if (context || voffset != 0)
1466 char ab[20];
1468 if (context)
1470 if (! append_type (info, "context ")
1471 || ! append_type (info, context_type)
1472 || ! append_type (info, " "))
1473 return FALSE;
1475 print_vma (voffset, ab, TRUE, FALSE);
1476 if (! append_type (info, "voffset ")
1477 || ! append_type (info, ab))
1478 return FALSE;
1481 return (append_type (info, " */;\n")
1482 && indent_type (info));
1485 /* Add a static variant to a method. */
1487 static bfd_boolean
1488 pr_class_static_method_variant (void *p, const char *physname,
1489 enum debug_visibility visibility,
1490 bfd_boolean constp, bfd_boolean volatilep)
1492 struct pr_handle *info = (struct pr_handle *) p;
1493 char *method_type;
1495 assert (info->stack != NULL);
1496 assert (info->stack->next != NULL);
1497 assert (info->stack->next->method != NULL);
1499 /* Put the const and volatile qualifiers on the type. */
1500 if (volatilep)
1502 if (! append_type (info, " volatile"))
1503 return FALSE;
1505 if (constp)
1507 if (! append_type (info, " const"))
1508 return FALSE;
1511 /* Mark it as static. */
1512 if (! prepend_type (info, "static "))
1513 return FALSE;
1515 /* Stick the name of the method into its type. */
1516 if (! substitute_type (info, info->stack->next->method))
1517 return FALSE;
1519 /* Get the type. */
1520 method_type = pop_type (info);
1521 if (method_type == NULL)
1522 return FALSE;
1524 /* Now the top of the stack is the class. */
1526 if (! pr_fix_visibility (info, visibility))
1527 return FALSE;
1529 return (append_type (info, method_type)
1530 && append_type (info, " /* ")
1531 && append_type (info, physname)
1532 && append_type (info, " */;\n")
1533 && indent_type (info));
1536 /* Finish up a method. */
1538 static bfd_boolean
1539 pr_class_end_method (void *p)
1541 struct pr_handle *info = (struct pr_handle *) p;
1543 info->stack->method = NULL;
1544 return TRUE;
1547 /* Finish up a class. */
1549 static bfd_boolean
1550 pr_end_class_type (void *p)
1552 return pr_end_struct_type (p);
1555 /* Push a type on the stack using a typedef name. */
1557 static bfd_boolean
1558 pr_typedef_type (void *p, const char *name)
1560 struct pr_handle *info = (struct pr_handle *) p;
1562 return push_type (info, name);
1565 /* Push a type on the stack using a tag name. */
1567 static bfd_boolean
1568 pr_tag_type (void *p, const char *name, unsigned int id,
1569 enum debug_type_kind kind)
1571 struct pr_handle *info = (struct pr_handle *) p;
1572 const char *t, *tag;
1573 char idbuf[20];
1575 switch (kind)
1577 case DEBUG_KIND_STRUCT:
1578 t = "struct ";
1579 break;
1580 case DEBUG_KIND_UNION:
1581 t = "union ";
1582 break;
1583 case DEBUG_KIND_ENUM:
1584 t = "enum ";
1585 break;
1586 case DEBUG_KIND_CLASS:
1587 t = "class ";
1588 break;
1589 case DEBUG_KIND_UNION_CLASS:
1590 t = "union class ";
1591 break;
1592 default:
1593 abort ();
1594 return FALSE;
1597 if (! push_type (info, t))
1598 return FALSE;
1599 if (name != NULL)
1600 tag = name;
1601 else
1603 sprintf (idbuf, "%%anon%u", id);
1604 tag = idbuf;
1607 if (! append_type (info, tag))
1608 return FALSE;
1609 if (name != NULL && kind != DEBUG_KIND_ENUM)
1611 sprintf (idbuf, " /* id %u */", id);
1612 if (! append_type (info, idbuf))
1613 return FALSE;
1616 return TRUE;
1619 /* Output a typedef. */
1621 static bfd_boolean
1622 pr_typdef (void *p, const char *name)
1624 struct pr_handle *info = (struct pr_handle *) p;
1625 char *s;
1627 if (! substitute_type (info, name))
1628 return FALSE;
1630 s = pop_type (info);
1631 if (s == NULL)
1632 return FALSE;
1634 indent (info);
1635 fprintf (info->f, "typedef %s;\n", s);
1637 free (s);
1639 return TRUE;
1642 /* Output a tag. The tag should already be in the string on the
1643 stack, so all we have to do here is print it out. */
1645 static bfd_boolean
1646 pr_tag (void *p, const char *name ATTRIBUTE_UNUSED)
1648 struct pr_handle *info = (struct pr_handle *) p;
1649 char *t;
1651 t = pop_type (info);
1652 if (t == NULL)
1653 return FALSE;
1655 indent (info);
1656 fprintf (info->f, "%s;\n", t);
1658 free (t);
1660 return TRUE;
1663 /* Output an integer constant. */
1665 static bfd_boolean
1666 pr_int_constant (void *p, const char *name, bfd_vma val)
1668 struct pr_handle *info = (struct pr_handle *) p;
1669 char ab[20];
1671 indent (info);
1672 print_vma (val, ab, FALSE, FALSE);
1673 fprintf (info->f, "const int %s = %s;\n", name, ab);
1674 return TRUE;
1677 /* Output a floating point constant. */
1679 static bfd_boolean
1680 pr_float_constant (void *p, const char *name, double val)
1682 struct pr_handle *info = (struct pr_handle *) p;
1684 indent (info);
1685 fprintf (info->f, "const double %s = %g;\n", name, val);
1686 return TRUE;
1689 /* Output a typed constant. */
1691 static bfd_boolean
1692 pr_typed_constant (void *p, const char *name, bfd_vma val)
1694 struct pr_handle *info = (struct pr_handle *) p;
1695 char *t;
1696 char ab[20];
1698 t = pop_type (info);
1699 if (t == NULL)
1700 return FALSE;
1702 indent (info);
1703 print_vma (val, ab, FALSE, FALSE);
1704 fprintf (info->f, "const %s %s = %s;\n", t, name, ab);
1706 free (t);
1708 return TRUE;
1711 /* Output a variable. */
1713 static bfd_boolean
1714 pr_variable (void *p, const char *name, enum debug_var_kind kind,
1715 bfd_vma val)
1717 struct pr_handle *info = (struct pr_handle *) p;
1718 char *t;
1719 char ab[20];
1721 if (! substitute_type (info, name))
1722 return FALSE;
1724 t = pop_type (info);
1725 if (t == NULL)
1726 return FALSE;
1728 indent (info);
1729 switch (kind)
1731 case DEBUG_STATIC:
1732 case DEBUG_LOCAL_STATIC:
1733 fprintf (info->f, "static ");
1734 break;
1735 case DEBUG_REGISTER:
1736 fprintf (info->f, "register ");
1737 break;
1738 default:
1739 break;
1741 print_vma (val, ab, TRUE, TRUE);
1742 fprintf (info->f, "%s /* %s */;\n", t, ab);
1744 free (t);
1746 return TRUE;
1749 /* Start outputting a function. */
1751 static bfd_boolean
1752 pr_start_function (void *p, const char *name, bfd_boolean global)
1754 struct pr_handle *info = (struct pr_handle *) p;
1755 char *t;
1757 if (! substitute_type (info, name))
1758 return FALSE;
1760 t = pop_type (info);
1761 if (t == NULL)
1762 return FALSE;
1764 indent (info);
1765 if (! global)
1766 fprintf (info->f, "static ");
1767 fprintf (info->f, "%s (", t);
1769 info->parameter = 1;
1771 return TRUE;
1774 /* Output a function parameter. */
1776 static bfd_boolean
1777 pr_function_parameter (void *p, const char *name,
1778 enum debug_parm_kind kind, bfd_vma val)
1780 struct pr_handle *info = (struct pr_handle *) p;
1781 char *t;
1782 char ab[20];
1784 if (kind == DEBUG_PARM_REFERENCE
1785 || kind == DEBUG_PARM_REF_REG)
1787 if (! pr_reference_type (p))
1788 return FALSE;
1791 if (! substitute_type (info, name))
1792 return FALSE;
1794 t = pop_type (info);
1795 if (t == NULL)
1796 return FALSE;
1798 if (info->parameter != 1)
1799 fprintf (info->f, ", ");
1801 if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG)
1802 fprintf (info->f, "register ");
1804 print_vma (val, ab, TRUE, TRUE);
1805 fprintf (info->f, "%s /* %s */", t, ab);
1807 free (t);
1809 ++info->parameter;
1811 return TRUE;
1814 /* Start writing out a block. */
1816 static bfd_boolean
1817 pr_start_block (void *p, bfd_vma addr)
1819 struct pr_handle *info = (struct pr_handle *) p;
1820 char ab[20];
1822 if (info->parameter > 0)
1824 fprintf (info->f, ")\n");
1825 info->parameter = 0;
1828 indent (info);
1829 print_vma (addr, ab, TRUE, TRUE);
1830 fprintf (info->f, "{ /* %s */\n", ab);
1832 info->indent += 2;
1834 return TRUE;
1837 /* Write out line number information. */
1839 static bfd_boolean
1840 pr_lineno (void *p, const char *filename, unsigned long lineno, bfd_vma addr)
1842 struct pr_handle *info = (struct pr_handle *) p;
1843 char ab[20];
1845 indent (info);
1846 print_vma (addr, ab, TRUE, TRUE);
1847 fprintf (info->f, "/* file %s line %lu addr %s */\n", filename, lineno, ab);
1849 return TRUE;
1852 /* Finish writing out a block. */
1854 static bfd_boolean
1855 pr_end_block (void *p, bfd_vma addr)
1857 struct pr_handle *info = (struct pr_handle *) p;
1858 char ab[20];
1860 info->indent -= 2;
1862 indent (info);
1863 print_vma (addr, ab, TRUE, TRUE);
1864 fprintf (info->f, "} /* %s */\n", ab);
1866 return TRUE;
1869 /* Finish writing out a function. */
1871 static bfd_boolean
1872 pr_end_function (void *p ATTRIBUTE_UNUSED)
1874 return TRUE;
1877 /* Tags style generation functions start here. */
1879 /* Variables for address to line translation. */
1880 static bfd_vma pc;
1881 static const char *filename;
1882 static const char *functionname;
1883 static unsigned int line;
1884 static bfd_boolean found;
1886 /* Look for an address in a section. This is called via
1887 bfd_map_over_sections. */
1889 static void
1890 find_address_in_section (bfd *abfd, asection *section, void *data)
1892 bfd_vma vma;
1893 bfd_size_type size;
1894 asymbol **syms = (asymbol **) data;
1896 if (found)
1897 return;
1899 if ((bfd_get_section_flags (abfd, section) & SEC_ALLOC) == 0)
1900 return;
1902 vma = bfd_get_section_vma (abfd, section);
1903 if (pc < vma)
1904 return;
1906 size = bfd_get_section_size (section);
1907 if (pc >= vma + size)
1908 return;
1910 found = bfd_find_nearest_line (abfd, section, syms, pc - vma,
1911 &filename, &functionname, &line);
1914 static void
1915 translate_addresses (bfd *abfd, char *addr_hex, FILE *f, asymbol **syms)
1917 pc = bfd_scan_vma (addr_hex, NULL, 16);
1918 found = FALSE;
1919 bfd_map_over_sections (abfd, find_address_in_section, syms);
1921 if (! found)
1922 fprintf (f, "??");
1923 else
1924 fprintf (f, "%u", line);
1927 /* Start a new compilation unit. */
1929 static bfd_boolean
1930 tg_start_compilation_unit (void * p, const char *filename ATTRIBUTE_UNUSED)
1932 struct pr_handle *info = (struct pr_handle *) p;
1934 fprintf (stderr, "New compilation unit: %s\n", filename);
1936 free (info->filename);
1937 /* Should it be relative? best way to do it here?. */
1938 info->filename = strdup (filename);
1940 return TRUE;
1943 /* Start a source file within a compilation unit. */
1945 static bfd_boolean
1946 tg_start_source (void *p, const char *filename)
1948 struct pr_handle *info = (struct pr_handle *) p;
1950 free (info->filename);
1951 /* Should it be relative? best way to do it here?. */
1952 info->filename = strdup (filename);
1954 return TRUE;
1957 /* Push an enum type onto the type stack. */
1959 static bfd_boolean
1960 tg_enum_type (void *p, const char *tag, const char **names,
1961 bfd_signed_vma *values)
1963 struct pr_handle *info = (struct pr_handle *) p;
1964 unsigned int i;
1965 const char *name;
1966 char ab[20];
1968 if (! pr_enum_type (p, tag, names, values))
1969 return FALSE;
1971 name = tag ? tag : "unknown";
1972 /* Generate an entry for the enum. */
1973 if (tag)
1974 fprintf (info->f, "%s\t%s\t0;\"\tkind:e\ttype:%s\n", tag,
1975 info->filename, info->stack->type);
1977 /* Generate entries for the values. */
1978 if (names != NULL)
1980 for (i = 0; names[i] != NULL; i++)
1982 print_vma (values[i], ab, FALSE, FALSE);
1983 fprintf (info->f, "%s\t%s\t0;\"\tkind:g\tenum:%s\tvalue:%s\n",
1984 names[i], info->filename, name, ab);
1988 return TRUE;
1991 /* Start accumulating a struct type. */
1993 static bfd_boolean
1994 tg_start_struct_type (void *p, const char *tag, unsigned int id,
1995 bfd_boolean structp,
1996 unsigned int size ATTRIBUTE_UNUSED)
1998 struct pr_handle *info = (struct pr_handle *) p;
1999 const char *name;
2000 char idbuf[20];
2002 if (tag != NULL)
2003 name = tag;
2004 else
2006 name = idbuf;
2007 sprintf (idbuf, "%%anon%u", id);
2010 if (! push_type (info, name))
2011 return FALSE;
2013 info->stack->flavor = structp ? "struct" : "union";
2015 fprintf (info->f, "%s\t%s\t0;\"\tkind:%c\n", name, info->filename,
2016 info->stack->flavor[0]);
2018 info->stack->visibility = DEBUG_VISIBILITY_PUBLIC;
2020 return indent_type (info);
2023 /* Output the visibility of a field in a struct. */
2025 static bfd_boolean
2026 tg_fix_visibility (struct pr_handle *info, enum debug_visibility visibility)
2028 assert (info->stack != NULL);
2030 if (info->stack->visibility == visibility)
2031 return TRUE;
2033 assert (info->stack->visibility != DEBUG_VISIBILITY_IGNORE);
2035 info->stack->visibility = visibility;
2037 return TRUE;
2040 /* Add a field to a struct type. */
2042 static bfd_boolean
2043 tg_struct_field (void *p, const char *name, bfd_vma bitpos ATTRIBUTE_UNUSED,
2044 bfd_vma bitsize ATTRIBUTE_UNUSED,
2045 enum debug_visibility visibility)
2047 struct pr_handle *info = (struct pr_handle *) p;
2048 char *t;
2050 t = pop_type (info);
2051 if (t == NULL)
2052 return FALSE;
2054 if (! tg_fix_visibility (info, visibility))
2055 return FALSE;
2057 /* It happens, a bug? */
2058 if (! name[0])
2059 return TRUE;
2061 fprintf (info->f, "%s\t%s\t0;\"\tkind:m\ttype:%s\t%s:%s\taccess:%s\n",
2062 name, info->filename, t, info->stack->flavor, info->stack->type,
2063 visibility_name (visibility));
2065 return TRUE;
2068 /* Finish a struct type. */
2070 static bfd_boolean
2071 tg_end_struct_type (void *p ATTRIBUTE_UNUSED)
2073 struct pr_handle *info = (struct pr_handle *) p;
2074 assert (info->stack != NULL);
2076 return TRUE;
2079 /* Start a class type. */
2081 static bfd_boolean
2082 tg_start_class_type (void *p, const char *tag, unsigned int id,
2083 bfd_boolean structp, unsigned int size,
2084 bfd_boolean vptr, bfd_boolean ownvptr)
2086 struct pr_handle *info = (struct pr_handle *) p;
2087 char *tv = NULL;
2088 const char *name;
2090 info->indent += 2;
2092 if (vptr && ! ownvptr)
2094 tv = pop_type (info);
2095 if (tv == NULL)
2096 return FALSE;
2099 if (tag != NULL)
2100 name = tag;
2101 else
2103 char idbuf[20];
2105 sprintf (idbuf, "%%anon%u", id);
2106 name = idbuf;
2109 if (! push_type (info, name))
2110 return FALSE;
2112 info->stack->flavor = structp ? "class" : "union class";
2113 info->stack->parents = NULL;
2114 info->stack->num_parents = 0;
2116 if (size != 0 || vptr || ownvptr || tag != NULL)
2118 if (vptr)
2120 if (! append_type (info, " vtable "))
2121 return FALSE;
2122 if (ownvptr)
2124 if (! append_type (info, "self "))
2125 return FALSE;
2127 else
2129 if (! append_type (info, tv)
2130 || ! append_type (info, " "))
2131 return FALSE;
2136 info->stack->visibility = DEBUG_VISIBILITY_PRIVATE;
2138 return TRUE;
2141 /* Add a static member to a class. */
2143 static bfd_boolean
2144 tg_class_static_member (void *p, const char *name,
2145 const char *physname ATTRIBUTE_UNUSED,
2146 enum debug_visibility visibility)
2148 struct pr_handle *info = (struct pr_handle *) p;
2149 char *t;
2150 int len_var, len_class;
2151 char *full_name;
2153 len_var = strlen (name);
2154 len_class = strlen (info->stack->next->type);
2155 full_name = xmalloc (len_var + len_class + 3);
2156 if (! full_name)
2157 return FALSE;
2158 sprintf (full_name, "%s::%s", info->stack->next->type, name);
2160 if (! substitute_type (info, full_name))
2161 return FALSE;
2163 if (! prepend_type (info, "static "))
2164 return FALSE;
2166 t = pop_type (info);
2167 if (t == NULL)
2168 return FALSE;
2170 if (! tg_fix_visibility (info, visibility))
2171 return FALSE;
2173 fprintf (info->f, "%s\t%s\t0;\"\tkind:x\ttype:%s\tclass:%s\taccess:%s\n",
2174 name, info->filename, t, info->stack->type,
2175 visibility_name (visibility));
2176 free (t);
2177 free (full_name);
2179 return TRUE;
2182 /* Add a base class to a class. */
2184 static bfd_boolean
2185 tg_class_baseclass (void *p, bfd_vma bitpos ATTRIBUTE_UNUSED,
2186 bfd_boolean virtual, enum debug_visibility visibility)
2188 struct pr_handle *info = (struct pr_handle *) p;
2189 char *t;
2190 const char *prefix;
2192 assert (info->stack != NULL && info->stack->next != NULL);
2194 t = pop_type (info);
2195 if (t == NULL)
2196 return FALSE;
2198 if (CONST_STRNEQ (t, "class "))
2199 t += sizeof "class " - 1;
2201 /* Push it back on to take advantage of the prepend_type and
2202 append_type routines. */
2203 if (! push_type (info, t))
2204 return FALSE;
2206 if (virtual)
2208 if (! prepend_type (info, "virtual "))
2209 return FALSE;
2212 switch (visibility)
2214 case DEBUG_VISIBILITY_PUBLIC:
2215 prefix = "public ";
2216 break;
2217 case DEBUG_VISIBILITY_PROTECTED:
2218 prefix = "protected ";
2219 break;
2220 case DEBUG_VISIBILITY_PRIVATE:
2221 prefix = "private ";
2222 break;
2223 default:
2224 prefix = "/* unknown visibility */ ";
2225 break;
2228 if (! prepend_type (info, prefix))
2229 return FALSE;
2231 t = pop_type (info);
2232 if (t == NULL)
2233 return FALSE;
2235 if (info->stack->num_parents && ! append_parent (info, ", "))
2236 return FALSE;
2238 if (! append_parent (info, t))
2239 return FALSE;
2240 info->stack->num_parents++;
2242 free (t);
2244 return TRUE;
2247 /* Add a variant to a method. */
2249 static bfd_boolean
2250 tg_class_method_variant (void *p, const char *physname ATTRIBUTE_UNUSED,
2251 enum debug_visibility visibility,
2252 bfd_boolean constp, bfd_boolean volatilep,
2253 bfd_vma voffset ATTRIBUTE_UNUSED,
2254 bfd_boolean context)
2256 struct pr_handle *info = (struct pr_handle *) p;
2257 char *method_type;
2258 char *context_type;
2259 char *method_name;
2261 assert (info->stack != NULL);
2262 assert (info->stack->next != NULL);
2264 /* Put the const and volatile qualifiers on the type. */
2265 if (volatilep)
2267 if (! append_type (info, " volatile"))
2268 return FALSE;
2270 if (constp)
2272 if (! append_type (info, " const"))
2273 return FALSE;
2276 method_name = strdup (context ? info->stack->next->next->method
2277 : info->stack->next->method);
2279 /* Stick the name of the method into its type. */
2280 if (! substitute_type (info, method_name))
2281 return FALSE;
2283 /* Get the type. */
2284 method_type = pop_type (info);
2285 if (method_type == NULL)
2286 return FALSE;
2288 /* Pull off the context type if there is one. */
2289 if (! context)
2290 context_type = NULL;
2291 else
2293 context_type = pop_type (info);
2294 if (context_type == NULL)
2295 return FALSE;
2298 /* Now the top of the stack is the class. */
2299 if (! tg_fix_visibility (info, visibility))
2300 return FALSE;
2302 fprintf (info->f, "%s\t%s\t0;\"\tkind:p\ttype:%s\tclass:%s\n",
2303 method_name, info->filename, method_type, info->stack->type);
2304 free (method_type);
2305 free (method_name);
2306 free (context_type);
2308 return TRUE;
2311 /* Add a static variant to a method. */
2313 static bfd_boolean
2314 tg_class_static_method_variant (void *p,
2315 const char *physname ATTRIBUTE_UNUSED,
2316 enum debug_visibility visibility,
2317 bfd_boolean constp, bfd_boolean volatilep)
2319 struct pr_handle *info = (struct pr_handle *) p;
2320 char *method_type;
2321 char *method_name;
2323 assert (info->stack != NULL);
2324 assert (info->stack->next != NULL);
2325 assert (info->stack->next->method != NULL);
2327 /* Put the const and volatile qualifiers on the type. */
2328 if (volatilep)
2330 if (! append_type (info, " volatile"))
2331 return FALSE;
2333 if (constp)
2335 if (! append_type (info, " const"))
2336 return FALSE;
2339 /* Mark it as static. */
2340 if (! prepend_type (info, "static "))
2341 return FALSE;
2343 method_name = strdup (info->stack->next->method);
2344 /* Stick the name of the method into its type. */
2345 if (! substitute_type (info, info->stack->next->method))
2346 return FALSE;
2348 /* Get the type. */
2349 method_type = pop_type (info);
2350 if (method_type == NULL)
2351 return FALSE;
2353 /* Now the top of the stack is the class. */
2354 if (! tg_fix_visibility (info, visibility))
2355 return FALSE;
2357 fprintf (info->f, "%s\t%s\t0;\"\tkind:p\ttype:%s\tclass:%s\taccess:%s\n",
2358 method_name, info->filename, method_type, info->stack->type,
2359 visibility_name (visibility));
2360 free (method_type);
2361 free (method_name);
2363 return TRUE;
2366 /* Finish up a class. */
2368 static bfd_boolean
2369 tg_end_class_type (void *p)
2371 struct pr_handle *info = (struct pr_handle *) p;
2373 fprintf (info->f, "%s\t%s\t0;\"\tkind:c\ttype:%s", info->stack->type,
2374 info->filename, info->stack->flavor);
2375 if (info->stack->num_parents)
2377 fprintf (info->f, "\tinherits:%s", info->stack->parents);
2378 free (info->stack->parents);
2380 fputc ('\n', info->f);
2382 return tg_end_struct_type (p);
2385 /* Push a type on the stack using a tag name. */
2387 static bfd_boolean
2388 tg_tag_type (void *p, const char *name, unsigned int id,
2389 enum debug_type_kind kind)
2391 struct pr_handle *info = (struct pr_handle *) p;
2392 const char *t, *tag;
2393 char idbuf[20];
2395 switch (kind)
2397 case DEBUG_KIND_STRUCT:
2398 t = "struct ";
2399 break;
2400 case DEBUG_KIND_UNION:
2401 t = "union ";
2402 break;
2403 case DEBUG_KIND_ENUM:
2404 t = "enum ";
2405 break;
2406 case DEBUG_KIND_CLASS:
2407 t = "class ";
2408 break;
2409 case DEBUG_KIND_UNION_CLASS:
2410 t = "union class ";
2411 break;
2412 default:
2413 abort ();
2414 return FALSE;
2417 if (! push_type (info, t))
2418 return FALSE;
2419 if (name != NULL)
2420 tag = name;
2421 else
2423 sprintf (idbuf, "%%anon%u", id);
2424 tag = idbuf;
2427 if (! append_type (info, tag))
2428 return FALSE;
2430 return TRUE;
2433 /* Output a typedef. */
2435 static bfd_boolean
2436 tg_typdef (void *p, const char *name)
2438 struct pr_handle *info = (struct pr_handle *) p;
2439 char *s;
2441 s = pop_type (info);
2442 if (s == NULL)
2443 return FALSE;
2445 fprintf (info->f, "%s\t%s\t0;\"\tkind:t\ttype:%s\n", name,
2446 info->filename, s);
2448 free (s);
2450 return TRUE;
2453 /* Output a tag. The tag should already be in the string on the
2454 stack, so all we have to do here is print it out. */
2456 static bfd_boolean
2457 tg_tag (void *p ATTRIBUTE_UNUSED, const char *name ATTRIBUTE_UNUSED)
2459 struct pr_handle *info = (struct pr_handle *) p;
2460 char *t;
2462 t = pop_type (info);
2463 if (t == NULL)
2464 return FALSE;
2465 free (t);
2467 return TRUE;
2470 /* Output an integer constant. */
2472 static bfd_boolean
2473 tg_int_constant (void *p, const char *name, bfd_vma val)
2475 struct pr_handle *info = (struct pr_handle *) p;
2476 char ab[20];
2478 indent (info);
2479 print_vma (val, ab, FALSE, FALSE);
2480 fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:const int\tvalue:%s\n",
2481 name, info->filename, ab);
2482 return TRUE;
2485 /* Output a floating point constant. */
2487 static bfd_boolean
2488 tg_float_constant (void *p, const char *name, double val)
2490 struct pr_handle *info = (struct pr_handle *) p;
2492 indent (info);
2493 fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:const double\tvalue:%g\n",
2494 name, info->filename, val);
2495 return TRUE;
2498 /* Output a typed constant. */
2500 static bfd_boolean
2501 tg_typed_constant (void *p, const char *name, bfd_vma val)
2503 struct pr_handle *info = (struct pr_handle *) p;
2504 char *t;
2505 char ab[20];
2507 t = pop_type (info);
2508 if (t == NULL)
2509 return FALSE;
2511 indent (info);
2512 print_vma (val, ab, FALSE, FALSE);
2513 fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:const %s\tvalue:%s\n",
2514 name, info->filename, t, ab);
2516 free (t);
2518 return TRUE;
2521 /* Output a variable. */
2523 static bfd_boolean
2524 tg_variable (void *p, const char *name, enum debug_var_kind kind,
2525 bfd_vma val ATTRIBUTE_UNUSED)
2527 struct pr_handle *info = (struct pr_handle *) p;
2528 char *t, *dname, *from_class;
2530 t = pop_type (info);
2531 if (t == NULL)
2532 return FALSE;
2534 dname = NULL;
2535 if (info->demangler)
2536 dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS);
2538 from_class = NULL;
2539 if (dname != NULL)
2541 char *sep;
2542 sep = strstr (dname, "::");
2543 if (sep)
2545 *sep = 0;
2546 name = sep + 2;
2547 from_class = dname;
2549 else
2550 /* Obscure types as vts and type_info nodes. */
2551 name = dname;
2554 fprintf (info->f, "%s\t%s\t0;\"\tkind:v\ttype:%s", name, info->filename, t);
2556 switch (kind)
2558 case DEBUG_STATIC:
2559 case DEBUG_LOCAL_STATIC:
2560 fprintf (info->f, "\tfile:");
2561 break;
2562 case DEBUG_REGISTER:
2563 fprintf (info->f, "\tregister:");
2564 break;
2565 default:
2566 break;
2569 if (from_class)
2570 fprintf (info->f, "\tclass:%s", from_class);
2572 if (dname)
2573 free (dname);
2575 fprintf (info->f, "\n");
2577 free (t);
2579 return TRUE;
2582 /* Start outputting a function. */
2584 static bfd_boolean
2585 tg_start_function (void *p, const char *name, bfd_boolean global)
2587 struct pr_handle *info = (struct pr_handle *) p;
2588 char *dname;
2590 if (! global)
2591 info->stack->flavor = "static";
2592 else
2593 info->stack->flavor = NULL;
2595 dname = NULL;
2596 if (info->demangler)
2597 dname = info->demangler (info->abfd, name, DMGL_ANSI | DMGL_PARAMS);
2599 if (! substitute_type (info, dname ? dname : name))
2600 return FALSE;
2602 info->stack->method = NULL;
2603 if (dname != NULL)
2605 char *sep;
2606 sep = strstr (dname, "::");
2607 if (sep)
2609 info->stack->method = dname;
2610 *sep = 0;
2611 name = sep + 2;
2613 else
2615 info->stack->method = "";
2616 name = dname;
2618 sep = strchr (name, '(');
2619 if (sep)
2620 *sep = 0;
2621 /* Obscure functions as type_info function. */
2624 info->stack->parents = strdup (name);
2626 if (! info->stack->method && ! append_type (info, "("))
2627 return FALSE;
2629 info->parameter = 1;
2631 return TRUE;
2634 /* Output a function parameter. */
2636 static bfd_boolean
2637 tg_function_parameter (void *p, const char *name, enum debug_parm_kind kind,
2638 bfd_vma val ATTRIBUTE_UNUSED)
2640 struct pr_handle *info = (struct pr_handle *) p;
2641 char *t;
2643 if (kind == DEBUG_PARM_REFERENCE
2644 || kind == DEBUG_PARM_REF_REG)
2646 if (! pr_reference_type (p))
2647 return FALSE;
2650 if (! substitute_type (info, name))
2651 return FALSE;
2653 t = pop_type (info);
2654 if (t == NULL)
2655 return FALSE;
2657 if (! info->stack->method)
2659 if (info->parameter != 1 && ! append_type (info, ", "))
2660 return FALSE;
2662 if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG)
2663 if (! append_type (info, "register "))
2664 return FALSE;
2666 if (! append_type (info, t))
2667 return FALSE;
2670 free (t);
2672 ++info->parameter;
2674 return TRUE;
2677 /* Start writing out a block. */
2679 static bfd_boolean
2680 tg_start_block (void *p, bfd_vma addr)
2682 struct pr_handle *info = (struct pr_handle *) p;
2683 char ab[20], kind, *partof;
2684 char *t;
2685 bfd_boolean local;
2687 if (info->parameter > 0)
2689 info->parameter = 0;
2691 /* Delayed name. */
2692 fprintf (info->f, "%s\t%s\t", info->stack->parents, info->filename);
2693 free (info->stack->parents);
2695 print_vma (addr, ab, TRUE, TRUE);
2696 translate_addresses (info->abfd, ab, info->f, info->syms);
2697 local = info->stack->flavor != NULL;
2698 if (info->stack->method && *info->stack->method)
2700 kind = 'm';
2701 partof = (char *) info->stack->method;
2703 else
2705 kind = 'f';
2706 partof = NULL;
2707 if (! info->stack->method && ! append_type (info, ")"))
2708 return FALSE;
2710 t = pop_type (info);
2711 if (t == NULL)
2712 return FALSE;
2713 fprintf (info->f, ";\"\tkind:%c\ttype:%s", kind, t);
2714 if (local)
2715 fputs ("\tfile:", info->f);
2716 if (partof)
2718 fprintf (info->f, "\tclass:%s", partof);
2719 free (partof);
2721 fputc ('\n', info->f);
2724 return TRUE;
2727 /* Write out line number information. */
2729 static bfd_boolean
2730 tg_lineno (void *p ATTRIBUTE_UNUSED, const char *filename ATTRIBUTE_UNUSED,
2731 unsigned long lineno ATTRIBUTE_UNUSED,
2732 bfd_vma addr ATTRIBUTE_UNUSED)
2734 return TRUE;
2737 /* Finish writing out a block. */
2739 static bfd_boolean
2740 tg_end_block (void *p ATTRIBUTE_UNUSED, bfd_vma addr ATTRIBUTE_UNUSED)
2742 return TRUE;
2745 /* Convert the visibility value into a human readable name. */
2747 static const char *
2748 visibility_name (enum debug_visibility visibility)
2750 const char *s;
2752 switch (visibility)
2754 case DEBUG_VISIBILITY_PUBLIC:
2755 s = "public";
2756 break;
2757 case DEBUG_VISIBILITY_PRIVATE:
2758 s = "private";
2759 break;
2760 case DEBUG_VISIBILITY_PROTECTED:
2761 s = "protected";
2762 break;
2763 case DEBUG_VISIBILITY_IGNORE:
2764 s = "/* ignore */";
2765 break;
2766 default:
2767 abort ();
2768 return FALSE;
2770 return s;