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