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