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