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