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