rtl.def (CALL_PLACEHOLDER): New rtx code.
[gcc.git] / gcc / dwarfout.c
1 /* Output Dwarf format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 95-97, 1998 Free Software Foundation, Inc.
3 Contributed by Ron Guilmette (rfg@monkeys.com) of Network Computing Devices.
4
5 This file is part of GNU CC.
6
7 GNU CC 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, or (at your option)
10 any later version.
11
12 GNU CC 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 GNU CC; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330,
20 Boston, MA 02111-1307, USA. */
21
22 #include "config.h"
23
24 #ifdef DWARF_DEBUGGING_INFO
25 #include "system.h"
26 #include "dwarf.h"
27 #include "tree.h"
28 #include "flags.h"
29 #include "rtl.h"
30 #include "hard-reg-set.h"
31 #include "insn-config.h"
32 #include "reload.h"
33 #include "output.h"
34 #include "defaults.h"
35 #include "dwarfout.h"
36 #include "toplev.h"
37
38 #if defined(DWARF_TIMESTAMPS)
39 #if !defined(POSIX)
40 extern time_t time PROTO ((time_t *)); /* FIXME: use NEED_DECLARATION_TIME */
41 #endif /* !defined(POSIX) */
42 #endif /* defined(DWARF_TIMESTAMPS) */
43
44 /* We cannot use <assert.h> in GCC source, since that would include
45 GCC's assert.h, which may not be compatible with the host compiler. */
46 #undef assert
47 #ifdef NDEBUG
48 # define assert(e)
49 #else
50 # define assert(e) do { if (! (e)) abort (); } while (0)
51 #endif
52
53 extern char *getpwd PROTO((void));
54
55 /* IMPORTANT NOTE: Please see the file README.DWARF for important details
56 regarding the GNU implementation of Dwarf. */
57
58 /* NOTE: In the comments in this file, many references are made to
59 so called "Debugging Information Entries". For the sake of brevity,
60 this term is abbreviated to `DIE' throughout the remainder of this
61 file. */
62
63 /* Note that the implementation of C++ support herein is (as yet) unfinished.
64 If you want to try to complete it, more power to you. */
65
66 #if !defined(__GNUC__) || (NDEBUG != 1)
67 #define inline
68 #endif
69
70 /* How to start an assembler comment. */
71 #ifndef ASM_COMMENT_START
72 #define ASM_COMMENT_START ";#"
73 #endif
74
75 /* How to print out a register name. */
76 #ifndef PRINT_REG
77 #define PRINT_REG(RTX, CODE, FILE) \
78 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
79 #endif
80
81 /* Define a macro which returns non-zero for any tagged type which is
82 used (directly or indirectly) in the specification of either some
83 function's return type or some formal parameter of some function.
84 We use this macro when we are operating in "terse" mode to help us
85 know what tagged types have to be represented in Dwarf (even in
86 terse mode) and which ones don't.
87
88 A flag bit with this meaning really should be a part of the normal
89 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
90 for these nodes. For now, we have to just fake it. It it safe for
91 us to simply return zero for all complete tagged types (which will
92 get forced out anyway if they were used in the specification of some
93 formal or return type) and non-zero for all incomplete tagged types.
94 */
95
96 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
97
98 /* Define a macro which returns non-zero for a TYPE_DECL which was
99 implicitly generated for a tagged type.
100
101 Note that unlike the gcc front end (which generates a NULL named
102 TYPE_DECL node for each complete tagged type, each array type, and
103 each function type node created) the g++ front end generates a
104 _named_ TYPE_DECL node for each tagged type node created.
105 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
106 generate a DW_TAG_typedef DIE for them. */
107 #define TYPE_DECL_IS_STUB(decl) \
108 (DECL_NAME (decl) == NULL \
109 || (DECL_ARTIFICIAL (decl) \
110 && is_tagged_type (TREE_TYPE (decl)) \
111 && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
112
113 extern int flag_traditional;
114 extern char *version_string;
115 extern char *language_string;
116
117 /* Maximum size (in bytes) of an artificially generated label. */
118
119 #define MAX_ARTIFICIAL_LABEL_BYTES 30
120 \f
121 /* Make sure we know the sizes of the various types dwarf can describe.
122 These are only defaults. If the sizes are different for your target,
123 you should override these values by defining the appropriate symbols
124 in your tm.h file. */
125
126 #ifndef CHAR_TYPE_SIZE
127 #define CHAR_TYPE_SIZE BITS_PER_UNIT
128 #endif
129
130 #ifndef SHORT_TYPE_SIZE
131 #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
132 #endif
133
134 #ifndef INT_TYPE_SIZE
135 #define INT_TYPE_SIZE BITS_PER_WORD
136 #endif
137
138 #ifndef LONG_TYPE_SIZE
139 #define LONG_TYPE_SIZE BITS_PER_WORD
140 #endif
141
142 #ifndef LONG_LONG_TYPE_SIZE
143 #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
144 #endif
145
146 #ifndef WCHAR_TYPE_SIZE
147 #define WCHAR_TYPE_SIZE INT_TYPE_SIZE
148 #endif
149
150 #ifndef WCHAR_UNSIGNED
151 #define WCHAR_UNSIGNED 0
152 #endif
153
154 #ifndef FLOAT_TYPE_SIZE
155 #define FLOAT_TYPE_SIZE BITS_PER_WORD
156 #endif
157
158 #ifndef DOUBLE_TYPE_SIZE
159 #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
160 #endif
161
162 #ifndef LONG_DOUBLE_TYPE_SIZE
163 #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
164 #endif
165 \f
166 /* Structure to keep track of source filenames. */
167
168 struct filename_entry {
169 unsigned number;
170 char * name;
171 };
172
173 typedef struct filename_entry filename_entry;
174
175 /* Pointer to an array of elements, each one having the structure above. */
176
177 static filename_entry *filename_table;
178
179 /* Total number of entries in the table (i.e. array) pointed to by
180 `filename_table'. This is the *total* and includes both used and
181 unused slots. */
182
183 static unsigned ft_entries_allocated;
184
185 /* Number of entries in the filename_table which are actually in use. */
186
187 static unsigned ft_entries;
188
189 /* Size (in elements) of increments by which we may expand the filename
190 table. Actually, a single hunk of space of this size should be enough
191 for most typical programs. */
192
193 #define FT_ENTRIES_INCREMENT 64
194
195 /* Local pointer to the name of the main input file. Initialized in
196 dwarfout_init. */
197
198 static char *primary_filename;
199
200 /* Pointer to the most recent filename for which we produced some line info. */
201
202 static char *last_filename;
203
204 /* For Dwarf output, we must assign lexical-blocks id numbers
205 in the order in which their beginnings are encountered.
206 We output Dwarf debugging info that refers to the beginnings
207 and ends of the ranges of code for each lexical block with
208 assembler labels ..Bn and ..Bn.e, where n is the block number.
209 The labels themselves are generated in final.c, which assigns
210 numbers to the blocks in the same way. */
211
212 static unsigned next_block_number = 2;
213
214 /* Counter to generate unique names for DIEs. */
215
216 static unsigned next_unused_dienum = 1;
217
218 /* Number of the DIE which is currently being generated. */
219
220 static unsigned current_dienum;
221
222 /* Number to use for the special "pubname" label on the next DIE which
223 represents a function or data object defined in this compilation
224 unit which has "extern" linkage. */
225
226 static int next_pubname_number = 0;
227
228 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
229
230 /* Pointer to a dynamically allocated list of pre-reserved and still
231 pending sibling DIE numbers. Note that this list will grow as needed. */
232
233 static unsigned *pending_sibling_stack;
234
235 /* Counter to keep track of the number of pre-reserved and still pending
236 sibling DIE numbers. */
237
238 static unsigned pending_siblings;
239
240 /* The currently allocated size of the above list (expressed in number of
241 list elements). */
242
243 static unsigned pending_siblings_allocated;
244
245 /* Size (in elements) of increments by which we may expand the pending
246 sibling stack. Actually, a single hunk of space of this size should
247 be enough for most typical programs. */
248
249 #define PENDING_SIBLINGS_INCREMENT 64
250
251 /* Non-zero if we are performing our file-scope finalization pass and if
252 we should force out Dwarf descriptions of any and all file-scope
253 tagged types which are still incomplete types. */
254
255 static int finalizing = 0;
256
257 /* A pointer to the base of a list of pending types which we haven't
258 generated DIEs for yet, but which we will have to come back to
259 later on. */
260
261 static tree *pending_types_list;
262
263 /* Number of elements currently allocated for the pending_types_list. */
264
265 static unsigned pending_types_allocated;
266
267 /* Number of elements of pending_types_list currently in use. */
268
269 static unsigned pending_types;
270
271 /* Size (in elements) of increments by which we may expand the pending
272 types list. Actually, a single hunk of space of this size should
273 be enough for most typical programs. */
274
275 #define PENDING_TYPES_INCREMENT 64
276
277 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
278 This is used in a hack to help us get the DIEs describing types of
279 formal parameters to come *after* all of the DIEs describing the formal
280 parameters themselves. That's necessary in order to be compatible
281 with what the brain-damaged svr4 SDB debugger requires. */
282
283 static tree fake_containing_scope;
284
285 /* The number of the current function definition that we are generating
286 debugging information for. These numbers range from 1 up to the maximum
287 number of function definitions contained within the current compilation
288 unit. These numbers are used to create unique labels for various things
289 contained within various function definitions. */
290
291 static unsigned current_funcdef_number = 1;
292
293 /* A pointer to the ..._DECL node which we have most recently been working
294 on. We keep this around just in case something about it looks screwy
295 and we want to tell the user what the source coordinates for the actual
296 declaration are. */
297
298 static tree dwarf_last_decl;
299
300 /* A flag indicating that we are emitting the member declarations of a
301 class, so member functions and variables should not be entirely emitted.
302 This is a kludge to avoid passing a second argument to output_*_die. */
303
304 static int in_class;
305
306 /* Forward declarations for functions defined in this file. */
307
308 static char *dwarf_tag_name PROTO((unsigned));
309 static char *dwarf_attr_name PROTO((unsigned));
310 static char *dwarf_stack_op_name PROTO((unsigned));
311 static char *dwarf_typemod_name PROTO((unsigned));
312 static char *dwarf_fmt_byte_name PROTO((unsigned));
313 static char *dwarf_fund_type_name PROTO((unsigned));
314 static tree decl_ultimate_origin PROTO((tree));
315 static tree block_ultimate_origin PROTO((tree));
316 static tree decl_class_context PROTO((tree));
317 #if 0
318 static void output_unsigned_leb128 PROTO((unsigned long));
319 static void output_signed_leb128 PROTO((long));
320 #endif
321 static inline int is_body_block PROTO((tree));
322 static int fundamental_type_code PROTO((tree));
323 static tree root_type_1 PROTO((tree, int));
324 static tree root_type PROTO((tree));
325 static void write_modifier_bytes_1 PROTO((tree, int, int, int));
326 static void write_modifier_bytes PROTO((tree, int, int));
327 static inline int type_is_fundamental PROTO((tree));
328 static void equate_decl_number_to_die_number PROTO((tree));
329 static inline void equate_type_number_to_die_number PROTO((tree));
330 static void output_reg_number PROTO((rtx));
331 static void output_mem_loc_descriptor PROTO((rtx));
332 static void output_loc_descriptor PROTO((rtx));
333 static void output_bound_representation PROTO((tree, unsigned, int));
334 static void output_enumeral_list PROTO((tree));
335 static inline unsigned ceiling PROTO((unsigned, unsigned));
336 static inline tree field_type PROTO((tree));
337 static inline unsigned simple_type_align_in_bits PROTO((tree));
338 static inline unsigned simple_type_size_in_bits PROTO((tree));
339 static unsigned field_byte_offset PROTO((tree));
340 static inline void sibling_attribute PROTO((void));
341 static void location_attribute PROTO((rtx));
342 static void data_member_location_attribute PROTO((tree));
343 static void const_value_attribute PROTO((rtx));
344 static void location_or_const_value_attribute PROTO((tree));
345 static inline void name_attribute PROTO((char *));
346 static inline void fund_type_attribute PROTO((unsigned));
347 static void mod_fund_type_attribute PROTO((tree, int, int));
348 static inline void user_def_type_attribute PROTO((tree));
349 static void mod_u_d_type_attribute PROTO((tree, int, int));
350 #ifdef USE_ORDERING_ATTRIBUTE
351 static inline void ordering_attribute PROTO((unsigned));
352 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
353 static void subscript_data_attribute PROTO((tree));
354 static void byte_size_attribute PROTO((tree));
355 static inline void bit_offset_attribute PROTO((tree));
356 static inline void bit_size_attribute PROTO((tree));
357 static inline void element_list_attribute PROTO((tree));
358 static inline void stmt_list_attribute PROTO((char *));
359 static inline void low_pc_attribute PROTO((char *));
360 static inline void high_pc_attribute PROTO((char *));
361 static inline void body_begin_attribute PROTO((char *));
362 static inline void body_end_attribute PROTO((char *));
363 static inline void language_attribute PROTO((unsigned));
364 static inline void member_attribute PROTO((tree));
365 #if 0
366 static inline void string_length_attribute PROTO((tree));
367 #endif
368 static inline void comp_dir_attribute PROTO((char *));
369 static inline void sf_names_attribute PROTO((char *));
370 static inline void src_info_attribute PROTO((char *));
371 static inline void mac_info_attribute PROTO((char *));
372 static inline void prototyped_attribute PROTO((tree));
373 static inline void producer_attribute PROTO((char *));
374 static inline void inline_attribute PROTO((tree));
375 static inline void containing_type_attribute PROTO((tree));
376 static inline void abstract_origin_attribute PROTO((tree));
377 #ifdef DWARF_DECL_COORDINATES
378 static inline void src_coords_attribute PROTO((unsigned, unsigned));
379 #endif /* defined(DWARF_DECL_COORDINATES) */
380 static inline void pure_or_virtual_attribute PROTO((tree));
381 static void name_and_src_coords_attributes PROTO((tree));
382 static void type_attribute PROTO((tree, int, int));
383 static char *type_tag PROTO((tree));
384 static inline void dienum_push PROTO((void));
385 static inline void dienum_pop PROTO((void));
386 static inline tree member_declared_type PROTO((tree));
387 static char *function_start_label PROTO((tree));
388 static void output_array_type_die PROTO((void *));
389 static void output_set_type_die PROTO((void *));
390 #if 0
391 static void output_entry_point_die PROTO((void *));
392 #endif
393 static void output_inlined_enumeration_type_die PROTO((void *));
394 static void output_inlined_structure_type_die PROTO((void *));
395 static void output_inlined_union_type_die PROTO((void *));
396 static void output_enumeration_type_die PROTO((void *));
397 static void output_formal_parameter_die PROTO((void *));
398 static void output_global_subroutine_die PROTO((void *));
399 static void output_global_variable_die PROTO((void *));
400 static void output_label_die PROTO((void *));
401 static void output_lexical_block_die PROTO((void *));
402 static void output_inlined_subroutine_die PROTO((void *));
403 static void output_local_variable_die PROTO((void *));
404 static void output_member_die PROTO((void *));
405 #if 0
406 static void output_pointer_type_die PROTO((void *));
407 static void output_reference_type_die PROTO((void *));
408 #endif
409 static void output_ptr_to_mbr_type_die PROTO((void *));
410 static void output_compile_unit_die PROTO((void *));
411 static void output_string_type_die PROTO((void *));
412 static void output_inheritance_die PROTO((void *));
413 static void output_structure_type_die PROTO((void *));
414 static void output_local_subroutine_die PROTO((void *));
415 static void output_subroutine_type_die PROTO((void *));
416 static void output_typedef_die PROTO((void *));
417 static void output_union_type_die PROTO((void *));
418 static void output_unspecified_parameters_die PROTO((void *));
419 static void output_padded_null_die PROTO((void *));
420 static void output_die PROTO((void (*) PROTO((void *)), void *));
421 static void end_sibling_chain PROTO((void));
422 static void output_formal_types PROTO((tree));
423 static void pend_type PROTO((tree));
424 static int type_ok_for_scope PROTO((tree, tree));
425 static void output_pending_types_for_scope PROTO((tree));
426 static void output_type PROTO((tree, tree));
427 static void output_tagged_type_instantiation PROTO((tree));
428 static void output_block PROTO((tree, int));
429 static void output_decls_for_scope PROTO((tree, int));
430 static void output_decl PROTO((tree, tree));
431 static void shuffle_filename_entry PROTO((filename_entry *));
432 static void generate_new_sfname_entry PROTO((void));
433 static unsigned lookup_filename PROTO((char *));
434 static void generate_srcinfo_entry PROTO((unsigned, unsigned));
435 static void generate_macinfo_entry PROTO((char *, char *));
436 static int is_pseudo_reg PROTO((rtx));
437 static tree type_main_variant PROTO((tree));
438 static int is_tagged_type PROTO((tree));
439 static int is_redundant_typedef PROTO((tree));
440 \f
441 /* Definitions of defaults for assembler-dependent names of various
442 pseudo-ops and section names.
443
444 Theses may be overridden in your tm.h file (if necessary) for your
445 particular assembler. The default values provided here correspond to
446 what is expected by "standard" AT&T System V.4 assemblers. */
447
448 #ifndef FILE_ASM_OP
449 #define FILE_ASM_OP ".file"
450 #endif
451 #ifndef VERSION_ASM_OP
452 #define VERSION_ASM_OP ".version"
453 #endif
454 #ifndef UNALIGNED_SHORT_ASM_OP
455 #define UNALIGNED_SHORT_ASM_OP ".2byte"
456 #endif
457 #ifndef UNALIGNED_INT_ASM_OP
458 #define UNALIGNED_INT_ASM_OP ".4byte"
459 #endif
460 #ifndef ASM_BYTE_OP
461 #define ASM_BYTE_OP ".byte"
462 #endif
463 #ifndef SET_ASM_OP
464 #define SET_ASM_OP ".set"
465 #endif
466
467 /* Pseudo-ops for pushing the current section onto the section stack (and
468 simultaneously changing to a new section) and for poping back to the
469 section we were in immediately before this one. Note that most svr4
470 assemblers only maintain a one level stack... you can push all the
471 sections you want, but you can only pop out one level. (The sparc
472 svr4 assembler is an exception to this general rule.) That's
473 OK because we only use at most one level of the section stack herein. */
474
475 #ifndef PUSHSECTION_ASM_OP
476 #define PUSHSECTION_ASM_OP ".section"
477 #endif
478 #ifndef POPSECTION_ASM_OP
479 #define POPSECTION_ASM_OP ".previous"
480 #endif
481
482 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
483 to print the PUSHSECTION_ASM_OP and the section name. The default here
484 works for almost all svr4 assemblers, except for the sparc, where the
485 section name must be enclosed in double quotes. (See sparcv4.h.) */
486
487 #ifndef PUSHSECTION_FORMAT
488 #define PUSHSECTION_FORMAT "\t%s\t%s\n"
489 #endif
490
491 #ifndef DEBUG_SECTION
492 #define DEBUG_SECTION ".debug"
493 #endif
494 #ifndef LINE_SECTION
495 #define LINE_SECTION ".line"
496 #endif
497 #ifndef SFNAMES_SECTION
498 #define SFNAMES_SECTION ".debug_sfnames"
499 #endif
500 #ifndef SRCINFO_SECTION
501 #define SRCINFO_SECTION ".debug_srcinfo"
502 #endif
503 #ifndef MACINFO_SECTION
504 #define MACINFO_SECTION ".debug_macinfo"
505 #endif
506 #ifndef PUBNAMES_SECTION
507 #define PUBNAMES_SECTION ".debug_pubnames"
508 #endif
509 #ifndef ARANGES_SECTION
510 #define ARANGES_SECTION ".debug_aranges"
511 #endif
512 #ifndef TEXT_SECTION
513 #define TEXT_SECTION ".text"
514 #endif
515 #ifndef DATA_SECTION
516 #define DATA_SECTION ".data"
517 #endif
518 #ifndef DATA1_SECTION
519 #define DATA1_SECTION ".data1"
520 #endif
521 #ifndef RODATA_SECTION
522 #define RODATA_SECTION ".rodata"
523 #endif
524 #ifndef RODATA1_SECTION
525 #define RODATA1_SECTION ".rodata1"
526 #endif
527 #ifndef BSS_SECTION
528 #define BSS_SECTION ".bss"
529 #endif
530 \f
531 /* Definitions of defaults for formats and names of various special
532 (artificial) labels which may be generated within this file (when
533 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
534
535 If necessary, these may be overridden from within your tm.h file,
536 but typically, you should never need to override these.
537
538 These labels have been hacked (temporarily) so that they all begin with
539 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
540 stock m88k/svr4 assembler, both of which need to see .L at the start of
541 a label in order to prevent that label from going into the linker symbol
542 table). When I get time, I'll have to fix this the right way so that we
543 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
544 but that will require a rather massive set of changes. For the moment,
545 the following definitions out to produce the right results for all svr4
546 and svr3 assemblers. -- rfg
547 */
548
549 #ifndef TEXT_BEGIN_LABEL
550 #define TEXT_BEGIN_LABEL "*.L_text_b"
551 #endif
552 #ifndef TEXT_END_LABEL
553 #define TEXT_END_LABEL "*.L_text_e"
554 #endif
555
556 #ifndef DATA_BEGIN_LABEL
557 #define DATA_BEGIN_LABEL "*.L_data_b"
558 #endif
559 #ifndef DATA_END_LABEL
560 #define DATA_END_LABEL "*.L_data_e"
561 #endif
562
563 #ifndef DATA1_BEGIN_LABEL
564 #define DATA1_BEGIN_LABEL "*.L_data1_b"
565 #endif
566 #ifndef DATA1_END_LABEL
567 #define DATA1_END_LABEL "*.L_data1_e"
568 #endif
569
570 #ifndef RODATA_BEGIN_LABEL
571 #define RODATA_BEGIN_LABEL "*.L_rodata_b"
572 #endif
573 #ifndef RODATA_END_LABEL
574 #define RODATA_END_LABEL "*.L_rodata_e"
575 #endif
576
577 #ifndef RODATA1_BEGIN_LABEL
578 #define RODATA1_BEGIN_LABEL "*.L_rodata1_b"
579 #endif
580 #ifndef RODATA1_END_LABEL
581 #define RODATA1_END_LABEL "*.L_rodata1_e"
582 #endif
583
584 #ifndef BSS_BEGIN_LABEL
585 #define BSS_BEGIN_LABEL "*.L_bss_b"
586 #endif
587 #ifndef BSS_END_LABEL
588 #define BSS_END_LABEL "*.L_bss_e"
589 #endif
590
591 #ifndef LINE_BEGIN_LABEL
592 #define LINE_BEGIN_LABEL "*.L_line_b"
593 #endif
594 #ifndef LINE_LAST_ENTRY_LABEL
595 #define LINE_LAST_ENTRY_LABEL "*.L_line_last"
596 #endif
597 #ifndef LINE_END_LABEL
598 #define LINE_END_LABEL "*.L_line_e"
599 #endif
600
601 #ifndef DEBUG_BEGIN_LABEL
602 #define DEBUG_BEGIN_LABEL "*.L_debug_b"
603 #endif
604 #ifndef SFNAMES_BEGIN_LABEL
605 #define SFNAMES_BEGIN_LABEL "*.L_sfnames_b"
606 #endif
607 #ifndef SRCINFO_BEGIN_LABEL
608 #define SRCINFO_BEGIN_LABEL "*.L_srcinfo_b"
609 #endif
610 #ifndef MACINFO_BEGIN_LABEL
611 #define MACINFO_BEGIN_LABEL "*.L_macinfo_b"
612 #endif
613
614 #ifndef DIE_BEGIN_LABEL_FMT
615 #define DIE_BEGIN_LABEL_FMT "*.L_D%u"
616 #endif
617 #ifndef DIE_END_LABEL_FMT
618 #define DIE_END_LABEL_FMT "*.L_D%u_e"
619 #endif
620 #ifndef PUB_DIE_LABEL_FMT
621 #define PUB_DIE_LABEL_FMT "*.L_P%u"
622 #endif
623 #ifndef INSN_LABEL_FMT
624 #define INSN_LABEL_FMT "*.L_I%u_%u"
625 #endif
626 #ifndef BLOCK_BEGIN_LABEL_FMT
627 #define BLOCK_BEGIN_LABEL_FMT "*.L_B%u"
628 #endif
629 #ifndef BLOCK_END_LABEL_FMT
630 #define BLOCK_END_LABEL_FMT "*.L_B%u_e"
631 #endif
632 #ifndef SS_BEGIN_LABEL_FMT
633 #define SS_BEGIN_LABEL_FMT "*.L_s%u"
634 #endif
635 #ifndef SS_END_LABEL_FMT
636 #define SS_END_LABEL_FMT "*.L_s%u_e"
637 #endif
638 #ifndef EE_BEGIN_LABEL_FMT
639 #define EE_BEGIN_LABEL_FMT "*.L_e%u"
640 #endif
641 #ifndef EE_END_LABEL_FMT
642 #define EE_END_LABEL_FMT "*.L_e%u_e"
643 #endif
644 #ifndef MT_BEGIN_LABEL_FMT
645 #define MT_BEGIN_LABEL_FMT "*.L_t%u"
646 #endif
647 #ifndef MT_END_LABEL_FMT
648 #define MT_END_LABEL_FMT "*.L_t%u_e"
649 #endif
650 #ifndef LOC_BEGIN_LABEL_FMT
651 #define LOC_BEGIN_LABEL_FMT "*.L_l%u"
652 #endif
653 #ifndef LOC_END_LABEL_FMT
654 #define LOC_END_LABEL_FMT "*.L_l%u_e"
655 #endif
656 #ifndef BOUND_BEGIN_LABEL_FMT
657 #define BOUND_BEGIN_LABEL_FMT "*.L_b%u_%u_%c"
658 #endif
659 #ifndef BOUND_END_LABEL_FMT
660 #define BOUND_END_LABEL_FMT "*.L_b%u_%u_%c_e"
661 #endif
662 #ifndef DERIV_BEGIN_LABEL_FMT
663 #define DERIV_BEGIN_LABEL_FMT "*.L_d%u"
664 #endif
665 #ifndef DERIV_END_LABEL_FMT
666 #define DERIV_END_LABEL_FMT "*.L_d%u_e"
667 #endif
668 #ifndef SL_BEGIN_LABEL_FMT
669 #define SL_BEGIN_LABEL_FMT "*.L_sl%u"
670 #endif
671 #ifndef SL_END_LABEL_FMT
672 #define SL_END_LABEL_FMT "*.L_sl%u_e"
673 #endif
674 #ifndef BODY_BEGIN_LABEL_FMT
675 #define BODY_BEGIN_LABEL_FMT "*.L_b%u"
676 #endif
677 #ifndef BODY_END_LABEL_FMT
678 #define BODY_END_LABEL_FMT "*.L_b%u_e"
679 #endif
680 #ifndef FUNC_END_LABEL_FMT
681 #define FUNC_END_LABEL_FMT "*.L_f%u_e"
682 #endif
683 #ifndef TYPE_NAME_FMT
684 #define TYPE_NAME_FMT "*.L_T%u"
685 #endif
686 #ifndef DECL_NAME_FMT
687 #define DECL_NAME_FMT "*.L_E%u"
688 #endif
689 #ifndef LINE_CODE_LABEL_FMT
690 #define LINE_CODE_LABEL_FMT "*.L_LC%u"
691 #endif
692 #ifndef SFNAMES_ENTRY_LABEL_FMT
693 #define SFNAMES_ENTRY_LABEL_FMT "*.L_F%u"
694 #endif
695 #ifndef LINE_ENTRY_LABEL_FMT
696 #define LINE_ENTRY_LABEL_FMT "*.L_LE%u"
697 #endif
698 \f
699 /* Definitions of defaults for various types of primitive assembly language
700 output operations.
701
702 If necessary, these may be overridden from within your tm.h file,
703 but typically, you shouldn't need to override these. */
704
705 #ifndef ASM_OUTPUT_PUSH_SECTION
706 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
707 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
708 #endif
709
710 #ifndef ASM_OUTPUT_POP_SECTION
711 #define ASM_OUTPUT_POP_SECTION(FILE) \
712 fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
713 #endif
714
715 #ifndef ASM_OUTPUT_DWARF_DELTA2
716 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
717 do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \
718 assemble_name (FILE, LABEL1); \
719 fprintf (FILE, "-"); \
720 assemble_name (FILE, LABEL2); \
721 fprintf (FILE, "\n"); \
722 } while (0)
723 #endif
724
725 #ifndef ASM_OUTPUT_DWARF_DELTA4
726 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
727 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
728 assemble_name (FILE, LABEL1); \
729 fprintf (FILE, "-"); \
730 assemble_name (FILE, LABEL2); \
731 fprintf (FILE, "\n"); \
732 } while (0)
733 #endif
734
735 #ifndef ASM_OUTPUT_DWARF_TAG
736 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
737 do { \
738 fprintf ((FILE), "\t%s\t0x%x", \
739 UNALIGNED_SHORT_ASM_OP, (unsigned) TAG); \
740 if (flag_debug_asm) \
741 fprintf ((FILE), "\t%s %s", \
742 ASM_COMMENT_START, dwarf_tag_name (TAG)); \
743 fputc ('\n', (FILE)); \
744 } while (0)
745 #endif
746
747 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
748 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
749 do { \
750 fprintf ((FILE), "\t%s\t0x%x", \
751 UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR); \
752 if (flag_debug_asm) \
753 fprintf ((FILE), "\t%s %s", \
754 ASM_COMMENT_START, dwarf_attr_name (ATTR)); \
755 fputc ('\n', (FILE)); \
756 } while (0)
757 #endif
758
759 #ifndef ASM_OUTPUT_DWARF_STACK_OP
760 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
761 do { \
762 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP); \
763 if (flag_debug_asm) \
764 fprintf ((FILE), "\t%s %s", \
765 ASM_COMMENT_START, dwarf_stack_op_name (OP)); \
766 fputc ('\n', (FILE)); \
767 } while (0)
768 #endif
769
770 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
771 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
772 do { \
773 fprintf ((FILE), "\t%s\t0x%x", \
774 UNALIGNED_SHORT_ASM_OP, (unsigned) FT); \
775 if (flag_debug_asm) \
776 fprintf ((FILE), "\t%s %s", \
777 ASM_COMMENT_START, dwarf_fund_type_name (FT)); \
778 fputc ('\n', (FILE)); \
779 } while (0)
780 #endif
781
782 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
783 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
784 do { \
785 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT); \
786 if (flag_debug_asm) \
787 fprintf ((FILE), "\t%s %s", \
788 ASM_COMMENT_START, dwarf_fmt_byte_name (FMT)); \
789 fputc ('\n', (FILE)); \
790 } while (0)
791 #endif
792
793 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
794 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
795 do { \
796 fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD); \
797 if (flag_debug_asm) \
798 fprintf ((FILE), "\t%s %s", \
799 ASM_COMMENT_START, dwarf_typemod_name (MOD)); \
800 fputc ('\n', (FILE)); \
801 } while (0)
802 #endif
803 \f
804 #ifndef ASM_OUTPUT_DWARF_ADDR
805 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
806 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
807 assemble_name (FILE, LABEL); \
808 fprintf (FILE, "\n"); \
809 } while (0)
810 #endif
811
812 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
813 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
814 do { \
815 fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
816 output_addr_const ((FILE), (RTX)); \
817 fputc ('\n', (FILE)); \
818 } while (0)
819 #endif
820
821 #ifndef ASM_OUTPUT_DWARF_REF
822 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
823 do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \
824 assemble_name (FILE, LABEL); \
825 fprintf (FILE, "\n"); \
826 } while (0)
827 #endif
828
829 #ifndef ASM_OUTPUT_DWARF_DATA1
830 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
831 fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
832 #endif
833
834 #ifndef ASM_OUTPUT_DWARF_DATA2
835 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
836 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
837 #endif
838
839 #ifndef ASM_OUTPUT_DWARF_DATA4
840 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
841 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
842 #endif
843
844 #ifndef ASM_OUTPUT_DWARF_DATA8
845 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
846 do { \
847 if (WORDS_BIG_ENDIAN) \
848 { \
849 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
850 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
851 } \
852 else \
853 { \
854 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
855 fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
856 } \
857 } while (0)
858 #endif
859
860 /* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
861 NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
862 based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
863 defined, we call it, then issue the line feed. If not, we supply a
864 default defintion of calling ASM_OUTPUT_ASCII */
865
866 #ifndef ASM_OUTPUT_DWARF_STRING
867 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
868 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
869 #else
870 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
871 ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n")
872 #endif
873
874 \f
875 /************************ general utility functions **************************/
876
877 inline static int
878 is_pseudo_reg (rtl)
879 register rtx rtl;
880 {
881 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
882 || ((GET_CODE (rtl) == SUBREG)
883 && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
884 }
885
886 inline static tree
887 type_main_variant (type)
888 register tree type;
889 {
890 type = TYPE_MAIN_VARIANT (type);
891
892 /* There really should be only one main variant among any group of variants
893 of a given type (and all of the MAIN_VARIANT values for all members of
894 the group should point to that one type) but sometimes the C front-end
895 messes this up for array types, so we work around that bug here. */
896
897 if (TREE_CODE (type) == ARRAY_TYPE)
898 {
899 while (type != TYPE_MAIN_VARIANT (type))
900 type = TYPE_MAIN_VARIANT (type);
901 }
902
903 return type;
904 }
905
906 /* Return non-zero if the given type node represents a tagged type. */
907
908 inline static int
909 is_tagged_type (type)
910 register tree type;
911 {
912 register enum tree_code code = TREE_CODE (type);
913
914 return (code == RECORD_TYPE || code == UNION_TYPE
915 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
916 }
917
918 static char *
919 dwarf_tag_name (tag)
920 register unsigned tag;
921 {
922 switch (tag)
923 {
924 case TAG_padding: return "TAG_padding";
925 case TAG_array_type: return "TAG_array_type";
926 case TAG_class_type: return "TAG_class_type";
927 case TAG_entry_point: return "TAG_entry_point";
928 case TAG_enumeration_type: return "TAG_enumeration_type";
929 case TAG_formal_parameter: return "TAG_formal_parameter";
930 case TAG_global_subroutine: return "TAG_global_subroutine";
931 case TAG_global_variable: return "TAG_global_variable";
932 case TAG_label: return "TAG_label";
933 case TAG_lexical_block: return "TAG_lexical_block";
934 case TAG_local_variable: return "TAG_local_variable";
935 case TAG_member: return "TAG_member";
936 case TAG_pointer_type: return "TAG_pointer_type";
937 case TAG_reference_type: return "TAG_reference_type";
938 case TAG_compile_unit: return "TAG_compile_unit";
939 case TAG_string_type: return "TAG_string_type";
940 case TAG_structure_type: return "TAG_structure_type";
941 case TAG_subroutine: return "TAG_subroutine";
942 case TAG_subroutine_type: return "TAG_subroutine_type";
943 case TAG_typedef: return "TAG_typedef";
944 case TAG_union_type: return "TAG_union_type";
945 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
946 case TAG_variant: return "TAG_variant";
947 case TAG_common_block: return "TAG_common_block";
948 case TAG_common_inclusion: return "TAG_common_inclusion";
949 case TAG_inheritance: return "TAG_inheritance";
950 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
951 case TAG_module: return "TAG_module";
952 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
953 case TAG_set_type: return "TAG_set_type";
954 case TAG_subrange_type: return "TAG_subrange_type";
955 case TAG_with_stmt: return "TAG_with_stmt";
956
957 /* GNU extensions. */
958
959 case TAG_format_label: return "TAG_format_label";
960 case TAG_namelist: return "TAG_namelist";
961 case TAG_function_template: return "TAG_function_template";
962 case TAG_class_template: return "TAG_class_template";
963
964 default: return "TAG_<unknown>";
965 }
966 }
967
968 static char *
969 dwarf_attr_name (attr)
970 register unsigned attr;
971 {
972 switch (attr)
973 {
974 case AT_sibling: return "AT_sibling";
975 case AT_location: return "AT_location";
976 case AT_name: return "AT_name";
977 case AT_fund_type: return "AT_fund_type";
978 case AT_mod_fund_type: return "AT_mod_fund_type";
979 case AT_user_def_type: return "AT_user_def_type";
980 case AT_mod_u_d_type: return "AT_mod_u_d_type";
981 case AT_ordering: return "AT_ordering";
982 case AT_subscr_data: return "AT_subscr_data";
983 case AT_byte_size: return "AT_byte_size";
984 case AT_bit_offset: return "AT_bit_offset";
985 case AT_bit_size: return "AT_bit_size";
986 case AT_element_list: return "AT_element_list";
987 case AT_stmt_list: return "AT_stmt_list";
988 case AT_low_pc: return "AT_low_pc";
989 case AT_high_pc: return "AT_high_pc";
990 case AT_language: return "AT_language";
991 case AT_member: return "AT_member";
992 case AT_discr: return "AT_discr";
993 case AT_discr_value: return "AT_discr_value";
994 case AT_string_length: return "AT_string_length";
995 case AT_common_reference: return "AT_common_reference";
996 case AT_comp_dir: return "AT_comp_dir";
997 case AT_const_value_string: return "AT_const_value_string";
998 case AT_const_value_data2: return "AT_const_value_data2";
999 case AT_const_value_data4: return "AT_const_value_data4";
1000 case AT_const_value_data8: return "AT_const_value_data8";
1001 case AT_const_value_block2: return "AT_const_value_block2";
1002 case AT_const_value_block4: return "AT_const_value_block4";
1003 case AT_containing_type: return "AT_containing_type";
1004 case AT_default_value_addr: return "AT_default_value_addr";
1005 case AT_default_value_data2: return "AT_default_value_data2";
1006 case AT_default_value_data4: return "AT_default_value_data4";
1007 case AT_default_value_data8: return "AT_default_value_data8";
1008 case AT_default_value_string: return "AT_default_value_string";
1009 case AT_friends: return "AT_friends";
1010 case AT_inline: return "AT_inline";
1011 case AT_is_optional: return "AT_is_optional";
1012 case AT_lower_bound_ref: return "AT_lower_bound_ref";
1013 case AT_lower_bound_data2: return "AT_lower_bound_data2";
1014 case AT_lower_bound_data4: return "AT_lower_bound_data4";
1015 case AT_lower_bound_data8: return "AT_lower_bound_data8";
1016 case AT_private: return "AT_private";
1017 case AT_producer: return "AT_producer";
1018 case AT_program: return "AT_program";
1019 case AT_protected: return "AT_protected";
1020 case AT_prototyped: return "AT_prototyped";
1021 case AT_public: return "AT_public";
1022 case AT_pure_virtual: return "AT_pure_virtual";
1023 case AT_return_addr: return "AT_return_addr";
1024 case AT_abstract_origin: return "AT_abstract_origin";
1025 case AT_start_scope: return "AT_start_scope";
1026 case AT_stride_size: return "AT_stride_size";
1027 case AT_upper_bound_ref: return "AT_upper_bound_ref";
1028 case AT_upper_bound_data2: return "AT_upper_bound_data2";
1029 case AT_upper_bound_data4: return "AT_upper_bound_data4";
1030 case AT_upper_bound_data8: return "AT_upper_bound_data8";
1031 case AT_virtual: return "AT_virtual";
1032
1033 /* GNU extensions */
1034
1035 case AT_sf_names: return "AT_sf_names";
1036 case AT_src_info: return "AT_src_info";
1037 case AT_mac_info: return "AT_mac_info";
1038 case AT_src_coords: return "AT_src_coords";
1039 case AT_body_begin: return "AT_body_begin";
1040 case AT_body_end: return "AT_body_end";
1041
1042 default: return "AT_<unknown>";
1043 }
1044 }
1045
1046 static char *
1047 dwarf_stack_op_name (op)
1048 register unsigned op;
1049 {
1050 switch (op)
1051 {
1052 case OP_REG: return "OP_REG";
1053 case OP_BASEREG: return "OP_BASEREG";
1054 case OP_ADDR: return "OP_ADDR";
1055 case OP_CONST: return "OP_CONST";
1056 case OP_DEREF2: return "OP_DEREF2";
1057 case OP_DEREF4: return "OP_DEREF4";
1058 case OP_ADD: return "OP_ADD";
1059 default: return "OP_<unknown>";
1060 }
1061 }
1062
1063 static char *
1064 dwarf_typemod_name (mod)
1065 register unsigned mod;
1066 {
1067 switch (mod)
1068 {
1069 case MOD_pointer_to: return "MOD_pointer_to";
1070 case MOD_reference_to: return "MOD_reference_to";
1071 case MOD_const: return "MOD_const";
1072 case MOD_volatile: return "MOD_volatile";
1073 default: return "MOD_<unknown>";
1074 }
1075 }
1076
1077 static char *
1078 dwarf_fmt_byte_name (fmt)
1079 register unsigned fmt;
1080 {
1081 switch (fmt)
1082 {
1083 case FMT_FT_C_C: return "FMT_FT_C_C";
1084 case FMT_FT_C_X: return "FMT_FT_C_X";
1085 case FMT_FT_X_C: return "FMT_FT_X_C";
1086 case FMT_FT_X_X: return "FMT_FT_X_X";
1087 case FMT_UT_C_C: return "FMT_UT_C_C";
1088 case FMT_UT_C_X: return "FMT_UT_C_X";
1089 case FMT_UT_X_C: return "FMT_UT_X_C";
1090 case FMT_UT_X_X: return "FMT_UT_X_X";
1091 case FMT_ET: return "FMT_ET";
1092 default: return "FMT_<unknown>";
1093 }
1094 }
1095
1096 static char *
1097 dwarf_fund_type_name (ft)
1098 register unsigned ft;
1099 {
1100 switch (ft)
1101 {
1102 case FT_char: return "FT_char";
1103 case FT_signed_char: return "FT_signed_char";
1104 case FT_unsigned_char: return "FT_unsigned_char";
1105 case FT_short: return "FT_short";
1106 case FT_signed_short: return "FT_signed_short";
1107 case FT_unsigned_short: return "FT_unsigned_short";
1108 case FT_integer: return "FT_integer";
1109 case FT_signed_integer: return "FT_signed_integer";
1110 case FT_unsigned_integer: return "FT_unsigned_integer";
1111 case FT_long: return "FT_long";
1112 case FT_signed_long: return "FT_signed_long";
1113 case FT_unsigned_long: return "FT_unsigned_long";
1114 case FT_pointer: return "FT_pointer";
1115 case FT_float: return "FT_float";
1116 case FT_dbl_prec_float: return "FT_dbl_prec_float";
1117 case FT_ext_prec_float: return "FT_ext_prec_float";
1118 case FT_complex: return "FT_complex";
1119 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
1120 case FT_void: return "FT_void";
1121 case FT_boolean: return "FT_boolean";
1122 case FT_ext_prec_complex: return "FT_ext_prec_complex";
1123 case FT_label: return "FT_label";
1124
1125 /* GNU extensions. */
1126
1127 case FT_long_long: return "FT_long_long";
1128 case FT_signed_long_long: return "FT_signed_long_long";
1129 case FT_unsigned_long_long: return "FT_unsigned_long_long";
1130
1131 case FT_int8: return "FT_int8";
1132 case FT_signed_int8: return "FT_signed_int8";
1133 case FT_unsigned_int8: return "FT_unsigned_int8";
1134 case FT_int16: return "FT_int16";
1135 case FT_signed_int16: return "FT_signed_int16";
1136 case FT_unsigned_int16: return "FT_unsigned_int16";
1137 case FT_int32: return "FT_int32";
1138 case FT_signed_int32: return "FT_signed_int32";
1139 case FT_unsigned_int32: return "FT_unsigned_int32";
1140 case FT_int64: return "FT_int64";
1141 case FT_signed_int64: return "FT_signed_int64";
1142 case FT_unsigned_int64: return "FT_unsigned_int64";
1143
1144 case FT_real32: return "FT_real32";
1145 case FT_real64: return "FT_real64";
1146 case FT_real96: return "FT_real96";
1147 case FT_real128: return "FT_real128";
1148
1149 default: return "FT_<unknown>";
1150 }
1151 }
1152
1153 /* Determine the "ultimate origin" of a decl. The decl may be an
1154 inlined instance of an inlined instance of a decl which is local
1155 to an inline function, so we have to trace all of the way back
1156 through the origin chain to find out what sort of node actually
1157 served as the original seed for the given block. */
1158
1159 static tree
1160 decl_ultimate_origin (decl)
1161 register tree decl;
1162 {
1163 #ifdef ENABLE_CHECKING
1164 if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
1165 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
1166 most distant ancestor, this should never happen. */
1167 abort ();
1168 #endif
1169
1170 return DECL_ABSTRACT_ORIGIN (decl);
1171 }
1172
1173 /* Determine the "ultimate origin" of a block. The block may be an
1174 inlined instance of an inlined instance of a block which is local
1175 to an inline function, so we have to trace all of the way back
1176 through the origin chain to find out what sort of node actually
1177 served as the original seed for the given block. */
1178
1179 static tree
1180 block_ultimate_origin (block)
1181 register tree block;
1182 {
1183 register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
1184
1185 if (immediate_origin == NULL)
1186 return NULL;
1187 else
1188 {
1189 register tree ret_val;
1190 register tree lookahead = immediate_origin;
1191
1192 do
1193 {
1194 ret_val = lookahead;
1195 lookahead = (TREE_CODE (ret_val) == BLOCK)
1196 ? BLOCK_ABSTRACT_ORIGIN (ret_val)
1197 : NULL;
1198 }
1199 while (lookahead != NULL && lookahead != ret_val);
1200 return ret_val;
1201 }
1202 }
1203
1204 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
1205 of a virtual function may refer to a base class, so we check the 'this'
1206 parameter. */
1207
1208 static tree
1209 decl_class_context (decl)
1210 tree decl;
1211 {
1212 tree context = NULL_TREE;
1213 if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
1214 context = DECL_CONTEXT (decl);
1215 else
1216 context = TYPE_MAIN_VARIANT
1217 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
1218
1219 if (context && TREE_CODE_CLASS (TREE_CODE (context)) != 't')
1220 context = NULL_TREE;
1221
1222 return context;
1223 }
1224
1225 #if 0
1226 static void
1227 output_unsigned_leb128 (value)
1228 register unsigned long value;
1229 {
1230 register unsigned long orig_value = value;
1231
1232 do
1233 {
1234 register unsigned byte = (value & 0x7f);
1235
1236 value >>= 7;
1237 if (value != 0) /* more bytes to follow */
1238 byte |= 0x80;
1239 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1240 if (flag_debug_asm && value == 0)
1241 fprintf (asm_out_file, "\t%s ULEB128 number - value = %lu",
1242 ASM_COMMENT_START, orig_value);
1243 fputc ('\n', asm_out_file);
1244 }
1245 while (value != 0);
1246 }
1247
1248 static void
1249 output_signed_leb128 (value)
1250 register long value;
1251 {
1252 register long orig_value = value;
1253 register int negative = (value < 0);
1254 register int more;
1255
1256 do
1257 {
1258 register unsigned byte = (value & 0x7f);
1259
1260 value >>= 7;
1261 if (negative)
1262 value |= 0xfe000000; /* manually sign extend */
1263 if (((value == 0) && ((byte & 0x40) == 0))
1264 || ((value == -1) && ((byte & 0x40) == 1)))
1265 more = 0;
1266 else
1267 {
1268 byte |= 0x80;
1269 more = 1;
1270 }
1271 fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
1272 if (flag_debug_asm && more == 0)
1273 fprintf (asm_out_file, "\t%s SLEB128 number - value = %ld",
1274 ASM_COMMENT_START, orig_value);
1275 fputc ('\n', asm_out_file);
1276 }
1277 while (more);
1278 }
1279 #endif
1280 \f
1281 /**************** utility functions for attribute functions ******************/
1282
1283 /* Given a pointer to a BLOCK node return non-zero if (and only if) the
1284 node in question represents the outermost pair of curly braces (i.e.
1285 the "body block") of a function or method.
1286
1287 For any BLOCK node representing a "body block" of a function or method,
1288 the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
1289 which represents the outermost (function) scope for the function or
1290 method (i.e. the one which includes the formal parameters). The
1291 BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
1292 FUNCTION_DECL node.
1293 */
1294
1295 static inline int
1296 is_body_block (stmt)
1297 register tree stmt;
1298 {
1299 if (TREE_CODE (stmt) == BLOCK)
1300 {
1301 register tree parent = BLOCK_SUPERCONTEXT (stmt);
1302
1303 if (TREE_CODE (parent) == BLOCK)
1304 {
1305 register tree grandparent = BLOCK_SUPERCONTEXT (parent);
1306
1307 if (TREE_CODE (grandparent) == FUNCTION_DECL)
1308 return 1;
1309 }
1310 }
1311 return 0;
1312 }
1313
1314 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1315 type code for the given type.
1316
1317 This routine must only be called for GCC type nodes that correspond to
1318 Dwarf fundamental types.
1319
1320 The current Dwarf draft specification calls for Dwarf fundamental types
1321 to accurately reflect the fact that a given type was either a "plain"
1322 integral type or an explicitly "signed" integral type. Unfortunately,
1323 we can't always do this, because GCC may already have thrown away the
1324 information about the precise way in which the type was originally
1325 specified, as in:
1326
1327 typedef signed int my_type;
1328
1329 struct s { my_type f; };
1330
1331 Since we may be stuck here without enought information to do exactly
1332 what is called for in the Dwarf draft specification, we do the best
1333 that we can under the circumstances and always use the "plain" integral
1334 fundamental type codes for int, short, and long types. That's probably
1335 good enough. The additional accuracy called for in the current DWARF
1336 draft specification is probably never even useful in practice. */
1337
1338 static int
1339 fundamental_type_code (type)
1340 register tree type;
1341 {
1342 if (TREE_CODE (type) == ERROR_MARK)
1343 return 0;
1344
1345 switch (TREE_CODE (type))
1346 {
1347 case ERROR_MARK:
1348 return FT_void;
1349
1350 case VOID_TYPE:
1351 return FT_void;
1352
1353 case INTEGER_TYPE:
1354 /* Carefully distinguish all the standard types of C,
1355 without messing up if the language is not C.
1356 Note that we check only for the names that contain spaces;
1357 other names might occur by coincidence in other languages. */
1358 if (TYPE_NAME (type) != 0
1359 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1360 && DECL_NAME (TYPE_NAME (type)) != 0
1361 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1362 {
1363 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1364
1365 if (!strcmp (name, "unsigned char"))
1366 return FT_unsigned_char;
1367 if (!strcmp (name, "signed char"))
1368 return FT_signed_char;
1369 if (!strcmp (name, "unsigned int"))
1370 return FT_unsigned_integer;
1371 if (!strcmp (name, "short int"))
1372 return FT_short;
1373 if (!strcmp (name, "short unsigned int"))
1374 return FT_unsigned_short;
1375 if (!strcmp (name, "long int"))
1376 return FT_long;
1377 if (!strcmp (name, "long unsigned int"))
1378 return FT_unsigned_long;
1379 if (!strcmp (name, "long long int"))
1380 return FT_long_long; /* Not grok'ed by svr4 SDB */
1381 if (!strcmp (name, "long long unsigned int"))
1382 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1383 }
1384
1385 /* Most integer types will be sorted out above, however, for the
1386 sake of special `array index' integer types, the following code
1387 is also provided. */
1388
1389 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1390 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1391
1392 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1393 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1394
1395 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1396 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1397
1398 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1399 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1400
1401 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1402 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1403
1404 abort ();
1405
1406 case REAL_TYPE:
1407 /* Carefully distinguish all the standard types of C,
1408 without messing up if the language is not C. */
1409 if (TYPE_NAME (type) != 0
1410 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1411 && DECL_NAME (TYPE_NAME (type)) != 0
1412 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1413 {
1414 char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1415
1416 /* Note that here we can run afowl of a serious bug in "classic"
1417 svr4 SDB debuggers. They don't seem to understand the
1418 FT_ext_prec_float type (even though they should). */
1419
1420 if (!strcmp (name, "long double"))
1421 return FT_ext_prec_float;
1422 }
1423
1424 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1425 {
1426 /* On the SH, when compiling with -m3e or -m4-single-only, both
1427 float and double are 32 bits. But since the debugger doesn't
1428 know about the subtarget, it always thinks double is 64 bits.
1429 So we have to tell the debugger that the type is float to
1430 make the output of the 'print' command etc. readable. */
1431 if (DOUBLE_TYPE_SIZE == FLOAT_TYPE_SIZE && FLOAT_TYPE_SIZE == 32)
1432 return FT_float;
1433 return FT_dbl_prec_float;
1434 }
1435 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1436 return FT_float;
1437
1438 /* Note that here we can run afowl of a serious bug in "classic"
1439 svr4 SDB debuggers. They don't seem to understand the
1440 FT_ext_prec_float type (even though they should). */
1441
1442 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1443 return FT_ext_prec_float;
1444 abort ();
1445
1446 case COMPLEX_TYPE:
1447 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1448
1449 case CHAR_TYPE:
1450 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1451
1452 case BOOLEAN_TYPE:
1453 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1454
1455 default:
1456 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1457 }
1458 return 0;
1459 }
1460 \f
1461 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1462 the Dwarf "root" type for the given input type. The Dwarf "root" type
1463 of a given type is generally the same as the given type, except that if
1464 the given type is a pointer or reference type, then the root type of
1465 the given type is the root type of the "basis" type for the pointer or
1466 reference type. (This definition of the "root" type is recursive.)
1467 Also, the root type of a `const' qualified type or a `volatile'
1468 qualified type is the root type of the given type without the
1469 qualifiers. */
1470
1471 static tree
1472 root_type_1 (type, count)
1473 register tree type;
1474 register int count;
1475 {
1476 /* Give up after searching 1000 levels, in case this is a recursive
1477 pointer type. Such types are possible in Ada, but it is not possible
1478 to represent them in DWARF1 debug info. */
1479 if (count > 1000)
1480 return error_mark_node;
1481
1482 switch (TREE_CODE (type))
1483 {
1484 case ERROR_MARK:
1485 return error_mark_node;
1486
1487 case POINTER_TYPE:
1488 case REFERENCE_TYPE:
1489 return root_type_1 (TREE_TYPE (type), count+1);
1490
1491 default:
1492 return type;
1493 }
1494 }
1495
1496 static tree
1497 root_type (type)
1498 register tree type;
1499 {
1500 type = root_type_1 (type, 0);
1501 if (type != error_mark_node)
1502 type = type_main_variant (type);
1503 return type;
1504 }
1505
1506 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1507 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1508
1509 static void
1510 write_modifier_bytes_1 (type, decl_const, decl_volatile, count)
1511 register tree type;
1512 register int decl_const;
1513 register int decl_volatile;
1514 register int count;
1515 {
1516 if (TREE_CODE (type) == ERROR_MARK)
1517 return;
1518
1519 /* Give up after searching 1000 levels, in case this is a recursive
1520 pointer type. Such types are possible in Ada, but it is not possible
1521 to represent them in DWARF1 debug info. */
1522 if (count > 1000)
1523 return;
1524
1525 if (TYPE_READONLY (type) || decl_const)
1526 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1527 if (TYPE_VOLATILE (type) || decl_volatile)
1528 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1529 switch (TREE_CODE (type))
1530 {
1531 case POINTER_TYPE:
1532 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1533 write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
1534 return;
1535
1536 case REFERENCE_TYPE:
1537 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1538 write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
1539 return;
1540
1541 case ERROR_MARK:
1542 default:
1543 return;
1544 }
1545 }
1546
1547 static void
1548 write_modifier_bytes (type, decl_const, decl_volatile)
1549 register tree type;
1550 register int decl_const;
1551 register int decl_volatile;
1552 {
1553 write_modifier_bytes_1 (type, decl_const, decl_volatile, 0);
1554 }
1555 \f
1556 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1557 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1558
1559 static inline int
1560 type_is_fundamental (type)
1561 register tree type;
1562 {
1563 switch (TREE_CODE (type))
1564 {
1565 case ERROR_MARK:
1566 case VOID_TYPE:
1567 case INTEGER_TYPE:
1568 case REAL_TYPE:
1569 case COMPLEX_TYPE:
1570 case BOOLEAN_TYPE:
1571 case CHAR_TYPE:
1572 return 1;
1573
1574 case SET_TYPE:
1575 case ARRAY_TYPE:
1576 case RECORD_TYPE:
1577 case UNION_TYPE:
1578 case QUAL_UNION_TYPE:
1579 case ENUMERAL_TYPE:
1580 case FUNCTION_TYPE:
1581 case METHOD_TYPE:
1582 case POINTER_TYPE:
1583 case REFERENCE_TYPE:
1584 case FILE_TYPE:
1585 case OFFSET_TYPE:
1586 case LANG_TYPE:
1587 return 0;
1588
1589 default:
1590 abort ();
1591 }
1592 return 0;
1593 }
1594
1595 /* Given a pointer to some ..._DECL tree node, generate an assembly language
1596 equate directive which will associate a symbolic name with the current DIE.
1597
1598 The name used is an artificial label generated from the DECL_UID number
1599 associated with the given decl node. The name it gets equated to is the
1600 symbolic label that we (previously) output at the start of the DIE that
1601 we are currently generating.
1602
1603 Calling this function while generating some "decl related" form of DIE
1604 makes it possible to later refer to the DIE which represents the given
1605 decl simply by re-generating the symbolic name from the ..._DECL node's
1606 UID number. */
1607
1608 static void
1609 equate_decl_number_to_die_number (decl)
1610 register tree decl;
1611 {
1612 /* In the case where we are generating a DIE for some ..._DECL node
1613 which represents either some inline function declaration or some
1614 entity declared within an inline function declaration/definition,
1615 setup a symbolic name for the current DIE so that we have a name
1616 for this DIE that we can easily refer to later on within
1617 AT_abstract_origin attributes. */
1618
1619 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
1620 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1621
1622 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
1623 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1624 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
1625 }
1626
1627 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
1628 equate directive which will associate a symbolic name with the current DIE.
1629
1630 The name used is an artificial label generated from the TYPE_UID number
1631 associated with the given type node. The name it gets equated to is the
1632 symbolic label that we (previously) output at the start of the DIE that
1633 we are currently generating.
1634
1635 Calling this function while generating some "type related" form of DIE
1636 makes it easy to later refer to the DIE which represents the given type
1637 simply by re-generating the alternative name from the ..._TYPE node's
1638 UID number. */
1639
1640 static inline void
1641 equate_type_number_to_die_number (type)
1642 register tree type;
1643 {
1644 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
1645 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
1646
1647 /* We are generating a DIE to represent the main variant of this type
1648 (i.e the type without any const or volatile qualifiers) so in order
1649 to get the equate to come out right, we need to get the main variant
1650 itself here. */
1651
1652 type = type_main_variant (type);
1653
1654 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
1655 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
1656 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
1657 }
1658
1659 static void
1660 output_reg_number (rtl)
1661 register rtx rtl;
1662 {
1663 register unsigned regno = REGNO (rtl);
1664
1665 if (regno >= FIRST_PSEUDO_REGISTER)
1666 {
1667 warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
1668 regno);
1669 regno = 0;
1670 }
1671 fprintf (asm_out_file, "\t%s\t0x%x",
1672 UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
1673 if (flag_debug_asm)
1674 {
1675 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
1676 PRINT_REG (rtl, 0, asm_out_file);
1677 }
1678 fputc ('\n', asm_out_file);
1679 }
1680
1681 /* The following routine is a nice and simple transducer. It converts the
1682 RTL for a variable or parameter (resident in memory) into an equivalent
1683 Dwarf representation of a mechanism for getting the address of that same
1684 variable onto the top of a hypothetical "address evaluation" stack.
1685
1686 When creating memory location descriptors, we are effectively trans-
1687 forming the RTL for a memory-resident object into its Dwarf postfix
1688 expression equivalent. This routine just recursively descends an
1689 RTL tree, turning it into Dwarf postfix code as it goes. */
1690
1691 static void
1692 output_mem_loc_descriptor (rtl)
1693 register rtx rtl;
1694 {
1695 /* Note that for a dynamically sized array, the location we will
1696 generate a description of here will be the lowest numbered location
1697 which is actually within the array. That's *not* necessarily the
1698 same as the zeroth element of the array. */
1699
1700 switch (GET_CODE (rtl))
1701 {
1702 case SUBREG:
1703
1704 /* The case of a subreg may arise when we have a local (register)
1705 variable or a formal (register) parameter which doesn't quite
1706 fill up an entire register. For now, just assume that it is
1707 legitimate to make the Dwarf info refer to the whole register
1708 which contains the given subreg. */
1709
1710 rtl = XEXP (rtl, 0);
1711 /* Drop thru. */
1712
1713 case REG:
1714
1715 /* Whenever a register number forms a part of the description of
1716 the method for calculating the (dynamic) address of a memory
1717 resident object, DWARF rules require the register number to
1718 be referred to as a "base register". This distinction is not
1719 based in any way upon what category of register the hardware
1720 believes the given register belongs to. This is strictly
1721 DWARF terminology we're dealing with here.
1722
1723 Note that in cases where the location of a memory-resident data
1724 object could be expressed as:
1725
1726 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
1727
1728 the actual DWARF location descriptor that we generate may just
1729 be OP_BASEREG (basereg). This may look deceptively like the
1730 object in question was allocated to a register (rather than
1731 in memory) so DWARF consumers need to be aware of the subtle
1732 distinction between OP_REG and OP_BASEREG. */
1733
1734 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
1735 output_reg_number (rtl);
1736 break;
1737
1738 case MEM:
1739 output_mem_loc_descriptor (XEXP (rtl, 0));
1740 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
1741 break;
1742
1743 case CONST:
1744 case SYMBOL_REF:
1745 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
1746 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
1747 break;
1748
1749 case PLUS:
1750 output_mem_loc_descriptor (XEXP (rtl, 0));
1751 output_mem_loc_descriptor (XEXP (rtl, 1));
1752 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
1753 break;
1754
1755 case CONST_INT:
1756 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
1757 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
1758 break;
1759
1760 case MULT:
1761 /* If a pseudo-reg is optimized away, it is possible for it to
1762 be replaced with a MEM containing a multiply. Use a GNU extension
1763 to describe it. */
1764 output_mem_loc_descriptor (XEXP (rtl, 0));
1765 output_mem_loc_descriptor (XEXP (rtl, 1));
1766 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_MULT);
1767 break;
1768
1769 default:
1770 abort ();
1771 }
1772 }
1773
1774 /* Output a proper Dwarf location descriptor for a variable or parameter
1775 which is either allocated in a register or in a memory location. For
1776 a register, we just generate an OP_REG and the register number. For a
1777 memory location we provide a Dwarf postfix expression describing how to
1778 generate the (dynamic) address of the object onto the address stack. */
1779
1780 static void
1781 output_loc_descriptor (rtl)
1782 register rtx rtl;
1783 {
1784 switch (GET_CODE (rtl))
1785 {
1786 case SUBREG:
1787
1788 /* The case of a subreg may arise when we have a local (register)
1789 variable or a formal (register) parameter which doesn't quite
1790 fill up an entire register. For now, just assume that it is
1791 legitimate to make the Dwarf info refer to the whole register
1792 which contains the given subreg. */
1793
1794 rtl = XEXP (rtl, 0);
1795 /* Drop thru. */
1796
1797 case REG:
1798 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
1799 output_reg_number (rtl);
1800 break;
1801
1802 case MEM:
1803 output_mem_loc_descriptor (XEXP (rtl, 0));
1804 break;
1805
1806 default:
1807 abort (); /* Should never happen */
1808 }
1809 }
1810
1811 /* Given a tree node describing an array bound (either lower or upper)
1812 output a representation for that bound. */
1813
1814 static void
1815 output_bound_representation (bound, dim_num, u_or_l)
1816 register tree bound;
1817 register unsigned dim_num; /* For multi-dimensional arrays. */
1818 register char u_or_l; /* Designates upper or lower bound. */
1819 {
1820 switch (TREE_CODE (bound))
1821 {
1822
1823 case ERROR_MARK:
1824 return;
1825
1826 /* All fixed-bounds are represented by INTEGER_CST nodes. */
1827
1828 case INTEGER_CST:
1829 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1830 (unsigned) TREE_INT_CST_LOW (bound));
1831 break;
1832
1833 default:
1834
1835 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
1836 SAVE_EXPR nodes, in which case we can do something, or as
1837 an expression, which we cannot represent. */
1838 {
1839 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
1840 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
1841
1842 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
1843 current_dienum, dim_num, u_or_l);
1844
1845 sprintf (end_label, BOUND_END_LABEL_FMT,
1846 current_dienum, dim_num, u_or_l);
1847
1848 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
1849 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
1850
1851 /* If optimization is turned on, the SAVE_EXPRs that describe
1852 how to access the upper bound values are essentially bogus.
1853 They only describe (at best) how to get at these values at
1854 the points in the generated code right after they have just
1855 been computed. Worse yet, in the typical case, the upper
1856 bound values will not even *be* computed in the optimized
1857 code, so these SAVE_EXPRs are entirely bogus.
1858
1859 In order to compensate for this fact, we check here to see
1860 if optimization is enabled, and if so, we effectively create
1861 an empty location description for the (unknown and unknowable)
1862 upper bound.
1863
1864 This should not cause too much trouble for existing (stupid?)
1865 debuggers because they have to deal with empty upper bounds
1866 location descriptions anyway in order to be able to deal with
1867 incomplete array types.
1868
1869 Of course an intelligent debugger (GDB?) should be able to
1870 comprehend that a missing upper bound specification in a
1871 array type used for a storage class `auto' local array variable
1872 indicates that the upper bound is both unknown (at compile-
1873 time) and unknowable (at run-time) due to optimization. */
1874
1875 if (! optimize)
1876 {
1877 while (TREE_CODE (bound) == NOP_EXPR
1878 || TREE_CODE (bound) == CONVERT_EXPR)
1879 bound = TREE_OPERAND (bound, 0);
1880
1881 if (TREE_CODE (bound) == SAVE_EXPR)
1882 output_loc_descriptor
1883 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
1884 }
1885
1886 ASM_OUTPUT_LABEL (asm_out_file, end_label);
1887 }
1888 break;
1889
1890 }
1891 }
1892
1893 /* Recursive function to output a sequence of value/name pairs for
1894 enumeration constants in reversed order. This is called from
1895 enumeration_type_die. */
1896
1897 static void
1898 output_enumeral_list (link)
1899 register tree link;
1900 {
1901 if (link)
1902 {
1903 output_enumeral_list (TREE_CHAIN (link));
1904 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
1905 (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
1906 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
1907 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
1908 }
1909 }
1910
1911 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
1912 which is not less than the value itself. */
1913
1914 static inline unsigned
1915 ceiling (value, boundary)
1916 register unsigned value;
1917 register unsigned boundary;
1918 {
1919 return (((value + boundary - 1) / boundary) * boundary);
1920 }
1921
1922 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
1923 pointer to the declared type for the relevant field variable, or return
1924 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
1925
1926 static inline tree
1927 field_type (decl)
1928 register tree decl;
1929 {
1930 register tree type;
1931
1932 if (TREE_CODE (decl) == ERROR_MARK)
1933 return integer_type_node;
1934
1935 type = DECL_BIT_FIELD_TYPE (decl);
1936 if (type == NULL)
1937 type = TREE_TYPE (decl);
1938 return type;
1939 }
1940
1941 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1942 node, return the alignment in bits for the type, or else return
1943 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
1944
1945 static inline unsigned
1946 simple_type_align_in_bits (type)
1947 register tree type;
1948 {
1949 return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
1950 }
1951
1952 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
1953 node, return the size in bits for the type if it is a constant, or
1954 else return the alignment for the type if the type's size is not
1955 constant, or else return BITS_PER_WORD if the type actually turns out
1956 to be an ERROR_MARK node. */
1957
1958 static inline unsigned
1959 simple_type_size_in_bits (type)
1960 register tree type;
1961 {
1962 if (TREE_CODE (type) == ERROR_MARK)
1963 return BITS_PER_WORD;
1964 else
1965 {
1966 register tree type_size_tree = TYPE_SIZE (type);
1967
1968 if (TREE_CODE (type_size_tree) != INTEGER_CST)
1969 return TYPE_ALIGN (type);
1970
1971 return (unsigned) TREE_INT_CST_LOW (type_size_tree);
1972 }
1973 }
1974
1975 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
1976 return the byte offset of the lowest addressed byte of the "containing
1977 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
1978 mine what that offset is, either because the argument turns out to be a
1979 pointer to an ERROR_MARK node, or because the offset is actually variable.
1980 (We can't handle the latter case just yet.) */
1981
1982 static unsigned
1983 field_byte_offset (decl)
1984 register tree decl;
1985 {
1986 register unsigned type_align_in_bytes;
1987 register unsigned type_align_in_bits;
1988 register unsigned type_size_in_bits;
1989 register unsigned object_offset_in_align_units;
1990 register unsigned object_offset_in_bits;
1991 register unsigned object_offset_in_bytes;
1992 register tree type;
1993 register tree bitpos_tree;
1994 register tree field_size_tree;
1995 register unsigned bitpos_int;
1996 register unsigned deepest_bitpos;
1997 register unsigned field_size_in_bits;
1998
1999 if (TREE_CODE (decl) == ERROR_MARK)
2000 return 0;
2001
2002 if (TREE_CODE (decl) != FIELD_DECL)
2003 abort ();
2004
2005 type = field_type (decl);
2006
2007 bitpos_tree = DECL_FIELD_BITPOS (decl);
2008 field_size_tree = DECL_SIZE (decl);
2009
2010 /* We cannot yet cope with fields whose positions or sizes are variable,
2011 so for now, when we see such things, we simply return 0. Someday,
2012 we may be able to handle such cases, but it will be damn difficult. */
2013
2014 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2015 return 0;
2016 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2017
2018 if (TREE_CODE (field_size_tree) != INTEGER_CST)
2019 return 0;
2020 field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
2021
2022 type_size_in_bits = simple_type_size_in_bits (type);
2023
2024 type_align_in_bits = simple_type_align_in_bits (type);
2025 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
2026
2027 /* Note that the GCC front-end doesn't make any attempt to keep track
2028 of the starting bit offset (relative to the start of the containing
2029 structure type) of the hypothetical "containing object" for a bit-
2030 field. Thus, when computing the byte offset value for the start of
2031 the "containing object" of a bit-field, we must deduce this infor-
2032 mation on our own.
2033
2034 This can be rather tricky to do in some cases. For example, handling
2035 the following structure type definition when compiling for an i386/i486
2036 target (which only aligns long long's to 32-bit boundaries) can be very
2037 tricky:
2038
2039 struct S {
2040 int field1;
2041 long long field2:31;
2042 };
2043
2044 Fortunately, there is a simple rule-of-thumb which can be used in such
2045 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
2046 the structure shown above. It decides to do this based upon one simple
2047 rule for bit-field allocation. Quite simply, GCC allocates each "con-
2048 taining object" for each bit-field at the first (i.e. lowest addressed)
2049 legitimate alignment boundary (based upon the required minimum alignment
2050 for the declared type of the field) which it can possibly use, subject
2051 to the condition that there is still enough available space remaining
2052 in the containing object (when allocated at the selected point) to
2053 fully accommodate all of the bits of the bit-field itself.
2054
2055 This simple rule makes it obvious why GCC allocates 8 bytes for each
2056 object of the structure type shown above. When looking for a place to
2057 allocate the "containing object" for `field2', the compiler simply tries
2058 to allocate a 64-bit "containing object" at each successive 32-bit
2059 boundary (starting at zero) until it finds a place to allocate that 64-
2060 bit field such that at least 31 contiguous (and previously unallocated)
2061 bits remain within that selected 64 bit field. (As it turns out, for
2062 the example above, the compiler finds that it is OK to allocate the
2063 "containing object" 64-bit field at bit-offset zero within the
2064 structure type.)
2065
2066 Here we attempt to work backwards from the limited set of facts we're
2067 given, and we try to deduce from those facts, where GCC must have
2068 believed that the containing object started (within the structure type).
2069
2070 The value we deduce is then used (by the callers of this routine) to
2071 generate AT_location and AT_bit_offset attributes for fields (both
2072 bit-fields and, in the case of AT_location, regular fields as well).
2073 */
2074
2075 /* Figure out the bit-distance from the start of the structure to the
2076 "deepest" bit of the bit-field. */
2077 deepest_bitpos = bitpos_int + field_size_in_bits;
2078
2079 /* This is the tricky part. Use some fancy footwork to deduce where the
2080 lowest addressed bit of the containing object must be. */
2081 object_offset_in_bits
2082 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
2083
2084 /* Compute the offset of the containing object in "alignment units". */
2085 object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
2086
2087 /* Compute the offset of the containing object in bytes. */
2088 object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
2089
2090 /* The above code assumes that the field does not cross an alignment
2091 boundary. This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
2092 or if the structure is packed. If this happens, then we get an object
2093 which starts after the bitfield, which means that the bit offset is
2094 negative. Gdb fails when given negative bit offsets. We avoid this
2095 by recomputing using the first bit of the bitfield. This will give
2096 us an object which does not completely contain the bitfield, but it
2097 will be aligned, and it will contain the first bit of the bitfield. */
2098 if (object_offset_in_bits > bitpos_int)
2099 {
2100 deepest_bitpos = bitpos_int + 1;
2101 object_offset_in_bits
2102 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
2103 object_offset_in_align_units = (object_offset_in_bits
2104 / type_align_in_bits);
2105 object_offset_in_bytes = (object_offset_in_align_units
2106 * type_align_in_bytes);
2107 }
2108
2109 return object_offset_in_bytes;
2110 }
2111
2112 /****************************** attributes *********************************/
2113
2114 /* The following routines are responsible for writing out the various types
2115 of Dwarf attributes (and any following data bytes associated with them).
2116 These routines are listed in order based on the numerical codes of their
2117 associated attributes. */
2118
2119 /* Generate an AT_sibling attribute. */
2120
2121 static inline void
2122 sibling_attribute ()
2123 {
2124 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2125
2126 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
2127 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
2128 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2129 }
2130
2131 /* Output the form of location attributes suitable for whole variables and
2132 whole parameters. Note that the location attributes for struct fields
2133 are generated by the routine `data_member_location_attribute' below. */
2134
2135 static void
2136 location_attribute (rtl)
2137 register rtx rtl;
2138 {
2139 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2140 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2141
2142 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2143 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2144 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2145 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2146 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2147
2148 /* Handle a special case. If we are about to output a location descriptor
2149 for a variable or parameter which has been optimized out of existence,
2150 don't do that. Instead we output a zero-length location descriptor
2151 value as part of the location attribute.
2152
2153 A variable which has been optimized out of existence will have a
2154 DECL_RTL value which denotes a pseudo-reg.
2155
2156 Currently, in some rare cases, variables can have DECL_RTL values
2157 which look like (MEM (REG pseudo-reg#)). These cases are due to
2158 bugs elsewhere in the compiler. We treat such cases
2159 as if the variable(s) in question had been optimized out of existence.
2160
2161 Note that in all cases where we wish to express the fact that a
2162 variable has been optimized out of existence, we do not simply
2163 suppress the generation of the entire location attribute because
2164 the absence of a location attribute in certain kinds of DIEs is
2165 used to indicate something else entirely... i.e. that the DIE
2166 represents an object declaration, but not a definition. So saith
2167 the PLSIG.
2168 */
2169
2170 if (! is_pseudo_reg (rtl)
2171 && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
2172 output_loc_descriptor (rtl);
2173
2174 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2175 }
2176
2177 /* Output the specialized form of location attribute used for data members
2178 of struct and union types.
2179
2180 In the special case of a FIELD_DECL node which represents a bit-field,
2181 the "offset" part of this special location descriptor must indicate the
2182 distance in bytes from the lowest-addressed byte of the containing
2183 struct or union type to the lowest-addressed byte of the "containing
2184 object" for the bit-field. (See the `field_byte_offset' function above.)
2185
2186 For any given bit-field, the "containing object" is a hypothetical
2187 object (of some integral or enum type) within which the given bit-field
2188 lives. The type of this hypothetical "containing object" is always the
2189 same as the declared type of the individual bit-field itself (for GCC
2190 anyway... the DWARF spec doesn't actually mandate this).
2191
2192 Note that it is the size (in bytes) of the hypothetical "containing
2193 object" which will be given in the AT_byte_size attribute for this
2194 bit-field. (See the `byte_size_attribute' function below.) It is
2195 also used when calculating the value of the AT_bit_offset attribute.
2196 (See the `bit_offset_attribute' function below.) */
2197
2198 static void
2199 data_member_location_attribute (t)
2200 register tree t;
2201 {
2202 register unsigned object_offset_in_bytes;
2203 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2204 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2205
2206 if (TREE_CODE (t) == TREE_VEC)
2207 object_offset_in_bytes = TREE_INT_CST_LOW (BINFO_OFFSET (t));
2208 else
2209 object_offset_in_bytes = field_byte_offset (t);
2210
2211 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2212 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2213 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2214 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2215 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2216 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
2217 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
2218 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2219 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2220 }
2221
2222 /* Output an AT_const_value attribute for a variable or a parameter which
2223 does not have a "location" either in memory or in a register. These
2224 things can arise in GNU C when a constant is passed as an actual
2225 parameter to an inlined function. They can also arise in C++ where
2226 declared constants do not necessarily get memory "homes". */
2227
2228 static void
2229 const_value_attribute (rtl)
2230 register rtx rtl;
2231 {
2232 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2233 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2234
2235 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
2236 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2237 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2238 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2239 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2240
2241 switch (GET_CODE (rtl))
2242 {
2243 case CONST_INT:
2244 /* Note that a CONST_INT rtx could represent either an integer or
2245 a floating-point constant. A CONST_INT is used whenever the
2246 constant will fit into a single word. In all such cases, the
2247 original mode of the constant value is wiped out, and the
2248 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2249 precise mode information for these constants, we always just
2250 output them using 4 bytes. */
2251
2252 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
2253 break;
2254
2255 case CONST_DOUBLE:
2256 /* Note that a CONST_DOUBLE rtx could represent either an integer
2257 or a floating-point constant. A CONST_DOUBLE is used whenever
2258 the constant requires more than one word in order to be adequately
2259 represented. In all such cases, the original mode of the constant
2260 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2261 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2262
2263 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
2264 (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
2265 (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
2266 break;
2267
2268 case CONST_STRING:
2269 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, XSTR (rtl, 0));
2270 break;
2271
2272 case SYMBOL_REF:
2273 case LABEL_REF:
2274 case CONST:
2275 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2276 break;
2277
2278 case PLUS:
2279 /* In cases where an inlined instance of an inline function is passed
2280 the address of an `auto' variable (which is local to the caller)
2281 we can get a situation where the DECL_RTL of the artificial
2282 local variable (for the inlining) which acts as a stand-in for
2283 the corresponding formal parameter (of the inline function)
2284 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2285 This is not exactly a compile-time constant expression, but it
2286 isn't the address of the (artificial) local variable either.
2287 Rather, it represents the *value* which the artificial local
2288 variable always has during its lifetime. We currently have no
2289 way to represent such quasi-constant values in Dwarf, so for now
2290 we just punt and generate an AT_const_value attribute with form
2291 FORM_BLOCK4 and a length of zero. */
2292 break;
2293
2294 default:
2295 abort (); /* No other kinds of rtx should be possible here. */
2296 }
2297
2298 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2299 }
2300
2301 /* Generate *either* an AT_location attribute or else an AT_const_value
2302 data attribute for a variable or a parameter. We generate the
2303 AT_const_value attribute only in those cases where the given
2304 variable or parameter does not have a true "location" either in
2305 memory or in a register. This can happen (for example) when a
2306 constant is passed as an actual argument in a call to an inline
2307 function. (It's possible that these things can crop up in other
2308 ways also.) Note that one type of constant value which can be
2309 passed into an inlined function is a constant pointer. This can
2310 happen for example if an actual argument in an inlined function
2311 call evaluates to a compile-time constant address. */
2312
2313 static void
2314 location_or_const_value_attribute (decl)
2315 register tree decl;
2316 {
2317 register rtx rtl;
2318
2319 if (TREE_CODE (decl) == ERROR_MARK)
2320 return;
2321
2322 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
2323 {
2324 /* Should never happen. */
2325 abort ();
2326 return;
2327 }
2328
2329 /* Here we have to decide where we are going to say the parameter "lives"
2330 (as far as the debugger is concerned). We only have a couple of choices.
2331 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2332 normally indicates where the parameter lives during most of the activa-
2333 tion of the function. If optimization is enabled however, this could
2334 be either NULL or else a pseudo-reg. Both of those cases indicate that
2335 the parameter doesn't really live anywhere (as far as the code generation
2336 parts of GCC are concerned) during most of the function's activation.
2337 That will happen (for example) if the parameter is never referenced
2338 within the function.
2339
2340 We could just generate a location descriptor here for all non-NULL
2341 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2342 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2343 cases where DECL_RTL is NULL or is a pseudo-reg.
2344
2345 Note however that we can only get away with using DECL_INCOMING_RTL as
2346 a backup substitute for DECL_RTL in certain limited cases. In cases
2347 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2348 we can be sure that the parameter was passed using the same type as it
2349 is declared to have within the function, and that its DECL_INCOMING_RTL
2350 points us to a place where a value of that type is passed. In cases
2351 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2352 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2353 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2354 points us to a value of some type which is *different* from the type
2355 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2356 to generate a location attribute in such cases, the debugger would
2357 end up (for example) trying to fetch a `float' from a place which
2358 actually contains the first part of a `double'. That would lead to
2359 really incorrect and confusing output at debug-time, and we don't
2360 want that now do we?
2361
2362 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2363 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2364 couple of cute exceptions however. On little-endian machines we can
2365 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2366 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2367 an integral type which is smaller than TREE_TYPE(decl). These cases
2368 arise when (on a little-endian machine) a non-prototyped function has
2369 a parameter declared to be of type `short' or `char'. In such cases,
2370 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2371 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2372 passed `int' value. If the debugger then uses that address to fetch a
2373 `short' or a `char' (on a little-endian machine) the result will be the
2374 correct data, so we allow for such exceptional cases below.
2375
2376 Note that our goal here is to describe the place where the given formal
2377 parameter lives during most of the function's activation (i.e. between
2378 the end of the prologue and the start of the epilogue). We'll do that
2379 as best as we can. Note however that if the given formal parameter is
2380 modified sometime during the execution of the function, then a stack
2381 backtrace (at debug-time) will show the function as having been called
2382 with the *new* value rather than the value which was originally passed
2383 in. This happens rarely enough that it is not a major problem, but it
2384 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2385 may generate two additional attributes for any given TAG_formal_parameter
2386 DIE which will describe the "passed type" and the "passed location" for
2387 the given formal parameter in addition to the attributes we now generate
2388 to indicate the "declared type" and the "active location" for each
2389 parameter. This additional set of attributes could be used by debuggers
2390 for stack backtraces.
2391
2392 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2393 can be NULL also. This happens (for example) for inlined-instances of
2394 inline function formal parameters which are never referenced. This really
2395 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2396 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2397 these values for inlined instances of inline function parameters, so
2398 when we see such cases, we are just out-of-luck for the time
2399 being (until integrate.c gets fixed).
2400 */
2401
2402 /* Use DECL_RTL as the "location" unless we find something better. */
2403 rtl = DECL_RTL (decl);
2404
2405 if (TREE_CODE (decl) == PARM_DECL)
2406 if (rtl == NULL_RTX || is_pseudo_reg (rtl))
2407 {
2408 /* This decl represents a formal parameter which was optimized out. */
2409 register tree declared_type = type_main_variant (TREE_TYPE (decl));
2410 register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
2411
2412 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2413 *all* cases where (rtl == NULL_RTX) just below. */
2414
2415 if (declared_type == passed_type)
2416 rtl = DECL_INCOMING_RTL (decl);
2417 else if (! BYTES_BIG_ENDIAN)
2418 if (TREE_CODE (declared_type) == INTEGER_TYPE)
2419 if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
2420 rtl = DECL_INCOMING_RTL (decl);
2421 }
2422
2423 if (rtl == NULL_RTX)
2424 return;
2425
2426 rtl = eliminate_regs (rtl, 0, NULL_RTX);
2427 #ifdef LEAF_REG_REMAP
2428 if (leaf_function)
2429 leaf_renumber_regs_insn (rtl);
2430 #endif
2431
2432 switch (GET_CODE (rtl))
2433 {
2434 case ADDRESSOF:
2435 /* The address of a variable that was optimized away; don't emit
2436 anything. */
2437 break;
2438
2439 case CONST_INT:
2440 case CONST_DOUBLE:
2441 case CONST_STRING:
2442 case SYMBOL_REF:
2443 case LABEL_REF:
2444 case CONST:
2445 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2446 const_value_attribute (rtl);
2447 break;
2448
2449 case MEM:
2450 case REG:
2451 case SUBREG:
2452 location_attribute (rtl);
2453 break;
2454
2455 case CONCAT:
2456 /* ??? CONCAT is used for complex variables, which may have the real
2457 part stored in one place and the imag part stored somewhere else.
2458 DWARF1 has no way to describe a variable that lives in two different
2459 places, so we just describe where the first part lives, and hope that
2460 the second part is stored after it. */
2461 location_attribute (XEXP (rtl, 0));
2462 break;
2463
2464 default:
2465 abort (); /* Should never happen. */
2466 }
2467 }
2468
2469 /* Generate an AT_name attribute given some string value to be included as
2470 the value of the attribute. */
2471
2472 static inline void
2473 name_attribute (name_string)
2474 register char *name_string;
2475 {
2476 if (name_string && *name_string)
2477 {
2478 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
2479 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, name_string);
2480 }
2481 }
2482
2483 static inline void
2484 fund_type_attribute (ft_code)
2485 register unsigned ft_code;
2486 {
2487 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
2488 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
2489 }
2490
2491 static void
2492 mod_fund_type_attribute (type, decl_const, decl_volatile)
2493 register tree type;
2494 register int decl_const;
2495 register int decl_volatile;
2496 {
2497 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2498 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2499
2500 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
2501 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2502 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2503 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2504 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2505 write_modifier_bytes (type, decl_const, decl_volatile);
2506 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2507 fundamental_type_code (root_type (type)));
2508 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2509 }
2510
2511 static inline void
2512 user_def_type_attribute (type)
2513 register tree type;
2514 {
2515 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2516
2517 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
2518 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
2519 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2520 }
2521
2522 static void
2523 mod_u_d_type_attribute (type, decl_const, decl_volatile)
2524 register tree type;
2525 register int decl_const;
2526 register int decl_volatile;
2527 {
2528 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2529 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2530 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2531
2532 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
2533 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2534 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2535 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2536 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2537 write_modifier_bytes (type, decl_const, decl_volatile);
2538 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
2539 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2540 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2541 }
2542
2543 #ifdef USE_ORDERING_ATTRIBUTE
2544 static inline void
2545 ordering_attribute (ordering)
2546 register unsigned ordering;
2547 {
2548 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2549 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2550 }
2551 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2552
2553 /* Note that the block of subscript information for an array type also
2554 includes information about the element type of type given array type. */
2555
2556 static void
2557 subscript_data_attribute (type)
2558 register tree type;
2559 {
2560 register unsigned dimension_number;
2561 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2562 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2563
2564 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2565 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
2566 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
2567 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2568 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2569
2570 /* The GNU compilers represent multidimensional array types as sequences
2571 of one dimensional array types whose element types are themselves array
2572 types. Here we squish that down, so that each multidimensional array
2573 type gets only one array_type DIE in the Dwarf debugging info. The
2574 draft Dwarf specification say that we are allowed to do this kind
2575 of compression in C (because there is no difference between an
2576 array or arrays and a multidimensional array in C) but for other
2577 source languages (e.g. Ada) we probably shouldn't do this. */
2578
2579 for (dimension_number = 0;
2580 TREE_CODE (type) == ARRAY_TYPE;
2581 type = TREE_TYPE (type), dimension_number++)
2582 {
2583 register tree domain = TYPE_DOMAIN (type);
2584
2585 /* Arrays come in three flavors. Unspecified bounds, fixed
2586 bounds, and (in GNU C only) variable bounds. Handle all
2587 three forms here. */
2588
2589 if (domain)
2590 {
2591 /* We have an array type with specified bounds. */
2592
2593 register tree lower = TYPE_MIN_VALUE (domain);
2594 register tree upper = TYPE_MAX_VALUE (domain);
2595
2596 /* Handle only fundamental types as index types for now. */
2597
2598 if (! type_is_fundamental (domain))
2599 abort ();
2600
2601 /* Output the representation format byte for this dimension. */
2602
2603 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
2604 FMT_CODE (1, TREE_CODE (lower) == INTEGER_CST,
2605 (upper && TREE_CODE (upper) == INTEGER_CST)));
2606
2607 /* Output the index type for this dimension. */
2608
2609 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2610 fundamental_type_code (domain));
2611
2612 /* Output the representation for the lower bound. */
2613
2614 output_bound_representation (lower, dimension_number, 'l');
2615
2616 /* Output the representation for the upper bound. */
2617
2618 output_bound_representation (upper, dimension_number, 'u');
2619 }
2620 else
2621 {
2622 /* We have an array type with an unspecified length. For C and
2623 C++ we can assume that this really means that (a) the index
2624 type is an integral type, and (b) the lower bound is zero.
2625 Note that Dwarf defines the representation of an unspecified
2626 (upper) bound as being a zero-length location description. */
2627
2628 /* Output the array-bounds format byte. */
2629
2630 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
2631
2632 /* Output the (assumed) index type. */
2633
2634 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
2635
2636 /* Output the (assumed) lower bound (constant) value. */
2637
2638 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
2639
2640 /* Output the (empty) location description for the upper bound. */
2641
2642 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
2643 }
2644 }
2645
2646 /* Output the prefix byte that says that the element type is coming up. */
2647
2648 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
2649
2650 /* Output a representation of the type of the elements of this array type. */
2651
2652 type_attribute (type, 0, 0);
2653
2654 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2655 }
2656
2657 static void
2658 byte_size_attribute (tree_node)
2659 register tree tree_node;
2660 {
2661 register unsigned size;
2662
2663 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
2664 switch (TREE_CODE (tree_node))
2665 {
2666 case ERROR_MARK:
2667 size = 0;
2668 break;
2669
2670 case ENUMERAL_TYPE:
2671 case RECORD_TYPE:
2672 case UNION_TYPE:
2673 case QUAL_UNION_TYPE:
2674 case ARRAY_TYPE:
2675 size = int_size_in_bytes (tree_node);
2676 break;
2677
2678 case FIELD_DECL:
2679 /* For a data member of a struct or union, the AT_byte_size is
2680 generally given as the number of bytes normally allocated for
2681 an object of the *declared* type of the member itself. This
2682 is true even for bit-fields. */
2683 size = simple_type_size_in_bits (field_type (tree_node))
2684 / BITS_PER_UNIT;
2685 break;
2686
2687 default:
2688 abort ();
2689 }
2690
2691 /* Note that `size' might be -1 when we get to this point. If it
2692 is, that indicates that the byte size of the entity in question
2693 is variable. We have no good way of expressing this fact in Dwarf
2694 at the present time, so just let the -1 pass on through. */
2695
2696 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
2697 }
2698
2699 /* For a FIELD_DECL node which represents a bit-field, output an attribute
2700 which specifies the distance in bits from the highest order bit of the
2701 "containing object" for the bit-field to the highest order bit of the
2702 bit-field itself.
2703
2704 For any given bit-field, the "containing object" is a hypothetical
2705 object (of some integral or enum type) within which the given bit-field
2706 lives. The type of this hypothetical "containing object" is always the
2707 same as the declared type of the individual bit-field itself.
2708
2709 The determination of the exact location of the "containing object" for
2710 a bit-field is rather complicated. It's handled by the `field_byte_offset'
2711 function (above).
2712
2713 Note that it is the size (in bytes) of the hypothetical "containing
2714 object" which will be given in the AT_byte_size attribute for this
2715 bit-field. (See `byte_size_attribute' above.) */
2716
2717 static inline void
2718 bit_offset_attribute (decl)
2719 register tree decl;
2720 {
2721 register unsigned object_offset_in_bytes = field_byte_offset (decl);
2722 register tree type = DECL_BIT_FIELD_TYPE (decl);
2723 register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
2724 register unsigned bitpos_int;
2725 register unsigned highest_order_object_bit_offset;
2726 register unsigned highest_order_field_bit_offset;
2727 register unsigned bit_offset;
2728
2729 /* Must be a bit field. */
2730 if (!type
2731 || TREE_CODE (decl) != FIELD_DECL)
2732 abort ();
2733
2734 /* We can't yet handle bit-fields whose offsets are variable, so if we
2735 encounter such things, just return without generating any attribute
2736 whatsoever. */
2737
2738 if (TREE_CODE (bitpos_tree) != INTEGER_CST)
2739 return;
2740 bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
2741
2742 /* Note that the bit offset is always the distance (in bits) from the
2743 highest-order bit of the "containing object" to the highest-order
2744 bit of the bit-field itself. Since the "high-order end" of any
2745 object or field is different on big-endian and little-endian machines,
2746 the computation below must take account of these differences. */
2747
2748 highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
2749 highest_order_field_bit_offset = bitpos_int;
2750
2751 if (! BYTES_BIG_ENDIAN)
2752 {
2753 highest_order_field_bit_offset
2754 += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
2755
2756 highest_order_object_bit_offset += simple_type_size_in_bits (type);
2757 }
2758
2759 bit_offset =
2760 (! BYTES_BIG_ENDIAN
2761 ? highest_order_object_bit_offset - highest_order_field_bit_offset
2762 : highest_order_field_bit_offset - highest_order_object_bit_offset);
2763
2764 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
2765 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
2766 }
2767
2768 /* For a FIELD_DECL node which represents a bit field, output an attribute
2769 which specifies the length in bits of the given field. */
2770
2771 static inline void
2772 bit_size_attribute (decl)
2773 register tree decl;
2774 {
2775 /* Must be a field and a bit field. */
2776 if (TREE_CODE (decl) != FIELD_DECL
2777 || ! DECL_BIT_FIELD_TYPE (decl))
2778 abort ();
2779
2780 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
2781 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2782 (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
2783 }
2784
2785 /* The following routine outputs the `element_list' attribute for enumeration
2786 type DIEs. The element_lits attribute includes the names and values of
2787 all of the enumeration constants associated with the given enumeration
2788 type. */
2789
2790 static inline void
2791 element_list_attribute (element)
2792 register tree element;
2793 {
2794 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2795 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2796
2797 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
2798 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
2799 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
2800 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2801 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2802
2803 /* Here we output a list of value/name pairs for each enumeration constant
2804 defined for this enumeration type (as required), but we do it in REVERSE
2805 order. The order is the one required by the draft #5 Dwarf specification
2806 published by the UI/PLSIG. */
2807
2808 output_enumeral_list (element); /* Recursively output the whole list. */
2809
2810 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2811 }
2812
2813 /* Generate an AT_stmt_list attribute. These are normally present only in
2814 DIEs with a TAG_compile_unit tag. */
2815
2816 static inline void
2817 stmt_list_attribute (label)
2818 register char *label;
2819 {
2820 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
2821 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2822 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
2823 }
2824
2825 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
2826 for a subroutine DIE. */
2827
2828 static inline void
2829 low_pc_attribute (asm_low_label)
2830 register char *asm_low_label;
2831 {
2832 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
2833 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
2834 }
2835
2836 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
2837 subroutine DIE. */
2838
2839 static inline void
2840 high_pc_attribute (asm_high_label)
2841 register char *asm_high_label;
2842 {
2843 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
2844 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
2845 }
2846
2847 /* Generate an AT_body_begin attribute for a subroutine DIE. */
2848
2849 static inline void
2850 body_begin_attribute (asm_begin_label)
2851 register char *asm_begin_label;
2852 {
2853 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
2854 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
2855 }
2856
2857 /* Generate an AT_body_end attribute for a subroutine DIE. */
2858
2859 static inline void
2860 body_end_attribute (asm_end_label)
2861 register char *asm_end_label;
2862 {
2863 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
2864 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
2865 }
2866
2867 /* Generate an AT_language attribute given a LANG value. These attributes
2868 are used only within TAG_compile_unit DIEs. */
2869
2870 static inline void
2871 language_attribute (language_code)
2872 register unsigned language_code;
2873 {
2874 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
2875 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
2876 }
2877
2878 static inline void
2879 member_attribute (context)
2880 register tree context;
2881 {
2882 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2883
2884 /* Generate this attribute only for members in C++. */
2885
2886 if (context != NULL && is_tagged_type (context))
2887 {
2888 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
2889 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
2890 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2891 }
2892 }
2893
2894 #if 0
2895 static inline void
2896 string_length_attribute (upper_bound)
2897 register tree upper_bound;
2898 {
2899 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2900 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2901
2902 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
2903 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
2904 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
2905 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2906 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2907 output_bound_representation (upper_bound, 0, 'u');
2908 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2909 }
2910 #endif
2911
2912 static inline void
2913 comp_dir_attribute (dirname)
2914 register char *dirname;
2915 {
2916 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
2917 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
2918 }
2919
2920 static inline void
2921 sf_names_attribute (sf_names_start_label)
2922 register char *sf_names_start_label;
2923 {
2924 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
2925 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2926 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
2927 }
2928
2929 static inline void
2930 src_info_attribute (src_info_start_label)
2931 register char *src_info_start_label;
2932 {
2933 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
2934 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2935 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
2936 }
2937
2938 static inline void
2939 mac_info_attribute (mac_info_start_label)
2940 register char *mac_info_start_label;
2941 {
2942 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
2943 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
2944 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
2945 }
2946
2947 static inline void
2948 prototyped_attribute (func_type)
2949 register tree func_type;
2950 {
2951 if ((strcmp (language_string, "GNU C") == 0)
2952 && (TYPE_ARG_TYPES (func_type) != NULL))
2953 {
2954 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
2955 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
2956 }
2957 }
2958
2959 static inline void
2960 producer_attribute (producer)
2961 register char *producer;
2962 {
2963 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
2964 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, producer);
2965 }
2966
2967 static inline void
2968 inline_attribute (decl)
2969 register tree decl;
2970 {
2971 if (DECL_INLINE (decl))
2972 {
2973 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
2974 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
2975 }
2976 }
2977
2978 static inline void
2979 containing_type_attribute (containing_type)
2980 register tree containing_type;
2981 {
2982 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2983
2984 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
2985 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
2986 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2987 }
2988
2989 static inline void
2990 abstract_origin_attribute (origin)
2991 register tree origin;
2992 {
2993 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2994
2995 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
2996 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
2997 {
2998 case 'd':
2999 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
3000 break;
3001
3002 case 't':
3003 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
3004 break;
3005
3006 default:
3007 abort (); /* Should never happen. */
3008
3009 }
3010 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
3011 }
3012
3013 #ifdef DWARF_DECL_COORDINATES
3014 static inline void
3015 src_coords_attribute (src_fileno, src_lineno)
3016 register unsigned src_fileno;
3017 register unsigned src_lineno;
3018 {
3019 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
3020 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
3021 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
3022 }
3023 #endif /* defined(DWARF_DECL_COORDINATES) */
3024
3025 static inline void
3026 pure_or_virtual_attribute (func_decl)
3027 register tree func_decl;
3028 {
3029 if (DECL_VIRTUAL_P (func_decl))
3030 {
3031 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
3032 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
3033 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
3034 else
3035 #endif
3036 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
3037 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3038 }
3039 }
3040
3041 /************************* end of attributes *****************************/
3042
3043 /********************* utility routines for DIEs *************************/
3044
3045 /* Output an AT_name attribute and an AT_src_coords attribute for the
3046 given decl, but only if it actually has a name. */
3047
3048 static void
3049 name_and_src_coords_attributes (decl)
3050 register tree decl;
3051 {
3052 register tree decl_name = DECL_NAME (decl);
3053
3054 if (decl_name && IDENTIFIER_POINTER (decl_name))
3055 {
3056 name_attribute (IDENTIFIER_POINTER (decl_name));
3057 #ifdef DWARF_DECL_COORDINATES
3058 {
3059 register unsigned file_index;
3060
3061 /* This is annoying, but we have to pop out of the .debug section
3062 for a moment while we call `lookup_filename' because calling it
3063 may cause a temporary switch into the .debug_sfnames section and
3064 most svr4 assemblers are not smart enough to be able to nest
3065 section switches to any depth greater than one. Note that we
3066 also can't skirt this issue by delaying all output to the
3067 .debug_sfnames section unit the end of compilation because that
3068 would cause us to have inter-section forward references and
3069 Fred Fish sez that m68k/svr4 assemblers botch those. */
3070
3071 ASM_OUTPUT_POP_SECTION (asm_out_file);
3072 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
3073 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
3074
3075 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
3076 }
3077 #endif /* defined(DWARF_DECL_COORDINATES) */
3078 }
3079 }
3080
3081 /* Many forms of DIEs contain a "type description" part. The following
3082 routine writes out these "type descriptor" parts. */
3083
3084 static void
3085 type_attribute (type, decl_const, decl_volatile)
3086 register tree type;
3087 register int decl_const;
3088 register int decl_volatile;
3089 {
3090 register enum tree_code code = TREE_CODE (type);
3091 register int root_type_modified;
3092
3093 if (code == ERROR_MARK)
3094 return;
3095
3096 /* Handle a special case. For functions whose return type is void,
3097 we generate *no* type attribute. (Note that no object may have
3098 type `void', so this only applies to function return types. */
3099
3100 if (code == VOID_TYPE)
3101 return;
3102
3103 /* If this is a subtype, find the underlying type. Eventually,
3104 this should write out the appropriate subtype info. */
3105 while ((code == INTEGER_TYPE || code == REAL_TYPE)
3106 && TREE_TYPE (type) != 0)
3107 type = TREE_TYPE (type), code = TREE_CODE (type);
3108
3109 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
3110 || decl_const || decl_volatile
3111 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
3112
3113 if (type_is_fundamental (root_type (type)))
3114 {
3115 if (root_type_modified)
3116 mod_fund_type_attribute (type, decl_const, decl_volatile);
3117 else
3118 fund_type_attribute (fundamental_type_code (type));
3119 }
3120 else
3121 {
3122 if (root_type_modified)
3123 mod_u_d_type_attribute (type, decl_const, decl_volatile);
3124 else
3125 /* We have to get the type_main_variant here (and pass that to the
3126 `user_def_type_attribute' routine) because the ..._TYPE node we
3127 have might simply be a *copy* of some original type node (where
3128 the copy was created to help us keep track of typedef names)
3129 and that copy might have a different TYPE_UID from the original
3130 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
3131 is labeling a given type DIE for future reference, it always and
3132 only creates labels for DIEs representing *main variants*, and it
3133 never even knows about non-main-variants.) */
3134 user_def_type_attribute (type_main_variant (type));
3135 }
3136 }
3137
3138 /* Given a tree pointer to a struct, class, union, or enum type node, return
3139 a pointer to the (string) tag name for the given type, or zero if the
3140 type was declared without a tag. */
3141
3142 static char *
3143 type_tag (type)
3144 register tree type;
3145 {
3146 register char *name = 0;
3147
3148 if (TYPE_NAME (type) != 0)
3149 {
3150 register tree t = 0;
3151
3152 /* Find the IDENTIFIER_NODE for the type name. */
3153 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
3154 t = TYPE_NAME (type);
3155
3156 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
3157 a TYPE_DECL node, regardless of whether or not a `typedef' was
3158 involved. */
3159 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
3160 && ! DECL_IGNORED_P (TYPE_NAME (type)))
3161 t = DECL_NAME (TYPE_NAME (type));
3162
3163 /* Now get the name as a string, or invent one. */
3164 if (t != 0)
3165 name = IDENTIFIER_POINTER (t);
3166 }
3167
3168 return (name == 0 || *name == '\0') ? 0 : name;
3169 }
3170
3171 static inline void
3172 dienum_push ()
3173 {
3174 /* Start by checking if the pending_sibling_stack needs to be expanded.
3175 If necessary, expand it. */
3176
3177 if (pending_siblings == pending_siblings_allocated)
3178 {
3179 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
3180 pending_sibling_stack
3181 = (unsigned *) xrealloc (pending_sibling_stack,
3182 pending_siblings_allocated * sizeof(unsigned));
3183 }
3184
3185 pending_siblings++;
3186 NEXT_DIE_NUM = next_unused_dienum++;
3187 }
3188
3189 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
3190 NEXT_DIE_NUM. */
3191
3192 static inline void
3193 dienum_pop ()
3194 {
3195 pending_siblings--;
3196 }
3197
3198 static inline tree
3199 member_declared_type (member)
3200 register tree member;
3201 {
3202 return (DECL_BIT_FIELD_TYPE (member))
3203 ? DECL_BIT_FIELD_TYPE (member)
3204 : TREE_TYPE (member);
3205 }
3206
3207 /* Get the function's label, as described by its RTL.
3208 This may be different from the DECL_NAME name used
3209 in the source file. */
3210
3211 static char *
3212 function_start_label (decl)
3213 register tree decl;
3214 {
3215 rtx x;
3216 char *fnname;
3217
3218 x = DECL_RTL (decl);
3219 if (GET_CODE (x) != MEM)
3220 abort ();
3221 x = XEXP (x, 0);
3222 if (GET_CODE (x) != SYMBOL_REF)
3223 abort ();
3224 fnname = XSTR (x, 0);
3225 return fnname;
3226 }
3227
3228
3229 /******************************* DIEs ************************************/
3230
3231 /* Output routines for individual types of DIEs. */
3232
3233 /* Note that every type of DIE (except a null DIE) gets a sibling. */
3234
3235 static void
3236 output_array_type_die (arg)
3237 register void *arg;
3238 {
3239 register tree type = arg;
3240
3241 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
3242 sibling_attribute ();
3243 equate_type_number_to_die_number (type);
3244 member_attribute (TYPE_CONTEXT (type));
3245
3246 /* I believe that we can default the array ordering. SDB will probably
3247 do the right things even if AT_ordering is not present. It's not
3248 even an issue until we start to get into multidimensional arrays
3249 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3250 dimensional arrays, then we'll have to put the AT_ordering attribute
3251 back in. (But if and when we find out that we need to put these in,
3252 we will only do so for multidimensional arrays. After all, we don't
3253 want to waste space in the .debug section now do we?) */
3254
3255 #ifdef USE_ORDERING_ATTRIBUTE
3256 ordering_attribute (ORD_row_major);
3257 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3258
3259 subscript_data_attribute (type);
3260 }
3261
3262 static void
3263 output_set_type_die (arg)
3264 register void *arg;
3265 {
3266 register tree type = arg;
3267
3268 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
3269 sibling_attribute ();
3270 equate_type_number_to_die_number (type);
3271 member_attribute (TYPE_CONTEXT (type));
3272 type_attribute (TREE_TYPE (type), 0, 0);
3273 }
3274
3275 #if 0
3276 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3277
3278 static void
3279 output_entry_point_die (arg)
3280 register void *arg;
3281 {
3282 register tree decl = arg;
3283 register tree origin = decl_ultimate_origin (decl);
3284
3285 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
3286 sibling_attribute ();
3287 dienum_push ();
3288 if (origin != NULL)
3289 abstract_origin_attribute (origin);
3290 else
3291 {
3292 name_and_src_coords_attributes (decl);
3293 member_attribute (DECL_CONTEXT (decl));
3294 type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
3295 }
3296 if (DECL_ABSTRACT (decl))
3297 equate_decl_number_to_die_number (decl);
3298 else
3299 low_pc_attribute (function_start_label (decl));
3300 }
3301 #endif
3302
3303 /* Output a DIE to represent an inlined instance of an enumeration type. */
3304
3305 static void
3306 output_inlined_enumeration_type_die (arg)
3307 register void *arg;
3308 {
3309 register tree type = arg;
3310
3311 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3312 sibling_attribute ();
3313 if (!TREE_ASM_WRITTEN (type))
3314 abort ();
3315 abstract_origin_attribute (type);
3316 }
3317
3318 /* Output a DIE to represent an inlined instance of a structure type. */
3319
3320 static void
3321 output_inlined_structure_type_die (arg)
3322 register void *arg;
3323 {
3324 register tree type = arg;
3325
3326 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3327 sibling_attribute ();
3328 if (!TREE_ASM_WRITTEN (type))
3329 abort ();
3330 abstract_origin_attribute (type);
3331 }
3332
3333 /* Output a DIE to represent an inlined instance of a union type. */
3334
3335 static void
3336 output_inlined_union_type_die (arg)
3337 register void *arg;
3338 {
3339 register tree type = arg;
3340
3341 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3342 sibling_attribute ();
3343 if (!TREE_ASM_WRITTEN (type))
3344 abort ();
3345 abstract_origin_attribute (type);
3346 }
3347
3348 /* Output a DIE to represent an enumeration type. Note that these DIEs
3349 include all of the information about the enumeration values also.
3350 This information is encoded into the element_list attribute. */
3351
3352 static void
3353 output_enumeration_type_die (arg)
3354 register void *arg;
3355 {
3356 register tree type = arg;
3357
3358 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3359 sibling_attribute ();
3360 equate_type_number_to_die_number (type);
3361 name_attribute (type_tag (type));
3362 member_attribute (TYPE_CONTEXT (type));
3363
3364 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3365 given enum type is incomplete, do not generate the AT_byte_size
3366 attribute or the AT_element_list attribute. */
3367
3368 if (TYPE_SIZE (type))
3369 {
3370 byte_size_attribute (type);
3371 element_list_attribute (TYPE_FIELDS (type));
3372 }
3373 }
3374
3375 /* Output a DIE to represent either a real live formal parameter decl or
3376 to represent just the type of some formal parameter position in some
3377 function type.
3378
3379 Note that this routine is a bit unusual because its argument may be
3380 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3381 represents an inlining of some PARM_DECL) or else some sort of a
3382 ..._TYPE node. If it's the former then this function is being called
3383 to output a DIE to represent a formal parameter object (or some inlining
3384 thereof). If it's the latter, then this function is only being called
3385 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3386 formal argument type of some subprogram type. */
3387
3388 static void
3389 output_formal_parameter_die (arg)
3390 register void *arg;
3391 {
3392 register tree node = arg;
3393
3394 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
3395 sibling_attribute ();
3396
3397 switch (TREE_CODE_CLASS (TREE_CODE (node)))
3398 {
3399 case 'd': /* We were called with some kind of a ..._DECL node. */
3400 {
3401 register tree origin = decl_ultimate_origin (node);
3402
3403 if (origin != NULL)
3404 abstract_origin_attribute (origin);
3405 else
3406 {
3407 name_and_src_coords_attributes (node);
3408 type_attribute (TREE_TYPE (node),
3409 TREE_READONLY (node), TREE_THIS_VOLATILE (node));
3410 }
3411 if (DECL_ABSTRACT (node))
3412 equate_decl_number_to_die_number (node);
3413 else
3414 location_or_const_value_attribute (node);
3415 }
3416 break;
3417
3418 case 't': /* We were called with some kind of a ..._TYPE node. */
3419 type_attribute (node, 0, 0);
3420 break;
3421
3422 default:
3423 abort (); /* Should never happen. */
3424 }
3425 }
3426
3427 /* Output a DIE to represent a declared function (either file-scope
3428 or block-local) which has "external linkage" (according to ANSI-C). */
3429
3430 static void
3431 output_global_subroutine_die (arg)
3432 register void *arg;
3433 {
3434 register tree decl = arg;
3435 register tree origin = decl_ultimate_origin (decl);
3436
3437 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
3438 sibling_attribute ();
3439 dienum_push ();
3440 if (origin != NULL)
3441 abstract_origin_attribute (origin);
3442 else
3443 {
3444 register tree type = TREE_TYPE (decl);
3445
3446 name_and_src_coords_attributes (decl);
3447 inline_attribute (decl);
3448 prototyped_attribute (type);
3449 member_attribute (DECL_CONTEXT (decl));
3450 type_attribute (TREE_TYPE (type), 0, 0);
3451 pure_or_virtual_attribute (decl);
3452 }
3453 if (DECL_ABSTRACT (decl))
3454 equate_decl_number_to_die_number (decl);
3455 else
3456 {
3457 if (! DECL_EXTERNAL (decl) && ! in_class
3458 && decl == current_function_decl)
3459 {
3460 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3461
3462 low_pc_attribute (function_start_label (decl));
3463 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3464 high_pc_attribute (label);
3465 if (use_gnu_debug_info_extensions)
3466 {
3467 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3468 body_begin_attribute (label);
3469 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3470 body_end_attribute (label);
3471 }
3472 }
3473 }
3474 }
3475
3476 /* Output a DIE to represent a declared data object (either file-scope
3477 or block-local) which has "external linkage" (according to ANSI-C). */
3478
3479 static void
3480 output_global_variable_die (arg)
3481 register void *arg;
3482 {
3483 register tree decl = arg;
3484 register tree origin = decl_ultimate_origin (decl);
3485
3486 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
3487 sibling_attribute ();
3488 if (origin != NULL)
3489 abstract_origin_attribute (origin);
3490 else
3491 {
3492 name_and_src_coords_attributes (decl);
3493 member_attribute (DECL_CONTEXT (decl));
3494 type_attribute (TREE_TYPE (decl),
3495 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3496 }
3497 if (DECL_ABSTRACT (decl))
3498 equate_decl_number_to_die_number (decl);
3499 else
3500 {
3501 if (! DECL_EXTERNAL (decl) && ! in_class
3502 && current_function_decl == decl_function_context (decl))
3503 location_or_const_value_attribute (decl);
3504 }
3505 }
3506
3507 static void
3508 output_label_die (arg)
3509 register void *arg;
3510 {
3511 register tree decl = arg;
3512 register tree origin = decl_ultimate_origin (decl);
3513
3514 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
3515 sibling_attribute ();
3516 if (origin != NULL)
3517 abstract_origin_attribute (origin);
3518 else
3519 name_and_src_coords_attributes (decl);
3520 if (DECL_ABSTRACT (decl))
3521 equate_decl_number_to_die_number (decl);
3522 else
3523 {
3524 register rtx insn = DECL_RTL (decl);
3525
3526 if (GET_CODE (insn) == CODE_LABEL)
3527 {
3528 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3529
3530 /* When optimization is enabled (via -O) some parts of the compiler
3531 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3532 represent source-level labels which were explicitly declared by
3533 the user. This really shouldn't be happening though, so catch
3534 it if it ever does happen. */
3535
3536 if (INSN_DELETED_P (insn))
3537 abort (); /* Should never happen. */
3538
3539 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
3540 (unsigned) INSN_UID (insn));
3541 low_pc_attribute (label);
3542 }
3543 }
3544 }
3545
3546 static void
3547 output_lexical_block_die (arg)
3548 register void *arg;
3549 {
3550 register tree stmt = arg;
3551
3552 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
3553 sibling_attribute ();
3554 dienum_push ();
3555 if (! BLOCK_ABSTRACT (stmt))
3556 {
3557 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3558 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3559
3560 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3561 low_pc_attribute (begin_label);
3562 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3563 high_pc_attribute (end_label);
3564 }
3565 }
3566
3567 static void
3568 output_inlined_subroutine_die (arg)
3569 register void *arg;
3570 {
3571 register tree stmt = arg;
3572
3573 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
3574 sibling_attribute ();
3575 dienum_push ();
3576 abstract_origin_attribute (block_ultimate_origin (stmt));
3577 if (! BLOCK_ABSTRACT (stmt))
3578 {
3579 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3580 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3581
3582 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
3583 low_pc_attribute (begin_label);
3584 sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
3585 high_pc_attribute (end_label);
3586 }
3587 }
3588
3589 /* Output a DIE to represent a declared data object (either file-scope
3590 or block-local) which has "internal linkage" (according to ANSI-C). */
3591
3592 static void
3593 output_local_variable_die (arg)
3594 register void *arg;
3595 {
3596 register tree decl = arg;
3597 register tree origin = decl_ultimate_origin (decl);
3598
3599 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
3600 sibling_attribute ();
3601 if (origin != NULL)
3602 abstract_origin_attribute (origin);
3603 else
3604 {
3605 name_and_src_coords_attributes (decl);
3606 member_attribute (DECL_CONTEXT (decl));
3607 type_attribute (TREE_TYPE (decl),
3608 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3609 }
3610 if (DECL_ABSTRACT (decl))
3611 equate_decl_number_to_die_number (decl);
3612 else
3613 location_or_const_value_attribute (decl);
3614 }
3615
3616 static void
3617 output_member_die (arg)
3618 register void *arg;
3619 {
3620 register tree decl = arg;
3621
3622 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
3623 sibling_attribute ();
3624 name_and_src_coords_attributes (decl);
3625 member_attribute (DECL_CONTEXT (decl));
3626 type_attribute (member_declared_type (decl),
3627 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3628 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
3629 {
3630 byte_size_attribute (decl);
3631 bit_size_attribute (decl);
3632 bit_offset_attribute (decl);
3633 }
3634 data_member_location_attribute (decl);
3635 }
3636
3637 #if 0
3638 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
3639 modified types instead.
3640
3641 We keep this code here just in case these types of DIEs may be
3642 needed to represent certain things in other languages (e.g. Pascal)
3643 someday. */
3644
3645 static void
3646 output_pointer_type_die (arg)
3647 register void *arg;
3648 {
3649 register tree type = arg;
3650
3651 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
3652 sibling_attribute ();
3653 equate_type_number_to_die_number (type);
3654 member_attribute (TYPE_CONTEXT (type));
3655 type_attribute (TREE_TYPE (type), 0, 0);
3656 }
3657
3658 static void
3659 output_reference_type_die (arg)
3660 register void *arg;
3661 {
3662 register tree type = arg;
3663
3664 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
3665 sibling_attribute ();
3666 equate_type_number_to_die_number (type);
3667 member_attribute (TYPE_CONTEXT (type));
3668 type_attribute (TREE_TYPE (type), 0, 0);
3669 }
3670 #endif
3671
3672 static void
3673 output_ptr_to_mbr_type_die (arg)
3674 register void *arg;
3675 {
3676 register tree type = arg;
3677
3678 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
3679 sibling_attribute ();
3680 equate_type_number_to_die_number (type);
3681 member_attribute (TYPE_CONTEXT (type));
3682 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
3683 type_attribute (TREE_TYPE (type), 0, 0);
3684 }
3685
3686 static void
3687 output_compile_unit_die (arg)
3688 register void *arg;
3689 {
3690 register char *main_input_filename = arg;
3691
3692 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
3693 sibling_attribute ();
3694 dienum_push ();
3695 name_attribute (main_input_filename);
3696
3697 {
3698 char producer[250];
3699
3700 sprintf (producer, "%s %s", language_string, version_string);
3701 producer_attribute (producer);
3702 }
3703
3704 if (strcmp (language_string, "GNU C++") == 0)
3705 language_attribute (LANG_C_PLUS_PLUS);
3706 else if (strcmp (language_string, "GNU Ada") == 0)
3707 language_attribute (LANG_ADA83);
3708 else if (strcmp (language_string, "GNU F77") == 0)
3709 language_attribute (LANG_FORTRAN77);
3710 else if (strcmp (language_string, "GNU Pascal") == 0)
3711 language_attribute (LANG_PASCAL83);
3712 else if (flag_traditional)
3713 language_attribute (LANG_C);
3714 else
3715 language_attribute (LANG_C89);
3716 low_pc_attribute (TEXT_BEGIN_LABEL);
3717 high_pc_attribute (TEXT_END_LABEL);
3718 if (debug_info_level >= DINFO_LEVEL_NORMAL)
3719 stmt_list_attribute (LINE_BEGIN_LABEL);
3720 last_filename = xstrdup (main_input_filename);
3721
3722 {
3723 char *wd = getpwd ();
3724 if (wd)
3725 comp_dir_attribute (wd);
3726 }
3727
3728 if (debug_info_level >= DINFO_LEVEL_NORMAL && use_gnu_debug_info_extensions)
3729 {
3730 sf_names_attribute (SFNAMES_BEGIN_LABEL);
3731 src_info_attribute (SRCINFO_BEGIN_LABEL);
3732 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
3733 mac_info_attribute (MACINFO_BEGIN_LABEL);
3734 }
3735 }
3736
3737 static void
3738 output_string_type_die (arg)
3739 register void *arg;
3740 {
3741 register tree type = arg;
3742
3743 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
3744 sibling_attribute ();
3745 equate_type_number_to_die_number (type);
3746 member_attribute (TYPE_CONTEXT (type));
3747 /* this is a fixed length string */
3748 byte_size_attribute (type);
3749 }
3750
3751 static void
3752 output_inheritance_die (arg)
3753 register void *arg;
3754 {
3755 register tree binfo = arg;
3756
3757 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
3758 sibling_attribute ();
3759 type_attribute (BINFO_TYPE (binfo), 0, 0);
3760 data_member_location_attribute (binfo);
3761 if (TREE_VIA_VIRTUAL (binfo))
3762 {
3763 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
3764 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3765 }
3766 if (TREE_VIA_PUBLIC (binfo))
3767 {
3768 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
3769 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3770 }
3771 else if (TREE_VIA_PROTECTED (binfo))
3772 {
3773 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
3774 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3775 }
3776 }
3777
3778 static void
3779 output_structure_type_die (arg)
3780 register void *arg;
3781 {
3782 register tree type = arg;
3783
3784 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3785 sibling_attribute ();
3786 equate_type_number_to_die_number (type);
3787 name_attribute (type_tag (type));
3788 member_attribute (TYPE_CONTEXT (type));
3789
3790 /* If this type has been completed, then give it a byte_size attribute
3791 and prepare to give a list of members. Otherwise, don't do either of
3792 these things. In the latter case, we will not be generating a list
3793 of members (since we don't have any idea what they might be for an
3794 incomplete type). */
3795
3796 if (TYPE_SIZE (type))
3797 {
3798 dienum_push ();
3799 byte_size_attribute (type);
3800 }
3801 }
3802
3803 /* Output a DIE to represent a declared function (either file-scope
3804 or block-local) which has "internal linkage" (according to ANSI-C). */
3805
3806 static void
3807 output_local_subroutine_die (arg)
3808 register void *arg;
3809 {
3810 register tree decl = arg;
3811 register tree origin = decl_ultimate_origin (decl);
3812
3813 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
3814 sibling_attribute ();
3815 dienum_push ();
3816 if (origin != NULL)
3817 abstract_origin_attribute (origin);
3818 else
3819 {
3820 register tree type = TREE_TYPE (decl);
3821
3822 name_and_src_coords_attributes (decl);
3823 inline_attribute (decl);
3824 prototyped_attribute (type);
3825 member_attribute (DECL_CONTEXT (decl));
3826 type_attribute (TREE_TYPE (type), 0, 0);
3827 pure_or_virtual_attribute (decl);
3828 }
3829 if (DECL_ABSTRACT (decl))
3830 equate_decl_number_to_die_number (decl);
3831 else
3832 {
3833 /* Avoid getting screwed up in cases where a function was declared
3834 static but where no definition was ever given for it. */
3835
3836 if (TREE_ASM_WRITTEN (decl))
3837 {
3838 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3839 low_pc_attribute (function_start_label (decl));
3840 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3841 high_pc_attribute (label);
3842 if (use_gnu_debug_info_extensions)
3843 {
3844 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3845 body_begin_attribute (label);
3846 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3847 body_end_attribute (label);
3848 }
3849 }
3850 }
3851 }
3852
3853 static void
3854 output_subroutine_type_die (arg)
3855 register void *arg;
3856 {
3857 register tree type = arg;
3858 register tree return_type = TREE_TYPE (type);
3859
3860 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
3861 sibling_attribute ();
3862 dienum_push ();
3863 equate_type_number_to_die_number (type);
3864 prototyped_attribute (type);
3865 member_attribute (TYPE_CONTEXT (type));
3866 type_attribute (return_type, 0, 0);
3867 }
3868
3869 static void
3870 output_typedef_die (arg)
3871 register void *arg;
3872 {
3873 register tree decl = arg;
3874 register tree origin = decl_ultimate_origin (decl);
3875
3876 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
3877 sibling_attribute ();
3878 if (origin != NULL)
3879 abstract_origin_attribute (origin);
3880 else
3881 {
3882 name_and_src_coords_attributes (decl);
3883 member_attribute (DECL_CONTEXT (decl));
3884 type_attribute (TREE_TYPE (decl),
3885 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3886 }
3887 if (DECL_ABSTRACT (decl))
3888 equate_decl_number_to_die_number (decl);
3889 }
3890
3891 static void
3892 output_union_type_die (arg)
3893 register void *arg;
3894 {
3895 register tree type = arg;
3896
3897 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3898 sibling_attribute ();
3899 equate_type_number_to_die_number (type);
3900 name_attribute (type_tag (type));
3901 member_attribute (TYPE_CONTEXT (type));
3902
3903 /* If this type has been completed, then give it a byte_size attribute
3904 and prepare to give a list of members. Otherwise, don't do either of
3905 these things. In the latter case, we will not be generating a list
3906 of members (since we don't have any idea what they might be for an
3907 incomplete type). */
3908
3909 if (TYPE_SIZE (type))
3910 {
3911 dienum_push ();
3912 byte_size_attribute (type);
3913 }
3914 }
3915
3916 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
3917 at the end of an (ANSI prototyped) formal parameters list. */
3918
3919 static void
3920 output_unspecified_parameters_die (arg)
3921 register void *arg;
3922 {
3923 register tree decl_or_type = arg;
3924
3925 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
3926 sibling_attribute ();
3927
3928 /* This kludge is here only for the sake of being compatible with what
3929 the USL CI5 C compiler does. The specification of Dwarf Version 1
3930 doesn't say that TAG_unspecified_parameters DIEs should contain any
3931 attributes other than the AT_sibling attribute, but they are certainly
3932 allowed to contain additional attributes, and the CI5 compiler
3933 generates AT_name, AT_fund_type, and AT_location attributes within
3934 TAG_unspecified_parameters DIEs which appear in the child lists for
3935 DIEs representing function definitions, so we do likewise here. */
3936
3937 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
3938 {
3939 name_attribute ("...");
3940 fund_type_attribute (FT_pointer);
3941 /* location_attribute (?); */
3942 }
3943 }
3944
3945 static void
3946 output_padded_null_die (arg)
3947 register void *arg ATTRIBUTE_UNUSED;
3948 {
3949 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
3950 }
3951
3952 /*************************** end of DIEs *********************************/
3953
3954 /* Generate some type of DIE. This routine generates the generic outer
3955 wrapper stuff which goes around all types of DIE's (regardless of their
3956 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
3957 DIE-length word, followed by the guts of the DIE itself. After the guts
3958 of the DIE, there must always be a terminator label for the DIE. */
3959
3960 static void
3961 output_die (die_specific_output_function, param)
3962 register void (*die_specific_output_function) PROTO ((void *));
3963 register void *param;
3964 {
3965 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3966 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3967
3968 current_dienum = NEXT_DIE_NUM;
3969 NEXT_DIE_NUM = next_unused_dienum;
3970
3971 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
3972 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
3973
3974 /* Write a label which will act as the name for the start of this DIE. */
3975
3976 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3977
3978 /* Write the DIE-length word. */
3979
3980 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3981
3982 /* Fill in the guts of the DIE. */
3983
3984 next_unused_dienum++;
3985 die_specific_output_function (param);
3986
3987 /* Write a label which will act as the name for the end of this DIE. */
3988
3989 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3990 }
3991
3992 static void
3993 end_sibling_chain ()
3994 {
3995 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3996
3997 current_dienum = NEXT_DIE_NUM;
3998 NEXT_DIE_NUM = next_unused_dienum;
3999
4000 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
4001
4002 /* Write a label which will act as the name for the start of this DIE. */
4003
4004 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
4005
4006 /* Write the DIE-length word. */
4007
4008 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
4009
4010 dienum_pop ();
4011 }
4012 \f
4013 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
4014 TAG_unspecified_parameters DIE) to represent the types of the formal
4015 parameters as specified in some function type specification (except
4016 for those which appear as part of a function *definition*).
4017
4018 Note that we must be careful here to output all of the parameter
4019 DIEs *before* we output any DIEs needed to represent the types of
4020 the formal parameters. This keeps svr4 SDB happy because it
4021 (incorrectly) thinks that the first non-parameter DIE it sees ends
4022 the formal parameter list. */
4023
4024 static void
4025 output_formal_types (function_or_method_type)
4026 register tree function_or_method_type;
4027 {
4028 register tree link;
4029 register tree formal_type = NULL;
4030 register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
4031
4032 /* Set TREE_ASM_WRITTEN while processing the parameters, lest we
4033 get bogus recursion when outputting tagged types local to a
4034 function declaration. */
4035 int save_asm_written = TREE_ASM_WRITTEN (function_or_method_type);
4036 TREE_ASM_WRITTEN (function_or_method_type) = 1;
4037
4038 /* In the case where we are generating a formal types list for a C++
4039 non-static member function type, skip over the first thing on the
4040 TYPE_ARG_TYPES list because it only represents the type of the
4041 hidden `this pointer'. The debugger should be able to figure
4042 out (without being explicitly told) that this non-static member
4043 function type takes a `this pointer' and should be able to figure
4044 what the type of that hidden parameter is from the AT_member
4045 attribute of the parent TAG_subroutine_type DIE. */
4046
4047 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
4048 first_parm_type = TREE_CHAIN (first_parm_type);
4049
4050 /* Make our first pass over the list of formal parameter types and output
4051 a TAG_formal_parameter DIE for each one. */
4052
4053 for (link = first_parm_type; link; link = TREE_CHAIN (link))
4054 {
4055 formal_type = TREE_VALUE (link);
4056 if (formal_type == void_type_node)
4057 break;
4058
4059 /* Output a (nameless) DIE to represent the formal parameter itself. */
4060
4061 output_die (output_formal_parameter_die, formal_type);
4062 }
4063
4064 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
4065 DIE to the end of the parameter list. */
4066
4067 if (formal_type != void_type_node)
4068 output_die (output_unspecified_parameters_die, function_or_method_type);
4069
4070 /* Make our second (and final) pass over the list of formal parameter types
4071 and output DIEs to represent those types (as necessary). */
4072
4073 for (link = TYPE_ARG_TYPES (function_or_method_type);
4074 link;
4075 link = TREE_CHAIN (link))
4076 {
4077 formal_type = TREE_VALUE (link);
4078 if (formal_type == void_type_node)
4079 break;
4080
4081 output_type (formal_type, function_or_method_type);
4082 }
4083
4084 TREE_ASM_WRITTEN (function_or_method_type) = save_asm_written;
4085 }
4086 \f
4087 /* Remember a type in the pending_types_list. */
4088
4089 static void
4090 pend_type (type)
4091 register tree type;
4092 {
4093 if (pending_types == pending_types_allocated)
4094 {
4095 pending_types_allocated += PENDING_TYPES_INCREMENT;
4096 pending_types_list
4097 = (tree *) xrealloc (pending_types_list,
4098 sizeof (tree) * pending_types_allocated);
4099 }
4100 pending_types_list[pending_types++] = type;
4101
4102 /* Mark the pending type as having been output already (even though
4103 it hasn't been). This prevents the type from being added to the
4104 pending_types_list more than once. */
4105
4106 TREE_ASM_WRITTEN (type) = 1;
4107 }
4108
4109 /* Return non-zero if it is legitimate to output DIEs to represent a
4110 given type while we are generating the list of child DIEs for some
4111 DIE (e.g. a function or lexical block DIE) associated with a given scope.
4112
4113 See the comments within the function for a description of when it is
4114 considered legitimate to output DIEs for various kinds of types.
4115
4116 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
4117 or it may point to a BLOCK node (for types local to a block), or to a
4118 FUNCTION_DECL node (for types local to the heading of some function
4119 definition), or to a FUNCTION_TYPE node (for types local to the
4120 prototyped parameter list of a function type specification), or to a
4121 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
4122 (in the case of C++ nested types).
4123
4124 The `scope' parameter should likewise be NULL or should point to a
4125 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
4126 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
4127
4128 This function is used only for deciding when to "pend" and when to
4129 "un-pend" types to/from the pending_types_list.
4130
4131 Note that we sometimes make use of this "type pending" feature in a
4132 rather twisted way to temporarily delay the production of DIEs for the
4133 types of formal parameters. (We do this just to make svr4 SDB happy.)
4134 It order to delay the production of DIEs representing types of formal
4135 parameters, callers of this function supply `fake_containing_scope' as
4136 the `scope' parameter to this function. Given that fake_containing_scope
4137 is a tagged type which is *not* the containing scope for *any* other type,
4138 the desired effect is achieved, i.e. output of DIEs representing types
4139 is temporarily suspended, and any type DIEs which would have otherwise
4140 been output are instead placed onto the pending_types_list. Later on,
4141 we force these (temporarily pended) types to be output simply by calling
4142 `output_pending_types_for_scope' with an actual argument equal to the
4143 true scope of the types we temporarily pended. */
4144
4145 static inline int
4146 type_ok_for_scope (type, scope)
4147 register tree type;
4148 register tree scope;
4149 {
4150 /* Tagged types (i.e. struct, union, and enum types) must always be
4151 output only in the scopes where they actually belong (or else the
4152 scoping of their own tag names and the scoping of their member
4153 names will be incorrect). Non-tagged-types on the other hand can
4154 generally be output anywhere, except that svr4 SDB really doesn't
4155 want to see them nested within struct or union types, so here we
4156 say it is always OK to immediately output any such a (non-tagged)
4157 type, so long as we are not within such a context. Note that the
4158 only kinds of non-tagged types which we will be dealing with here
4159 (for C and C++ anyway) will be array types and function types. */
4160
4161 return is_tagged_type (type)
4162 ? (TYPE_CONTEXT (type) == scope
4163 /* Ignore namespaces for the moment. */
4164 || (scope == NULL_TREE
4165 && TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
4166 || (scope == NULL_TREE && is_tagged_type (TYPE_CONTEXT (type))
4167 && TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
4168 : (scope == NULL_TREE || ! is_tagged_type (scope));
4169 }
4170
4171 /* Output any pending types (from the pending_types list) which we can output
4172 now (taking into account the scope that we are working on now).
4173
4174 For each type output, remove the given type from the pending_types_list
4175 *before* we try to output it.
4176
4177 Note that we have to process the list in beginning-to-end order,
4178 because the call made here to output_type may cause yet more types
4179 to be added to the end of the list, and we may have to output some
4180 of them too. */
4181
4182 static void
4183 output_pending_types_for_scope (containing_scope)
4184 register tree containing_scope;
4185 {
4186 register unsigned i;
4187
4188 for (i = 0; i < pending_types; )
4189 {
4190 register tree type = pending_types_list[i];
4191
4192 if (type_ok_for_scope (type, containing_scope))
4193 {
4194 register tree *mover;
4195 register tree *limit;
4196
4197 pending_types--;
4198 limit = &pending_types_list[pending_types];
4199 for (mover = &pending_types_list[i]; mover < limit; mover++)
4200 *mover = *(mover+1);
4201
4202 /* Un-mark the type as having been output already (because it
4203 hasn't been, really). Then call output_type to generate a
4204 Dwarf representation of it. */
4205
4206 TREE_ASM_WRITTEN (type) = 0;
4207 output_type (type, containing_scope);
4208
4209 /* Don't increment the loop counter in this case because we
4210 have shifted all of the subsequent pending types down one
4211 element in the pending_types_list array. */
4212 }
4213 else
4214 i++;
4215 }
4216 }
4217
4218 static void
4219 output_type (type, containing_scope)
4220 register tree type;
4221 register tree containing_scope;
4222 {
4223 if (type == 0 || type == error_mark_node)
4224 return;
4225
4226 /* We are going to output a DIE to represent the unqualified version of
4227 this type (i.e. without any const or volatile qualifiers) so get
4228 the main variant (i.e. the unqualified version) of this type now. */
4229
4230 type = type_main_variant (type);
4231
4232 if (TREE_ASM_WRITTEN (type))
4233 {
4234 if (finalizing && AGGREGATE_TYPE_P (type))
4235 {
4236 register tree member;
4237
4238 /* Some of our nested types might not have been defined when we
4239 were written out before; force them out now. */
4240
4241 for (member = TYPE_FIELDS (type); member;
4242 member = TREE_CHAIN (member))
4243 if (TREE_CODE (member) == TYPE_DECL
4244 && ! TREE_ASM_WRITTEN (TREE_TYPE (member)))
4245 output_type (TREE_TYPE (member), containing_scope);
4246 }
4247 return;
4248 }
4249
4250 /* If this is a nested type whose containing class hasn't been
4251 written out yet, writing it out will cover this one, too. */
4252
4253 if (TYPE_CONTEXT (type)
4254 && TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type))) == 't'
4255 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
4256 {
4257 output_type (TYPE_CONTEXT (type), containing_scope);
4258 return;
4259 }
4260
4261 /* Don't generate any DIEs for this type now unless it is OK to do so
4262 (based upon what `type_ok_for_scope' tells us). */
4263
4264 if (! type_ok_for_scope (type, containing_scope))
4265 {
4266 pend_type (type);
4267 return;
4268 }
4269
4270 switch (TREE_CODE (type))
4271 {
4272 case ERROR_MARK:
4273 break;
4274
4275 case POINTER_TYPE:
4276 case REFERENCE_TYPE:
4277 /* Prevent infinite recursion in cases where this is a recursive
4278 type. Recursive types are possible in Ada. */
4279 TREE_ASM_WRITTEN (type) = 1;
4280 /* For these types, all that is required is that we output a DIE
4281 (or a set of DIEs) to represent the "basis" type. */
4282 output_type (TREE_TYPE (type), containing_scope);
4283 break;
4284
4285 case OFFSET_TYPE:
4286 /* This code is used for C++ pointer-to-data-member types. */
4287 /* Output a description of the relevant class type. */
4288 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
4289 /* Output a description of the type of the object pointed to. */
4290 output_type (TREE_TYPE (type), containing_scope);
4291 /* Now output a DIE to represent this pointer-to-data-member type
4292 itself. */
4293 output_die (output_ptr_to_mbr_type_die, type);
4294 break;
4295
4296 case SET_TYPE:
4297 output_type (TYPE_DOMAIN (type), containing_scope);
4298 output_die (output_set_type_die, type);
4299 break;
4300
4301 case FILE_TYPE:
4302 output_type (TREE_TYPE (type), containing_scope);
4303 abort (); /* No way to represent these in Dwarf yet! */
4304 break;
4305
4306 case FUNCTION_TYPE:
4307 /* Force out return type (in case it wasn't forced out already). */
4308 output_type (TREE_TYPE (type), containing_scope);
4309 output_die (output_subroutine_type_die, type);
4310 output_formal_types (type);
4311 end_sibling_chain ();
4312 break;
4313
4314 case METHOD_TYPE:
4315 /* Force out return type (in case it wasn't forced out already). */
4316 output_type (TREE_TYPE (type), containing_scope);
4317 output_die (output_subroutine_type_die, type);
4318 output_formal_types (type);
4319 end_sibling_chain ();
4320 break;
4321
4322 case ARRAY_TYPE:
4323 if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
4324 {
4325 output_type (TREE_TYPE (type), containing_scope);
4326 output_die (output_string_type_die, type);
4327 }
4328 else
4329 {
4330 register tree element_type;
4331
4332 element_type = TREE_TYPE (type);
4333 while (TREE_CODE (element_type) == ARRAY_TYPE)
4334 element_type = TREE_TYPE (element_type);
4335
4336 output_type (element_type, containing_scope);
4337 output_die (output_array_type_die, type);
4338 }
4339 break;
4340
4341 case ENUMERAL_TYPE:
4342 case RECORD_TYPE:
4343 case UNION_TYPE:
4344 case QUAL_UNION_TYPE:
4345
4346 /* For a non-file-scope tagged type, we can always go ahead and
4347 output a Dwarf description of this type right now, even if
4348 the type in question is still incomplete, because if this
4349 local type *was* ever completed anywhere within its scope,
4350 that complete definition would already have been attached to
4351 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4352 node by the time we reach this point. That's true because of the
4353 way the front-end does its processing of file-scope declarations (of
4354 functions and class types) within which other types might be
4355 nested. The C and C++ front-ends always gobble up such "local
4356 scope" things en-mass before they try to output *any* debugging
4357 information for any of the stuff contained inside them and thus,
4358 we get the benefit here of what is (in effect) a pre-resolution
4359 of forward references to tagged types in local scopes.
4360
4361 Note however that for file-scope tagged types we cannot assume
4362 that such pre-resolution of forward references has taken place.
4363 A given file-scope tagged type may appear to be incomplete when
4364 we reach this point, but it may yet be given a full definition
4365 (at file-scope) later on during compilation. In order to avoid
4366 generating a premature (and possibly incorrect) set of Dwarf
4367 DIEs for such (as yet incomplete) file-scope tagged types, we
4368 generate nothing at all for as-yet incomplete file-scope tagged
4369 types here unless we are making our special "finalization" pass
4370 for file-scope things at the very end of compilation. At that
4371 time, we will certainly know as much about each file-scope tagged
4372 type as we are ever going to know, so at that point in time, we
4373 can safely generate correct Dwarf descriptions for these file-
4374 scope tagged types. */
4375
4376 if (TYPE_SIZE (type) == 0
4377 && (TYPE_CONTEXT (type) == NULL
4378 || (TREE_CODE_CLASS (TREE_CODE (TYPE_CONTEXT (type))) == 't'
4379 && TREE_CODE (TYPE_CONTEXT (type)) != FUNCTION_TYPE
4380 && TREE_CODE (TYPE_CONTEXT (type)) != METHOD_TYPE))
4381 && !finalizing)
4382 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4383
4384 /* Prevent infinite recursion in cases where the type of some
4385 member of this type is expressed in terms of this type itself. */
4386
4387 TREE_ASM_WRITTEN (type) = 1;
4388
4389 /* Output a DIE to represent the tagged type itself. */
4390
4391 switch (TREE_CODE (type))
4392 {
4393 case ENUMERAL_TYPE:
4394 output_die (output_enumeration_type_die, type);
4395 return; /* a special case -- nothing left to do so just return */
4396
4397 case RECORD_TYPE:
4398 output_die (output_structure_type_die, type);
4399 break;
4400
4401 case UNION_TYPE:
4402 case QUAL_UNION_TYPE:
4403 output_die (output_union_type_die, type);
4404 break;
4405
4406 default:
4407 abort (); /* Should never happen. */
4408 }
4409
4410 /* If this is not an incomplete type, output descriptions of
4411 each of its members.
4412
4413 Note that as we output the DIEs necessary to represent the
4414 members of this record or union type, we will also be trying
4415 to output DIEs to represent the *types* of those members.
4416 However the `output_type' function (above) will specifically
4417 avoid generating type DIEs for member types *within* the list
4418 of member DIEs for this (containing) type execpt for those
4419 types (of members) which are explicitly marked as also being
4420 members of this (containing) type themselves. The g++ front-
4421 end can force any given type to be treated as a member of some
4422 other (containing) type by setting the TYPE_CONTEXT of the
4423 given (member) type to point to the TREE node representing the
4424 appropriate (containing) type.
4425 */
4426
4427 if (TYPE_SIZE (type))
4428 {
4429 /* First output info about the base classes. */
4430 if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
4431 {
4432 register tree bases = TYPE_BINFO_BASETYPES (type);
4433 register int n_bases = TREE_VEC_LENGTH (bases);
4434 register int i;
4435
4436 for (i = 0; i < n_bases; i++)
4437 output_die (output_inheritance_die, TREE_VEC_ELT (bases, i));
4438 }
4439
4440 ++in_class;
4441
4442 {
4443 register tree normal_member;
4444
4445 /* Now output info about the data members and type members. */
4446
4447 for (normal_member = TYPE_FIELDS (type);
4448 normal_member;
4449 normal_member = TREE_CHAIN (normal_member))
4450 output_decl (normal_member, type);
4451 }
4452
4453 {
4454 register tree func_member;
4455
4456 /* Now output info about the function members (if any). */
4457
4458 for (func_member = TYPE_METHODS (type);
4459 func_member;
4460 func_member = TREE_CHAIN (func_member))
4461 output_decl (func_member, type);
4462 }
4463
4464 --in_class;
4465
4466 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4467 scopes (at least in C++) so we must now output any nested
4468 pending types which are local just to this type. */
4469
4470 output_pending_types_for_scope (type);
4471
4472 end_sibling_chain (); /* Terminate member chain. */
4473 }
4474
4475 break;
4476
4477 case VOID_TYPE:
4478 case INTEGER_TYPE:
4479 case REAL_TYPE:
4480 case COMPLEX_TYPE:
4481 case BOOLEAN_TYPE:
4482 case CHAR_TYPE:
4483 break; /* No DIEs needed for fundamental types. */
4484
4485 case LANG_TYPE: /* No Dwarf representation currently defined. */
4486 break;
4487
4488 default:
4489 abort ();
4490 }
4491
4492 TREE_ASM_WRITTEN (type) = 1;
4493 }
4494
4495 static void
4496 output_tagged_type_instantiation (type)
4497 register tree type;
4498 {
4499 if (type == 0 || type == error_mark_node)
4500 return;
4501
4502 /* We are going to output a DIE to represent the unqualified version of
4503 this type (i.e. without any const or volatile qualifiers) so make
4504 sure that we have the main variant (i.e. the unqualified version) of
4505 this type now. */
4506
4507 if (type != type_main_variant (type))
4508 abort ();
4509
4510 if (!TREE_ASM_WRITTEN (type))
4511 abort ();
4512
4513 switch (TREE_CODE (type))
4514 {
4515 case ERROR_MARK:
4516 break;
4517
4518 case ENUMERAL_TYPE:
4519 output_die (output_inlined_enumeration_type_die, type);
4520 break;
4521
4522 case RECORD_TYPE:
4523 output_die (output_inlined_structure_type_die, type);
4524 break;
4525
4526 case UNION_TYPE:
4527 case QUAL_UNION_TYPE:
4528 output_die (output_inlined_union_type_die, type);
4529 break;
4530
4531 default:
4532 abort (); /* Should never happen. */
4533 }
4534 }
4535 \f
4536 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
4537 the things which are local to the given block. */
4538
4539 static void
4540 output_block (stmt, depth)
4541 register tree stmt;
4542 int depth;
4543 {
4544 register int must_output_die = 0;
4545 register tree origin;
4546 register enum tree_code origin_code;
4547
4548 /* Ignore blocks never really used to make RTL. */
4549
4550 if (! stmt || ! TREE_USED (stmt))
4551 return;
4552
4553 /* Determine the "ultimate origin" of this block. This block may be an
4554 inlined instance of an inlined instance of inline function, so we
4555 have to trace all of the way back through the origin chain to find
4556 out what sort of node actually served as the original seed for the
4557 creation of the current block. */
4558
4559 origin = block_ultimate_origin (stmt);
4560 origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
4561
4562 /* Determine if we need to output any Dwarf DIEs at all to represent this
4563 block. */
4564
4565 if (origin_code == FUNCTION_DECL)
4566 /* The outer scopes for inlinings *must* always be represented. We
4567 generate TAG_inlined_subroutine DIEs for them. (See below.) */
4568 must_output_die = 1;
4569 else
4570 {
4571 /* In the case where the current block represents an inlining of the
4572 "body block" of an inline function, we must *NOT* output any DIE
4573 for this block because we have already output a DIE to represent
4574 the whole inlined function scope and the "body block" of any
4575 function doesn't really represent a different scope according to
4576 ANSI C rules. So we check here to make sure that this block does
4577 not represent a "body block inlining" before trying to set the
4578 `must_output_die' flag. */
4579
4580 if (! is_body_block (origin ? origin : stmt))
4581 {
4582 /* Determine if this block directly contains any "significant"
4583 local declarations which we will need to output DIEs for. */
4584
4585 if (debug_info_level > DINFO_LEVEL_TERSE)
4586 /* We are not in terse mode so *any* local declaration counts
4587 as being a "significant" one. */
4588 must_output_die = (BLOCK_VARS (stmt) != NULL);
4589 else
4590 {
4591 register tree decl;
4592
4593 /* We are in terse mode, so only local (nested) function
4594 definitions count as "significant" local declarations. */
4595
4596 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4597 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
4598 {
4599 must_output_die = 1;
4600 break;
4601 }
4602 }
4603 }
4604 }
4605
4606 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
4607 DIE for any block which contains no significant local declarations
4608 at all. Rather, in such cases we just call `output_decls_for_scope'
4609 so that any needed Dwarf info for any sub-blocks will get properly
4610 generated. Note that in terse mode, our definition of what constitutes
4611 a "significant" local declaration gets restricted to include only
4612 inlined function instances and local (nested) function definitions. */
4613
4614 if (origin_code == FUNCTION_DECL && BLOCK_ABSTRACT (stmt))
4615 /* We don't care about an abstract inlined subroutine. */;
4616 else if (must_output_die)
4617 {
4618 output_die ((origin_code == FUNCTION_DECL)
4619 ? output_inlined_subroutine_die
4620 : output_lexical_block_die,
4621 stmt);
4622 output_decls_for_scope (stmt, depth);
4623 end_sibling_chain ();
4624 }
4625 else
4626 output_decls_for_scope (stmt, depth);
4627 }
4628
4629 /* Output all of the decls declared within a given scope (also called
4630 a `binding contour') and (recursively) all of it's sub-blocks. */
4631
4632 static void
4633 output_decls_for_scope (stmt, depth)
4634 register tree stmt;
4635 int depth;
4636 {
4637 /* Ignore blocks never really used to make RTL. */
4638
4639 if (! stmt || ! TREE_USED (stmt))
4640 return;
4641
4642 if (! BLOCK_ABSTRACT (stmt) && depth > 0)
4643 next_block_number++;
4644
4645 /* Output the DIEs to represent all of the data objects, functions,
4646 typedefs, and tagged types declared directly within this block
4647 but not within any nested sub-blocks. */
4648
4649 {
4650 register tree decl;
4651
4652 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
4653 output_decl (decl, stmt);
4654 }
4655
4656 output_pending_types_for_scope (stmt);
4657
4658 /* Output the DIEs to represent all sub-blocks (and the items declared
4659 therein) of this block. */
4660
4661 {
4662 register tree subblocks;
4663
4664 for (subblocks = BLOCK_SUBBLOCKS (stmt);
4665 subblocks;
4666 subblocks = BLOCK_CHAIN (subblocks))
4667 output_block (subblocks, depth + 1);
4668 }
4669 }
4670
4671 /* Is this a typedef we can avoid emitting? */
4672
4673 inline static int
4674 is_redundant_typedef (decl)
4675 register tree decl;
4676 {
4677 if (TYPE_DECL_IS_STUB (decl))
4678 return 1;
4679 if (DECL_ARTIFICIAL (decl)
4680 && DECL_CONTEXT (decl)
4681 && is_tagged_type (DECL_CONTEXT (decl))
4682 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl))) == TYPE_DECL
4683 && DECL_NAME (decl) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))))
4684 /* Also ignore the artificial member typedef for the class name. */
4685 return 1;
4686 return 0;
4687 }
4688
4689 /* Output Dwarf .debug information for a decl described by DECL. */
4690
4691 static void
4692 output_decl (decl, containing_scope)
4693 register tree decl;
4694 register tree containing_scope;
4695 {
4696 /* Make a note of the decl node we are going to be working on. We may
4697 need to give the user the source coordinates of where it appeared in
4698 case we notice (later on) that something about it looks screwy. */
4699
4700 dwarf_last_decl = decl;
4701
4702 if (TREE_CODE (decl) == ERROR_MARK)
4703 return;
4704
4705 /* If a structure is declared within an initialization, e.g. as the
4706 operand of a sizeof, then it will not have a name. We don't want
4707 to output a DIE for it, as the tree nodes are in the temporary obstack */
4708
4709 if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
4710 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
4711 && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
4712 || (TYPE_FIELDS (TREE_TYPE (decl))
4713 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
4714 return;
4715
4716 /* If this ..._DECL node is marked to be ignored, then ignore it.
4717 But don't ignore a function definition, since that would screw
4718 up our count of blocks, and that it turn will completely screw up the
4719 labels we will reference in subsequent AT_low_pc and AT_high_pc
4720 attributes (for subsequent blocks). */
4721
4722 if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
4723 return;
4724
4725 switch (TREE_CODE (decl))
4726 {
4727 case CONST_DECL:
4728 /* The individual enumerators of an enum type get output when we
4729 output the Dwarf representation of the relevant enum type itself. */
4730 break;
4731
4732 case FUNCTION_DECL:
4733 /* If we are in terse mode, don't output any DIEs to represent
4734 mere function declarations. Also, if we are conforming
4735 to the DWARF version 1 specification, don't output DIEs for
4736 mere function declarations. */
4737
4738 if (DECL_INITIAL (decl) == NULL_TREE)
4739 #if (DWARF_VERSION > 1)
4740 if (debug_info_level <= DINFO_LEVEL_TERSE)
4741 #endif
4742 break;
4743
4744 /* Before we describe the FUNCTION_DECL itself, make sure that we
4745 have described its return type. */
4746
4747 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
4748
4749 {
4750 /* And its containing type. */
4751 register tree origin = decl_class_context (decl);
4752 if (origin)
4753 output_type (origin, containing_scope);
4754 }
4755
4756 /* If the following DIE will represent a function definition for a
4757 function with "extern" linkage, output a special "pubnames" DIE
4758 label just ahead of the actual DIE. A reference to this label
4759 was already generated in the .debug_pubnames section sub-entry
4760 for this function definition. */
4761
4762 if (TREE_PUBLIC (decl))
4763 {
4764 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4765
4766 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
4767 ASM_OUTPUT_LABEL (asm_out_file, label);
4768 }
4769
4770 /* Now output a DIE to represent the function itself. */
4771
4772 output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
4773 ? output_global_subroutine_die
4774 : output_local_subroutine_die,
4775 decl);
4776
4777 /* Now output descriptions of the arguments for this function.
4778 This gets (unnecessarily?) complex because of the fact that
4779 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
4780 cases where there was a trailing `...' at the end of the formal
4781 parameter list. In order to find out if there was a trailing
4782 ellipsis or not, we must instead look at the type associated
4783 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
4784 If the chain of type nodes hanging off of this FUNCTION_TYPE node
4785 ends with a void_type_node then there should *not* be an ellipsis
4786 at the end. */
4787
4788 /* In the case where we are describing a mere function declaration, all
4789 we need to do here (and all we *can* do here) is to describe
4790 the *types* of its formal parameters. */
4791
4792 if (decl != current_function_decl || in_class)
4793 output_formal_types (TREE_TYPE (decl));
4794 else
4795 {
4796 /* Generate DIEs to represent all known formal parameters */
4797
4798 register tree arg_decls = DECL_ARGUMENTS (decl);
4799 register tree parm;
4800
4801 /* WARNING! Kludge zone ahead! Here we have a special
4802 hack for svr4 SDB compatibility. Instead of passing the
4803 current FUNCTION_DECL node as the second parameter (i.e.
4804 the `containing_scope' parameter) to `output_decl' (as
4805 we ought to) we instead pass a pointer to our own private
4806 fake_containing_scope node. That node is a RECORD_TYPE
4807 node which NO OTHER TYPE may ever actually be a member of.
4808
4809 This pointer will ultimately get passed into `output_type'
4810 as its `containing_scope' parameter. `Output_type' will
4811 then perform its part in the hack... i.e. it will pend
4812 the type of the formal parameter onto the pending_types
4813 list. Later on, when we are done generating the whole
4814 sequence of formal parameter DIEs for this function
4815 definition, we will un-pend all previously pended types
4816 of formal parameters for this function definition.
4817
4818 This whole kludge prevents any type DIEs from being
4819 mixed in with the formal parameter DIEs. That's good
4820 because svr4 SDB believes that the list of formal
4821 parameter DIEs for a function ends wherever the first
4822 non-formal-parameter DIE appears. Thus, we have to
4823 keep the formal parameter DIEs segregated. They must
4824 all appear (consecutively) at the start of the list of
4825 children for the DIE representing the function definition.
4826 Then (and only then) may we output any additional DIEs
4827 needed to represent the types of these formal parameters.
4828 */
4829
4830 /*
4831 When generating DIEs, generate the unspecified_parameters
4832 DIE instead if we come across the arg "__builtin_va_alist"
4833 */
4834
4835 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
4836 if (TREE_CODE (parm) == PARM_DECL)
4837 {
4838 if (DECL_NAME(parm) &&
4839 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
4840 "__builtin_va_alist") )
4841 output_die (output_unspecified_parameters_die, decl);
4842 else
4843 output_decl (parm, fake_containing_scope);
4844 }
4845
4846 /*
4847 Now that we have finished generating all of the DIEs to
4848 represent the formal parameters themselves, force out
4849 any DIEs needed to represent their types. We do this
4850 simply by un-pending all previously pended types which
4851 can legitimately go into the chain of children DIEs for
4852 the current FUNCTION_DECL.
4853 */
4854
4855 output_pending_types_for_scope (decl);
4856
4857 /*
4858 Decide whether we need a unspecified_parameters DIE at the end.
4859 There are 2 more cases to do this for:
4860 1) the ansi ... declaration - this is detectable when the end
4861 of the arg list is not a void_type_node
4862 2) an unprototyped function declaration (not a definition). This
4863 just means that we have no info about the parameters at all.
4864 */
4865
4866 {
4867 register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
4868
4869 if (fn_arg_types)
4870 {
4871 /* this is the prototyped case, check for ... */
4872 if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
4873 output_die (output_unspecified_parameters_die, decl);
4874 }
4875 else
4876 {
4877 /* this is unprototyped, check for undefined (just declaration) */
4878 if (!DECL_INITIAL (decl))
4879 output_die (output_unspecified_parameters_die, decl);
4880 }
4881 }
4882
4883 /* Output Dwarf info for all of the stuff within the body of the
4884 function (if it has one - it may be just a declaration). */
4885
4886 {
4887 register tree outer_scope = DECL_INITIAL (decl);
4888
4889 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
4890 {
4891 /* Note that here, `outer_scope' is a pointer to the outermost
4892 BLOCK node created to represent a function.
4893 This outermost BLOCK actually represents the outermost
4894 binding contour for the function, i.e. the contour in which
4895 the function's formal parameters and labels get declared.
4896
4897 Curiously, it appears that the front end doesn't actually
4898 put the PARM_DECL nodes for the current function onto the
4899 BLOCK_VARS list for this outer scope. (They are strung
4900 off of the DECL_ARGUMENTS list for the function instead.)
4901 The BLOCK_VARS list for the `outer_scope' does provide us
4902 with a list of the LABEL_DECL nodes for the function however,
4903 and we output DWARF info for those here.
4904
4905 Just within the `outer_scope' there will be a BLOCK node
4906 representing the function's outermost pair of curly braces,
4907 and any blocks used for the base and member initializers of
4908 a C++ constructor function. */
4909
4910 output_decls_for_scope (outer_scope, 0);
4911
4912 /* Finally, force out any pending types which are local to the
4913 outermost block of this function definition. These will
4914 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
4915 node itself. */
4916
4917 output_pending_types_for_scope (decl);
4918 }
4919 }
4920 }
4921
4922 /* Generate a terminator for the list of stuff `owned' by this
4923 function. */
4924
4925 end_sibling_chain ();
4926
4927 break;
4928
4929 case TYPE_DECL:
4930 /* If we are in terse mode, don't generate any DIEs to represent
4931 any actual typedefs. Note that even when we are in terse mode,
4932 we must still output DIEs to represent those tagged types which
4933 are used (directly or indirectly) in the specification of either
4934 a return type or a formal parameter type of some function. */
4935
4936 if (debug_info_level <= DINFO_LEVEL_TERSE)
4937 if (! TYPE_DECL_IS_STUB (decl)
4938 || (! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)) && ! in_class))
4939 return;
4940
4941 /* In the special case of a TYPE_DECL node representing
4942 the declaration of some type tag, if the given TYPE_DECL is
4943 marked as having been instantiated from some other (original)
4944 TYPE_DECL node (e.g. one which was generated within the original
4945 definition of an inline function) we have to generate a special
4946 (abbreviated) TAG_structure_type, TAG_union_type, or
4947 TAG_enumeration-type DIE here. */
4948
4949 if (TYPE_DECL_IS_STUB (decl) && DECL_ABSTRACT_ORIGIN (decl))
4950 {
4951 output_tagged_type_instantiation (TREE_TYPE (decl));
4952 return;
4953 }
4954
4955 output_type (TREE_TYPE (decl), containing_scope);
4956
4957 if (! is_redundant_typedef (decl))
4958 /* Output a DIE to represent the typedef itself. */
4959 output_die (output_typedef_die, decl);
4960 break;
4961
4962 case LABEL_DECL:
4963 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4964 output_die (output_label_die, decl);
4965 break;
4966
4967 case VAR_DECL:
4968 /* If we are conforming to the DWARF version 1 specification, don't
4969 generated any DIEs to represent mere external object declarations. */
4970
4971 #if (DWARF_VERSION <= 1)
4972 if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
4973 break;
4974 #endif
4975
4976 /* If we are in terse mode, don't generate any DIEs to represent
4977 any variable declarations or definitions. */
4978
4979 if (debug_info_level <= DINFO_LEVEL_TERSE)
4980 break;
4981
4982 /* Output any DIEs that are needed to specify the type of this data
4983 object. */
4984
4985 output_type (TREE_TYPE (decl), containing_scope);
4986
4987 {
4988 /* And its containing type. */
4989 register tree origin = decl_class_context (decl);
4990 if (origin)
4991 output_type (origin, containing_scope);
4992 }
4993
4994 /* If the following DIE will represent a data object definition for a
4995 data object with "extern" linkage, output a special "pubnames" DIE
4996 label just ahead of the actual DIE. A reference to this label
4997 was already generated in the .debug_pubnames section sub-entry
4998 for this data object definition. */
4999
5000 if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
5001 {
5002 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5003
5004 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
5005 ASM_OUTPUT_LABEL (asm_out_file, label);
5006 }
5007
5008 /* Now output the DIE to represent the data object itself. This gets
5009 complicated because of the possibility that the VAR_DECL really
5010 represents an inlined instance of a formal parameter for an inline
5011 function. */
5012
5013 {
5014 register void (*func) PROTO((void *));
5015 register tree origin = decl_ultimate_origin (decl);
5016
5017 if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
5018 func = output_formal_parameter_die;
5019 else
5020 {
5021 if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
5022 func = output_global_variable_die;
5023 else
5024 func = output_local_variable_die;
5025 }
5026 output_die (func, decl);
5027 }
5028 break;
5029
5030 case FIELD_DECL:
5031 /* Ignore the nameless fields that are used to skip bits. */
5032 if (DECL_NAME (decl) != 0)
5033 {
5034 output_type (member_declared_type (decl), containing_scope);
5035 output_die (output_member_die, decl);
5036 }
5037 break;
5038
5039 case PARM_DECL:
5040 /* Force out the type of this formal, if it was not forced out yet.
5041 Note that here we can run afowl of a bug in "classic" svr4 SDB.
5042 It should be able to grok the presence of type DIEs within a list
5043 of TAG_formal_parameter DIEs, but it doesn't. */
5044
5045 output_type (TREE_TYPE (decl), containing_scope);
5046 output_die (output_formal_parameter_die, decl);
5047 break;
5048
5049 default:
5050 abort ();
5051 }
5052 }
5053 \f
5054 void
5055 dwarfout_file_scope_decl (decl, set_finalizing)
5056 register tree decl;
5057 register int set_finalizing;
5058 {
5059 if (TREE_CODE (decl) == ERROR_MARK)
5060 return;
5061
5062 /* If this ..._DECL node is marked to be ignored, then ignore it. We
5063 gotta hope that the node in question doesn't represent a function
5064 definition. If it does, then totally ignoring it is bound to screw
5065 up our count of blocks, and that it turn will completely screw up the
5066 labels we will reference in subsequent AT_low_pc and AT_high_pc
5067 attributes (for subsequent blocks). (It's too bad that BLOCK nodes
5068 don't carry their own sequence numbers with them!) */
5069
5070 if (DECL_IGNORED_P (decl))
5071 {
5072 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
5073 abort ();
5074 return;
5075 }
5076
5077 switch (TREE_CODE (decl))
5078 {
5079 case FUNCTION_DECL:
5080
5081 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
5082 a builtin function. Explicit programmer-supplied declarations of
5083 these same functions should NOT be ignored however. */
5084
5085 if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
5086 return;
5087
5088 /* What we would really like to do here is to filter out all mere
5089 file-scope declarations of file-scope functions which are never
5090 referenced later within this translation unit (and keep all of
5091 ones that *are* referenced later on) but we aren't clairvoyant,
5092 so we have no idea which functions will be referenced in the
5093 future (i.e. later on within the current translation unit).
5094 So here we just ignore all file-scope function declarations
5095 which are not also definitions. If and when the debugger needs
5096 to know something about these functions, it wil have to hunt
5097 around and find the DWARF information associated with the
5098 *definition* of the function.
5099
5100 Note that we can't just check `DECL_EXTERNAL' to find out which
5101 FUNCTION_DECL nodes represent definitions and which ones represent
5102 mere declarations. We have to check `DECL_INITIAL' instead. That's
5103 because the C front-end supports some weird semantics for "extern
5104 inline" function definitions. These can get inlined within the
5105 current translation unit (an thus, we need to generate DWARF info
5106 for their abstract instances so that the DWARF info for the
5107 concrete inlined instances can have something to refer to) but
5108 the compiler never generates any out-of-lines instances of such
5109 things (despite the fact that they *are* definitions). The
5110 important point is that the C front-end marks these "extern inline"
5111 functions as DECL_EXTERNAL, but we need to generate DWARF for them
5112 anyway.
5113
5114 Note that the C++ front-end also plays some similar games for inline
5115 function definitions appearing within include files which also
5116 contain `#pragma interface' pragmas. */
5117
5118 if (DECL_INITIAL (decl) == NULL_TREE)
5119 return;
5120
5121 if (TREE_PUBLIC (decl)
5122 && ! DECL_EXTERNAL (decl)
5123 && ! DECL_ABSTRACT (decl))
5124 {
5125 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5126
5127 /* Output a .debug_pubnames entry for a public function
5128 defined in this compilation unit. */
5129
5130 fputc ('\n', asm_out_file);
5131 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5132 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
5133 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
5134 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
5135 IDENTIFIER_POINTER (DECL_NAME (decl)));
5136 ASM_OUTPUT_POP_SECTION (asm_out_file);
5137 }
5138
5139 break;
5140
5141 case VAR_DECL:
5142
5143 /* Ignore this VAR_DECL if it refers to a file-scope extern data
5144 object declaration and if the declaration was never even
5145 referenced from within this entire compilation unit. We
5146 suppress these DIEs in order to save space in the .debug section
5147 (by eliminating entries which are probably useless). Note that
5148 we must not suppress block-local extern declarations (whether
5149 used or not) because that would screw-up the debugger's name
5150 lookup mechanism and cause it to miss things which really ought
5151 to be in scope at a given point. */
5152
5153 if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
5154 return;
5155
5156 if (TREE_PUBLIC (decl)
5157 && ! DECL_EXTERNAL (decl)
5158 && GET_CODE (DECL_RTL (decl)) == MEM
5159 && ! DECL_ABSTRACT (decl))
5160 {
5161 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5162
5163 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5164 {
5165 /* Output a .debug_pubnames entry for a public variable
5166 defined in this compilation unit. */
5167
5168 fputc ('\n', asm_out_file);
5169 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5170 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
5171 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
5172 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
5173 IDENTIFIER_POINTER (DECL_NAME (decl)));
5174 ASM_OUTPUT_POP_SECTION (asm_out_file);
5175 }
5176
5177 if (DECL_INITIAL (decl) == NULL)
5178 {
5179 /* Output a .debug_aranges entry for a public variable
5180 which is tentatively defined in this compilation unit. */
5181
5182 fputc ('\n', asm_out_file);
5183 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5184 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
5185 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
5186 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
5187 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
5188 ASM_OUTPUT_POP_SECTION (asm_out_file);
5189 }
5190 }
5191
5192 /* If we are in terse mode, don't generate any DIEs to represent
5193 any variable declarations or definitions. */
5194
5195 if (debug_info_level <= DINFO_LEVEL_TERSE)
5196 return;
5197
5198 break;
5199
5200 case TYPE_DECL:
5201 /* Don't bother trying to generate any DIEs to represent any of the
5202 normal built-in types for the language we are compiling, except
5203 in cases where the types in question are *not* DWARF fundamental
5204 types. We make an exception in the case of non-fundamental types
5205 for the sake of objective C (and perhaps C++) because the GNU
5206 front-ends for these languages may in fact create certain "built-in"
5207 types which are (for example) RECORD_TYPEs. In such cases, we
5208 really need to output these (non-fundamental) types because other
5209 DIEs may contain references to them. */
5210
5211 /* Also ignore language dependent types here, because they are probably
5212 also built-in types. If we didn't ignore them, then we would get
5213 references to undefined labels because output_type doesn't support
5214 them. So, for now, we need to ignore them to avoid assembler
5215 errors. */
5216
5217 /* ??? This code is different than the equivalent code in dwarf2out.c.
5218 The dwarf2out.c code is probably more correct. */
5219
5220 if (DECL_SOURCE_LINE (decl) == 0
5221 && (type_is_fundamental (TREE_TYPE (decl))
5222 || TREE_CODE (TREE_TYPE (decl)) == LANG_TYPE))
5223 return;
5224
5225 /* If we are in terse mode, don't generate any DIEs to represent
5226 any actual typedefs. Note that even when we are in terse mode,
5227 we must still output DIEs to represent those tagged types which
5228 are used (directly or indirectly) in the specification of either
5229 a return type or a formal parameter type of some function. */
5230
5231 if (debug_info_level <= DINFO_LEVEL_TERSE)
5232 if (! TYPE_DECL_IS_STUB (decl)
5233 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
5234 return;
5235
5236 break;
5237
5238 default:
5239 return;
5240 }
5241
5242 fputc ('\n', asm_out_file);
5243 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5244 finalizing = set_finalizing;
5245 output_decl (decl, NULL_TREE);
5246
5247 /* NOTE: The call above to `output_decl' may have caused one or more
5248 file-scope named types (i.e. tagged types) to be placed onto the
5249 pending_types_list. We have to get those types off of that list
5250 at some point, and this is the perfect time to do it. If we didn't
5251 take them off now, they might still be on the list when cc1 finally
5252 exits. That might be OK if it weren't for the fact that when we put
5253 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
5254 for these types, and that causes them never to be output unless
5255 `output_pending_types_for_scope' takes them off of the list and un-sets
5256 their TREE_ASM_WRITTEN flags. */
5257
5258 output_pending_types_for_scope (NULL_TREE);
5259
5260 /* The above call should have totally emptied the pending_types_list
5261 if this is not a nested function or class. If this is a nested type,
5262 then the remaining pending_types will be emitted when the containing type
5263 is handled. */
5264
5265 if (! DECL_CONTEXT (decl))
5266 {
5267 if (pending_types != 0)
5268 abort ();
5269 }
5270
5271 ASM_OUTPUT_POP_SECTION (asm_out_file);
5272
5273 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
5274 current_funcdef_number++;
5275 }
5276 \f
5277 /* Output a marker (i.e. a label) for the beginning of the generated code
5278 for a lexical block. */
5279
5280 void
5281 dwarfout_begin_block (blocknum)
5282 register unsigned blocknum;
5283 {
5284 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5285
5286 function_section (current_function_decl);
5287 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
5288 ASM_OUTPUT_LABEL (asm_out_file, label);
5289 }
5290
5291 /* Output a marker (i.e. a label) for the end of the generated code
5292 for a lexical block. */
5293
5294 void
5295 dwarfout_end_block (blocknum)
5296 register unsigned blocknum;
5297 {
5298 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5299
5300 function_section (current_function_decl);
5301 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
5302 ASM_OUTPUT_LABEL (asm_out_file, label);
5303 }
5304
5305 /* Output a marker (i.e. a label) at a point in the assembly code which
5306 corresponds to a given source level label. */
5307
5308 void
5309 dwarfout_label (insn)
5310 register rtx insn;
5311 {
5312 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5313 {
5314 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5315
5316 function_section (current_function_decl);
5317 sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
5318 (unsigned) INSN_UID (insn));
5319 ASM_OUTPUT_LABEL (asm_out_file, label);
5320 }
5321 }
5322
5323 /* Output a marker (i.e. a label) for the point in the generated code where
5324 the real body of the function begins (after parameters have been moved
5325 to their home locations). */
5326
5327 void
5328 dwarfout_begin_function ()
5329 {
5330 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5331
5332 if (! use_gnu_debug_info_extensions)
5333 return;
5334 function_section (current_function_decl);
5335 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
5336 ASM_OUTPUT_LABEL (asm_out_file, label);
5337 }
5338
5339 /* Output a marker (i.e. a label) for the point in the generated code where
5340 the real body of the function ends (just before the epilogue code). */
5341
5342 void
5343 dwarfout_end_function ()
5344 {
5345 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5346
5347 if (! use_gnu_debug_info_extensions)
5348 return;
5349 function_section (current_function_decl);
5350 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
5351 ASM_OUTPUT_LABEL (asm_out_file, label);
5352 }
5353
5354 /* Output a marker (i.e. a label) for the absolute end of the generated code
5355 for a function definition. This gets called *after* the epilogue code
5356 has been generated. */
5357
5358 void
5359 dwarfout_end_epilogue ()
5360 {
5361 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5362
5363 /* Output a label to mark the endpoint of the code generated for this
5364 function. */
5365
5366 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
5367 ASM_OUTPUT_LABEL (asm_out_file, label);
5368 }
5369
5370 static void
5371 shuffle_filename_entry (new_zeroth)
5372 register filename_entry *new_zeroth;
5373 {
5374 filename_entry temp_entry;
5375 register filename_entry *limit_p;
5376 register filename_entry *move_p;
5377
5378 if (new_zeroth == &filename_table[0])
5379 return;
5380
5381 temp_entry = *new_zeroth;
5382
5383 /* Shift entries up in the table to make room at [0]. */
5384
5385 limit_p = &filename_table[0];
5386 for (move_p = new_zeroth; move_p > limit_p; move_p--)
5387 *move_p = *(move_p-1);
5388
5389 /* Install the found entry at [0]. */
5390
5391 filename_table[0] = temp_entry;
5392 }
5393
5394 /* Create a new (string) entry for the .debug_sfnames section. */
5395
5396 static void
5397 generate_new_sfname_entry ()
5398 {
5399 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5400
5401 fputc ('\n', asm_out_file);
5402 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5403 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
5404 ASM_OUTPUT_LABEL (asm_out_file, label);
5405 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
5406 filename_table[0].name
5407 ? filename_table[0].name
5408 : "");
5409 ASM_OUTPUT_POP_SECTION (asm_out_file);
5410 }
5411
5412 /* Lookup a filename (in the list of filenames that we know about here in
5413 dwarfout.c) and return its "index". The index of each (known) filename
5414 is just a unique number which is associated with only that one filename.
5415 We need such numbers for the sake of generating labels (in the
5416 .debug_sfnames section) and references to those unique labels (in the
5417 .debug_srcinfo and .debug_macinfo sections).
5418
5419 If the filename given as an argument is not found in our current list,
5420 add it to the list and assign it the next available unique index number.
5421
5422 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5423 one), we shuffle the filename found (or added) up to the zeroth entry of
5424 our list of filenames (which is always searched linearly). We do this so
5425 as to optimize the most common case for these filename lookups within
5426 dwarfout.c. The most common case by far is the case where we call
5427 lookup_filename to lookup the very same filename that we did a lookup
5428 on the last time we called lookup_filename. We make sure that this
5429 common case is fast because such cases will constitute 99.9% of the
5430 lookups we ever do (in practice).
5431
5432 If we add a new filename entry to our table, we go ahead and generate
5433 the corresponding entry in the .debug_sfnames section right away.
5434 Doing so allows us to avoid tickling an assembler bug (present in some
5435 m68k assemblers) which yields assembly-time errors in cases where the
5436 difference of two label addresses is taken and where the two labels
5437 are in a section *other* than the one where the difference is being
5438 calculated, and where at least one of the two symbol references is a
5439 forward reference. (This bug could be tickled by our .debug_srcinfo
5440 entries if we don't output their corresponding .debug_sfnames entries
5441 before them.) */
5442
5443 static unsigned
5444 lookup_filename (file_name)
5445 char *file_name;
5446 {
5447 register filename_entry *search_p;
5448 register filename_entry *limit_p = &filename_table[ft_entries];
5449
5450 for (search_p = filename_table; search_p < limit_p; search_p++)
5451 if (!strcmp (file_name, search_p->name))
5452 {
5453 /* When we get here, we have found the filename that we were
5454 looking for in the filename_table. Now we want to make sure
5455 that it gets moved to the zero'th entry in the table (if it
5456 is not already there) so that subsequent attempts to find the
5457 same filename will find it as quickly as possible. */
5458
5459 shuffle_filename_entry (search_p);
5460 return filename_table[0].number;
5461 }
5462
5463 /* We come here whenever we have a new filename which is not registered
5464 in the current table. Here we add it to the table. */
5465
5466 /* Prepare to add a new table entry by making sure there is enough space
5467 in the table to do so. If not, expand the current table. */
5468
5469 if (ft_entries == ft_entries_allocated)
5470 {
5471 ft_entries_allocated += FT_ENTRIES_INCREMENT;
5472 filename_table
5473 = (filename_entry *)
5474 xrealloc (filename_table,
5475 ft_entries_allocated * sizeof (filename_entry));
5476 }
5477
5478 /* Initially, add the new entry at the end of the filename table. */
5479
5480 filename_table[ft_entries].number = ft_entries;
5481 filename_table[ft_entries].name = xstrdup (file_name);
5482
5483 /* Shuffle the new entry into filename_table[0]. */
5484
5485 shuffle_filename_entry (&filename_table[ft_entries]);
5486
5487 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5488 generate_new_sfname_entry ();
5489
5490 ft_entries++;
5491 return filename_table[0].number;
5492 }
5493
5494 static void
5495 generate_srcinfo_entry (line_entry_num, files_entry_num)
5496 unsigned line_entry_num;
5497 unsigned files_entry_num;
5498 {
5499 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5500
5501 fputc ('\n', asm_out_file);
5502 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5503 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
5504 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
5505 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
5506 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
5507 ASM_OUTPUT_POP_SECTION (asm_out_file);
5508 }
5509
5510 void
5511 dwarfout_line (filename, line)
5512 register char *filename;
5513 register unsigned line;
5514 {
5515 if (debug_info_level >= DINFO_LEVEL_NORMAL
5516 /* We can't emit line number info for functions in separate sections,
5517 because the assembler can't subtract labels in different sections. */
5518 && DECL_SECTION_NAME (current_function_decl) == NULL_TREE)
5519 {
5520 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5521 static unsigned last_line_entry_num = 0;
5522 static unsigned prev_file_entry_num = (unsigned) -1;
5523 register unsigned this_file_entry_num;
5524
5525 function_section (current_function_decl);
5526 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
5527 ASM_OUTPUT_LABEL (asm_out_file, label);
5528
5529 fputc ('\n', asm_out_file);
5530
5531 if (use_gnu_debug_info_extensions)
5532 this_file_entry_num = lookup_filename (filename);
5533 else
5534 this_file_entry_num = (unsigned) -1;
5535
5536 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5537 if (this_file_entry_num != prev_file_entry_num)
5538 {
5539 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
5540
5541 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
5542 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
5543 }
5544
5545 {
5546 register char *tail = rindex (filename, '/');
5547
5548 if (tail != NULL)
5549 filename = tail;
5550 }
5551
5552 fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
5553 UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
5554 filename, line);
5555 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5556 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
5557 ASM_OUTPUT_POP_SECTION (asm_out_file);
5558
5559 if (this_file_entry_num != prev_file_entry_num)
5560 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
5561 prev_file_entry_num = this_file_entry_num;
5562 }
5563 }
5564
5565 /* Generate an entry in the .debug_macinfo section. */
5566
5567 static void
5568 generate_macinfo_entry (type_and_offset, string)
5569 register char *type_and_offset;
5570 register char *string;
5571 {
5572 if (! use_gnu_debug_info_extensions)
5573 return;
5574
5575 fputc ('\n', asm_out_file);
5576 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5577 fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
5578 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, string);
5579 ASM_OUTPUT_POP_SECTION (asm_out_file);
5580 }
5581
5582 void
5583 dwarfout_start_new_source_file (filename)
5584 register char *filename;
5585 {
5586 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5587 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
5588
5589 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
5590 sprintf (type_and_offset, "0x%08x+%s-%s",
5591 ((unsigned) MACINFO_start << 24),
5592 /* Hack: skip leading '*' . */
5593 (*label == '*') + label,
5594 (*SFNAMES_BEGIN_LABEL == '*') + SFNAMES_BEGIN_LABEL);
5595 generate_macinfo_entry (type_and_offset, "");
5596 }
5597
5598 void
5599 dwarfout_resume_previous_source_file (lineno)
5600 register unsigned lineno;
5601 {
5602 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5603
5604 sprintf (type_and_offset, "0x%08x+%u",
5605 ((unsigned) MACINFO_resume << 24), lineno);
5606 generate_macinfo_entry (type_and_offset, "");
5607 }
5608
5609 /* Called from check_newline in c-parse.y. The `buffer' parameter
5610 contains the tail part of the directive line, i.e. the part which
5611 is past the initial whitespace, #, whitespace, directive-name,
5612 whitespace part. */
5613
5614 void
5615 dwarfout_define (lineno, buffer)
5616 register unsigned lineno;
5617 register char *buffer;
5618 {
5619 static int initialized = 0;
5620 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5621
5622 if (!initialized)
5623 {
5624 dwarfout_start_new_source_file (primary_filename);
5625 initialized = 1;
5626 }
5627 sprintf (type_and_offset, "0x%08x+%u",
5628 ((unsigned) MACINFO_define << 24), lineno);
5629 generate_macinfo_entry (type_and_offset, buffer);
5630 }
5631
5632 /* Called from check_newline in c-parse.y. The `buffer' parameter
5633 contains the tail part of the directive line, i.e. the part which
5634 is past the initial whitespace, #, whitespace, directive-name,
5635 whitespace part. */
5636
5637 void
5638 dwarfout_undef (lineno, buffer)
5639 register unsigned lineno;
5640 register char *buffer;
5641 {
5642 char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
5643
5644 sprintf (type_and_offset, "0x%08x+%u",
5645 ((unsigned) MACINFO_undef << 24), lineno);
5646 generate_macinfo_entry (type_and_offset, buffer);
5647 }
5648
5649 /* Set up for Dwarf output at the start of compilation. */
5650
5651 void
5652 dwarfout_init (asm_out_file, main_input_filename)
5653 register FILE *asm_out_file;
5654 register char *main_input_filename;
5655 {
5656 /* Remember the name of the primary input file. */
5657
5658 primary_filename = main_input_filename;
5659
5660 /* Allocate the initial hunk of the pending_sibling_stack. */
5661
5662 pending_sibling_stack
5663 = (unsigned *)
5664 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
5665 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
5666 pending_siblings = 1;
5667
5668 /* Allocate the initial hunk of the filename_table. */
5669
5670 filename_table
5671 = (filename_entry *)
5672 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
5673 ft_entries_allocated = FT_ENTRIES_INCREMENT;
5674 ft_entries = 0;
5675
5676 /* Allocate the initial hunk of the pending_types_list. */
5677
5678 pending_types_list
5679 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
5680 pending_types_allocated = PENDING_TYPES_INCREMENT;
5681 pending_types = 0;
5682
5683 /* Create an artificial RECORD_TYPE node which we can use in our hack
5684 to get the DIEs representing types of formal parameters to come out
5685 only *after* the DIEs for the formal parameters themselves. */
5686
5687 fake_containing_scope = make_node (RECORD_TYPE);
5688
5689 /* Output a starting label for the .text section. */
5690
5691 fputc ('\n', asm_out_file);
5692 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5693 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
5694 ASM_OUTPUT_POP_SECTION (asm_out_file);
5695
5696 /* Output a starting label for the .data section. */
5697
5698 fputc ('\n', asm_out_file);
5699 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5700 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
5701 ASM_OUTPUT_POP_SECTION (asm_out_file);
5702
5703 #if 0 /* GNU C doesn't currently use .data1. */
5704 /* Output a starting label for the .data1 section. */
5705
5706 fputc ('\n', asm_out_file);
5707 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5708 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
5709 ASM_OUTPUT_POP_SECTION (asm_out_file);
5710 #endif
5711
5712 /* Output a starting label for the .rodata section. */
5713
5714 fputc ('\n', asm_out_file);
5715 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5716 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
5717 ASM_OUTPUT_POP_SECTION (asm_out_file);
5718
5719 #if 0 /* GNU C doesn't currently use .rodata1. */
5720 /* Output a starting label for the .rodata1 section. */
5721
5722 fputc ('\n', asm_out_file);
5723 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5724 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
5725 ASM_OUTPUT_POP_SECTION (asm_out_file);
5726 #endif
5727
5728 /* Output a starting label for the .bss section. */
5729
5730 fputc ('\n', asm_out_file);
5731 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5732 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
5733 ASM_OUTPUT_POP_SECTION (asm_out_file);
5734
5735 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5736 {
5737 if (use_gnu_debug_info_extensions)
5738 {
5739 /* Output a starting label and an initial (compilation directory)
5740 entry for the .debug_sfnames section. The starting label will be
5741 referenced by the initial entry in the .debug_srcinfo section. */
5742
5743 fputc ('\n', asm_out_file);
5744 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
5745 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
5746 {
5747 register char *pwd;
5748 register unsigned len;
5749 register char *dirname;
5750
5751 pwd = getpwd ();
5752 if (!pwd)
5753 pfatal_with_name ("getpwd");
5754 len = strlen (pwd);
5755 dirname = (char *) xmalloc (len + 2);
5756
5757 strcpy (dirname, pwd);
5758 strcpy (dirname + len, "/");
5759 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
5760 free (dirname);
5761 }
5762 ASM_OUTPUT_POP_SECTION (asm_out_file);
5763 }
5764
5765 if (debug_info_level >= DINFO_LEVEL_VERBOSE
5766 && use_gnu_debug_info_extensions)
5767 {
5768 /* Output a starting label for the .debug_macinfo section. This
5769 label will be referenced by the AT_mac_info attribute in the
5770 TAG_compile_unit DIE. */
5771
5772 fputc ('\n', asm_out_file);
5773 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5774 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
5775 ASM_OUTPUT_POP_SECTION (asm_out_file);
5776 }
5777
5778 /* Generate the initial entry for the .line section. */
5779
5780 fputc ('\n', asm_out_file);
5781 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5782 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
5783 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
5784 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5785 ASM_OUTPUT_POP_SECTION (asm_out_file);
5786
5787 if (use_gnu_debug_info_extensions)
5788 {
5789 /* Generate the initial entry for the .debug_srcinfo section. */
5790
5791 fputc ('\n', asm_out_file);
5792 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5793 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
5794 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
5795 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
5796 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5797 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
5798 #ifdef DWARF_TIMESTAMPS
5799 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
5800 #else
5801 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5802 #endif
5803 ASM_OUTPUT_POP_SECTION (asm_out_file);
5804 }
5805
5806 /* Generate the initial entry for the .debug_pubnames section. */
5807
5808 fputc ('\n', asm_out_file);
5809 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5810 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5811 ASM_OUTPUT_POP_SECTION (asm_out_file);
5812
5813 /* Generate the initial entry for the .debug_aranges section. */
5814
5815 fputc ('\n', asm_out_file);
5816 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5817 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
5818 ASM_OUTPUT_POP_SECTION (asm_out_file);
5819 }
5820
5821 /* Setup first DIE number == 1. */
5822 NEXT_DIE_NUM = next_unused_dienum++;
5823
5824 /* Generate the initial DIE for the .debug section. Note that the
5825 (string) value given in the AT_name attribute of the TAG_compile_unit
5826 DIE will (typically) be a relative pathname and that this pathname
5827 should be taken as being relative to the directory from which the
5828 compiler was invoked when the given (base) source file was compiled. */
5829
5830 fputc ('\n', asm_out_file);
5831 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5832 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
5833 output_die (output_compile_unit_die, main_input_filename);
5834 ASM_OUTPUT_POP_SECTION (asm_out_file);
5835
5836 fputc ('\n', asm_out_file);
5837 }
5838
5839 /* Output stuff that dwarf requires at the end of every file. */
5840
5841 void
5842 dwarfout_finish ()
5843 {
5844 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5845
5846 fputc ('\n', asm_out_file);
5847 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5848
5849 /* Mark the end of the chain of siblings which represent all file-scope
5850 declarations in this compilation unit. */
5851
5852 /* The (null) DIE which represents the terminator for the (sibling linked)
5853 list of file-scope items is *special*. Normally, we would just call
5854 end_sibling_chain at this point in order to output a word with the
5855 value `4' and that word would act as the terminator for the list of
5856 DIEs describing file-scope items. Unfortunately, if we were to simply
5857 do that, the label that would follow this DIE in the .debug section
5858 (i.e. `..D2') would *not* be properly aligned (as it must be on some
5859 machines) to a 4 byte boundary.
5860
5861 In order to force the label `..D2' to get aligned to a 4 byte boundary,
5862 the trick used is to insert extra (otherwise useless) padding bytes
5863 into the (null) DIE that we know must precede the ..D2 label in the
5864 .debug section. The amount of padding required can be anywhere between
5865 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
5866 with the padding) would normally contain the value 4, but now it will
5867 also have to include the padding bytes, so it will instead have some
5868 value in the range 4..7.
5869
5870 Fortunately, the rules of Dwarf say that any DIE whose length word
5871 contains *any* value less than 8 should be treated as a null DIE, so
5872 this trick works out nicely. Clever, eh? Don't give me any credit
5873 (or blame). I didn't think of this scheme. I just conformed to it.
5874 */
5875
5876 output_die (output_padded_null_die, (void *) 0);
5877 dienum_pop ();
5878
5879 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
5880 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
5881 ASM_OUTPUT_POP_SECTION (asm_out_file);
5882
5883 /* Output a terminator label for the .text section. */
5884
5885 fputc ('\n', asm_out_file);
5886 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
5887 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
5888 ASM_OUTPUT_POP_SECTION (asm_out_file);
5889
5890 /* Output a terminator label for the .data section. */
5891
5892 fputc ('\n', asm_out_file);
5893 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
5894 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
5895 ASM_OUTPUT_POP_SECTION (asm_out_file);
5896
5897 #if 0 /* GNU C doesn't currently use .data1. */
5898 /* Output a terminator label for the .data1 section. */
5899
5900 fputc ('\n', asm_out_file);
5901 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
5902 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
5903 ASM_OUTPUT_POP_SECTION (asm_out_file);
5904 #endif
5905
5906 /* Output a terminator label for the .rodata section. */
5907
5908 fputc ('\n', asm_out_file);
5909 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
5910 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
5911 ASM_OUTPUT_POP_SECTION (asm_out_file);
5912
5913 #if 0 /* GNU C doesn't currently use .rodata1. */
5914 /* Output a terminator label for the .rodata1 section. */
5915
5916 fputc ('\n', asm_out_file);
5917 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
5918 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
5919 ASM_OUTPUT_POP_SECTION (asm_out_file);
5920 #endif
5921
5922 /* Output a terminator label for the .bss section. */
5923
5924 fputc ('\n', asm_out_file);
5925 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
5926 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
5927 ASM_OUTPUT_POP_SECTION (asm_out_file);
5928
5929 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5930 {
5931 /* Output a terminating entry for the .line section. */
5932
5933 fputc ('\n', asm_out_file);
5934 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
5935 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
5936 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5937 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
5938 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5939 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
5940 ASM_OUTPUT_POP_SECTION (asm_out_file);
5941
5942 if (use_gnu_debug_info_extensions)
5943 {
5944 /* Output a terminating entry for the .debug_srcinfo section. */
5945
5946 fputc ('\n', asm_out_file);
5947 ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
5948 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
5949 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
5950 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
5951 ASM_OUTPUT_POP_SECTION (asm_out_file);
5952 }
5953
5954 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
5955 {
5956 /* Output terminating entries for the .debug_macinfo section. */
5957
5958 dwarfout_resume_previous_source_file (0);
5959
5960 fputc ('\n', asm_out_file);
5961 ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
5962 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5963 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
5964 ASM_OUTPUT_POP_SECTION (asm_out_file);
5965 }
5966
5967 /* Generate the terminating entry for the .debug_pubnames section. */
5968
5969 fputc ('\n', asm_out_file);
5970 ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
5971 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
5972 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
5973 ASM_OUTPUT_POP_SECTION (asm_out_file);
5974
5975 /* Generate the terminating entries for the .debug_aranges section.
5976
5977 Note that we want to do this only *after* we have output the end
5978 labels (for the various program sections) which we are going to
5979 refer to here. This allows us to work around a bug in the m68k
5980 svr4 assembler. That assembler gives bogus assembly-time errors
5981 if (within any given section) you try to take the difference of
5982 two relocatable symbols, both of which are located within some
5983 other section, and if one (or both?) of the symbols involved is
5984 being forward-referenced. By generating the .debug_aranges
5985 entries at this late point in the assembly output, we skirt the
5986 issue simply by avoiding forward-references.
5987 */
5988
5989 fputc ('\n', asm_out_file);
5990 ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
5991
5992 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
5993 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
5994
5995 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
5996 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
5997
5998 #if 0 /* GNU C doesn't currently use .data1. */
5999 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
6000 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
6001 DATA1_BEGIN_LABEL);
6002 #endif
6003
6004 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
6005 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
6006 RODATA_BEGIN_LABEL);
6007
6008 #if 0 /* GNU C doesn't currently use .rodata1. */
6009 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
6010 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
6011 RODATA1_BEGIN_LABEL);
6012 #endif
6013
6014 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
6015 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
6016
6017 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6018 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6019
6020 ASM_OUTPUT_POP_SECTION (asm_out_file);
6021 }
6022
6023 /* There should not be any pending types left at the end. We need
6024 this now because it may not have been checked on the last call to
6025 dwarfout_file_scope_decl. */
6026 if (pending_types != 0)
6027 abort ();
6028 }
6029
6030 #endif /* DWARF_DEBUGGING_INFO */