Commit | Line | Data |
---|---|---|
252b5132 | 1 | /* prdbg.c -- Print out generic debugging information. |
b34976b6 | 2 | Copyright 1995, 1996, 2002 Free Software Foundation, Inc. |
252b5132 RH |
3 | Written by Ian Lance Taylor <ian@cygnus.com>. |
4 | ||
5 | This file is part of GNU Binutils. | |
6 | ||
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. | |
11 | ||
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. | |
16 | ||
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 | |
20 | 02111-1307, USA. */ | |
21 | ||
22 | /* This file prints out the generic debugging information, by | |
23 | supplying a set of routines to debug_write. */ | |
24 | ||
25 | #include <stdio.h> | |
26 | #include <assert.h> | |
27 | ||
28 | #include "bfd.h" | |
29 | #include "bucomm.h" | |
30 | #include "libiberty.h" | |
31 | #include "debug.h" | |
32 | #include "budbg.h" | |
33 | ||
34 | /* This is the structure we use as a handle for these routines. */ | |
35 | ||
36 | struct pr_handle | |
37 | { | |
38 | /* File to print information to. */ | |
39 | FILE *f; | |
40 | /* Current indentation level. */ | |
41 | unsigned int indent; | |
42 | /* Type stack. */ | |
43 | struct pr_stack *stack; | |
44 | /* Parameter number we are about to output. */ | |
45 | int parameter; | |
46 | }; | |
47 | ||
48 | /* The type stack. */ | |
49 | ||
50 | struct pr_stack | |
51 | { | |
52 | /* Next element on the stack. */ | |
53 | struct pr_stack *next; | |
54 | /* This element. */ | |
55 | char *type; | |
56 | /* Current visibility of fields if this is a class. */ | |
57 | enum debug_visibility visibility; | |
58 | /* Name of the current method we are handling. */ | |
59 | const char *method; | |
60 | }; | |
61 | ||
b34976b6 AM |
62 | static void indent |
63 | PARAMS ((struct pr_handle *)); | |
64 | static bfd_boolean push_type | |
65 | PARAMS ((struct pr_handle *, const char *)); | |
66 | static bfd_boolean prepend_type | |
67 | PARAMS ((struct pr_handle *, const char *)); | |
68 | static bfd_boolean append_type | |
69 | PARAMS ((struct pr_handle *, const char *)); | |
70 | static bfd_boolean substitute_type | |
71 | PARAMS ((struct pr_handle *, const char *)); | |
72 | static bfd_boolean indent_type | |
73 | PARAMS ((struct pr_handle *)); | |
74 | static char *pop_type | |
75 | PARAMS ((struct pr_handle *)); | |
76 | static void print_vma | |
77 | PARAMS ((bfd_vma, char *, bfd_boolean, bfd_boolean)); | |
78 | static bfd_boolean pr_fix_visibility | |
252b5132 | 79 | PARAMS ((struct pr_handle *, enum debug_visibility)); |
b34976b6 AM |
80 | static bfd_boolean pr_start_compilation_unit |
81 | PARAMS ((PTR, const char *)); | |
82 | static bfd_boolean pr_start_source | |
83 | PARAMS ((PTR, const char *)); | |
84 | static bfd_boolean pr_empty_type | |
85 | PARAMS ((PTR)); | |
86 | static bfd_boolean pr_void_type | |
87 | PARAMS ((PTR)); | |
88 | static bfd_boolean pr_int_type | |
89 | PARAMS ((PTR, unsigned int, bfd_boolean)); | |
90 | static bfd_boolean pr_float_type | |
91 | PARAMS ((PTR, unsigned int)); | |
92 | static bfd_boolean pr_complex_type | |
93 | PARAMS ((PTR, unsigned int)); | |
94 | static bfd_boolean pr_bool_type | |
95 | PARAMS ((PTR, unsigned int)); | |
96 | static bfd_boolean pr_enum_type | |
252b5132 | 97 | PARAMS ((PTR, const char *, const char **, bfd_signed_vma *)); |
b34976b6 AM |
98 | static bfd_boolean pr_pointer_type |
99 | PARAMS ((PTR)); | |
100 | static bfd_boolean pr_function_type | |
101 | PARAMS ((PTR, int, bfd_boolean)); | |
102 | static bfd_boolean pr_reference_type | |
103 | PARAMS ((PTR)); | |
104 | static bfd_boolean pr_range_type | |
105 | PARAMS ((PTR, bfd_signed_vma, bfd_signed_vma)); | |
106 | static bfd_boolean pr_array_type | |
107 | PARAMS ((PTR, bfd_signed_vma, bfd_signed_vma, bfd_boolean)); | |
108 | static bfd_boolean pr_set_type | |
109 | PARAMS ((PTR, bfd_boolean)); | |
110 | static bfd_boolean pr_offset_type | |
111 | PARAMS ((PTR)); | |
112 | static bfd_boolean pr_method_type | |
113 | PARAMS ((PTR, bfd_boolean, int, bfd_boolean)); | |
114 | static bfd_boolean pr_const_type | |
115 | PARAMS ((PTR)); | |
116 | static bfd_boolean pr_volatile_type | |
117 | PARAMS ((PTR)); | |
118 | static bfd_boolean pr_start_struct_type | |
119 | PARAMS ((PTR, const char *, unsigned int, bfd_boolean, unsigned int)); | |
120 | static bfd_boolean pr_struct_field | |
252b5132 | 121 | PARAMS ((PTR, const char *, bfd_vma, bfd_vma, enum debug_visibility)); |
b34976b6 AM |
122 | static bfd_boolean pr_end_struct_type |
123 | PARAMS ((PTR)); | |
124 | static bfd_boolean pr_start_class_type | |
125 | PARAMS ((PTR, const char *, unsigned int, bfd_boolean, unsigned int, | |
126 | bfd_boolean, bfd_boolean)); | |
127 | static bfd_boolean pr_class_static_member | |
252b5132 | 128 | PARAMS ((PTR, const char *, const char *, enum debug_visibility)); |
b34976b6 AM |
129 | static bfd_boolean pr_class_baseclass |
130 | PARAMS ((PTR, bfd_vma, bfd_boolean, enum debug_visibility)); | |
131 | static bfd_boolean pr_class_start_method | |
132 | PARAMS ((PTR, const char *)); | |
133 | static bfd_boolean pr_class_method_variant | |
134 | PARAMS ((PTR, const char *, enum debug_visibility, bfd_boolean, bfd_boolean, | |
135 | bfd_vma, bfd_boolean)); | |
136 | static bfd_boolean pr_class_static_method_variant | |
137 | PARAMS ((PTR, const char *, enum debug_visibility, bfd_boolean, | |
138 | bfd_boolean)); | |
139 | static bfd_boolean pr_class_end_method | |
140 | PARAMS ((PTR)); | |
141 | static bfd_boolean pr_end_class_type | |
142 | PARAMS ((PTR)); | |
143 | static bfd_boolean pr_typedef_type | |
144 | PARAMS ((PTR, const char *)); | |
145 | static bfd_boolean pr_tag_type | |
252b5132 | 146 | PARAMS ((PTR, const char *, unsigned int, enum debug_type_kind)); |
b34976b6 AM |
147 | static bfd_boolean pr_typdef |
148 | PARAMS ((PTR, const char *)); | |
149 | static bfd_boolean pr_tag | |
150 | PARAMS ((PTR, const char *)); | |
151 | static bfd_boolean pr_int_constant | |
152 | PARAMS ((PTR, const char *, bfd_vma)); | |
153 | static bfd_boolean pr_float_constant | |
154 | PARAMS ((PTR, const char *, double)); | |
155 | static bfd_boolean pr_typed_constant | |
156 | PARAMS ((PTR, const char *, bfd_vma)); | |
157 | static bfd_boolean pr_variable | |
252b5132 | 158 | PARAMS ((PTR, const char *, enum debug_var_kind, bfd_vma)); |
b34976b6 AM |
159 | static bfd_boolean pr_start_function |
160 | PARAMS ((PTR, const char *, bfd_boolean)); | |
161 | static bfd_boolean pr_function_parameter | |
252b5132 | 162 | PARAMS ((PTR, const char *, enum debug_parm_kind, bfd_vma)); |
b34976b6 AM |
163 | static bfd_boolean pr_start_block |
164 | PARAMS ((PTR, bfd_vma)); | |
165 | static bfd_boolean pr_end_block | |
166 | PARAMS ((PTR, bfd_vma)); | |
167 | static bfd_boolean pr_end_function | |
168 | PARAMS ((PTR)); | |
169 | static bfd_boolean pr_lineno | |
170 | PARAMS ((PTR, const char *, unsigned long, bfd_vma)); | |
252b5132 RH |
171 | |
172 | static const struct debug_write_fns pr_fns = | |
173 | { | |
174 | pr_start_compilation_unit, | |
175 | pr_start_source, | |
176 | pr_empty_type, | |
177 | pr_void_type, | |
178 | pr_int_type, | |
179 | pr_float_type, | |
180 | pr_complex_type, | |
181 | pr_bool_type, | |
182 | pr_enum_type, | |
183 | pr_pointer_type, | |
184 | pr_function_type, | |
185 | pr_reference_type, | |
186 | pr_range_type, | |
187 | pr_array_type, | |
188 | pr_set_type, | |
189 | pr_offset_type, | |
190 | pr_method_type, | |
191 | pr_const_type, | |
192 | pr_volatile_type, | |
193 | pr_start_struct_type, | |
194 | pr_struct_field, | |
195 | pr_end_struct_type, | |
196 | pr_start_class_type, | |
197 | pr_class_static_member, | |
198 | pr_class_baseclass, | |
199 | pr_class_start_method, | |
200 | pr_class_method_variant, | |
201 | pr_class_static_method_variant, | |
202 | pr_class_end_method, | |
203 | pr_end_class_type, | |
204 | pr_typedef_type, | |
205 | pr_tag_type, | |
206 | pr_typdef, | |
207 | pr_tag, | |
208 | pr_int_constant, | |
209 | pr_float_constant, | |
210 | pr_typed_constant, | |
211 | pr_variable, | |
212 | pr_start_function, | |
213 | pr_function_parameter, | |
214 | pr_start_block, | |
215 | pr_end_block, | |
216 | pr_end_function, | |
217 | pr_lineno | |
218 | }; | |
219 | \f | |
220 | /* Print out the generic debugging information recorded in dhandle. */ | |
221 | ||
b34976b6 | 222 | bfd_boolean |
252b5132 RH |
223 | print_debugging_info (f, dhandle) |
224 | FILE *f; | |
225 | PTR dhandle; | |
226 | { | |
227 | struct pr_handle info; | |
228 | ||
229 | info.f = f; | |
230 | info.indent = 0; | |
231 | info.stack = NULL; | |
232 | info.parameter = 0; | |
233 | ||
234 | return debug_write (dhandle, &pr_fns, (PTR) &info); | |
235 | } | |
236 | \f | |
237 | /* Indent to the current indentation level. */ | |
238 | ||
239 | static void | |
240 | indent (info) | |
241 | struct pr_handle *info; | |
242 | { | |
243 | unsigned int i; | |
244 | ||
245 | for (i = 0; i < info->indent; i++) | |
246 | putc (' ', info->f); | |
247 | } | |
248 | ||
249 | /* Push a type on the type stack. */ | |
250 | ||
b34976b6 | 251 | static bfd_boolean |
252b5132 RH |
252 | push_type (info, type) |
253 | struct pr_handle *info; | |
254 | const char *type; | |
255 | { | |
256 | struct pr_stack *n; | |
257 | ||
258 | if (type == NULL) | |
b34976b6 | 259 | return FALSE; |
252b5132 RH |
260 | |
261 | n = (struct pr_stack *) xmalloc (sizeof *n); | |
262 | memset (n, 0, sizeof *n); | |
263 | ||
264 | n->type = xstrdup (type); | |
265 | n->visibility = DEBUG_VISIBILITY_IGNORE; | |
266 | n->method = NULL; | |
267 | n->next = info->stack; | |
268 | info->stack = n; | |
269 | ||
b34976b6 | 270 | return TRUE; |
252b5132 RH |
271 | } |
272 | ||
273 | /* Prepend a string onto the type on the top of the type stack. */ | |
274 | ||
b34976b6 | 275 | static bfd_boolean |
252b5132 RH |
276 | prepend_type (info, s) |
277 | struct pr_handle *info; | |
278 | const char *s; | |
279 | { | |
280 | char *n; | |
281 | ||
282 | assert (info->stack != NULL); | |
283 | ||
284 | n = (char *) xmalloc (strlen (s) + strlen (info->stack->type) + 1); | |
285 | sprintf (n, "%s%s", s, info->stack->type); | |
286 | free (info->stack->type); | |
287 | info->stack->type = n; | |
288 | ||
b34976b6 | 289 | return TRUE; |
252b5132 RH |
290 | } |
291 | ||
292 | /* Append a string to the type on the top of the type stack. */ | |
293 | ||
b34976b6 | 294 | static bfd_boolean |
252b5132 RH |
295 | append_type (info, s) |
296 | struct pr_handle *info; | |
297 | const char *s; | |
298 | { | |
299 | unsigned int len; | |
300 | ||
301 | if (s == NULL) | |
b34976b6 | 302 | return FALSE; |
252b5132 RH |
303 | |
304 | assert (info->stack != NULL); | |
305 | ||
306 | len = strlen (info->stack->type); | |
307 | info->stack->type = (char *) xrealloc (info->stack->type, | |
308 | len + strlen (s) + 1); | |
309 | strcpy (info->stack->type + len, s); | |
310 | ||
b34976b6 | 311 | return TRUE; |
252b5132 RH |
312 | } |
313 | ||
314 | /* We use an underscore to indicate where the name should go in a type | |
315 | string. This function substitutes a string for the underscore. If | |
316 | there is no underscore, the name follows the type. */ | |
317 | ||
b34976b6 | 318 | static bfd_boolean |
252b5132 RH |
319 | substitute_type (info, s) |
320 | struct pr_handle *info; | |
321 | const char *s; | |
322 | { | |
323 | char *u; | |
324 | ||
325 | assert (info->stack != NULL); | |
326 | ||
327 | u = strchr (info->stack->type, '|'); | |
328 | if (u != NULL) | |
329 | { | |
330 | char *n; | |
331 | ||
332 | n = (char *) xmalloc (strlen (info->stack->type) + strlen (s)); | |
333 | ||
334 | memcpy (n, info->stack->type, u - info->stack->type); | |
335 | strcpy (n + (u - info->stack->type), s); | |
336 | strcat (n, u + 1); | |
337 | ||
338 | free (info->stack->type); | |
339 | info->stack->type = n; | |
340 | ||
b34976b6 | 341 | return TRUE; |
252b5132 RH |
342 | } |
343 | ||
344 | if (strchr (s, '|') != NULL | |
345 | && (strchr (info->stack->type, '{') != NULL | |
346 | || strchr (info->stack->type, '(') != NULL)) | |
347 | { | |
348 | if (! prepend_type (info, "(") | |
349 | || ! append_type (info, ")")) | |
b34976b6 | 350 | return FALSE; |
252b5132 RH |
351 | } |
352 | ||
353 | if (*s == '\0') | |
b34976b6 | 354 | return TRUE; |
252b5132 RH |
355 | |
356 | return (append_type (info, " ") | |
357 | && append_type (info, s)); | |
358 | } | |
359 | ||
360 | /* Indent the type at the top of the stack by appending spaces. */ | |
361 | ||
b34976b6 | 362 | static bfd_boolean |
252b5132 RH |
363 | indent_type (info) |
364 | struct pr_handle *info; | |
365 | { | |
366 | unsigned int i; | |
367 | ||
368 | for (i = 0; i < info->indent; i++) | |
369 | { | |
370 | if (! append_type (info, " ")) | |
b34976b6 | 371 | return FALSE; |
252b5132 RH |
372 | } |
373 | ||
b34976b6 | 374 | return TRUE; |
252b5132 RH |
375 | } |
376 | ||
377 | /* Pop a type from the type stack. */ | |
378 | ||
379 | static char * | |
380 | pop_type (info) | |
381 | struct pr_handle *info; | |
382 | { | |
383 | struct pr_stack *o; | |
384 | char *ret; | |
385 | ||
386 | assert (info->stack != NULL); | |
387 | ||
388 | o = info->stack; | |
389 | info->stack = o->next; | |
390 | ret = o->type; | |
391 | free (o); | |
392 | ||
393 | return ret; | |
394 | } | |
395 | ||
396 | /* Print a VMA value into a string. */ | |
397 | ||
398 | static void | |
399 | print_vma (vma, buf, unsignedp, hexp) | |
400 | bfd_vma vma; | |
401 | char *buf; | |
b34976b6 AM |
402 | bfd_boolean unsignedp; |
403 | bfd_boolean hexp; | |
252b5132 RH |
404 | { |
405 | if (sizeof (vma) <= sizeof (unsigned long)) | |
406 | { | |
407 | if (hexp) | |
408 | sprintf (buf, "0x%lx", (unsigned long) vma); | |
409 | else if (unsignedp) | |
410 | sprintf (buf, "%lu", (unsigned long) vma); | |
411 | else | |
412 | sprintf (buf, "%ld", (long) vma); | |
413 | } | |
414 | else | |
415 | { | |
416 | buf[0] = '0'; | |
417 | buf[1] = 'x'; | |
418 | sprintf_vma (buf + 2, vma); | |
419 | } | |
420 | } | |
421 | \f | |
422 | /* Start a new compilation unit. */ | |
423 | ||
b34976b6 | 424 | static bfd_boolean |
252b5132 RH |
425 | pr_start_compilation_unit (p, filename) |
426 | PTR p; | |
427 | const char *filename; | |
428 | { | |
429 | struct pr_handle *info = (struct pr_handle *) p; | |
430 | ||
431 | assert (info->indent == 0); | |
432 | ||
433 | fprintf (info->f, "%s:\n", filename); | |
434 | ||
b34976b6 | 435 | return TRUE; |
252b5132 RH |
436 | } |
437 | ||
438 | /* Start a source file within a compilation unit. */ | |
439 | ||
b34976b6 | 440 | static bfd_boolean |
252b5132 RH |
441 | pr_start_source (p, filename) |
442 | PTR p; | |
443 | const char *filename; | |
444 | { | |
445 | struct pr_handle *info = (struct pr_handle *) p; | |
446 | ||
447 | assert (info->indent == 0); | |
448 | ||
449 | fprintf (info->f, " %s:\n", filename); | |
450 | ||
b34976b6 | 451 | return TRUE; |
252b5132 RH |
452 | } |
453 | ||
454 | /* Push an empty type onto the type stack. */ | |
455 | ||
b34976b6 | 456 | static bfd_boolean |
252b5132 RH |
457 | pr_empty_type (p) |
458 | PTR p; | |
459 | { | |
460 | struct pr_handle *info = (struct pr_handle *) p; | |
461 | ||
462 | return push_type (info, "<undefined>"); | |
463 | } | |
464 | ||
465 | /* Push a void type onto the type stack. */ | |
466 | ||
b34976b6 | 467 | static bfd_boolean |
252b5132 RH |
468 | pr_void_type (p) |
469 | PTR p; | |
470 | { | |
471 | struct pr_handle *info = (struct pr_handle *) p; | |
472 | ||
473 | return push_type (info, "void"); | |
474 | } | |
475 | ||
476 | /* Push an integer type onto the type stack. */ | |
477 | ||
b34976b6 | 478 | static bfd_boolean |
252b5132 RH |
479 | pr_int_type (p, size, unsignedp) |
480 | PTR p; | |
481 | unsigned int size; | |
b34976b6 | 482 | bfd_boolean unsignedp; |
252b5132 RH |
483 | { |
484 | struct pr_handle *info = (struct pr_handle *) p; | |
485 | char ab[10]; | |
486 | ||
487 | sprintf (ab, "%sint%d", unsignedp ? "u" : "", size * 8); | |
488 | return push_type (info, ab); | |
489 | } | |
490 | ||
491 | /* Push a floating type onto the type stack. */ | |
492 | ||
b34976b6 | 493 | static bfd_boolean |
252b5132 RH |
494 | pr_float_type (p, size) |
495 | PTR p; | |
496 | unsigned int size; | |
497 | { | |
498 | struct pr_handle *info = (struct pr_handle *) p; | |
499 | char ab[10]; | |
500 | ||
501 | if (size == 4) | |
502 | return push_type (info, "float"); | |
503 | else if (size == 8) | |
504 | return push_type (info, "double"); | |
505 | ||
506 | sprintf (ab, "float%d", size * 8); | |
507 | return push_type (info, ab); | |
508 | } | |
509 | ||
510 | /* Push a complex type onto the type stack. */ | |
511 | ||
b34976b6 | 512 | static bfd_boolean |
252b5132 RH |
513 | pr_complex_type (p, size) |
514 | PTR p; | |
515 | unsigned int size; | |
516 | { | |
517 | struct pr_handle *info = (struct pr_handle *) p; | |
518 | ||
519 | if (! pr_float_type (p, size)) | |
b34976b6 | 520 | return FALSE; |
252b5132 RH |
521 | |
522 | return prepend_type (info, "complex "); | |
523 | } | |
524 | ||
b34976b6 | 525 | /* Push a bfd_boolean type onto the type stack. */ |
252b5132 | 526 | |
b34976b6 | 527 | static bfd_boolean |
252b5132 RH |
528 | pr_bool_type (p, size) |
529 | PTR p; | |
530 | unsigned int size; | |
531 | { | |
532 | struct pr_handle *info = (struct pr_handle *) p; | |
533 | char ab[10]; | |
534 | ||
535 | sprintf (ab, "bool%d", size * 8); | |
536 | ||
537 | return push_type (info, ab); | |
538 | } | |
539 | ||
540 | /* Push an enum type onto the type stack. */ | |
541 | ||
b34976b6 | 542 | static bfd_boolean |
252b5132 RH |
543 | pr_enum_type (p, tag, names, values) |
544 | PTR p; | |
545 | const char *tag; | |
546 | const char **names; | |
547 | bfd_signed_vma *values; | |
548 | { | |
549 | struct pr_handle *info = (struct pr_handle *) p; | |
550 | unsigned int i; | |
551 | bfd_signed_vma val; | |
552 | ||
553 | if (! push_type (info, "enum ")) | |
b34976b6 | 554 | return FALSE; |
252b5132 RH |
555 | if (tag != NULL) |
556 | { | |
557 | if (! append_type (info, tag) | |
558 | || ! append_type (info, " ")) | |
b34976b6 | 559 | return FALSE; |
252b5132 RH |
560 | } |
561 | if (! append_type (info, "{ ")) | |
b34976b6 | 562 | return FALSE; |
252b5132 RH |
563 | |
564 | if (names == NULL) | |
565 | { | |
566 | if (! append_type (info, "/* undefined */")) | |
b34976b6 | 567 | return FALSE; |
252b5132 RH |
568 | } |
569 | else | |
570 | { | |
571 | val = 0; | |
572 | for (i = 0; names[i] != NULL; i++) | |
573 | { | |
574 | if (i > 0) | |
575 | { | |
576 | if (! append_type (info, ", ")) | |
b34976b6 | 577 | return FALSE; |
252b5132 RH |
578 | } |
579 | ||
580 | if (! append_type (info, names[i])) | |
b34976b6 | 581 | return FALSE; |
252b5132 RH |
582 | |
583 | if (values[i] != val) | |
584 | { | |
585 | char ab[20]; | |
586 | ||
b34976b6 | 587 | print_vma (values[i], ab, FALSE, FALSE); |
252b5132 RH |
588 | if (! append_type (info, " = ") |
589 | || ! append_type (info, ab)) | |
b34976b6 | 590 | return FALSE; |
252b5132 RH |
591 | val = values[i]; |
592 | } | |
593 | ||
594 | ++val; | |
595 | } | |
596 | } | |
597 | ||
598 | return append_type (info, " }"); | |
599 | } | |
600 | ||
601 | /* Turn the top type on the stack into a pointer. */ | |
602 | ||
b34976b6 | 603 | static bfd_boolean |
252b5132 RH |
604 | pr_pointer_type (p) |
605 | PTR p; | |
606 | { | |
607 | struct pr_handle *info = (struct pr_handle *) p; | |
608 | char *s; | |
609 | ||
610 | assert (info->stack != NULL); | |
611 | ||
612 | s = strchr (info->stack->type, '|'); | |
613 | if (s != NULL && s[1] == '[') | |
614 | return substitute_type (info, "(*|)"); | |
615 | return substitute_type (info, "*|"); | |
616 | } | |
617 | ||
618 | /* Turn the top type on the stack into a function returning that type. */ | |
619 | ||
b34976b6 | 620 | static bfd_boolean |
252b5132 RH |
621 | pr_function_type (p, argcount, varargs) |
622 | PTR p; | |
623 | int argcount; | |
b34976b6 | 624 | bfd_boolean varargs; |
252b5132 RH |
625 | { |
626 | struct pr_handle *info = (struct pr_handle *) p; | |
627 | char **arg_types; | |
628 | unsigned int len; | |
629 | char *s; | |
630 | ||
631 | assert (info->stack != NULL); | |
632 | ||
633 | len = 10; | |
634 | ||
635 | if (argcount <= 0) | |
636 | { | |
637 | arg_types = NULL; | |
638 | len += 15; | |
639 | } | |
640 | else | |
641 | { | |
642 | int i; | |
643 | ||
644 | arg_types = (char **) xmalloc (argcount * sizeof *arg_types); | |
645 | for (i = argcount - 1; i >= 0; i--) | |
646 | { | |
647 | if (! substitute_type (info, "")) | |
b34976b6 | 648 | return FALSE; |
252b5132 RH |
649 | arg_types[i] = pop_type (info); |
650 | if (arg_types[i] == NULL) | |
b34976b6 | 651 | return FALSE; |
252b5132 RH |
652 | len += strlen (arg_types[i]) + 2; |
653 | } | |
654 | if (varargs) | |
655 | len += 5; | |
656 | } | |
657 | ||
658 | /* Now the return type is on the top of the stack. */ | |
659 | ||
660 | s = (char *) xmalloc (len); | |
661 | strcpy (s, "(|) ("); | |
662 | ||
663 | if (argcount < 0) | |
664 | strcat (s, "/* unknown */"); | |
665 | else | |
666 | { | |
667 | int i; | |
668 | ||
669 | for (i = 0; i < argcount; i++) | |
670 | { | |
671 | if (i > 0) | |
672 | strcat (s, ", "); | |
673 | strcat (s, arg_types[i]); | |
674 | } | |
675 | if (varargs) | |
676 | { | |
677 | if (i > 0) | |
678 | strcat (s, ", "); | |
679 | strcat (s, "..."); | |
680 | } | |
681 | if (argcount > 0) | |
682 | free (arg_types); | |
683 | } | |
684 | ||
685 | strcat (s, ")"); | |
686 | ||
687 | if (! substitute_type (info, s)) | |
b34976b6 | 688 | return FALSE; |
252b5132 RH |
689 | |
690 | free (s); | |
691 | ||
b34976b6 | 692 | return TRUE; |
252b5132 RH |
693 | } |
694 | ||
695 | /* Turn the top type on the stack into a reference to that type. */ | |
696 | ||
b34976b6 | 697 | static bfd_boolean |
252b5132 RH |
698 | pr_reference_type (p) |
699 | PTR p; | |
700 | { | |
701 | struct pr_handle *info = (struct pr_handle *) p; | |
702 | ||
703 | assert (info->stack != NULL); | |
704 | ||
705 | return substitute_type (info, "&|"); | |
706 | } | |
707 | ||
708 | /* Make a range type. */ | |
709 | ||
b34976b6 | 710 | static bfd_boolean |
252b5132 RH |
711 | pr_range_type (p, lower, upper) |
712 | PTR p; | |
713 | bfd_signed_vma lower; | |
714 | bfd_signed_vma upper; | |
715 | { | |
716 | struct pr_handle *info = (struct pr_handle *) p; | |
717 | char abl[20], abu[20]; | |
718 | ||
719 | assert (info->stack != NULL); | |
720 | ||
721 | if (! substitute_type (info, "")) | |
b34976b6 | 722 | return FALSE; |
252b5132 | 723 | |
b34976b6 AM |
724 | print_vma (lower, abl, FALSE, FALSE); |
725 | print_vma (upper, abu, FALSE, FALSE); | |
252b5132 RH |
726 | |
727 | return (prepend_type (info, "range (") | |
728 | && append_type (info, "):") | |
729 | && append_type (info, abl) | |
730 | && append_type (info, ":") | |
731 | && append_type (info, abu)); | |
732 | } | |
733 | ||
734 | /* Make an array type. */ | |
735 | ||
b34976b6 | 736 | static bfd_boolean |
252b5132 RH |
737 | pr_array_type (p, lower, upper, stringp) |
738 | PTR p; | |
739 | bfd_signed_vma lower; | |
740 | bfd_signed_vma upper; | |
b34976b6 | 741 | bfd_boolean stringp; |
252b5132 RH |
742 | { |
743 | struct pr_handle *info = (struct pr_handle *) p; | |
744 | char *range_type; | |
745 | char abl[20], abu[20], ab[50]; | |
746 | ||
747 | range_type = pop_type (info); | |
748 | if (range_type == NULL) | |
b34976b6 | 749 | return FALSE; |
252b5132 RH |
750 | |
751 | if (lower == 0) | |
752 | { | |
753 | if (upper == -1) | |
754 | sprintf (ab, "|[]"); | |
755 | else | |
756 | { | |
b34976b6 | 757 | print_vma (upper + 1, abu, FALSE, FALSE); |
252b5132 RH |
758 | sprintf (ab, "|[%s]", abu); |
759 | } | |
760 | } | |
761 | else | |
762 | { | |
b34976b6 AM |
763 | print_vma (lower, abl, FALSE, FALSE); |
764 | print_vma (upper, abu, FALSE, FALSE); | |
252b5132 RH |
765 | sprintf (ab, "|[%s:%s]", abl, abu); |
766 | } | |
767 | ||
768 | if (! substitute_type (info, ab)) | |
b34976b6 | 769 | return FALSE; |
252b5132 RH |
770 | |
771 | if (strcmp (range_type, "int") != 0) | |
772 | { | |
773 | if (! append_type (info, ":") | |
774 | || ! append_type (info, range_type)) | |
b34976b6 | 775 | return FALSE; |
252b5132 RH |
776 | } |
777 | ||
778 | if (stringp) | |
779 | { | |
780 | if (! append_type (info, " /* string */")) | |
b34976b6 | 781 | return FALSE; |
252b5132 RH |
782 | } |
783 | ||
b34976b6 | 784 | return TRUE; |
252b5132 RH |
785 | } |
786 | ||
787 | /* Make a set type. */ | |
788 | ||
b34976b6 | 789 | static bfd_boolean |
252b5132 RH |
790 | pr_set_type (p, bitstringp) |
791 | PTR p; | |
b34976b6 | 792 | bfd_boolean bitstringp; |
252b5132 RH |
793 | { |
794 | struct pr_handle *info = (struct pr_handle *) p; | |
795 | ||
796 | if (! substitute_type (info, "")) | |
b34976b6 | 797 | return FALSE; |
252b5132 RH |
798 | |
799 | if (! prepend_type (info, "set { ") | |
800 | || ! append_type (info, " }")) | |
b34976b6 | 801 | return FALSE; |
252b5132 RH |
802 | |
803 | if (bitstringp) | |
804 | { | |
805 | if (! append_type (info, "/* bitstring */")) | |
b34976b6 | 806 | return FALSE; |
252b5132 RH |
807 | } |
808 | ||
b34976b6 | 809 | return TRUE; |
252b5132 RH |
810 | } |
811 | ||
812 | /* Make an offset type. */ | |
813 | ||
b34976b6 | 814 | static bfd_boolean |
252b5132 RH |
815 | pr_offset_type (p) |
816 | PTR p; | |
817 | { | |
818 | struct pr_handle *info = (struct pr_handle *) p; | |
819 | char *t; | |
820 | ||
821 | if (! substitute_type (info, "")) | |
b34976b6 | 822 | return FALSE; |
252b5132 RH |
823 | |
824 | t = pop_type (info); | |
825 | if (t == NULL) | |
b34976b6 | 826 | return FALSE; |
252b5132 RH |
827 | |
828 | return (substitute_type (info, "") | |
829 | && prepend_type (info, " ") | |
830 | && prepend_type (info, t) | |
831 | && append_type (info, "::|")); | |
832 | } | |
833 | ||
834 | /* Make a method type. */ | |
835 | ||
b34976b6 | 836 | static bfd_boolean |
252b5132 RH |
837 | pr_method_type (p, domain, argcount, varargs) |
838 | PTR p; | |
b34976b6 | 839 | bfd_boolean domain; |
252b5132 | 840 | int argcount; |
b34976b6 | 841 | bfd_boolean varargs; |
252b5132 RH |
842 | { |
843 | struct pr_handle *info = (struct pr_handle *) p; | |
844 | unsigned int len; | |
845 | char *domain_type; | |
846 | char **arg_types; | |
847 | char *s; | |
848 | ||
849 | len = 10; | |
850 | ||
851 | if (! domain) | |
852 | domain_type = NULL; | |
853 | else | |
854 | { | |
855 | if (! substitute_type (info, "")) | |
b34976b6 | 856 | return FALSE; |
252b5132 RH |
857 | domain_type = pop_type (info); |
858 | if (domain_type == NULL) | |
b34976b6 | 859 | return FALSE; |
252b5132 RH |
860 | if (strncmp (domain_type, "class ", sizeof "class " - 1) == 0 |
861 | && strchr (domain_type + sizeof "class " - 1, ' ') == NULL) | |
862 | domain_type += sizeof "class " - 1; | |
863 | else if (strncmp (domain_type, "union class ", | |
864 | sizeof "union class ") == 0 | |
865 | && (strchr (domain_type + sizeof "union class " - 1, ' ') | |
866 | == NULL)) | |
867 | domain_type += sizeof "union class " - 1; | |
868 | len += strlen (domain_type); | |
869 | } | |
870 | ||
871 | if (argcount <= 0) | |
872 | { | |
873 | arg_types = NULL; | |
874 | len += 15; | |
875 | } | |
876 | else | |
877 | { | |
878 | int i; | |
879 | ||
880 | arg_types = (char **) xmalloc (argcount * sizeof *arg_types); | |
881 | for (i = argcount - 1; i >= 0; i--) | |
882 | { | |
883 | if (! substitute_type (info, "")) | |
b34976b6 | 884 | return FALSE; |
252b5132 RH |
885 | arg_types[i] = pop_type (info); |
886 | if (arg_types[i] == NULL) | |
b34976b6 | 887 | return FALSE; |
252b5132 RH |
888 | len += strlen (arg_types[i]) + 2; |
889 | } | |
890 | if (varargs) | |
891 | len += 5; | |
892 | } | |
893 | ||
894 | /* Now the return type is on the top of the stack. */ | |
895 | ||
896 | s = (char *) xmalloc (len); | |
897 | if (! domain) | |
898 | *s = '\0'; | |
899 | else | |
900 | strcpy (s, domain_type); | |
901 | strcat (s, "::| ("); | |
902 | ||
903 | if (argcount < 0) | |
904 | strcat (s, "/* unknown */"); | |
905 | else | |
906 | { | |
907 | int i; | |
908 | ||
909 | for (i = 0; i < argcount; i++) | |
910 | { | |
911 | if (i > 0) | |
912 | strcat (s, ", "); | |
913 | strcat (s, arg_types[i]); | |
914 | } | |
915 | if (varargs) | |
916 | { | |
917 | if (i > 0) | |
918 | strcat (s, ", "); | |
919 | strcat (s, "..."); | |
920 | } | |
921 | if (argcount > 0) | |
922 | free (arg_types); | |
923 | } | |
924 | ||
925 | strcat (s, ")"); | |
926 | ||
927 | if (! substitute_type (info, s)) | |
b34976b6 | 928 | return FALSE; |
252b5132 RH |
929 | |
930 | free (s); | |
931 | ||
b34976b6 | 932 | return TRUE; |
252b5132 RH |
933 | } |
934 | ||
935 | /* Make a const qualified type. */ | |
936 | ||
b34976b6 | 937 | static bfd_boolean |
252b5132 RH |
938 | pr_const_type (p) |
939 | PTR p; | |
940 | { | |
941 | struct pr_handle *info = (struct pr_handle *) p; | |
942 | ||
943 | return substitute_type (info, "const |"); | |
944 | } | |
945 | ||
946 | /* Make a volatile qualified type. */ | |
947 | ||
b34976b6 | 948 | static bfd_boolean |
252b5132 RH |
949 | pr_volatile_type (p) |
950 | PTR p; | |
951 | { | |
952 | struct pr_handle *info = (struct pr_handle *) p; | |
953 | ||
954 | return substitute_type (info, "volatile |"); | |
955 | } | |
956 | ||
957 | /* Start accumulating a struct type. */ | |
958 | ||
b34976b6 | 959 | static bfd_boolean |
252b5132 RH |
960 | pr_start_struct_type (p, tag, id, structp, size) |
961 | PTR p; | |
962 | const char *tag; | |
963 | unsigned int id; | |
b34976b6 | 964 | bfd_boolean structp; |
252b5132 RH |
965 | unsigned int size; |
966 | { | |
967 | struct pr_handle *info = (struct pr_handle *) p; | |
968 | ||
969 | info->indent += 2; | |
970 | ||
971 | if (! push_type (info, structp ? "struct " : "union ")) | |
b34976b6 | 972 | return FALSE; |
252b5132 RH |
973 | if (tag != NULL) |
974 | { | |
975 | if (! append_type (info, tag)) | |
b34976b6 | 976 | return FALSE; |
252b5132 RH |
977 | } |
978 | else | |
979 | { | |
980 | char idbuf[20]; | |
981 | ||
982 | sprintf (idbuf, "%%anon%u", id); | |
983 | if (! append_type (info, idbuf)) | |
b34976b6 | 984 | return FALSE; |
252b5132 RH |
985 | } |
986 | ||
987 | if (! append_type (info, " {")) | |
b34976b6 | 988 | return FALSE; |
252b5132 RH |
989 | if (size != 0 || tag != NULL) |
990 | { | |
991 | char ab[30]; | |
992 | ||
993 | if (! append_type (info, " /*")) | |
b34976b6 | 994 | return FALSE; |
252b5132 RH |
995 | |
996 | if (size != 0) | |
997 | { | |
998 | sprintf (ab, " size %u", size); | |
999 | if (! append_type (info, ab)) | |
b34976b6 | 1000 | return FALSE; |
252b5132 RH |
1001 | } |
1002 | if (tag != NULL) | |
1003 | { | |
1004 | sprintf (ab, " id %u", id); | |
1005 | if (! append_type (info, ab)) | |
b34976b6 | 1006 | return FALSE; |
252b5132 RH |
1007 | } |
1008 | if (! append_type (info, " */")) | |
b34976b6 | 1009 | return FALSE; |
252b5132 RH |
1010 | } |
1011 | if (! append_type (info, "\n")) | |
b34976b6 | 1012 | return FALSE; |
252b5132 RH |
1013 | |
1014 | info->stack->visibility = DEBUG_VISIBILITY_PUBLIC; | |
1015 | ||
1016 | return indent_type (info); | |
1017 | } | |
1018 | ||
1019 | /* Output the visibility of a field in a struct. */ | |
1020 | ||
b34976b6 | 1021 | static bfd_boolean |
252b5132 RH |
1022 | pr_fix_visibility (info, visibility) |
1023 | struct pr_handle *info; | |
1024 | enum debug_visibility visibility; | |
1025 | { | |
b4c96d0d | 1026 | const char *s = NULL; |
252b5132 RH |
1027 | char *t; |
1028 | unsigned int len; | |
1029 | ||
1030 | assert (info->stack != NULL); | |
1031 | ||
1032 | if (info->stack->visibility == visibility) | |
b34976b6 | 1033 | return TRUE; |
252b5132 | 1034 | |
252b5132 RH |
1035 | switch (visibility) |
1036 | { | |
1037 | case DEBUG_VISIBILITY_PUBLIC: | |
1038 | s = "public"; | |
1039 | break; | |
1040 | case DEBUG_VISIBILITY_PRIVATE: | |
1041 | s = "private"; | |
1042 | break; | |
1043 | case DEBUG_VISIBILITY_PROTECTED: | |
1044 | s = "protected"; | |
1045 | break; | |
1046 | case DEBUG_VISIBILITY_IGNORE: | |
1047 | s = "/* ignore */"; | |
1048 | break; | |
1049 | default: | |
1050 | abort (); | |
b34976b6 | 1051 | return FALSE; |
252b5132 RH |
1052 | } |
1053 | ||
1054 | /* Trim off a trailing space in the struct string, to make the | |
1055 | output look a bit better, then stick on the visibility string. */ | |
1056 | ||
1057 | t = info->stack->type; | |
1058 | len = strlen (t); | |
1059 | assert (t[len - 1] == ' '); | |
1060 | t[len - 1] = '\0'; | |
1061 | ||
1062 | if (! append_type (info, s) | |
1063 | || ! append_type (info, ":\n") | |
1064 | || ! indent_type (info)) | |
b34976b6 | 1065 | return FALSE; |
252b5132 RH |
1066 | |
1067 | info->stack->visibility = visibility; | |
1068 | ||
b34976b6 | 1069 | return TRUE; |
252b5132 RH |
1070 | } |
1071 | ||
1072 | /* Add a field to a struct type. */ | |
1073 | ||
b34976b6 | 1074 | static bfd_boolean |
252b5132 RH |
1075 | pr_struct_field (p, name, bitpos, bitsize, visibility) |
1076 | PTR p; | |
1077 | const char *name; | |
1078 | bfd_vma bitpos; | |
1079 | bfd_vma bitsize; | |
1080 | enum debug_visibility visibility; | |
1081 | { | |
1082 | struct pr_handle *info = (struct pr_handle *) p; | |
1083 | char ab[20]; | |
1084 | char *t; | |
1085 | ||
1086 | if (! substitute_type (info, name)) | |
b34976b6 | 1087 | return FALSE; |
252b5132 RH |
1088 | |
1089 | if (! append_type (info, "; /* ")) | |
b34976b6 | 1090 | return FALSE; |
252b5132 RH |
1091 | |
1092 | if (bitsize != 0) | |
1093 | { | |
b34976b6 | 1094 | print_vma (bitsize, ab, TRUE, FALSE); |
252b5132 RH |
1095 | if (! append_type (info, "bitsize ") |
1096 | || ! append_type (info, ab) | |
1097 | || ! append_type (info, ", ")) | |
b34976b6 | 1098 | return FALSE; |
252b5132 RH |
1099 | } |
1100 | ||
b34976b6 | 1101 | print_vma (bitpos, ab, TRUE, FALSE); |
252b5132 RH |
1102 | if (! append_type (info, "bitpos ") |
1103 | || ! append_type (info, ab) | |
1104 | || ! append_type (info, " */\n") | |
1105 | || ! indent_type (info)) | |
b34976b6 | 1106 | return FALSE; |
252b5132 RH |
1107 | |
1108 | t = pop_type (info); | |
1109 | if (t == NULL) | |
b34976b6 | 1110 | return FALSE; |
252b5132 RH |
1111 | |
1112 | if (! pr_fix_visibility (info, visibility)) | |
b34976b6 | 1113 | return FALSE; |
252b5132 RH |
1114 | |
1115 | return append_type (info, t); | |
1116 | } | |
1117 | ||
1118 | /* Finish a struct type. */ | |
1119 | ||
b34976b6 | 1120 | static bfd_boolean |
252b5132 RH |
1121 | pr_end_struct_type (p) |
1122 | PTR p; | |
1123 | { | |
1124 | struct pr_handle *info = (struct pr_handle *) p; | |
1125 | char *s; | |
1126 | ||
1127 | assert (info->stack != NULL); | |
1128 | assert (info->indent >= 2); | |
1129 | ||
1130 | info->indent -= 2; | |
1131 | ||
1132 | /* Change the trailing indentation to have a close brace. */ | |
1133 | s = info->stack->type + strlen (info->stack->type) - 2; | |
1134 | assert (s[0] == ' ' && s[1] == ' ' && s[2] == '\0'); | |
1135 | ||
1136 | *s++ = '}'; | |
1137 | *s = '\0'; | |
1138 | ||
b34976b6 | 1139 | return TRUE; |
252b5132 RH |
1140 | } |
1141 | ||
1142 | /* Start a class type. */ | |
1143 | ||
b34976b6 | 1144 | static bfd_boolean |
252b5132 RH |
1145 | pr_start_class_type (p, tag, id, structp, size, vptr, ownvptr) |
1146 | PTR p; | |
1147 | const char *tag; | |
1148 | unsigned int id; | |
b34976b6 | 1149 | bfd_boolean structp; |
252b5132 | 1150 | unsigned int size; |
b34976b6 AM |
1151 | bfd_boolean vptr; |
1152 | bfd_boolean ownvptr; | |
252b5132 RH |
1153 | { |
1154 | struct pr_handle *info = (struct pr_handle *) p; | |
1155 | char *tv = NULL; | |
1156 | ||
1157 | info->indent += 2; | |
1158 | ||
1159 | if (vptr && ! ownvptr) | |
1160 | { | |
1161 | tv = pop_type (info); | |
1162 | if (tv == NULL) | |
b34976b6 | 1163 | return FALSE; |
252b5132 RH |
1164 | } |
1165 | ||
1166 | if (! push_type (info, structp ? "class " : "union class ")) | |
b34976b6 | 1167 | return FALSE; |
252b5132 RH |
1168 | if (tag != NULL) |
1169 | { | |
1170 | if (! append_type (info, tag)) | |
b34976b6 | 1171 | return FALSE; |
252b5132 RH |
1172 | } |
1173 | else | |
1174 | { | |
1175 | char idbuf[20]; | |
1176 | ||
1177 | sprintf (idbuf, "%%anon%u", id); | |
1178 | if (! append_type (info, idbuf)) | |
b34976b6 | 1179 | return FALSE; |
252b5132 RH |
1180 | } |
1181 | ||
1182 | if (! append_type (info, " {")) | |
b34976b6 | 1183 | return FALSE; |
252b5132 RH |
1184 | if (size != 0 || vptr || ownvptr || tag != NULL) |
1185 | { | |
1186 | if (! append_type (info, " /*")) | |
b34976b6 | 1187 | return FALSE; |
252b5132 RH |
1188 | |
1189 | if (size != 0) | |
1190 | { | |
1191 | char ab[20]; | |
1192 | ||
1193 | sprintf (ab, "%u", size); | |
1194 | if (! append_type (info, " size ") | |
1195 | || ! append_type (info, ab)) | |
b34976b6 | 1196 | return FALSE; |
252b5132 RH |
1197 | } |
1198 | ||
1199 | if (vptr) | |
1200 | { | |
1201 | if (! append_type (info, " vtable ")) | |
b34976b6 | 1202 | return FALSE; |
252b5132 RH |
1203 | if (ownvptr) |
1204 | { | |
1205 | if (! append_type (info, "self ")) | |
b34976b6 | 1206 | return FALSE; |
252b5132 RH |
1207 | } |
1208 | else | |
1209 | { | |
1210 | if (! append_type (info, tv) | |
1211 | || ! append_type (info, " ")) | |
b34976b6 | 1212 | return FALSE; |
252b5132 RH |
1213 | } |
1214 | } | |
1215 | ||
1216 | if (tag != NULL) | |
1217 | { | |
1218 | char ab[30]; | |
1219 | ||
1220 | sprintf (ab, " id %u", id); | |
1221 | if (! append_type (info, ab)) | |
b34976b6 | 1222 | return FALSE; |
252b5132 RH |
1223 | } |
1224 | ||
1225 | if (! append_type (info, " */")) | |
b34976b6 | 1226 | return FALSE; |
252b5132 RH |
1227 | } |
1228 | ||
1229 | info->stack->visibility = DEBUG_VISIBILITY_PRIVATE; | |
1230 | ||
1231 | return (append_type (info, "\n") | |
1232 | && indent_type (info)); | |
1233 | } | |
1234 | ||
1235 | /* Add a static member to a class. */ | |
1236 | ||
b34976b6 | 1237 | static bfd_boolean |
252b5132 RH |
1238 | pr_class_static_member (p, name, physname, visibility) |
1239 | PTR p; | |
1240 | const char *name; | |
1241 | const char *physname; | |
1242 | enum debug_visibility visibility; | |
1243 | { | |
1244 | struct pr_handle *info = (struct pr_handle *) p; | |
1245 | char *t; | |
1246 | ||
1247 | if (! substitute_type (info, name)) | |
b34976b6 | 1248 | return FALSE; |
252b5132 RH |
1249 | |
1250 | if (! prepend_type (info, "static ") | |
1251 | || ! append_type (info, "; /* ") | |
1252 | || ! append_type (info, physname) | |
1253 | || ! append_type (info, " */\n") | |
1254 | || ! indent_type (info)) | |
b34976b6 | 1255 | return FALSE; |
252b5132 RH |
1256 | |
1257 | t = pop_type (info); | |
1258 | if (t == NULL) | |
b34976b6 | 1259 | return FALSE; |
252b5132 RH |
1260 | |
1261 | if (! pr_fix_visibility (info, visibility)) | |
b34976b6 | 1262 | return FALSE; |
252b5132 RH |
1263 | |
1264 | return append_type (info, t); | |
1265 | } | |
1266 | ||
1267 | /* Add a base class to a class. */ | |
1268 | ||
b34976b6 | 1269 | static bfd_boolean |
252b5132 RH |
1270 | pr_class_baseclass (p, bitpos, virtual, visibility) |
1271 | PTR p; | |
1272 | bfd_vma bitpos; | |
b34976b6 | 1273 | bfd_boolean virtual; |
252b5132 RH |
1274 | enum debug_visibility visibility; |
1275 | { | |
1276 | struct pr_handle *info = (struct pr_handle *) p; | |
1277 | char *t; | |
1278 | const char *prefix; | |
1279 | char ab[20]; | |
1280 | char *s, *l, *n; | |
1281 | ||
1282 | assert (info->stack != NULL && info->stack->next != NULL); | |
1283 | ||
1284 | if (! substitute_type (info, "")) | |
b34976b6 | 1285 | return FALSE; |
252b5132 RH |
1286 | |
1287 | t = pop_type (info); | |
1288 | if (t == NULL) | |
b34976b6 | 1289 | return FALSE; |
252b5132 RH |
1290 | |
1291 | if (strncmp (t, "class ", sizeof "class " - 1) == 0) | |
1292 | t += sizeof "class " - 1; | |
1293 | ||
1294 | /* Push it back on to take advantage of the prepend_type and | |
1295 | append_type routines. */ | |
1296 | if (! push_type (info, t)) | |
b34976b6 | 1297 | return FALSE; |
252b5132 RH |
1298 | |
1299 | if (virtual) | |
1300 | { | |
1301 | if (! prepend_type (info, "virtual ")) | |
b34976b6 | 1302 | return FALSE; |
252b5132 RH |
1303 | } |
1304 | ||
1305 | switch (visibility) | |
1306 | { | |
1307 | case DEBUG_VISIBILITY_PUBLIC: | |
1308 | prefix = "public "; | |
1309 | break; | |
1310 | case DEBUG_VISIBILITY_PROTECTED: | |
1311 | prefix = "protected "; | |
1312 | break; | |
1313 | case DEBUG_VISIBILITY_PRIVATE: | |
1314 | prefix = "private "; | |
1315 | break; | |
1316 | default: | |
1317 | prefix = "/* unknown visibility */ "; | |
1318 | break; | |
1319 | } | |
1320 | ||
1321 | if (! prepend_type (info, prefix)) | |
b34976b6 | 1322 | return FALSE; |
252b5132 RH |
1323 | |
1324 | if (bitpos != 0) | |
1325 | { | |
b34976b6 | 1326 | print_vma (bitpos, ab, TRUE, FALSE); |
252b5132 RH |
1327 | if (! append_type (info, " /* bitpos ") |
1328 | || ! append_type (info, ab) | |
1329 | || ! append_type (info, " */")) | |
b34976b6 | 1330 | return FALSE; |
252b5132 RH |
1331 | } |
1332 | ||
1333 | /* Now the top of the stack is something like "public A / * bitpos | |
1334 | 10 * /". The next element on the stack is something like "class | |
1335 | xx { / * size 8 * /\n...". We want to substitute the top of the | |
1336 | stack in before the {. */ | |
1337 | s = strchr (info->stack->next->type, '{'); | |
1338 | assert (s != NULL); | |
1339 | --s; | |
1340 | ||
1341 | /* If there is already a ':', then we already have a baseclass, and | |
1342 | we must append this one after a comma. */ | |
1343 | for (l = info->stack->next->type; l != s; l++) | |
1344 | if (*l == ':') | |
1345 | break; | |
1346 | if (! prepend_type (info, l == s ? " : " : ", ")) | |
b34976b6 | 1347 | return FALSE; |
252b5132 RH |
1348 | |
1349 | t = pop_type (info); | |
1350 | if (t == NULL) | |
b34976b6 | 1351 | return FALSE; |
252b5132 RH |
1352 | |
1353 | n = (char *) xmalloc (strlen (info->stack->type) + strlen (t) + 1); | |
1354 | memcpy (n, info->stack->type, s - info->stack->type); | |
1355 | strcpy (n + (s - info->stack->type), t); | |
1356 | strcat (n, s); | |
1357 | ||
1358 | free (info->stack->type); | |
1359 | info->stack->type = n; | |
1360 | ||
1361 | free (t); | |
1362 | ||
b34976b6 | 1363 | return TRUE; |
252b5132 RH |
1364 | } |
1365 | ||
1366 | /* Start adding a method to a class. */ | |
1367 | ||
b34976b6 | 1368 | static bfd_boolean |
252b5132 RH |
1369 | pr_class_start_method (p, name) |
1370 | PTR p; | |
1371 | const char *name; | |
1372 | { | |
1373 | struct pr_handle *info = (struct pr_handle *) p; | |
1374 | ||
1375 | assert (info->stack != NULL); | |
1376 | info->stack->method = name; | |
b34976b6 | 1377 | return TRUE; |
252b5132 RH |
1378 | } |
1379 | ||
1380 | /* Add a variant to a method. */ | |
1381 | ||
b34976b6 | 1382 | static bfd_boolean |
252b5132 RH |
1383 | pr_class_method_variant (p, physname, visibility, constp, volatilep, voffset, |
1384 | context) | |
1385 | PTR p; | |
1386 | const char *physname; | |
1387 | enum debug_visibility visibility; | |
b34976b6 AM |
1388 | bfd_boolean constp; |
1389 | bfd_boolean volatilep; | |
252b5132 | 1390 | bfd_vma voffset; |
b34976b6 | 1391 | bfd_boolean context; |
252b5132 RH |
1392 | { |
1393 | struct pr_handle *info = (struct pr_handle *) p; | |
1394 | char *method_type; | |
1395 | char *context_type; | |
1396 | ||
1397 | assert (info->stack != NULL); | |
1398 | assert (info->stack->next != NULL); | |
1399 | ||
1400 | /* Put the const and volatile qualifiers on the type. */ | |
1401 | if (volatilep) | |
1402 | { | |
1403 | if (! append_type (info, " volatile")) | |
b34976b6 | 1404 | return FALSE; |
252b5132 RH |
1405 | } |
1406 | if (constp) | |
1407 | { | |
1408 | if (! append_type (info, " const")) | |
b34976b6 | 1409 | return FALSE; |
252b5132 RH |
1410 | } |
1411 | ||
1412 | /* Stick the name of the method into its type. */ | |
1413 | if (! substitute_type (info, | |
1414 | (context | |
1415 | ? info->stack->next->next->method | |
1416 | : info->stack->next->method))) | |
b34976b6 | 1417 | return FALSE; |
252b5132 RH |
1418 | |
1419 | /* Get the type. */ | |
1420 | method_type = pop_type (info); | |
1421 | if (method_type == NULL) | |
b34976b6 | 1422 | return FALSE; |
252b5132 RH |
1423 | |
1424 | /* Pull off the context type if there is one. */ | |
1425 | if (! context) | |
1426 | context_type = NULL; | |
1427 | else | |
1428 | { | |
1429 | context_type = pop_type (info); | |
1430 | if (context_type == NULL) | |
b34976b6 | 1431 | return FALSE; |
252b5132 RH |
1432 | } |
1433 | ||
1434 | /* Now the top of the stack is the class. */ | |
1435 | ||
1436 | if (! pr_fix_visibility (info, visibility)) | |
b34976b6 | 1437 | return FALSE; |
252b5132 RH |
1438 | |
1439 | if (! append_type (info, method_type) | |
1440 | || ! append_type (info, " /* ") | |
1441 | || ! append_type (info, physname) | |
1442 | || ! append_type (info, " ")) | |
b34976b6 | 1443 | return FALSE; |
252b5132 RH |
1444 | if (context || voffset != 0) |
1445 | { | |
1446 | char ab[20]; | |
1447 | ||
1448 | if (context) | |
1449 | { | |
1450 | if (! append_type (info, "context ") | |
1451 | || ! append_type (info, context_type) | |
1452 | || ! append_type (info, " ")) | |
b34976b6 | 1453 | return FALSE; |
252b5132 | 1454 | } |
b34976b6 | 1455 | print_vma (voffset, ab, TRUE, FALSE); |
252b5132 RH |
1456 | if (! append_type (info, "voffset ") |
1457 | || ! append_type (info, ab)) | |
b34976b6 | 1458 | return FALSE; |
252b5132 RH |
1459 | } |
1460 | ||
1461 | return (append_type (info, " */;\n") | |
1462 | && indent_type (info)); | |
1463 | } | |
1464 | ||
1465 | /* Add a static variant to a method. */ | |
1466 | ||
b34976b6 | 1467 | static bfd_boolean |
252b5132 RH |
1468 | pr_class_static_method_variant (p, physname, visibility, constp, volatilep) |
1469 | PTR p; | |
1470 | const char *physname; | |
1471 | enum debug_visibility visibility; | |
b34976b6 AM |
1472 | bfd_boolean constp; |
1473 | bfd_boolean volatilep; | |
252b5132 RH |
1474 | { |
1475 | struct pr_handle *info = (struct pr_handle *) p; | |
1476 | char *method_type; | |
1477 | ||
1478 | assert (info->stack != NULL); | |
1479 | assert (info->stack->next != NULL); | |
1480 | assert (info->stack->next->method != NULL); | |
1481 | ||
1482 | /* Put the const and volatile qualifiers on the type. */ | |
1483 | if (volatilep) | |
1484 | { | |
1485 | if (! append_type (info, " volatile")) | |
b34976b6 | 1486 | return FALSE; |
252b5132 RH |
1487 | } |
1488 | if (constp) | |
1489 | { | |
1490 | if (! append_type (info, " const")) | |
b34976b6 | 1491 | return FALSE; |
252b5132 RH |
1492 | } |
1493 | ||
1494 | /* Mark it as static. */ | |
1495 | if (! prepend_type (info, "static ")) | |
b34976b6 | 1496 | return FALSE; |
252b5132 RH |
1497 | |
1498 | /* Stick the name of the method into its type. */ | |
1499 | if (! substitute_type (info, info->stack->next->method)) | |
b34976b6 | 1500 | return FALSE; |
252b5132 RH |
1501 | |
1502 | /* Get the type. */ | |
1503 | method_type = pop_type (info); | |
1504 | if (method_type == NULL) | |
b34976b6 | 1505 | return FALSE; |
252b5132 RH |
1506 | |
1507 | /* Now the top of the stack is the class. */ | |
1508 | ||
1509 | if (! pr_fix_visibility (info, visibility)) | |
b34976b6 | 1510 | return FALSE; |
252b5132 RH |
1511 | |
1512 | return (append_type (info, method_type) | |
1513 | && append_type (info, " /* ") | |
1514 | && append_type (info, physname) | |
1515 | && append_type (info, " */;\n") | |
1516 | && indent_type (info)); | |
1517 | } | |
1518 | ||
1519 | /* Finish up a method. */ | |
1520 | ||
b34976b6 | 1521 | static bfd_boolean |
252b5132 RH |
1522 | pr_class_end_method (p) |
1523 | PTR p; | |
1524 | { | |
1525 | struct pr_handle *info = (struct pr_handle *) p; | |
1526 | ||
1527 | info->stack->method = NULL; | |
b34976b6 | 1528 | return TRUE; |
252b5132 RH |
1529 | } |
1530 | ||
1531 | /* Finish up a class. */ | |
1532 | ||
b34976b6 | 1533 | static bfd_boolean |
252b5132 RH |
1534 | pr_end_class_type (p) |
1535 | PTR p; | |
1536 | { | |
1537 | return pr_end_struct_type (p); | |
1538 | } | |
1539 | ||
1540 | /* Push a type on the stack using a typedef name. */ | |
1541 | ||
b34976b6 | 1542 | static bfd_boolean |
252b5132 RH |
1543 | pr_typedef_type (p, name) |
1544 | PTR p; | |
1545 | const char *name; | |
1546 | { | |
1547 | struct pr_handle *info = (struct pr_handle *) p; | |
1548 | ||
1549 | return push_type (info, name); | |
1550 | } | |
1551 | ||
1552 | /* Push a type on the stack using a tag name. */ | |
1553 | ||
b34976b6 | 1554 | static bfd_boolean |
252b5132 RH |
1555 | pr_tag_type (p, name, id, kind) |
1556 | PTR p; | |
1557 | const char *name; | |
1558 | unsigned int id; | |
1559 | enum debug_type_kind kind; | |
1560 | { | |
1561 | struct pr_handle *info = (struct pr_handle *) p; | |
1562 | const char *t, *tag; | |
1563 | char idbuf[20]; | |
1564 | ||
1565 | switch (kind) | |
1566 | { | |
1567 | case DEBUG_KIND_STRUCT: | |
1568 | t = "struct "; | |
1569 | break; | |
1570 | case DEBUG_KIND_UNION: | |
1571 | t = "union "; | |
1572 | break; | |
1573 | case DEBUG_KIND_ENUM: | |
1574 | t = "enum "; | |
1575 | break; | |
1576 | case DEBUG_KIND_CLASS: | |
1577 | t = "class "; | |
1578 | break; | |
1579 | case DEBUG_KIND_UNION_CLASS: | |
1580 | t = "union class "; | |
1581 | break; | |
1582 | default: | |
1583 | abort (); | |
b34976b6 | 1584 | return FALSE; |
252b5132 RH |
1585 | } |
1586 | ||
1587 | if (! push_type (info, t)) | |
b34976b6 | 1588 | return FALSE; |
252b5132 RH |
1589 | if (name != NULL) |
1590 | tag = name; | |
1591 | else | |
1592 | { | |
1593 | sprintf (idbuf, "%%anon%u", id); | |
1594 | tag = idbuf; | |
1595 | } | |
1596 | ||
1597 | if (! append_type (info, tag)) | |
b34976b6 | 1598 | return FALSE; |
252b5132 RH |
1599 | if (name != NULL && kind != DEBUG_KIND_ENUM) |
1600 | { | |
1601 | sprintf (idbuf, " /* id %u */", id); | |
1602 | if (! append_type (info, idbuf)) | |
b34976b6 | 1603 | return FALSE; |
252b5132 RH |
1604 | } |
1605 | ||
b34976b6 | 1606 | return TRUE; |
252b5132 RH |
1607 | } |
1608 | ||
1609 | /* Output a typedef. */ | |
1610 | ||
b34976b6 | 1611 | static bfd_boolean |
252b5132 RH |
1612 | pr_typdef (p, name) |
1613 | PTR p; | |
1614 | const char *name; | |
1615 | { | |
1616 | struct pr_handle *info = (struct pr_handle *) p; | |
1617 | char *s; | |
1618 | ||
1619 | if (! substitute_type (info, name)) | |
b34976b6 | 1620 | return FALSE; |
252b5132 RH |
1621 | |
1622 | s = pop_type (info); | |
1623 | if (s == NULL) | |
b34976b6 | 1624 | return FALSE; |
252b5132 RH |
1625 | |
1626 | indent (info); | |
1627 | fprintf (info->f, "typedef %s;\n", s); | |
1628 | ||
1629 | free (s); | |
1630 | ||
b34976b6 | 1631 | return TRUE; |
252b5132 RH |
1632 | } |
1633 | ||
1634 | /* Output a tag. The tag should already be in the string on the | |
1635 | stack, so all we have to do here is print it out. */ | |
1636 | ||
b34976b6 | 1637 | static bfd_boolean |
252b5132 RH |
1638 | pr_tag (p, name) |
1639 | PTR p; | |
b4c96d0d | 1640 | const char *name ATTRIBUTE_UNUSED; |
252b5132 RH |
1641 | { |
1642 | struct pr_handle *info = (struct pr_handle *) p; | |
1643 | char *t; | |
1644 | ||
1645 | t = pop_type (info); | |
1646 | if (t == NULL) | |
b34976b6 | 1647 | return FALSE; |
252b5132 RH |
1648 | |
1649 | indent (info); | |
1650 | fprintf (info->f, "%s;\n", t); | |
1651 | ||
1652 | free (t); | |
1653 | ||
b34976b6 | 1654 | return TRUE; |
252b5132 RH |
1655 | } |
1656 | ||
1657 | /* Output an integer constant. */ | |
1658 | ||
b34976b6 | 1659 | static bfd_boolean |
252b5132 RH |
1660 | pr_int_constant (p, name, val) |
1661 | PTR p; | |
1662 | const char *name; | |
1663 | bfd_vma val; | |
1664 | { | |
1665 | struct pr_handle *info = (struct pr_handle *) p; | |
1666 | char ab[20]; | |
1667 | ||
1668 | indent (info); | |
b34976b6 | 1669 | print_vma (val, ab, FALSE, FALSE); |
252b5132 | 1670 | fprintf (info->f, "const int %s = %s;\n", name, ab); |
b34976b6 | 1671 | return TRUE; |
252b5132 RH |
1672 | } |
1673 | ||
1674 | /* Output a floating point constant. */ | |
1675 | ||
b34976b6 | 1676 | static bfd_boolean |
252b5132 RH |
1677 | pr_float_constant (p, name, val) |
1678 | PTR p; | |
1679 | const char *name; | |
1680 | double val; | |
1681 | { | |
1682 | struct pr_handle *info = (struct pr_handle *) p; | |
1683 | ||
1684 | indent (info); | |
1685 | fprintf (info->f, "const double %s = %g;\n", name, val); | |
b34976b6 | 1686 | return TRUE; |
252b5132 RH |
1687 | } |
1688 | ||
1689 | /* Output a typed constant. */ | |
1690 | ||
b34976b6 | 1691 | static bfd_boolean |
252b5132 RH |
1692 | pr_typed_constant (p, name, val) |
1693 | PTR p; | |
1694 | const char *name; | |
1695 | bfd_vma val; | |
1696 | { | |
1697 | struct pr_handle *info = (struct pr_handle *) p; | |
1698 | char *t; | |
1699 | char ab[20]; | |
1700 | ||
1701 | t = pop_type (info); | |
1702 | if (t == NULL) | |
b34976b6 | 1703 | return FALSE; |
252b5132 RH |
1704 | |
1705 | indent (info); | |
b34976b6 | 1706 | print_vma (val, ab, FALSE, FALSE); |
252b5132 RH |
1707 | fprintf (info->f, "const %s %s = %s;\n", t, name, ab); |
1708 | ||
1709 | free (t); | |
1710 | ||
b34976b6 | 1711 | return TRUE; |
252b5132 RH |
1712 | } |
1713 | ||
1714 | /* Output a variable. */ | |
1715 | ||
b34976b6 | 1716 | static bfd_boolean |
252b5132 RH |
1717 | pr_variable (p, name, kind, val) |
1718 | PTR p; | |
1719 | const char *name; | |
1720 | enum debug_var_kind kind; | |
1721 | bfd_vma val; | |
1722 | { | |
1723 | struct pr_handle *info = (struct pr_handle *) p; | |
1724 | char *t; | |
1725 | char ab[20]; | |
1726 | ||
1727 | if (! substitute_type (info, name)) | |
b34976b6 | 1728 | return FALSE; |
252b5132 RH |
1729 | |
1730 | t = pop_type (info); | |
1731 | if (t == NULL) | |
b34976b6 | 1732 | return FALSE; |
252b5132 RH |
1733 | |
1734 | indent (info); | |
1735 | switch (kind) | |
1736 | { | |
1737 | case DEBUG_STATIC: | |
1738 | case DEBUG_LOCAL_STATIC: | |
1739 | fprintf (info->f, "static "); | |
1740 | break; | |
1741 | case DEBUG_REGISTER: | |
1742 | fprintf (info->f, "register "); | |
1743 | break; | |
1744 | default: | |
1745 | break; | |
1746 | } | |
b34976b6 | 1747 | print_vma (val, ab, TRUE, TRUE); |
252b5132 RH |
1748 | fprintf (info->f, "%s /* %s */;\n", t, ab); |
1749 | ||
1750 | free (t); | |
1751 | ||
b34976b6 | 1752 | return TRUE; |
252b5132 RH |
1753 | } |
1754 | ||
1755 | /* Start outputting a function. */ | |
1756 | ||
b34976b6 | 1757 | static bfd_boolean |
252b5132 RH |
1758 | pr_start_function (p, name, global) |
1759 | PTR p; | |
1760 | const char *name; | |
b34976b6 | 1761 | bfd_boolean global; |
252b5132 RH |
1762 | { |
1763 | struct pr_handle *info = (struct pr_handle *) p; | |
1764 | char *t; | |
1765 | ||
1766 | if (! substitute_type (info, name)) | |
b34976b6 | 1767 | return FALSE; |
252b5132 RH |
1768 | |
1769 | t = pop_type (info); | |
1770 | if (t == NULL) | |
b34976b6 | 1771 | return FALSE; |
252b5132 RH |
1772 | |
1773 | indent (info); | |
1774 | if (! global) | |
1775 | fprintf (info->f, "static "); | |
1776 | fprintf (info->f, "%s (", t); | |
1777 | ||
1778 | info->parameter = 1; | |
1779 | ||
b34976b6 | 1780 | return TRUE; |
252b5132 RH |
1781 | } |
1782 | ||
1783 | /* Output a function parameter. */ | |
1784 | ||
b34976b6 | 1785 | static bfd_boolean |
252b5132 RH |
1786 | pr_function_parameter (p, name, kind, val) |
1787 | PTR p; | |
1788 | const char *name; | |
1789 | enum debug_parm_kind kind; | |
1790 | bfd_vma val; | |
1791 | { | |
1792 | struct pr_handle *info = (struct pr_handle *) p; | |
1793 | char *t; | |
1794 | char ab[20]; | |
1795 | ||
1796 | if (kind == DEBUG_PARM_REFERENCE | |
1797 | || kind == DEBUG_PARM_REF_REG) | |
1798 | { | |
1799 | if (! pr_reference_type (p)) | |
b34976b6 | 1800 | return FALSE; |
252b5132 RH |
1801 | } |
1802 | ||
1803 | if (! substitute_type (info, name)) | |
b34976b6 | 1804 | return FALSE; |
252b5132 RH |
1805 | |
1806 | t = pop_type (info); | |
1807 | if (t == NULL) | |
b34976b6 | 1808 | return FALSE; |
252b5132 RH |
1809 | |
1810 | if (info->parameter != 1) | |
1811 | fprintf (info->f, ", "); | |
1812 | ||
1813 | if (kind == DEBUG_PARM_REG || kind == DEBUG_PARM_REF_REG) | |
1814 | fprintf (info->f, "register "); | |
1815 | ||
b34976b6 | 1816 | print_vma (val, ab, TRUE, TRUE); |
252b5132 RH |
1817 | fprintf (info->f, "%s /* %s */", t, ab); |
1818 | ||
1819 | free (t); | |
1820 | ||
1821 | ++info->parameter; | |
1822 | ||
b34976b6 | 1823 | return TRUE; |
252b5132 RH |
1824 | } |
1825 | ||
1826 | /* Start writing out a block. */ | |
1827 | ||
b34976b6 | 1828 | static bfd_boolean |
252b5132 RH |
1829 | pr_start_block (p, addr) |
1830 | PTR p; | |
1831 | bfd_vma addr; | |
1832 | { | |
1833 | struct pr_handle *info = (struct pr_handle *) p; | |
1834 | char ab[20]; | |
1835 | ||
1836 | if (info->parameter > 0) | |
1837 | { | |
1838 | fprintf (info->f, ")\n"); | |
1839 | info->parameter = 0; | |
1840 | } | |
1841 | ||
1842 | indent (info); | |
b34976b6 | 1843 | print_vma (addr, ab, TRUE, TRUE); |
252b5132 RH |
1844 | fprintf (info->f, "{ /* %s */\n", ab); |
1845 | ||
1846 | info->indent += 2; | |
1847 | ||
b34976b6 | 1848 | return TRUE; |
252b5132 RH |
1849 | } |
1850 | ||
1851 | /* Write out line number information. */ | |
1852 | ||
b34976b6 | 1853 | static bfd_boolean |
252b5132 RH |
1854 | pr_lineno (p, filename, lineno, addr) |
1855 | PTR p; | |
1856 | const char *filename; | |
1857 | unsigned long lineno; | |
1858 | bfd_vma addr; | |
1859 | { | |
1860 | struct pr_handle *info = (struct pr_handle *) p; | |
1861 | char ab[20]; | |
1862 | ||
1863 | indent (info); | |
b34976b6 | 1864 | print_vma (addr, ab, TRUE, TRUE); |
252b5132 RH |
1865 | fprintf (info->f, "/* file %s line %lu addr %s */\n", filename, lineno, ab); |
1866 | ||
b34976b6 | 1867 | return TRUE; |
252b5132 RH |
1868 | } |
1869 | ||
1870 | /* Finish writing out a block. */ | |
1871 | ||
b34976b6 | 1872 | static bfd_boolean |
252b5132 RH |
1873 | pr_end_block (p, addr) |
1874 | PTR p; | |
1875 | bfd_vma addr; | |
1876 | { | |
1877 | struct pr_handle *info = (struct pr_handle *) p; | |
1878 | char ab[20]; | |
1879 | ||
1880 | info->indent -= 2; | |
1881 | ||
1882 | indent (info); | |
b34976b6 | 1883 | print_vma (addr, ab, TRUE, TRUE); |
252b5132 RH |
1884 | fprintf (info->f, "} /* %s */\n", ab); |
1885 | ||
b34976b6 | 1886 | return TRUE; |
252b5132 RH |
1887 | } |
1888 | ||
1889 | /* Finish writing out a function. */ | |
1890 | ||
b34976b6 | 1891 | static bfd_boolean |
252b5132 | 1892 | pr_end_function (p) |
b4c96d0d | 1893 | PTR p ATTRIBUTE_UNUSED; |
252b5132 | 1894 | { |
b34976b6 | 1895 | return TRUE; |
252b5132 | 1896 | } |