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