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