]>
Commit | Line | Data |
---|---|---|
a3f97cbb JW |
1 | /* Output Dwarf2 format symbol table information from the GNU C compiler. |
2 | Copyright (C) 1992, 1993, 1995, 1996 Free Software Foundation, Inc. | |
3 | Contributed by Gary Funck (gary@intrepid.com). Derived from the | |
4 | DWARF 1 implementation written by Ron Guilmette (rfg@monkeys.com). | |
5 | ||
6 | This file is part of GNU CC. | |
7 | ||
8 | GNU CC is free software; you can redistribute it and/or modify | |
9 | it under the terms of the GNU General Public License as published by | |
10 | the Free Software Foundation; either version 2, or (at your option) | |
11 | any later version. | |
12 | ||
13 | GNU CC is distributed in the hope that it will be useful, | |
14 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
15 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
16 | GNU General Public License for more details. | |
17 | ||
18 | You should have received a copy of the GNU General Public License | |
19 | along with GNU CC; see the file COPYING. If not, write to | |
20 | the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA. */ | |
21 | ||
22 | #include "config.h" | |
23 | ||
6ba95bc9 RK |
24 | #ifndef DWARF_VERSION |
25 | #define DWARF_VERSION 1 | |
26 | #endif | |
27 | #if defined (DWARF_DEBUGGING_INFO) && (DWARF_VERSION == 2) | |
a3f97cbb JW |
28 | #include <stdio.h> |
29 | #include "dwarf2.h" | |
30 | #include "tree.h" | |
31 | #include "flags.h" | |
32 | #include "rtl.h" | |
33 | #include "hard-reg-set.h" | |
34 | #include "regs.h" | |
35 | #include "insn-config.h" | |
36 | #include "reload.h" | |
37 | #include "output.h" | |
38 | #include "defaults.h" | |
39 | ||
40 | /* #define NDEBUG 1 */ | |
41 | #include "assert.h" | |
42 | #if defined(DWARF_TIMESTAMPS) | |
43 | #if defined(POSIX) | |
44 | #include <time.h> | |
45 | #else /* !defined(POSIX) */ | |
46 | #include <sys/types.h> | |
47 | #if defined(__STDC__) | |
48 | extern time_t time (time_t *); | |
49 | #else /* !defined(__STDC__) */ | |
50 | extern time_t time (); | |
51 | #endif /* !defined(__STDC__) */ | |
52 | #endif /* !defined(POSIX) */ | |
53 | #endif /* defined(DWARF_TIMESTAMPS) */ | |
54 | ||
55 | extern char *getpwd (); | |
56 | extern char *index (); | |
57 | extern char *rindex (); | |
58 | ||
59 | /* IMPORTANT NOTE: Please see the file README.DWARF for important details | |
60 | regarding the GNU implementation of DWARF. */ | |
61 | ||
62 | /* NOTE: In the comments in this file, many references are made to | |
63 | "Debugging Information Entries". This term is abbreviated as `DIE' | |
64 | throughout the remainder of this file. */ | |
65 | ||
66 | /* NOTE: The implementation of C++ support is unfinished. */ | |
67 | ||
68 | #if defined(__GNUC__) && (NDEBUG == 1) | |
69 | #define inline static inline | |
70 | #else | |
71 | #define inline static | |
72 | #endif | |
73 | ||
74 | ||
75 | /* An internal representation of the DWARF output is built, and then | |
76 | walked to generate the DWARF debugging info. The walk of the internal | |
77 | representation is done after the entire program has been compiled. | |
78 | The types below are used to describe the internal representation. */ | |
79 | ||
80 | /* Each DIE may have a series of attribute/value pairs. Values | |
81 | can take on several forms. The forms that are used in this | |
82 | impelementation are listed below. */ | |
83 | typedef enum | |
84 | { | |
85 | dw_val_class_addr, | |
86 | dw_val_class_loc, | |
87 | dw_val_class_const, | |
88 | dw_val_class_unsigned_const, | |
89 | dw_val_class_double_const, | |
90 | dw_val_class_flag, | |
91 | dw_val_class_die_ref, | |
92 | dw_val_class_fde_ref, | |
93 | dw_val_class_lbl_id, | |
94 | dw_val_class_section_offset, | |
95 | dw_val_class_str | |
96 | } | |
97 | dw_val_class; | |
98 | ||
99 | /* Various DIE's use offsets relative to the beginning of the | |
100 | .debug_info section to refer to each other. */ | |
101 | typedef long int dw_offset; | |
102 | ||
103 | /* Define typedefs here to avoid circular dependencies. */ | |
104 | typedef struct die_struct *dw_die_ref; | |
105 | typedef struct dw_attr_struct *dw_attr_ref; | |
106 | typedef struct dw_val_struct *dw_val_ref; | |
107 | typedef struct dw_line_info_struct *dw_line_info_ref; | |
108 | typedef struct dw_loc_descr_struct *dw_loc_descr_ref; | |
109 | typedef struct dw_cfi_struct *dw_cfi_ref; | |
110 | typedef struct dw_fde_struct *dw_fde_ref; | |
111 | typedef union dw_cfi_oprnd_struct *dw_cfi_oprnd_ref; | |
a3f97cbb JW |
112 | |
113 | /* Describe a double word constant value. */ | |
114 | typedef struct dw_double_const_struct | |
115 | { | |
116 | unsigned long dw_dbl_hi; | |
117 | unsigned long dw_dbl_low; | |
118 | } | |
119 | dw_dbl_const; | |
120 | ||
121 | /* Each entry in the line_info_table maintains the file and | |
122 | line nuber associated with the label generated for that | |
123 | entry. The label gives the PC value associated with | |
124 | the line number entry. */ | |
125 | typedef struct dw_line_info_struct | |
126 | { | |
127 | unsigned long dw_file_num; | |
128 | unsigned long dw_line_num; | |
129 | } | |
130 | dw_line_info_entry; | |
131 | ||
132 | /* The dw_val_node describes an attibute's value, as it is | |
133 | represnted internally. */ | |
134 | typedef struct dw_val_struct | |
135 | { | |
136 | dw_val_class val_class; | |
137 | union | |
138 | { | |
139 | char *val_addr; | |
140 | dw_loc_descr_ref val_loc; | |
141 | long int val_int; | |
142 | long unsigned val_unsigned; | |
143 | dw_dbl_const val_dbl_const; | |
144 | dw_die_ref val_die_ref; | |
145 | unsigned val_fde_index; | |
146 | char *val_str; | |
147 | char *val_lbl_id; | |
148 | char *val_section; | |
149 | unsigned char val_flag; | |
150 | } | |
151 | v; | |
152 | } | |
153 | dw_val_node; | |
154 | ||
155 | /* Locations in memory are described using a sequence of stack machine | |
156 | operations. */ | |
157 | typedef struct dw_loc_descr_struct | |
158 | { | |
159 | dw_loc_descr_ref dw_loc_next; | |
160 | enum dwarf_location_atom dw_loc_opc; | |
161 | dw_val_node dw_loc_oprnd1; | |
162 | dw_val_node dw_loc_oprnd2; | |
163 | } | |
164 | dw_loc_descr_node; | |
165 | ||
166 | /* Each DIE attribute has a field specifying the attribute kind, | |
167 | a link to the next attribute in the chain, and an attribute value. | |
168 | Attributes are typically linked below the DIE they modify. */ | |
169 | typedef struct dw_attr_struct | |
170 | { | |
171 | enum dwarf_attribute dw_attr; | |
172 | dw_attr_ref dw_attr_next; | |
173 | dw_val_node dw_attr_val; | |
174 | } | |
175 | dw_attr_node; | |
176 | ||
177 | /* Call frames are described using a sequence of Call Frame | |
178 | Information instructions. The register number, offset | |
179 | and address fields are provided as possible operands; | |
180 | their use is selected by the opcode field. */ | |
181 | typedef union dw_cfi_oprnd_struct | |
182 | { | |
183 | unsigned long dw_cfi_reg_num; | |
184 | long int dw_cfi_offset; | |
185 | char *dw_cfi_addr; | |
186 | } | |
187 | dw_cfi_oprnd; | |
188 | ||
189 | typedef struct dw_cfi_struct | |
190 | { | |
191 | dw_cfi_ref dw_cfi_next; | |
192 | enum dwarf_call_frame_info dw_cfi_opc; | |
193 | dw_cfi_oprnd dw_cfi_oprnd1; | |
194 | dw_cfi_oprnd dw_cfi_oprnd2; | |
195 | } | |
196 | dw_cfi_node; | |
197 | ||
198 | /* All call frame descriptions (FDE's) in the GCC generated DWARF | |
4b674448 | 199 | refer to a single Common Information Entry (CIE), defined at |
a3f97cbb JW |
200 | the beginning of the .debug_frame section. This used of a single |
201 | CIE obviates the need to keep track of multiple CIE's | |
202 | in the DWARF generation routines below. */ | |
203 | typedef struct dw_fde_struct | |
204 | { | |
205 | unsigned long dw_fde_offset; | |
206 | char *dw_fde_begin; | |
207 | char *dw_fde_end_prolog; | |
208 | char *dw_fde_begin_epilogue; | |
209 | char *dw_fde_end; | |
210 | dw_cfi_ref dw_fde_cfi; | |
211 | } | |
212 | dw_fde_node; | |
213 | ||
214 | /* The Debugging Information Entry (DIE) structure */ | |
215 | typedef struct die_struct | |
216 | { | |
217 | enum dwarf_tag die_tag; | |
218 | dw_attr_ref die_attr; | |
219 | dw_attr_ref die_attr_last; | |
220 | dw_die_ref die_parent; | |
221 | dw_die_ref die_child; | |
222 | dw_die_ref die_child_last; | |
223 | dw_die_ref die_sib; | |
224 | dw_offset die_offset; | |
225 | unsigned long die_abbrev; | |
226 | } | |
227 | die_node; | |
228 | ||
a3f97cbb JW |
229 | /* How to start an assembler comment. */ |
230 | #ifndef ASM_COMMENT_START | |
231 | #define ASM_COMMENT_START ";#" | |
232 | #endif | |
233 | ||
234 | /* Define a macro which returns non-zero for any tagged type which is used | |
235 | (directly or indirectly) in the specification of either some function's | |
236 | return type or some formal parameter of some function. We use this macro | |
237 | when we are operating in "terse" mode to help us know what tagged types | |
238 | have to be represented in Dwarf (even in terse mode) and which ones don't. | |
239 | A flag bit with this meaning really should be a part of the normal GCC | |
240 | ..._TYPE nodes, but at the moment, there is no such bit defined for these | |
241 | nodes. For now, we have to just fake it. It it safe for us to simply | |
242 | return zero for all complete tagged types (which will get forced out | |
243 | anyway if they were used in the specification of some formal or return | |
244 | type) and non-zero for all incomplete tagged types. */ | |
245 | #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0) | |
246 | ||
247 | /* Information concerning the compilation unit's programming | |
248 | language, and compiler version. */ | |
249 | extern int flag_traditional; | |
250 | extern char *version_string; | |
251 | extern char *language_string; | |
252 | ||
253 | /* Maximum size (in bytes) of an artificially generated label. */ | |
254 | #define MAX_ARTIFICIAL_LABEL_BYTES 30 | |
255 | ||
256 | /* Make sure we know the sizes of the various types dwarf can describe. These | |
257 | are only defaults. If the sizes are different for your target, you should | |
258 | override these values by defining the appropriate symbols in your tm.h | |
259 | file. */ | |
260 | #ifndef CHAR_TYPE_SIZE | |
261 | #define CHAR_TYPE_SIZE BITS_PER_UNIT | |
262 | #endif | |
263 | #ifndef SHORT_TYPE_SIZE | |
264 | #define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2) | |
265 | #endif | |
266 | #ifndef INT_TYPE_SIZE | |
267 | #define INT_TYPE_SIZE BITS_PER_WORD | |
268 | #endif | |
269 | #ifndef LONG_TYPE_SIZE | |
270 | #define LONG_TYPE_SIZE BITS_PER_WORD | |
271 | #endif | |
272 | #ifndef LONG_LONG_TYPE_SIZE | |
273 | #define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2) | |
274 | #endif | |
275 | #ifndef WCHAR_TYPE_SIZE | |
276 | #define WCHAR_TYPE_SIZE INT_TYPE_SIZE | |
277 | #endif | |
278 | #ifndef WCHAR_UNSIGNED | |
279 | #define WCHAR_UNSIGNED 0 | |
280 | #endif | |
281 | #ifndef FLOAT_TYPE_SIZE | |
282 | #define FLOAT_TYPE_SIZE BITS_PER_WORD | |
283 | #endif | |
284 | #ifndef DOUBLE_TYPE_SIZE | |
285 | #define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) | |
286 | #endif | |
287 | #ifndef LONG_DOUBLE_TYPE_SIZE | |
288 | #define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2) | |
289 | #endif | |
290 | #ifndef PTR_SIZE | |
291 | #define PTR_SIZE (POINTER_SIZE / 8) | |
292 | #endif | |
293 | ||
294 | /* Fixed size portion of the DWARF compilation unit header. */ | |
295 | #define DWARF_COMPILE_UNIT_HEADER_SIZE 11 | |
296 | ||
297 | /* Fixed size portion of debugging line information prolog. */ | |
298 | #define DWARF_LINE_PROLOG_HEADER_SIZE 5 | |
299 | ||
300 | /* Fixed size portion of public names info. */ | |
301 | #define DWARF_PUBNAMES_HEADER_SIZE 10 | |
302 | ||
303 | /* Fixed size portion of the address range info. */ | |
304 | #define DWARF_ARANGES_HEADER_SIZE 12 | |
305 | ||
306 | /* Fixed size portion of the Common Information Entry (including | |
307 | the length field). */ | |
308 | #define DWARF_CIE_HEADER_SIZE 16 | |
309 | ||
310 | /* Fixed size of the Common Information Entry in the call frame | |
311 | information (.debug_frame) section rounded up to an 8 byte boundary. */ | |
312 | #define DWARF_CIE_SIZE ((DWARF_CIE_HEADER_SIZE + 7) & ~7) | |
313 | ||
314 | /* Offsets recorded in opcodes are a multiple of this alignment factor. */ | |
315 | #define DWARF_CIE_DATA_ALIGNMENT -4 | |
316 | ||
317 | /* Fixed size portion of the FDE. */ | |
318 | #define DWARF_FDE_HEADER_SIZE (4 + 4 + (2 * PTR_SIZE)) | |
319 | ||
320 | /* Define the architecture-dependent minimum instruction length (in bytes). | |
321 | In this implementation of DWARF, this field is used for information | |
322 | purposes only. Since GCC generates assembly language, we have | |
323 | no a priori knowledge of how many instruction bytes are generated | |
324 | for each source line, and therefore can use only the DW_LNE_set_address | |
325 | and DW_LNS_fixed_advance_pc line information commands. */ | |
326 | #ifndef DWARF_LINE_MIN_INSTR_LENGTH | |
327 | #define DWARF_LINE_MIN_INSTR_LENGTH 4 | |
328 | #endif | |
329 | ||
330 | /* Minimum line offset in a special line info. opcode. | |
331 | This value was chosen to give a reasonable range of values. */ | |
332 | #define DWARF_LINE_BASE -10 | |
333 | ||
334 | /* First special line opcde - leave room for the standard opcodes. */ | |
335 | #define DWARF_LINE_OPCODE_BASE 10 | |
336 | ||
337 | /* Range of line offsets in a special line info. opcode. */ | |
338 | #define DWARF_LINE_RANGE (254-DWARF_LINE_OPCODE_BASE+1) | |
339 | ||
340 | /* Flag that indicates the initial value of the is_stmt_start flag. | |
341 | In the present implementation, we do not mark any lines as | |
342 | the beginning of a source statement, because that information | |
343 | is not made available by the GCC front-end. */ | |
344 | #define DWARF_LINE_DEFAULT_IS_STMT_START 1 | |
345 | ||
346 | /* This location is used by calc_die_sizes() to keep track | |
347 | the offset of each DIE within the .debug_info section. */ | |
348 | static unsigned long next_die_offset; | |
349 | ||
350 | /* This location is used by calc_fde_sizes() to keep track | |
351 | the offset of each FDE within the .debug_frame section. */ | |
352 | static unsigned long next_fde_offset; | |
353 | ||
354 | /* Record the root of the DIE's built for the current compilation unit. */ | |
355 | dw_die_ref comp_unit_die; | |
356 | ||
357 | /* Pointer to an array of filenames referenced by this compilation unit. */ | |
358 | static char **file_table; | |
359 | ||
360 | /* Total number of entries in the table (i.e. array) pointed to by | |
361 | `file_table'. This is the *total* and includes both used and unused | |
362 | slots. */ | |
363 | static unsigned file_table_allocated; | |
364 | ||
365 | /* Number of entries in the file_table which are actually in use. */ | |
366 | static unsigned file_table_in_use; | |
367 | ||
368 | /* Size (in elements) of increments by which we may expand the filename | |
369 | table. */ | |
370 | #define FILE_TABLE_INCREMENT 64 | |
371 | ||
372 | /* Local pointer to the name of the main input file. Initialized in | |
373 | dwarfout_init. */ | |
374 | static char *primary_filename; | |
375 | ||
376 | /* For Dwarf output, we must assign lexical-blocks id numbers in the order in | |
377 | which their beginnings are encountered. We output Dwarf debugging info | |
378 | that refers to the beginnings and ends of the ranges of code for each | |
379 | lexical block. The labels themselves are generated in final.c, which | |
380 | assigns numbers to the blocks in the same way. */ | |
381 | static unsigned next_block_number = 2; | |
382 | ||
383 | /* Non-zero if we are performing the file-scope finalization pass and if we | |
384 | should force out Dwarf descriptions of any and all file-scope tagged types | |
385 | which are still incomplete types. */ | |
386 | static int finalizing = 0; | |
387 | ||
388 | /* A pointer to the base of a list of references to DIE's that describe | |
389 | types. The table is indexed by TYPE_UID() which is a unique number, | |
390 | indentifying each type. */ | |
391 | static dw_die_ref *type_die_table; | |
392 | ||
393 | /* Number of elements currently allocated for type_die_table. */ | |
394 | static unsigned type_die_table_allocated; | |
395 | ||
396 | /* Number of elements in type_die_table currently in use. */ | |
397 | static unsigned type_die_table_in_use; | |
398 | ||
399 | /* Size (in elements) of increments by which we may expand the | |
400 | type_die_table. */ | |
401 | #define TYPE_DIE_TABLE_INCREMENT 4096 | |
402 | ||
403 | /* A pointer to the base of a table of references to DIE's that describe | |
404 | declarations. The table is indexed by DECL_UID() which is a unique | |
405 | number, indentifying each decl. */ | |
406 | static dw_die_ref *decl_die_table; | |
407 | ||
408 | /* Number of elements currently allocated for the decl_die_table. */ | |
409 | static unsigned decl_die_table_allocated; | |
410 | ||
411 | /* Number of elements in decl_die_table currently in use. */ | |
412 | static unsigned decl_die_table_in_use; | |
413 | ||
414 | /* Size (in elements) of increments by which we may expand the | |
415 | decl_die_table. */ | |
416 | #define DECL_DIE_TABLE_INCREMENT 256 | |
417 | ||
418 | /* A pointer to the base of a table of references to declaration | |
419 | scopes. This table is a display which tracks the nesting | |
420 | of declaration scopes at the current scope and containing | |
421 | scopes. This table is used to find the proper place to | |
422 | define type declaration DIE's. */ | |
423 | static tree *decl_scope_table; | |
424 | ||
425 | /* Number of elements currently allocated for the decl_scope_table. */ | |
426 | static unsigned decl_scope_table_allocated; | |
427 | ||
428 | /* Current level of nesting of declataion scopes. */ | |
429 | static unsigned decl_scope_depth; | |
430 | ||
431 | /* Size (in elements) of increments by which we may expand the | |
432 | decl_scope_table. */ | |
433 | #define DECL_SCOPE_TABLE_INCREMENT 64 | |
434 | ||
435 | /* A pointer to the base of a list of references to DIE's that | |
436 | are uniquely identified by their tag, presence/absence of | |
437 | children DIE's, and list of attribute/value pairs. */ | |
438 | static dw_die_ref *abbrev_die_table; | |
439 | ||
440 | /* Number of elements currently allocated for abbrev_die_table. */ | |
441 | static unsigned abbrev_die_table_allocated; | |
442 | ||
443 | /* Number of elements in type_die_table currently in use. */ | |
444 | static unsigned abbrev_die_table_in_use; | |
445 | ||
446 | /* Size (in elements) of increments by which we may expand the | |
447 | abbrev_die_table. */ | |
448 | #define ABBREV_DIE_TABLE_INCREMENT 256 | |
449 | ||
450 | /* A pointer to the base of a table that contains line information | |
451 | for each source code line in the compilation unit. */ | |
452 | static dw_line_info_ref line_info_table; | |
453 | ||
454 | /* Number of elements currently allocated for line_info_table. */ | |
455 | static unsigned line_info_table_allocated; | |
456 | ||
457 | /* Number of elements in line_info_table currently in use. */ | |
458 | static unsigned line_info_table_in_use; | |
459 | ||
460 | /* Size (in elements) of increments by which we may expand the | |
461 | line_info_table. */ | |
462 | #define LINE_INFO_TABLE_INCREMENT 1024 | |
463 | ||
464 | /* Keep track of the last line_info_table entry number, returned | |
465 | by the prior call to lookup_filename(). This serves as a | |
466 | cache used to speed up file name look ups. */ | |
467 | static unsigned prev_file_entry_num = (unsigned) -1; | |
468 | ||
469 | /* A pointer to the base of a table that contains frame description | |
470 | information for each routine. */ | |
471 | static dw_fde_ref fde_table; | |
472 | ||
473 | /* Number of elements currently allocated for fde_table. */ | |
474 | static unsigned fde_table_allocated; | |
475 | ||
476 | /* Number of elements in fde_table currently in use. */ | |
477 | static unsigned fde_table_in_use; | |
478 | ||
479 | /* Size (in elements) of increments by which we may expand the | |
480 | fde_table. */ | |
481 | #define FDE_TABLE_INCREMENT 256 | |
482 | ||
483 | /* The number of the current function definition for which debugging | |
484 | information is being generated. These numbers range from 1 up to the | |
485 | maximum number of function definitions contained within the current | |
486 | compilation unit. These numbers are used to create unique label id's | |
487 | unique to each function definition. */ | |
488 | static unsigned current_funcdef_number = 1; | |
489 | ||
490 | /* Some DWARF extensions (e.g., MIPS/SGI) implement a subprogram | |
491 | attribute that accelerates the lookup of the FDE associated | |
492 | with the subprogram. This variable holds the table index of the FDE | |
493 | associated with the current function (body) definition. */ | |
494 | static unsigned current_funcdef_fde; | |
495 | ||
496 | /* Record the size of the frame, so that the DW_AT_frame_base | |
497 | attribute can be set properly in gen_subprogram_die. */ | |
498 | static long int current_funcdef_frame_size = 0; | |
499 | ||
500 | /* DWARF requires that the compiler's primary datatypes | |
501 | are mapped into a reference to a DIE that defines that | |
502 | primary (base) type. The base_type_info structure is used | |
503 | to track the correspondence between the name of a | |
504 | base type used by GCC, and its corresponding type | |
505 | characteristics. Note, that the bt_size field below | |
506 | is the size in bits. */ | |
507 | typedef struct base_type_struct *base_type_ref; | |
508 | typedef struct base_type_struct | |
509 | { | |
510 | char *bt_name; | |
511 | enum dwarf_type bt_type; | |
512 | int bt_is_signed; | |
513 | int bt_size; | |
514 | } | |
515 | base_type_info; | |
516 | ||
517 | /* Characteristics of base types used by the compiler. */ | |
518 | static base_type_info base_type_table[] = | |
519 | { | |
520 | {"void", DW_ATE_unsigned, 0, 0}, | |
521 | /* TODO: on some architectures, "char" may be signed. */ | |
522 | {"char", DW_ATE_unsigned_char, 0, CHAR_TYPE_SIZE}, | |
523 | {"unsigned char", DW_ATE_unsigned_char, 0, CHAR_TYPE_SIZE}, | |
524 | {"signed char", DW_ATE_signed_char, 1, CHAR_TYPE_SIZE}, | |
525 | {"int", DW_ATE_signed, 1, /* INT_TYPE_SIZE */ 4*8}, | |
526 | {"unsigned int", DW_ATE_unsigned, 0, /* INT_TYPE_SIZE */ 4*8}, | |
527 | {"short", DW_ATE_signed, 1, SHORT_TYPE_SIZE}, | |
528 | {"short int", DW_ATE_signed, 1, SHORT_TYPE_SIZE}, | |
529 | {"short unsigned int", DW_ATE_unsigned, 0, SHORT_TYPE_SIZE}, | |
530 | {"long", DW_ATE_signed, 1, /* LONG_TYPE_SIZE */ 4*8}, | |
531 | {"long int", DW_ATE_signed, 1, /* LONG_TYPE_SIZE */ 4*8}, | |
532 | {"long unsigned int", DW_ATE_unsigned, 0, /* LONG_TYPE_SIZE */ 4*8}, | |
533 | {"long long int", DW_ATE_signed, 1, LONG_LONG_TYPE_SIZE}, | |
534 | {"long long unsigned int", DW_ATE_unsigned, 0, LONG_LONG_TYPE_SIZE}, | |
535 | {"float", DW_ATE_float, 1, /* FLOAT_TYPE_SIZE */ 4*8}, | |
536 | {"double", DW_ATE_float, 1, DOUBLE_TYPE_SIZE}, | |
537 | {"long double", DW_ATE_float, 1, LONG_DOUBLE_TYPE_SIZE}, | |
538 | {"complex", DW_ATE_complex_float, 1, 2 * /* FLOAT_TYPE_SIZE */ 4*8}, | |
539 | {"double complex", DW_ATE_complex_float, 1, 2 * DOUBLE_TYPE_SIZE}, | |
540 | {"long double complex", DW_ATE_complex_float, 1, 2 * LONG_DOUBLE_TYPE_SIZE} | |
541 | }; | |
542 | #define NUM_BASE_TYPES (sizeof(base_type_table)/sizeof(base_type_info)) | |
543 | ||
544 | /* Record the DIE associated with a given base type This table is | |
545 | parallel to the base_type_table, and records the DIE genereated | |
546 | to describe base type that has been previously referenced. */ | |
547 | static dw_die_ref base_type_die_table[NUM_BASE_TYPES]; | |
548 | ||
549 | /* This predefined base type is used to create certain anonymous types */ | |
550 | static dw_die_ref int_base_type_die; | |
551 | ||
552 | /* A pointer to the ..._DECL node which we have most recently been working | |
553 | on. We keep this around just in case something about it looks screwy and | |
554 | we want to tell the user what the source coordinates for the actual | |
555 | declaration are. */ | |
556 | static tree dwarf_last_decl; | |
557 | ||
a3f97cbb JW |
558 | /* Forward declarations for functions defined in this file. */ |
559 | static void gen_type_die (); | |
560 | static void add_type_attribute (); | |
561 | static void decls_for_scope (); | |
562 | static void gen_decl_die (); | |
563 | static unsigned lookup_filename (); | |
564 | ||
565 | ||
566 | /* Definitions of defaults for assembler-dependent names of various | |
567 | pseudo-ops and section names. | |
568 | Theses may be overridden in the tm.h file (if necessary) for a particular | |
569 | assembler. */ | |
570 | #ifndef UNALIGNED_SHORT_ASM_OP | |
571 | #define UNALIGNED_SHORT_ASM_OP ".2byte" | |
572 | #endif | |
573 | #ifndef UNALIGNED_INT_ASM_OP | |
574 | #define UNALIGNED_INT_ASM_OP ".4byte" | |
575 | #endif | |
576 | #ifndef ASM_BYTE_OP | |
577 | #define ASM_BYTE_OP ".byte" | |
578 | #endif | |
579 | ||
580 | /* Pseudo-op for defining a new section. */ | |
581 | #ifndef SECTION_ASM_OP | |
582 | #define SECTION_ASM_OP ".section" | |
583 | #endif | |
584 | ||
585 | /* The default format used by the ASM_OUTPUT_SECTION macro (see below) to | |
586 | print the SECTION_ASM_OP and the section name. The default here works for | |
587 | almost all svr4 assemblers, except for the sparc, where the section name | |
588 | must be enclosed in double quotes. (See sparcv4.h). */ | |
589 | #ifndef SECTION_FORMAT | |
590 | #define SECTION_FORMAT "\t%s\t%s\n" | |
591 | #endif | |
592 | ||
593 | /* Section names used to hold DWARF debugging information. */ | |
594 | #ifndef DEBUG_SECTION | |
595 | #define DEBUG_SECTION ".debug_info" | |
596 | #endif | |
597 | #ifndef ABBREV_SECTION | |
598 | #define ABBREV_SECTION ".debug_abbrev" | |
599 | #endif | |
600 | #ifndef ARANGES_SECTION | |
601 | #define ARANGES_SECTION ".debug_aranges" | |
602 | #endif | |
603 | #ifndef DW_MACINFO_SECTION | |
604 | #define DW_MACINFO_SECTION ".debug_macinfo" | |
605 | #endif | |
606 | #ifndef FRAME_SECTION | |
607 | #define FRAME_SECTION ".debug_frame" | |
608 | #endif | |
609 | #ifndef LINE_SECTION | |
610 | #define LINE_SECTION ".debug_line" | |
611 | #endif | |
612 | #ifndef LOC_SECTION | |
613 | #define LOC_SECTION ".debug_loc" | |
614 | #endif | |
615 | #ifndef PUBNAMES_SECTION | |
616 | #define PUBNAMES_SECTION ".debug_pubnames" | |
617 | #endif | |
618 | #ifndef STR_SECTION | |
619 | #define STR_SECTION ".debug_str" | |
620 | #endif | |
621 | ||
622 | /* Standerd ELF section names for compiled code and data. */ | |
623 | #ifndef TEXT_SECTION | |
624 | #define TEXT_SECTION ".text" | |
625 | #endif | |
626 | #ifndef DATA_SECTION | |
627 | #define DATA_SECTION ".data" | |
628 | #endif | |
629 | #ifndef DATA1_SECTION | |
630 | #define DATA1_SECTION ".data1" | |
631 | #endif | |
632 | #ifndef RODATA_SECTION | |
633 | #define RODATA_SECTION ".rodata" | |
634 | #endif | |
635 | #ifndef RODATA1_SECTION | |
636 | #define RODATA1_SECTION ".rodata1" | |
637 | #endif | |
638 | #ifndef BSS_SECTION | |
639 | #define BSS_SECTION ".bss" | |
640 | #endif | |
641 | ||
642 | ||
643 | /* Definitions of defaults for formats and names of various special | |
644 | (artificial) labels which may be generated within this file (when the -g | |
645 | options is used and DWARF_DEBUGGING_INFO is in effect. | |
646 | If necessary, these may be overridden from within the tm.h file, but | |
647 | typically, overriding these defaults is unnecessary. | |
648 | These labels have been hacked so that they all begin with a | |
649 | `.L' sequence to appease the stock sparc/svr4 assembler and the | |
650 | stock m88k/svr4 assembler, both of which need to see .L at the start of a | |
651 | label in order to prevent that label from going into the linker symbol | |
652 | table). Eventually, the ASM_GENERATE_INTERNAL_LABEL and | |
653 | ASM_OUTPUT_INTERNAL_LABEL should be used, but that will require | |
654 | a major rework. */ | |
655 | #ifndef TEXT_BEGIN_LABEL | |
656 | #define TEXT_BEGIN_LABEL ".L_text_b" | |
657 | #endif | |
658 | #ifndef TEXT_END_LABEL | |
659 | #define TEXT_END_LABEL ".L_text_e" | |
660 | #endif | |
661 | #ifndef DATA_BEGIN_LABEL | |
662 | #define DATA_BEGIN_LABEL ".L_data_b" | |
663 | #endif | |
664 | #ifndef DATA_END_LABEL | |
665 | #define DATA_END_LABEL ".L_data_e" | |
666 | #endif | |
667 | #ifndef RODATA_BEGIN_LABEL | |
668 | #define RODATA_BEGIN_LABEL ".L_rodata_b" | |
669 | #endif | |
670 | #ifndef RODATA_END_LABEL | |
671 | #define RODATA_END_LABEL ".L_rodata_e" | |
672 | #endif | |
673 | #ifndef BSS_BEGIN_LABEL | |
674 | #define BSS_BEGIN_LABEL ".L_bss_b" | |
675 | #endif | |
676 | #ifndef BSS_END_LABEL | |
677 | #define BSS_END_LABEL ".L_bss_e" | |
678 | #endif | |
679 | #ifndef LINE_BEGIN_LABEL | |
680 | #define LINE_BEGIN_LABEL ".L_line_b" | |
681 | #endif | |
682 | #ifndef LINE_END_LABEL | |
683 | #define LINE_END_LABEL ".L_line_e" | |
684 | #endif | |
685 | #ifndef INSN_LABEL_FMT | |
686 | #define INSN_LABEL_FMT ".L_I%u_%u" | |
687 | #endif | |
688 | #ifndef BLOCK_BEGIN_LABEL_FMT | |
689 | #define BLOCK_BEGIN_LABEL_FMT ".L_B%u" | |
690 | #endif | |
691 | #ifndef BLOCK_END_LABEL_FMT | |
692 | #define BLOCK_END_LABEL_FMT ".L_B%u_e" | |
693 | #endif | |
694 | #ifndef BODY_BEGIN_LABEL_FMT | |
695 | #define BODY_BEGIN_LABEL_FMT ".L_b%u" | |
696 | #endif | |
697 | #ifndef BODY_END_LABEL_FMT | |
698 | #define BODY_END_LABEL_FMT ".L_b%u_e" | |
699 | #endif | |
700 | #ifndef FUNC_END_LABEL_FMT | |
701 | #define FUNC_END_LABEL_FMT ".L_f%u_e" | |
702 | #endif | |
703 | #ifndef LINE_CODE_LABEL_FMT | |
704 | #define LINE_CODE_LABEL_FMT ".L_LC%u" | |
705 | #endif | |
706 | #ifndef SFNAMES_ENTRY_LABEL_FMT | |
707 | #define SFNAMES_ENTRY_LABEL_FMT ".L_F%u" | |
708 | #endif | |
709 | ||
a3f97cbb JW |
710 | /* Definitions of defaults for various types of primitive assembly language |
711 | output operations. These may be overridden from within the tm.h file, | |
712 | but typically, that is unecessary. */ | |
713 | #ifndef ASM_OUTPUT_SECTION | |
714 | #define ASM_OUTPUT_SECTION(FILE, SECTION) \ | |
715 | fprintf ((FILE), SECTION_FORMAT, SECTION_ASM_OP, SECTION) | |
716 | #endif | |
717 | ||
718 | #ifndef ASM_OUTPUT_DWARF_DELTA2 | |
719 | #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \ | |
720 | do { fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP); \ | |
721 | assemble_name (FILE, LABEL1); \ | |
722 | fprintf (FILE, "-"); \ | |
723 | assemble_name (FILE, LABEL2); \ | |
724 | } while (0) | |
725 | #endif | |
726 | ||
727 | #ifndef ASM_OUTPUT_DWARF_DELTA4 | |
728 | #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \ | |
729 | do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \ | |
730 | assemble_name (FILE, LABEL1); \ | |
731 | fprintf (FILE, "-"); \ | |
732 | assemble_name (FILE, LABEL2); \ | |
733 | } while (0) | |
734 | #endif | |
735 | ||
736 | #ifndef ASM_OUTPUT_DWARF_ADDR | |
737 | #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \ | |
738 | do { fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP); \ | |
739 | assemble_name (FILE, LABEL); \ | |
740 | } while (0) | |
741 | #endif | |
742 | ||
743 | #ifndef ASM_OUTPUT_DWARF_ADDR_CONST | |
744 | #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,ADDR) \ | |
745 | fprintf ((FILE), "\t%s\t%s", UNALIGNED_INT_ASM_OP, (ADDR)) | |
746 | #endif | |
747 | ||
748 | #ifndef ASM_OUTPUT_DWARF_DATA1 | |
749 | #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \ | |
750 | fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, VALUE) | |
751 | #endif | |
752 | ||
753 | #ifndef ASM_OUTPUT_DWARF_DATA2 | |
754 | #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \ | |
755 | fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE) | |
756 | #endif | |
757 | ||
758 | #ifndef ASM_OUTPUT_DWARF_DATA4 | |
759 | #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \ | |
760 | fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, (unsigned) VALUE) | |
761 | #endif | |
762 | ||
763 | #ifndef ASM_OUTPUT_DWARF_DATA8 | |
764 | #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \ | |
765 | do { \ | |
766 | if (WORDS_BIG_ENDIAN) \ | |
767 | { \ | |
768 | fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \ | |
769 | fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, LOW_VALUE);\ | |
770 | } \ | |
771 | else \ | |
772 | { \ | |
773 | fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\ | |
774 | fprintf ((FILE), "\t%s\t0x%x", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \ | |
775 | } \ | |
776 | } while (0) | |
777 | #endif | |
778 | ||
779 | /* This is similar to the default ASM_OUTPUT_ASCII, except that no trailing | |
780 | newline is produced. When flag_verbose_asm is asserted, we add commnetary | |
781 | at the end of the line, so we must avoid output of a newline here. */ | |
782 | #ifndef ASM_OUTPUT_DWARF_STRING | |
783 | #define ASM_OUTPUT_DWARF_STRING(FILE,P) \ | |
784 | do { \ | |
785 | register int slen = strlen(P); \ | |
786 | register char *p = (P); \ | |
787 | register int i; \ | |
788 | fprintf (FILE, "\t.ascii \""); \ | |
789 | for (i = 0; i < slen; i++) \ | |
790 | { \ | |
791 | register int c = p[i]; \ | |
792 | if (c == '\"' || c == '\\') \ | |
793 | putc ('\\', FILE); \ | |
794 | if (c >= ' ' && c < 0177) \ | |
795 | putc (c, FILE); \ | |
796 | else \ | |
797 | { \ | |
798 | fprintf (FILE, "\\%o", c); \ | |
799 | } \ | |
800 | } \ | |
801 | fprintf (FILE, "\\0\""); \ | |
802 | } \ | |
803 | while (0) | |
804 | #endif | |
805 | ||
806 | /* Convert a reference to the assembler name of a C-level name. This | |
807 | macro has the same effect as ASM_OUTPUT_LABELREF, but copies to | |
808 | a string rather than writing to a file. */ | |
809 | #ifndef ASM_NAME_TO_STRING | |
810 | #define ASM_NAME_TO_STRING(STR, NAME) \ | |
811 | do { \ | |
812 | if ((NAME)[0] == '*') \ | |
813 | strcpy (STR, NAME+1); \ | |
814 | else \ | |
815 | strcpy (STR, NAME); \ | |
816 | } \ | |
817 | while (0) | |
818 | #endif | |
819 | ||
820 | \f | |
821 | /************************ general utility functions **************************/ | |
822 | ||
823 | /* Return a pointer to a copy of the section string name 's' with all | |
824 | attributes stripped off. */ | |
825 | inline char * | |
826 | stripattributes (s) | |
827 | register char *s; | |
828 | { | |
829 | register char *stripped, *p; | |
830 | stripped = xstrdup (s); | |
831 | p = stripped; | |
832 | while (*p && *p != ',') | |
833 | p++; | |
834 | *p = '\0'; | |
835 | return stripped; | |
836 | } | |
837 | ||
838 | /* Convert an integer constant expression into assembler syntax. | |
839 | Addition and subtraction are the only arithmetic | |
840 | that may appear in these expressions. This is an adaptation | |
841 | of output_addr_const() in final.c. Here, the target of the | |
842 | conversion is a string buffer. We can't use output_addr_const | |
843 | directly, because it writes to a file. */ | |
844 | static void | |
845 | addr_const_to_string (str, x) | |
846 | char *str; | |
847 | rtx x; | |
848 | { | |
849 | char buf1[256]; | |
850 | char buf2[256]; | |
851 | ||
852 | restart: | |
853 | str[0] = '\0'; | |
854 | switch (GET_CODE (x)) | |
855 | { | |
856 | case PC: | |
857 | if (flag_pic) | |
858 | strcat (str, ","); | |
859 | else | |
860 | abort (); | |
861 | break; | |
862 | ||
863 | case SYMBOL_REF: | |
864 | ASM_NAME_TO_STRING (buf1, XSTR (x, 0)); | |
865 | strcat (str, buf1); | |
866 | break; | |
867 | ||
868 | case LABEL_REF: | |
869 | ASM_GENERATE_INTERNAL_LABEL (buf1, "L", CODE_LABEL_NUMBER (XEXP (x, 0))); | |
870 | ASM_NAME_TO_STRING (buf2, buf1); | |
871 | strcat (str, buf2); | |
872 | break; | |
873 | ||
874 | case CODE_LABEL: | |
875 | ASM_GENERATE_INTERNAL_LABEL (buf1, "L", CODE_LABEL_NUMBER (x)); | |
876 | ASM_NAME_TO_STRING (buf2, buf1); | |
877 | strcat (str, buf2); | |
878 | break; | |
879 | ||
880 | case CONST_INT: | |
881 | sprintf (buf1, | |
882 | #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
883 | "%d", | |
884 | #else | |
885 | "%ld", | |
886 | #endif | |
887 | INTVAL (x)); | |
888 | strcat (str, buf1); | |
889 | break; | |
890 | ||
891 | case CONST: | |
892 | /* This used to output parentheses around the expression, but that does | |
893 | not work on the 386 (either ATT or BSD assembler). */ | |
894 | addr_const_to_string (buf1, XEXP (x, 0)); | |
895 | strcat (str, buf1); | |
896 | break; | |
897 | ||
898 | case CONST_DOUBLE: | |
899 | if (GET_MODE (x) == VOIDmode) | |
900 | { | |
901 | /* We can use %d if the number is one word and positive. */ | |
902 | if (CONST_DOUBLE_HIGH (x)) | |
903 | sprintf (buf1, | |
904 | #if HOST_BITS_PER_WIDE_INT == 64 | |
905 | #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT | |
906 | "0x%lx%016lx", | |
907 | #else | |
908 | "0x%x%016x", | |
909 | #endif | |
910 | #else | |
911 | #if HOST_BITS_PER_WIDE_INT != HOST_BITS_PER_INT | |
912 | "0x%lx%08lx", | |
913 | #else | |
914 | "0x%x%08x", | |
915 | #endif | |
916 | #endif | |
917 | CONST_DOUBLE_HIGH (x), CONST_DOUBLE_LOW (x)); | |
918 | else if (CONST_DOUBLE_LOW (x) < 0) | |
919 | sprintf (buf1, | |
920 | #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
921 | "0x%x", | |
922 | #else | |
923 | "0x%lx", | |
924 | #endif | |
925 | CONST_DOUBLE_LOW (x)); | |
926 | else | |
927 | sprintf (buf1, | |
928 | #if HOST_BITS_PER_WIDE_INT == HOST_BITS_PER_INT | |
929 | "%d", | |
930 | #else | |
931 | "%ld", | |
932 | #endif | |
933 | CONST_DOUBLE_LOW (x)); | |
934 | strcat (str, buf1); | |
935 | } | |
936 | else | |
937 | /* We can't handle floating point constants; PRINT_OPERAND must | |
938 | handle them. */ | |
939 | output_operand_lossage ("floating constant misused"); | |
940 | break; | |
941 | ||
942 | case PLUS: | |
943 | /* Some assemblers need integer constants to appear last (eg masm). */ | |
944 | if (GET_CODE (XEXP (x, 0)) == CONST_INT) | |
945 | { | |
946 | addr_const_to_string (buf1, XEXP (x, 1)); | |
947 | strcat (str, buf1); | |
948 | if (INTVAL (XEXP (x, 0)) >= 0) | |
949 | strcat (str, "+"); | |
950 | addr_const_to_string (buf1, XEXP (x, 0)); | |
951 | strcat (str, buf1); | |
952 | } | |
953 | else | |
954 | { | |
955 | addr_const_to_string (buf1, XEXP (x, 0)); | |
956 | strcat (str, buf1); | |
bdb669cb | 957 | if (INTVAL (XEXP (x, 1)) >= 0) |
a3f97cbb JW |
958 | strcat (str, "+"); |
959 | addr_const_to_string (buf1, XEXP (x, 1)); | |
bdb669cb | 960 | strcat (str, buf1); |
a3f97cbb JW |
961 | } |
962 | break; | |
963 | ||
964 | case MINUS: | |
965 | /* Avoid outputting things like x-x or x+5-x, since some assemblers | |
966 | can't handle that. */ | |
967 | x = simplify_subtraction (x); | |
968 | if (GET_CODE (x) != MINUS) | |
969 | goto restart; | |
970 | ||
971 | addr_const_to_string (buf1, XEXP (x, 0)); | |
972 | strcat (str, buf1); | |
973 | strcat (str, "-"); | |
974 | if (GET_CODE (XEXP (x, 1)) == CONST_INT | |
975 | && INTVAL (XEXP (x, 1)) < 0) | |
976 | { | |
977 | strcat (str, ASM_OPEN_PAREN); | |
978 | addr_const_to_string (buf1, XEXP (x, 1)); | |
979 | strcat (str, buf1); | |
980 | strcat (str, ASM_CLOSE_PAREN); | |
981 | } | |
982 | else | |
983 | { | |
984 | addr_const_to_string (buf1, XEXP (x, 1)); | |
985 | strcat (str, buf1); | |
986 | } | |
987 | break; | |
988 | ||
989 | case ZERO_EXTEND: | |
990 | case SIGN_EXTEND: | |
991 | addr_const_to_string (buf1, XEXP (x, 0)); | |
992 | strcat (str, buf1); | |
993 | break; | |
994 | ||
995 | default: | |
996 | output_operand_lossage ("invalid expression as operand"); | |
997 | } | |
998 | } | |
999 | ||
1000 | /* Convert an address constant to a string, and return a pointer to | |
1001 | a copy of the result, located on the heap. */ | |
1002 | static char * | |
1003 | addr_to_string (x) | |
1004 | rtx x; | |
1005 | { | |
1006 | char buf[1024]; | |
1007 | addr_const_to_string (buf, x); | |
1008 | return xstrdup (buf); | |
1009 | } | |
1010 | ||
1011 | /* Test if rtl node points to a psuedo register. */ | |
1012 | inline int | |
1013 | is_pseudo_reg (rtl) | |
1014 | register rtx rtl; | |
1015 | { | |
1016 | return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER)) | |
1017 | || ((GET_CODE (rtl) == SUBREG) | |
1018 | && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER))); | |
1019 | } | |
1020 | ||
1021 | ||
1022 | /* Return a reference to a type, with its const and volatile qualifiers | |
1023 | removed. */ | |
1024 | inline tree | |
1025 | type_main_variant (type) | |
1026 | register tree type; | |
1027 | { | |
1028 | type = TYPE_MAIN_VARIANT (type); | |
1029 | ||
1030 | /* There really should be only one main variant among any group of variants | |
1031 | of a given type (and all of the MAIN_VARIANT values for all members of | |
1032 | the group should point to that one type) but sometimes the C front-end | |
1033 | messes this up for array types, so we work around that bug here. */ | |
1034 | if (TREE_CODE (type) == ARRAY_TYPE) | |
1035 | { | |
1036 | while (type != TYPE_MAIN_VARIANT (type)) | |
1037 | type = TYPE_MAIN_VARIANT (type); | |
1038 | } | |
1039 | return type; | |
1040 | } | |
1041 | ||
1042 | /* Return non-zero if the given type node represents a tagged type. */ | |
1043 | inline int | |
1044 | is_tagged_type (type) | |
1045 | register tree type; | |
1046 | { | |
1047 | register enum tree_code code = TREE_CODE (type); | |
1048 | ||
1049 | return (code == RECORD_TYPE || code == UNION_TYPE | |
1050 | || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE); | |
1051 | } | |
1052 | ||
1053 | /* Convert a DIE tag into its string name. */ | |
1054 | static char * | |
1055 | dwarf_tag_name (tag) | |
1056 | register unsigned tag; | |
1057 | { | |
1058 | switch (tag) | |
1059 | { | |
1060 | case DW_TAG_padding: | |
1061 | return "DW_TAG_padding"; | |
1062 | case DW_TAG_array_type: | |
1063 | return "DW_TAG_array_type"; | |
1064 | case DW_TAG_class_type: | |
1065 | return "DW_TAG_class_type"; | |
1066 | case DW_TAG_entry_point: | |
1067 | return "DW_TAG_entry_point"; | |
1068 | case DW_TAG_enumeration_type: | |
1069 | return "DW_TAG_enumeration_type"; | |
1070 | case DW_TAG_formal_parameter: | |
1071 | return "DW_TAG_formal_parameter"; | |
1072 | case DW_TAG_imported_declaration: | |
1073 | return "DW_TAG_imported_declaration"; | |
1074 | case DW_TAG_label: | |
1075 | return "DW_TAG_label"; | |
1076 | case DW_TAG_lexical_block: | |
1077 | return "DW_TAG_lexical_block"; | |
1078 | case DW_TAG_member: | |
1079 | return "DW_TAG_member"; | |
1080 | case DW_TAG_pointer_type: | |
1081 | return "DW_TAG_pointer_type"; | |
1082 | case DW_TAG_reference_type: | |
1083 | return "DW_TAG_reference_type"; | |
1084 | case DW_TAG_compile_unit: | |
1085 | return "DW_TAG_compile_unit"; | |
1086 | case DW_TAG_string_type: | |
1087 | return "DW_TAG_string_type"; | |
1088 | case DW_TAG_structure_type: | |
1089 | return "DW_TAG_structure_type"; | |
1090 | case DW_TAG_subroutine_type: | |
1091 | return "DW_TAG_subroutine_type"; | |
1092 | case DW_TAG_typedef: | |
1093 | return "DW_TAG_typedef"; | |
1094 | case DW_TAG_union_type: | |
1095 | return "DW_TAG_union_type"; | |
1096 | case DW_TAG_unspecified_parameters: | |
1097 | return "DW_TAG_unspecified_parameters"; | |
1098 | case DW_TAG_variant: | |
1099 | return "DW_TAG_variant"; | |
1100 | case DW_TAG_common_block: | |
1101 | return "DW_TAG_common_block"; | |
1102 | case DW_TAG_common_inclusion: | |
1103 | return "DW_TAG_common_inclusion"; | |
1104 | case DW_TAG_inheritance: | |
1105 | return "DW_TAG_inheritance"; | |
1106 | case DW_TAG_inlined_subroutine: | |
1107 | return "DW_TAG_inlined_subroutine"; | |
1108 | case DW_TAG_module: | |
1109 | return "DW_TAG_module"; | |
1110 | case DW_TAG_ptr_to_member_type: | |
1111 | return "DW_TAG_ptr_to_member_type"; | |
1112 | case DW_TAG_set_type: | |
1113 | return "DW_TAG_set_type"; | |
1114 | case DW_TAG_subrange_type: | |
1115 | return "DW_TAG_subrange_type"; | |
1116 | case DW_TAG_with_stmt: | |
1117 | return "DW_TAG_with_stmt"; | |
1118 | case DW_TAG_access_declaration: | |
1119 | return "DW_TAG_access_declaration"; | |
1120 | case DW_TAG_base_type: | |
1121 | return "DW_TAG_base_type"; | |
1122 | case DW_TAG_catch_block: | |
1123 | return "DW_TAG_catch_block"; | |
1124 | case DW_TAG_const_type: | |
1125 | return "DW_TAG_const_type"; | |
1126 | case DW_TAG_constant: | |
1127 | return "DW_TAG_constant"; | |
1128 | case DW_TAG_enumerator: | |
1129 | return "DW_TAG_enumerator"; | |
1130 | case DW_TAG_file_type: | |
1131 | return "DW_TAG_file_type"; | |
1132 | case DW_TAG_friend: | |
1133 | return "DW_TAG_friend"; | |
1134 | case DW_TAG_namelist: | |
1135 | return "DW_TAG_namelist"; | |
1136 | case DW_TAG_namelist_item: | |
1137 | return "DW_TAG_namelist_item"; | |
1138 | case DW_TAG_packed_type: | |
1139 | return "DW_TAG_packed_type"; | |
1140 | case DW_TAG_subprogram: | |
1141 | return "DW_TAG_subprogram"; | |
1142 | case DW_TAG_template_type_param: | |
1143 | return "DW_TAG_template_type_param"; | |
1144 | case DW_TAG_template_value_param: | |
1145 | return "DW_TAG_template_value_param"; | |
1146 | case DW_TAG_thrown_type: | |
1147 | return "DW_TAG_thrown_type"; | |
1148 | case DW_TAG_try_block: | |
1149 | return "DW_TAG_try_block"; | |
1150 | case DW_TAG_variant_part: | |
1151 | return "DW_TAG_variant_part"; | |
1152 | case DW_TAG_variable: | |
1153 | return "DW_TAG_variable"; | |
1154 | case DW_TAG_volatile_type: | |
1155 | return "DW_TAG_volatile_type"; | |
1156 | case DW_TAG_MIPS_loop: | |
1157 | return "DW_TAG_MIPS_loop"; | |
1158 | case DW_TAG_format_label: | |
1159 | return "DW_TAG_format_label"; | |
1160 | case DW_TAG_function_template: | |
1161 | return "DW_TAG_function_template"; | |
1162 | case DW_TAG_class_template: | |
1163 | return "DW_TAG_class_template"; | |
1164 | default: | |
1165 | return "DW_TAG_<unknown>"; | |
1166 | } | |
1167 | } | |
1168 | ||
1169 | /* Convert a DWARF attribute code into its string name. */ | |
1170 | static char * | |
1171 | dwarf_attr_name (attr) | |
1172 | register unsigned attr; | |
1173 | { | |
1174 | switch (attr) | |
1175 | { | |
1176 | case DW_AT_sibling: | |
1177 | return "DW_AT_sibling"; | |
1178 | case DW_AT_location: | |
1179 | return "DW_AT_location"; | |
1180 | case DW_AT_name: | |
1181 | return "DW_AT_name"; | |
1182 | case DW_AT_ordering: | |
1183 | return "DW_AT_ordering"; | |
1184 | case DW_AT_subscr_data: | |
1185 | return "DW_AT_subscr_data"; | |
1186 | case DW_AT_byte_size: | |
1187 | return "DW_AT_byte_size"; | |
1188 | case DW_AT_bit_offset: | |
1189 | return "DW_AT_bit_offset"; | |
1190 | case DW_AT_bit_size: | |
1191 | return "DW_AT_bit_size"; | |
1192 | case DW_AT_element_list: | |
1193 | return "DW_AT_element_list"; | |
1194 | case DW_AT_stmt_list: | |
1195 | return "DW_AT_stmt_list"; | |
1196 | case DW_AT_low_pc: | |
1197 | return "DW_AT_low_pc"; | |
1198 | case DW_AT_high_pc: | |
1199 | return "DW_AT_high_pc"; | |
1200 | case DW_AT_language: | |
1201 | return "DW_AT_language"; | |
1202 | case DW_AT_member: | |
1203 | return "DW_AT_member"; | |
1204 | case DW_AT_discr: | |
1205 | return "DW_AT_discr"; | |
1206 | case DW_AT_discr_value: | |
1207 | return "DW_AT_discr_value"; | |
1208 | case DW_AT_visibility: | |
1209 | return "DW_AT_visibility"; | |
1210 | case DW_AT_import: | |
1211 | return "DW_AT_import"; | |
1212 | case DW_AT_string_length: | |
1213 | return "DW_AT_string_length"; | |
1214 | case DW_AT_common_reference: | |
1215 | return "DW_AT_common_reference"; | |
1216 | case DW_AT_comp_dir: | |
1217 | return "DW_AT_comp_dir"; | |
1218 | case DW_AT_const_value: | |
1219 | return "DW_AT_const_value"; | |
1220 | case DW_AT_containing_type: | |
1221 | return "DW_AT_containing_type"; | |
1222 | case DW_AT_default_value: | |
1223 | return "DW_AT_default_value"; | |
1224 | case DW_AT_inline: | |
1225 | return "DW_AT_inline"; | |
1226 | case DW_AT_is_optional: | |
1227 | return "DW_AT_is_optional"; | |
1228 | case DW_AT_lower_bound: | |
1229 | return "DW_AT_lower_bound"; | |
1230 | case DW_AT_producer: | |
1231 | return "DW_AT_producer"; | |
1232 | case DW_AT_prototyped: | |
1233 | return "DW_AT_prototyped"; | |
1234 | case DW_AT_return_addr: | |
1235 | return "DW_AT_return_addr"; | |
1236 | case DW_AT_start_scope: | |
1237 | return "DW_AT_start_scope"; | |
1238 | case DW_AT_stride_size: | |
1239 | return "DW_AT_stride_size"; | |
1240 | case DW_AT_upper_bound: | |
1241 | return "DW_AT_upper_bound"; | |
1242 | case DW_AT_abstract_origin: | |
1243 | return "DW_AT_abstract_origin"; | |
1244 | case DW_AT_accessibility: | |
1245 | return "DW_AT_accessibility"; | |
1246 | case DW_AT_address_class: | |
1247 | return "DW_AT_address_class"; | |
1248 | case DW_AT_artificial: | |
1249 | return "DW_AT_artificial"; | |
1250 | case DW_AT_base_types: | |
1251 | return "DW_AT_base_types"; | |
1252 | case DW_AT_calling_convention: | |
1253 | return "DW_AT_calling_convention"; | |
1254 | case DW_AT_count: | |
1255 | return "DW_AT_count"; | |
1256 | case DW_AT_data_member_location: | |
1257 | return "DW_AT_data_member_location"; | |
1258 | case DW_AT_decl_column: | |
1259 | return "DW_AT_decl_column"; | |
1260 | case DW_AT_decl_file: | |
1261 | return "DW_AT_decl_file"; | |
1262 | case DW_AT_decl_line: | |
1263 | return "DW_AT_decl_line"; | |
1264 | case DW_AT_declaration: | |
1265 | return "DW_AT_declaration"; | |
1266 | case DW_AT_discr_list: | |
1267 | return "DW_AT_discr_list"; | |
1268 | case DW_AT_encoding: | |
1269 | return "DW_AT_encoding"; | |
1270 | case DW_AT_external: | |
1271 | return "DW_AT_external"; | |
1272 | case DW_AT_frame_base: | |
1273 | return "DW_AT_frame_base"; | |
1274 | case DW_AT_friend: | |
1275 | return "DW_AT_friend"; | |
1276 | case DW_AT_identifier_case: | |
1277 | return "DW_AT_identifier_case"; | |
1278 | case DW_AT_macro_info: | |
1279 | return "DW_AT_macro_info"; | |
1280 | case DW_AT_namelist_items: | |
1281 | return "DW_AT_namelist_items"; | |
1282 | case DW_AT_priority: | |
1283 | return "DW_AT_priority"; | |
1284 | case DW_AT_segment: | |
1285 | return "DW_AT_segment"; | |
1286 | case DW_AT_specification: | |
1287 | return "DW_AT_specification"; | |
1288 | case DW_AT_static_link: | |
1289 | return "DW_AT_static_link"; | |
1290 | case DW_AT_type: | |
1291 | return "DW_AT_type"; | |
1292 | case DW_AT_use_location: | |
1293 | return "DW_AT_use_location"; | |
1294 | case DW_AT_variable_parameter: | |
1295 | return "DW_AT_variable_parameter"; | |
1296 | case DW_AT_virtuality: | |
1297 | return "DW_AT_virtuality"; | |
1298 | case DW_AT_vtable_elem_location: | |
1299 | return "DW_AT_vtable_elem_location"; | |
1300 | ||
1301 | #ifdef MIPS_DEBUGGING_INFO | |
1302 | case DW_AT_MIPS_fde: | |
1303 | return "DW_AT_MIPS_fde"; | |
1304 | case DW_AT_MIPS_loop_begin: | |
1305 | return "DW_AT_MIPS_loop_begin"; | |
1306 | case DW_AT_MIPS_tail_loop_begin: | |
1307 | return "DW_AT_MIPS_tail_loop_begin"; | |
1308 | case DW_AT_MIPS_epilog_begin: | |
1309 | return "DW_AT_MIPS_epilog_begin"; | |
1310 | case DW_AT_MIPS_loop_unroll_factor: | |
1311 | return "DW_AT_MIPS_loop_unroll_factor"; | |
1312 | case DW_AT_MIPS_software_pipeline_depth: | |
1313 | return "DW_AT_MIPS_software_pipeline_depth"; | |
1314 | case DW_AT_MIPS_linkage_name: | |
1315 | return "DW_AT_MIPS_linkage_name"; | |
1316 | #endif | |
1317 | ||
1318 | case DW_AT_sf_names: | |
1319 | return "DW_AT_sf_names"; | |
1320 | case DW_AT_src_info: | |
1321 | return "DW_AT_src_info"; | |
1322 | case DW_AT_mac_info: | |
1323 | return "DW_AT_mac_info"; | |
1324 | case DW_AT_src_coords: | |
1325 | return "DW_AT_src_coords"; | |
1326 | case DW_AT_body_begin: | |
1327 | return "DW_AT_body_begin"; | |
1328 | case DW_AT_body_end: | |
1329 | return "DW_AT_body_end"; | |
1330 | default: | |
1331 | return "DW_AT_<unknown>"; | |
1332 | } | |
1333 | } | |
1334 | ||
1335 | /* Convert a DWARF value form code into its string name. */ | |
1336 | static char * | |
1337 | dwarf_form_name (form) | |
1338 | register unsigned form; | |
1339 | { | |
1340 | switch (form) | |
1341 | { | |
1342 | case DW_FORM_addr: | |
1343 | return "DW_FORM_addr"; | |
1344 | case DW_FORM_block2: | |
1345 | return "DW_FORM_block2"; | |
1346 | case DW_FORM_block4: | |
1347 | return "DW_FORM_block4"; | |
1348 | case DW_FORM_data2: | |
1349 | return "DW_FORM_data2"; | |
1350 | case DW_FORM_data4: | |
1351 | return "DW_FORM_data4"; | |
1352 | case DW_FORM_data8: | |
1353 | return "DW_FORM_data8"; | |
1354 | case DW_FORM_string: | |
1355 | return "DW_FORM_string"; | |
1356 | case DW_FORM_block: | |
1357 | return "DW_FORM_block"; | |
1358 | case DW_FORM_block1: | |
1359 | return "DW_FORM_block1"; | |
1360 | case DW_FORM_data1: | |
1361 | return "DW_FORM_data1"; | |
1362 | case DW_FORM_flag: | |
1363 | return "DW_FORM_flag"; | |
1364 | case DW_FORM_sdata: | |
1365 | return "DW_FORM_sdata"; | |
1366 | case DW_FORM_strp: | |
1367 | return "DW_FORM_strp"; | |
1368 | case DW_FORM_udata: | |
1369 | return "DW_FORM_udata"; | |
1370 | case DW_FORM_ref_addr: | |
1371 | return "DW_FORM_ref_addr"; | |
1372 | case DW_FORM_ref1: | |
1373 | return "DW_FORM_ref1"; | |
1374 | case DW_FORM_ref2: | |
1375 | return "DW_FORM_ref2"; | |
1376 | case DW_FORM_ref4: | |
1377 | return "DW_FORM_ref4"; | |
1378 | case DW_FORM_ref8: | |
1379 | return "DW_FORM_ref8"; | |
1380 | case DW_FORM_ref_udata: | |
1381 | return "DW_FORM_ref_udata"; | |
1382 | case DW_FORM_indirect: | |
1383 | return "DW_FORM_indirect"; | |
1384 | default: | |
1385 | return "DW_FORM_<unknown>"; | |
1386 | } | |
1387 | } | |
1388 | ||
1389 | /* Convert a DWARF stack opcode into its string name. */ | |
1390 | static char * | |
1391 | dwarf_stack_op_name (op) | |
1392 | register unsigned op; | |
1393 | { | |
1394 | switch (op) | |
1395 | { | |
1396 | case DW_OP_addr: | |
1397 | return "DW_OP_addr"; | |
1398 | case DW_OP_deref: | |
1399 | return "DW_OP_deref"; | |
1400 | case DW_OP_const1u: | |
1401 | return "DW_OP_const1u"; | |
1402 | case DW_OP_const1s: | |
1403 | return "DW_OP_const1s"; | |
1404 | case DW_OP_const2u: | |
1405 | return "DW_OP_const2u"; | |
1406 | case DW_OP_const2s: | |
1407 | return "DW_OP_const2s"; | |
1408 | case DW_OP_const4u: | |
1409 | return "DW_OP_const4u"; | |
1410 | case DW_OP_const4s: | |
1411 | return "DW_OP_const4s"; | |
1412 | case DW_OP_const8u: | |
1413 | return "DW_OP_const8u"; | |
1414 | case DW_OP_const8s: | |
1415 | return "DW_OP_const8s"; | |
1416 | case DW_OP_constu: | |
1417 | return "DW_OP_constu"; | |
1418 | case DW_OP_consts: | |
1419 | return "DW_OP_consts"; | |
1420 | case DW_OP_dup: | |
1421 | return "DW_OP_dup"; | |
1422 | case DW_OP_drop: | |
1423 | return "DW_OP_drop"; | |
1424 | case DW_OP_over: | |
1425 | return "DW_OP_over"; | |
1426 | case DW_OP_pick: | |
1427 | return "DW_OP_pick"; | |
1428 | case DW_OP_swap: | |
1429 | return "DW_OP_swap"; | |
1430 | case DW_OP_rot: | |
1431 | return "DW_OP_rot"; | |
1432 | case DW_OP_xderef: | |
1433 | return "DW_OP_xderef"; | |
1434 | case DW_OP_abs: | |
1435 | return "DW_OP_abs"; | |
1436 | case DW_OP_and: | |
1437 | return "DW_OP_and"; | |
1438 | case DW_OP_div: | |
1439 | return "DW_OP_div"; | |
1440 | case DW_OP_minus: | |
1441 | return "DW_OP_minus"; | |
1442 | case DW_OP_mod: | |
1443 | return "DW_OP_mod"; | |
1444 | case DW_OP_mul: | |
1445 | return "DW_OP_mul"; | |
1446 | case DW_OP_neg: | |
1447 | return "DW_OP_neg"; | |
1448 | case DW_OP_not: | |
1449 | return "DW_OP_not"; | |
1450 | case DW_OP_or: | |
1451 | return "DW_OP_or"; | |
1452 | case DW_OP_plus: | |
1453 | return "DW_OP_plus"; | |
1454 | case DW_OP_plus_uconst: | |
1455 | return "DW_OP_plus_uconst"; | |
1456 | case DW_OP_shl: | |
1457 | return "DW_OP_shl"; | |
1458 | case DW_OP_shr: | |
1459 | return "DW_OP_shr"; | |
1460 | case DW_OP_shra: | |
1461 | return "DW_OP_shra"; | |
1462 | case DW_OP_xor: | |
1463 | return "DW_OP_xor"; | |
1464 | case DW_OP_bra: | |
1465 | return "DW_OP_bra"; | |
1466 | case DW_OP_eq: | |
1467 | return "DW_OP_eq"; | |
1468 | case DW_OP_ge: | |
1469 | return "DW_OP_ge"; | |
1470 | case DW_OP_gt: | |
1471 | return "DW_OP_gt"; | |
1472 | case DW_OP_le: | |
1473 | return "DW_OP_le"; | |
1474 | case DW_OP_lt: | |
1475 | return "DW_OP_lt"; | |
1476 | case DW_OP_ne: | |
1477 | return "DW_OP_ne"; | |
1478 | case DW_OP_skip: | |
1479 | return "DW_OP_skip"; | |
1480 | case DW_OP_lit0: | |
1481 | return "DW_OP_lit0"; | |
1482 | case DW_OP_lit1: | |
1483 | return "DW_OP_lit1"; | |
1484 | case DW_OP_lit2: | |
1485 | return "DW_OP_lit2"; | |
1486 | case DW_OP_lit3: | |
1487 | return "DW_OP_lit3"; | |
1488 | case DW_OP_lit4: | |
1489 | return "DW_OP_lit4"; | |
1490 | case DW_OP_lit5: | |
1491 | return "DW_OP_lit5"; | |
1492 | case DW_OP_lit6: | |
1493 | return "DW_OP_lit6"; | |
1494 | case DW_OP_lit7: | |
1495 | return "DW_OP_lit7"; | |
1496 | case DW_OP_lit8: | |
1497 | return "DW_OP_lit8"; | |
1498 | case DW_OP_lit9: | |
1499 | return "DW_OP_lit9"; | |
1500 | case DW_OP_lit10: | |
1501 | return "DW_OP_lit10"; | |
1502 | case DW_OP_lit11: | |
1503 | return "DW_OP_lit11"; | |
1504 | case DW_OP_lit12: | |
1505 | return "DW_OP_lit12"; | |
1506 | case DW_OP_lit13: | |
1507 | return "DW_OP_lit13"; | |
1508 | case DW_OP_lit14: | |
1509 | return "DW_OP_lit14"; | |
1510 | case DW_OP_lit15: | |
1511 | return "DW_OP_lit15"; | |
1512 | case DW_OP_lit16: | |
1513 | return "DW_OP_lit16"; | |
1514 | case DW_OP_lit17: | |
1515 | return "DW_OP_lit17"; | |
1516 | case DW_OP_lit18: | |
1517 | return "DW_OP_lit18"; | |
1518 | case DW_OP_lit19: | |
1519 | return "DW_OP_lit19"; | |
1520 | case DW_OP_lit20: | |
1521 | return "DW_OP_lit20"; | |
1522 | case DW_OP_lit21: | |
1523 | return "DW_OP_lit21"; | |
1524 | case DW_OP_lit22: | |
1525 | return "DW_OP_lit22"; | |
1526 | case DW_OP_lit23: | |
1527 | return "DW_OP_lit23"; | |
1528 | case DW_OP_lit24: | |
1529 | return "DW_OP_lit24"; | |
1530 | case DW_OP_lit25: | |
1531 | return "DW_OP_lit25"; | |
1532 | case DW_OP_lit26: | |
1533 | return "DW_OP_lit26"; | |
1534 | case DW_OP_lit27: | |
1535 | return "DW_OP_lit27"; | |
1536 | case DW_OP_lit28: | |
1537 | return "DW_OP_lit28"; | |
1538 | case DW_OP_lit29: | |
1539 | return "DW_OP_lit29"; | |
1540 | case DW_OP_lit30: | |
1541 | return "DW_OP_lit30"; | |
1542 | case DW_OP_lit31: | |
1543 | return "DW_OP_lit31"; | |
1544 | case DW_OP_reg0: | |
1545 | return "DW_OP_reg0"; | |
1546 | case DW_OP_reg1: | |
1547 | return "DW_OP_reg1"; | |
1548 | case DW_OP_reg2: | |
1549 | return "DW_OP_reg2"; | |
1550 | case DW_OP_reg3: | |
1551 | return "DW_OP_reg3"; | |
1552 | case DW_OP_reg4: | |
1553 | return "DW_OP_reg4"; | |
1554 | case DW_OP_reg5: | |
1555 | return "DW_OP_reg5"; | |
1556 | case DW_OP_reg6: | |
1557 | return "DW_OP_reg6"; | |
1558 | case DW_OP_reg7: | |
1559 | return "DW_OP_reg7"; | |
1560 | case DW_OP_reg8: | |
1561 | return "DW_OP_reg8"; | |
1562 | case DW_OP_reg9: | |
1563 | return "DW_OP_reg9"; | |
1564 | case DW_OP_reg10: | |
1565 | return "DW_OP_reg10"; | |
1566 | case DW_OP_reg11: | |
1567 | return "DW_OP_reg11"; | |
1568 | case DW_OP_reg12: | |
1569 | return "DW_OP_reg12"; | |
1570 | case DW_OP_reg13: | |
1571 | return "DW_OP_reg13"; | |
1572 | case DW_OP_reg14: | |
1573 | return "DW_OP_reg14"; | |
1574 | case DW_OP_reg15: | |
1575 | return "DW_OP_reg15"; | |
1576 | case DW_OP_reg16: | |
1577 | return "DW_OP_reg16"; | |
1578 | case DW_OP_reg17: | |
1579 | return "DW_OP_reg17"; | |
1580 | case DW_OP_reg18: | |
1581 | return "DW_OP_reg18"; | |
1582 | case DW_OP_reg19: | |
1583 | return "DW_OP_reg19"; | |
1584 | case DW_OP_reg20: | |
1585 | return "DW_OP_reg20"; | |
1586 | case DW_OP_reg21: | |
1587 | return "DW_OP_reg21"; | |
1588 | case DW_OP_reg22: | |
1589 | return "DW_OP_reg22"; | |
1590 | case DW_OP_reg23: | |
1591 | return "DW_OP_reg23"; | |
1592 | case DW_OP_reg24: | |
1593 | return "DW_OP_reg24"; | |
1594 | case DW_OP_reg25: | |
1595 | return "DW_OP_reg25"; | |
1596 | case DW_OP_reg26: | |
1597 | return "DW_OP_reg26"; | |
1598 | case DW_OP_reg27: | |
1599 | return "DW_OP_reg27"; | |
1600 | case DW_OP_reg28: | |
1601 | return "DW_OP_reg28"; | |
1602 | case DW_OP_reg29: | |
1603 | return "DW_OP_reg29"; | |
1604 | case DW_OP_reg30: | |
1605 | return "DW_OP_reg30"; | |
1606 | case DW_OP_reg31: | |
1607 | return "DW_OP_reg31"; | |
1608 | case DW_OP_breg0: | |
1609 | return "DW_OP_breg0"; | |
1610 | case DW_OP_breg1: | |
1611 | return "DW_OP_breg1"; | |
1612 | case DW_OP_breg2: | |
1613 | return "DW_OP_breg2"; | |
1614 | case DW_OP_breg3: | |
1615 | return "DW_OP_breg3"; | |
1616 | case DW_OP_breg4: | |
1617 | return "DW_OP_breg4"; | |
1618 | case DW_OP_breg5: | |
1619 | return "DW_OP_breg5"; | |
1620 | case DW_OP_breg6: | |
1621 | return "DW_OP_breg6"; | |
1622 | case DW_OP_breg7: | |
1623 | return "DW_OP_breg7"; | |
1624 | case DW_OP_breg8: | |
1625 | return "DW_OP_breg8"; | |
1626 | case DW_OP_breg9: | |
1627 | return "DW_OP_breg9"; | |
1628 | case DW_OP_breg10: | |
1629 | return "DW_OP_breg10"; | |
1630 | case DW_OP_breg11: | |
1631 | return "DW_OP_breg11"; | |
1632 | case DW_OP_breg12: | |
1633 | return "DW_OP_breg12"; | |
1634 | case DW_OP_breg13: | |
1635 | return "DW_OP_breg13"; | |
1636 | case DW_OP_breg14: | |
1637 | return "DW_OP_breg14"; | |
1638 | case DW_OP_breg15: | |
1639 | return "DW_OP_breg15"; | |
1640 | case DW_OP_breg16: | |
1641 | return "DW_OP_breg16"; | |
1642 | case DW_OP_breg17: | |
1643 | return "DW_OP_breg17"; | |
1644 | case DW_OP_breg18: | |
1645 | return "DW_OP_breg18"; | |
1646 | case DW_OP_breg19: | |
1647 | return "DW_OP_breg19"; | |
1648 | case DW_OP_breg20: | |
1649 | return "DW_OP_breg20"; | |
1650 | case DW_OP_breg21: | |
1651 | return "DW_OP_breg21"; | |
1652 | case DW_OP_breg22: | |
1653 | return "DW_OP_breg22"; | |
1654 | case DW_OP_breg23: | |
1655 | return "DW_OP_breg23"; | |
1656 | case DW_OP_breg24: | |
1657 | return "DW_OP_breg24"; | |
1658 | case DW_OP_breg25: | |
1659 | return "DW_OP_breg25"; | |
1660 | case DW_OP_breg26: | |
1661 | return "DW_OP_breg26"; | |
1662 | case DW_OP_breg27: | |
1663 | return "DW_OP_breg27"; | |
1664 | case DW_OP_breg28: | |
1665 | return "DW_OP_breg28"; | |
1666 | case DW_OP_breg29: | |
1667 | return "DW_OP_breg29"; | |
1668 | case DW_OP_breg30: | |
1669 | return "DW_OP_breg30"; | |
1670 | case DW_OP_breg31: | |
1671 | return "DW_OP_breg31"; | |
1672 | case DW_OP_regx: | |
1673 | return "DW_OP_regx"; | |
1674 | case DW_OP_fbreg: | |
1675 | return "DW_OP_fbreg"; | |
1676 | case DW_OP_bregx: | |
1677 | return "DW_OP_bregx"; | |
1678 | case DW_OP_piece: | |
1679 | return "DW_OP_piece"; | |
1680 | case DW_OP_deref_size: | |
1681 | return "DW_OP_deref_size"; | |
1682 | case DW_OP_xderef_size: | |
1683 | return "DW_OP_xderef_size"; | |
1684 | case DW_OP_nop: | |
1685 | return "DW_OP_nop"; | |
1686 | default: | |
1687 | return "OP_<unknown>"; | |
1688 | } | |
1689 | } | |
1690 | ||
1691 | /* Convert a DWARF type code into its string name. */ | |
1692 | static char * | |
1693 | dwarf_type_encoding_name (enc) | |
1694 | register unsigned enc; | |
1695 | { | |
1696 | switch (enc) | |
1697 | { | |
1698 | case DW_ATE_address: | |
1699 | return "DW_ATE_address"; | |
1700 | case DW_ATE_boolean: | |
1701 | return "DW_ATE_boolean"; | |
1702 | case DW_ATE_complex_float: | |
1703 | return "DW_ATE_complex_float"; | |
1704 | case DW_ATE_float: | |
1705 | return "DW_ATE_float"; | |
1706 | case DW_ATE_signed: | |
1707 | return "DW_ATE_signed"; | |
1708 | case DW_ATE_signed_char: | |
1709 | return "DW_ATE_signed_char"; | |
1710 | case DW_ATE_unsigned: | |
1711 | return "DW_ATE_unsigned"; | |
1712 | case DW_ATE_unsigned_char: | |
1713 | return "DW_ATE_unsigned_char"; | |
1714 | default: | |
1715 | return "DW_ATE_<unknown>"; | |
1716 | } | |
1717 | } | |
1718 | ||
1719 | /* Convert a DWARF call frame info. operation to its string name */ | |
1720 | static char * | |
1721 | dwarf_cfi_name (cfi_opc) | |
1722 | register unsigned cfi_opc; | |
1723 | { | |
1724 | switch (cfi_opc) | |
1725 | { | |
1726 | case DW_CFA_advance_loc: | |
1727 | return "DW_CFA_advance_loc"; | |
1728 | case DW_CFA_offset: | |
1729 | return "DW_CFA_offset"; | |
1730 | case DW_CFA_restore: | |
1731 | return "DW_CFA_restore"; | |
1732 | case DW_CFA_nop: | |
1733 | return "DW_CFA_nop"; | |
1734 | case DW_CFA_set_loc: | |
1735 | return "DW_CFA_set_loc"; | |
1736 | case DW_CFA_advance_loc1: | |
1737 | return "DW_CFA_advance_loc1"; | |
1738 | case DW_CFA_advance_loc2: | |
1739 | return "DW_CFA_advance_loc2"; | |
1740 | case DW_CFA_advance_loc4: | |
1741 | return "DW_CFA_advance_loc4"; | |
1742 | case DW_CFA_offset_extended: | |
1743 | return "DW_CFA_offset_extended"; | |
1744 | case DW_CFA_restore_extended: | |
1745 | return "DW_CFA_restore_extended"; | |
1746 | case DW_CFA_undefined: | |
1747 | return "DW_CFA_undefined"; | |
1748 | case DW_CFA_same_value: | |
1749 | return "DW_CFA_same_value"; | |
1750 | case DW_CFA_register: | |
1751 | return "DW_CFA_register"; | |
1752 | case DW_CFA_remember_state: | |
1753 | return "DW_CFA_remember_state"; | |
1754 | case DW_CFA_restore_state: | |
1755 | return "DW_CFA_restore_state"; | |
1756 | case DW_CFA_def_cfa: | |
1757 | return "DW_CFA_def_cfa"; | |
1758 | case DW_CFA_def_cfa_register: | |
1759 | return "DW_CFA_def_cfa_register"; | |
1760 | case DW_CFA_def_cfa_offset: | |
1761 | return "DW_CFA_def_cfa_offset"; | |
1762 | /* SGI/MIPS specific */ | |
1763 | case DW_CFA_MIPS_advance_loc8: | |
1764 | return "DW_CFA_MIPS_advance_loc8"; | |
1765 | default: | |
1766 | return "DW_CFA_<unknown>"; | |
1767 | } | |
1768 | } | |
1769 | \f | |
1770 | /* Determine the "ultimate origin" of a decl. The decl may be an inlined | |
1771 | instance of an inlined instance of a decl which is local to an inline | |
1772 | function, so we have to trace all of the way back through the origin chain | |
1773 | to find out what sort of node actually served as the original seed for the | |
1774 | given block. */ | |
1775 | static tree | |
1776 | decl_ultimate_origin (decl) | |
1777 | register tree decl; | |
1778 | { | |
1779 | register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl); | |
1780 | ||
1781 | if (immediate_origin == NULL) | |
1782 | return NULL; | |
1783 | else | |
1784 | { | |
1785 | register tree ret_val; | |
1786 | register tree lookahead = immediate_origin; | |
1787 | ||
1788 | do | |
1789 | { | |
1790 | ret_val = lookahead; | |
1791 | lookahead = DECL_ABSTRACT_ORIGIN (ret_val); | |
1792 | } | |
1793 | while (lookahead != NULL && lookahead != ret_val); | |
1794 | return ret_val; | |
1795 | } | |
1796 | } | |
1797 | ||
1798 | /* Determine the "ultimate origin" of a block. The block may be an inlined | |
1799 | instance of an inlined instance of a block which is local to an inline | |
1800 | function, so we have to trace all of the way back through the origin chain | |
1801 | to find out what sort of node actually served as the original seed for the | |
1802 | given block. */ | |
1803 | static tree | |
1804 | block_ultimate_origin (block) | |
1805 | register tree block; | |
1806 | { | |
1807 | register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block); | |
1808 | ||
1809 | if (immediate_origin == NULL) | |
1810 | return NULL; | |
1811 | else | |
1812 | { | |
1813 | register tree ret_val; | |
1814 | register tree lookahead = immediate_origin; | |
1815 | ||
1816 | do | |
1817 | { | |
1818 | ret_val = lookahead; | |
1819 | lookahead = (TREE_CODE (ret_val) == BLOCK) | |
1820 | ? BLOCK_ABSTRACT_ORIGIN (ret_val) | |
1821 | : NULL; | |
1822 | } | |
1823 | while (lookahead != NULL && lookahead != ret_val); | |
1824 | return ret_val; | |
1825 | } | |
1826 | } | |
bdb669cb JM |
1827 | |
1828 | /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT | |
1829 | of a virtual function may refer to a base class, so we check the 'this' | |
1830 | parameter. */ | |
1831 | ||
1832 | tree | |
1833 | decl_class_context (decl) | |
1834 | tree decl; | |
1835 | { | |
1836 | tree context = NULL_TREE; | |
1837 | if (TREE_CODE (decl) != FUNCTION_DECL | |
1838 | || ! DECL_VIRTUAL_P (decl)) | |
1839 | context = DECL_CONTEXT (decl); | |
1840 | else | |
1841 | context = TYPE_MAIN_VARIANT | |
1842 | (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl))))); | |
1843 | ||
1844 | if (context && TREE_CODE_CLASS (TREE_CODE (context)) != 't') | |
1845 | context = NULL_TREE; | |
1846 | ||
1847 | return context; | |
1848 | } | |
a3f97cbb JW |
1849 | \f |
1850 | /**************** DIE internal representation constturction *******************/ | |
1851 | ||
1852 | /* Add an attribute/value pair to a DIE */ | |
1853 | inline void | |
1854 | add_dwarf_attr (die, attr) | |
1855 | register dw_die_ref die; | |
1856 | register dw_attr_ref attr; | |
1857 | { | |
1858 | if (die != NULL && attr != NULL) | |
1859 | { | |
1860 | if (die->die_attr == NULL) | |
1861 | { | |
1862 | die->die_attr = attr; | |
1863 | die->die_attr_last = attr; | |
1864 | } | |
1865 | else | |
1866 | { | |
1867 | die->die_attr_last->dw_attr_next = attr; | |
1868 | die->die_attr_last = attr; | |
1869 | } | |
1870 | } | |
1871 | } | |
1872 | ||
1873 | /* Add a flag value attribute to a DIE. */ | |
1874 | inline void | |
1875 | add_AT_flag (die, attr_kind, flag) | |
1876 | register dw_die_ref die; | |
1877 | register enum dwarf_attribute attr_kind; | |
1878 | register unsigned flag; | |
1879 | { | |
1880 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1881 | if (attr != NULL) | |
1882 | { | |
1883 | attr->dw_attr_next = NULL; | |
1884 | attr->dw_attr = attr_kind; | |
1885 | attr->dw_attr_val.val_class = dw_val_class_flag; | |
1886 | attr->dw_attr_val.v.val_flag = flag; | |
1887 | add_dwarf_attr (die, attr); | |
1888 | } | |
1889 | } | |
1890 | ||
1891 | /* Add a signed integer attribute value to a DIE. */ | |
1892 | inline void | |
1893 | add_AT_int (die, attr_kind, int_val) | |
1894 | register dw_die_ref die; | |
1895 | register enum dwarf_attribute attr_kind; | |
1896 | register long int int_val; | |
1897 | { | |
1898 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1899 | if (attr != NULL) | |
1900 | { | |
1901 | attr->dw_attr_next = NULL; | |
1902 | attr->dw_attr = attr_kind; | |
1903 | attr->dw_attr_val.val_class = dw_val_class_const; | |
1904 | attr->dw_attr_val.v.val_int = int_val; | |
1905 | add_dwarf_attr (die, attr); | |
1906 | } | |
1907 | } | |
1908 | ||
1909 | /* Add an unsigned integer attribute value to a DIE. */ | |
1910 | inline void | |
1911 | add_AT_unsigned (die, attr_kind, unsigned_val) | |
1912 | register dw_die_ref die; | |
1913 | register enum dwarf_attribute attr_kind; | |
1914 | register unsigned long unsigned_val; | |
1915 | { | |
1916 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1917 | if (attr != NULL) | |
1918 | { | |
1919 | attr->dw_attr_next = NULL; | |
1920 | attr->dw_attr = attr_kind; | |
1921 | attr->dw_attr_val.val_class = dw_val_class_unsigned_const; | |
1922 | attr->dw_attr_val.v.val_unsigned = unsigned_val; | |
1923 | add_dwarf_attr (die, attr); | |
1924 | } | |
1925 | } | |
1926 | ||
1927 | /* Add an unsigned double integer attribute value to a DIE. */ | |
1928 | inline void | |
1929 | add_AT_double (die, attr_kind, val_hi, val_low) | |
1930 | register dw_die_ref die; | |
1931 | register enum dwarf_attribute attr_kind; | |
1932 | register unsigned long val_hi; | |
1933 | register unsigned long val_low; | |
1934 | { | |
1935 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1936 | if (attr != NULL) | |
1937 | { | |
1938 | attr->dw_attr_next = NULL; | |
1939 | attr->dw_attr = attr_kind; | |
1940 | attr->dw_attr_val.val_class = dw_val_class_double_const; | |
1941 | attr->dw_attr_val.v.val_dbl_const.dw_dbl_hi = val_hi; | |
1942 | attr->dw_attr_val.v.val_dbl_const.dw_dbl_low = val_low; | |
1943 | add_dwarf_attr (die, attr); | |
1944 | } | |
1945 | } | |
1946 | ||
1947 | /* Add a string attribute value to a DIE. */ | |
1948 | inline void | |
1949 | add_AT_string (die, attr_kind, str) | |
1950 | register dw_die_ref die; | |
1951 | register enum dwarf_attribute attr_kind; | |
1952 | register char *str; | |
1953 | { | |
1954 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1955 | if (attr != NULL) | |
1956 | { | |
1957 | attr->dw_attr_next = NULL; | |
1958 | attr->dw_attr = attr_kind; | |
1959 | attr->dw_attr_val.val_class = dw_val_class_str; | |
1960 | attr->dw_attr_val.v.val_str = xstrdup (str); | |
1961 | add_dwarf_attr (die, attr); | |
1962 | } | |
1963 | } | |
1964 | ||
1965 | /* Add a DIE reference attribute value to a DIE. */ | |
1966 | inline void | |
1967 | add_AT_die_ref (die, attr_kind, targ_die) | |
1968 | register dw_die_ref die; | |
1969 | register enum dwarf_attribute attr_kind; | |
1970 | register dw_die_ref targ_die; | |
1971 | { | |
1972 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1973 | if (attr != NULL) | |
1974 | { | |
1975 | attr->dw_attr_next = NULL; | |
1976 | attr->dw_attr = attr_kind; | |
1977 | attr->dw_attr_val.val_class = dw_val_class_die_ref; | |
1978 | attr->dw_attr_val.v.val_die_ref = targ_die; | |
1979 | add_dwarf_attr (die, attr); | |
1980 | } | |
1981 | } | |
1982 | ||
1983 | /* Add an FDE reference attribute value to a DIE. */ | |
1984 | inline void | |
1985 | add_AT_fde_ref (die, attr_kind, targ_fde) | |
1986 | register dw_die_ref die; | |
1987 | register enum dwarf_attribute attr_kind; | |
1988 | register unsigned targ_fde; | |
1989 | { | |
1990 | register dw_attr_ref attr; | |
1991 | ||
1992 | attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
1993 | if (attr != NULL) | |
1994 | { | |
1995 | attr->dw_attr_next = NULL; | |
1996 | attr->dw_attr = attr_kind; | |
1997 | attr->dw_attr_val.val_class = dw_val_class_fde_ref; | |
1998 | attr->dw_attr_val.v.val_fde_index = targ_fde; | |
1999 | add_dwarf_attr (die, attr); | |
2000 | } | |
2001 | } | |
2002 | ||
2003 | /* Add a location description attribute value to a DIE. */ | |
2004 | inline void | |
2005 | add_AT_loc (die, attr_kind, loc) | |
2006 | register dw_die_ref die; | |
2007 | register enum dwarf_attribute attr_kind; | |
2008 | register dw_loc_descr_ref loc; | |
2009 | { | |
2010 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
2011 | if (attr != NULL) | |
2012 | { | |
2013 | attr->dw_attr_next = NULL; | |
2014 | attr->dw_attr = attr_kind; | |
2015 | attr->dw_attr_val.val_class = dw_val_class_loc; | |
2016 | attr->dw_attr_val.v.val_loc = loc; | |
2017 | add_dwarf_attr (die, attr); | |
2018 | } | |
2019 | } | |
2020 | ||
2021 | /* Add an address constant attribute value to a DIE. */ | |
2022 | inline void | |
2023 | add_AT_addr (die, attr_kind, addr) | |
2024 | register dw_die_ref die; | |
2025 | register enum dwarf_attribute attr_kind; | |
2026 | char *addr; | |
2027 | { | |
2028 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
2029 | if (attr != NULL) | |
2030 | { | |
2031 | attr->dw_attr_next = NULL; | |
2032 | attr->dw_attr = attr_kind; | |
2033 | attr->dw_attr_val.val_class = dw_val_class_addr; | |
2034 | attr->dw_attr_val.v.val_addr = addr; | |
2035 | add_dwarf_attr (die, attr); | |
2036 | } | |
2037 | } | |
2038 | ||
2039 | /* Add a label identifier attribute value to a DIE. */ | |
2040 | inline void | |
2041 | add_AT_lbl_id (die, attr_kind, lbl_id) | |
2042 | register dw_die_ref die; | |
2043 | register enum dwarf_attribute attr_kind; | |
2044 | register char *lbl_id; | |
2045 | { | |
2046 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
2047 | if (attr != NULL) | |
2048 | { | |
2049 | attr->dw_attr_next = NULL; | |
2050 | attr->dw_attr = attr_kind; | |
2051 | attr->dw_attr_val.val_class = dw_val_class_lbl_id; | |
2052 | attr->dw_attr_val.v.val_lbl_id = xstrdup (lbl_id); | |
2053 | add_dwarf_attr (die, attr); | |
2054 | } | |
2055 | } | |
2056 | ||
2057 | /* Add a section offset attribute value to a DIE. */ | |
2058 | inline void | |
2059 | add_AT_section_offset (die, attr_kind, section) | |
2060 | register dw_die_ref die; | |
2061 | register enum dwarf_attribute attr_kind; | |
2062 | register char *section; | |
2063 | { | |
2064 | register dw_attr_ref attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
2065 | if (attr != NULL) | |
2066 | { | |
2067 | attr->dw_attr_next = NULL; | |
2068 | attr->dw_attr = attr_kind; | |
2069 | attr->dw_attr_val.val_class = dw_val_class_section_offset; | |
2070 | attr->dw_attr_val.v.val_section = section; | |
2071 | add_dwarf_attr (die, attr); | |
2072 | } | |
2073 | } | |
2074 | ||
a3f97cbb JW |
2075 | /* Test if die refers to an external subroutine. */ |
2076 | inline int | |
2077 | is_extern_subr_die (die) | |
2078 | register dw_die_ref die; | |
2079 | { | |
2080 | register dw_attr_ref a; | |
2081 | register int is_subr = FALSE; | |
2082 | register int is_extern = FALSE; | |
2083 | if (die != NULL && die->die_tag == DW_TAG_subprogram) | |
2084 | { | |
2085 | is_subr = TRUE; | |
2086 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2087 | { | |
2088 | if (a->dw_attr == DW_AT_external | |
2089 | && a->dw_attr_val.val_class == dw_val_class_flag | |
2090 | && a->dw_attr_val.v.val_flag != 0) | |
2091 | { | |
2092 | is_extern = TRUE; | |
2093 | break; | |
2094 | } | |
2095 | } | |
2096 | } | |
2097 | return is_subr && is_extern; | |
2098 | } | |
2099 | ||
2100 | /* Return the "low pc" attribute value, typically associated with | |
2101 | a subprogram DIE. Return null if the "low pc" attribute is | |
2102 | either not prsent, or if it cannot be represented as an | |
2103 | assembler label identifier. */ | |
2104 | inline char * | |
2105 | get_AT_low_pc (die) | |
2106 | register dw_die_ref die; | |
2107 | { | |
2108 | register dw_attr_ref a; | |
2109 | register char *low_pc = NULL; | |
2110 | if (die != NULL) | |
2111 | { | |
2112 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2113 | { | |
2114 | if (a->dw_attr == DW_AT_low_pc | |
2115 | && a->dw_attr_val.val_class == dw_val_class_lbl_id) | |
2116 | { | |
2117 | low_pc = a->dw_attr_val.v.val_lbl_id; | |
2118 | break; | |
2119 | } | |
2120 | } | |
2121 | } | |
2122 | return low_pc; | |
2123 | } | |
2124 | ||
bdb669cb JM |
2125 | /* Return the value of the flag attribute designated by ATTR_KIND, or -1 |
2126 | if it is not present. */ | |
2127 | inline int | |
2128 | get_AT_flag (die, attr_kind) | |
2129 | register dw_die_ref die; | |
2130 | register enum dwarf_attribute attr_kind; | |
2131 | { | |
2132 | register dw_attr_ref a; | |
2133 | if (die != NULL) | |
2134 | { | |
2135 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2136 | { | |
2137 | if (a->dw_attr == attr_kind | |
2138 | && a->dw_attr_val.val_class == dw_val_class_flag) | |
2139 | return a->dw_attr_val.v.val_flag; | |
2140 | } | |
2141 | } | |
2142 | return -1; | |
2143 | } | |
2144 | ||
2145 | /* Return the value of the unsigned attribute designated by ATTR_KIND, or 0 | |
2146 | if it is not present. */ | |
2147 | inline unsigned | |
2148 | get_AT_unsigned (die, attr_kind) | |
2149 | register dw_die_ref die; | |
2150 | register enum dwarf_attribute attr_kind; | |
2151 | { | |
2152 | register dw_attr_ref a; | |
2153 | if (die != NULL) | |
2154 | { | |
2155 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2156 | { | |
2157 | if (a->dw_attr == attr_kind | |
2158 | && a->dw_attr_val.val_class == dw_val_class_unsigned_const) | |
2159 | return a->dw_attr_val.v.val_unsigned; | |
2160 | } | |
2161 | } | |
2162 | return 0; | |
2163 | } | |
a3f97cbb JW |
2164 | |
2165 | /* Return the "high pc" attribute value, typically associated with | |
2166 | a subprogram DIE. Return null if the "high pc" attribute is | |
2167 | either not prsent, or if it cannot be represented as an | |
2168 | assembler label identifier. */ | |
2169 | inline char * | |
2170 | get_AT_hi_pc (die) | |
2171 | register dw_die_ref die; | |
2172 | { | |
2173 | register dw_attr_ref a; | |
2174 | register char *hi_pc = NULL; | |
2175 | if (die != NULL) | |
2176 | { | |
2177 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2178 | { | |
2179 | if (a->dw_attr == DW_AT_high_pc | |
2180 | && a->dw_attr_val.val_class == dw_val_class_lbl_id) | |
2181 | { | |
2182 | hi_pc = a->dw_attr_val.v.val_lbl_id; | |
2183 | break; | |
2184 | } | |
2185 | } | |
2186 | } | |
2187 | return hi_pc; | |
2188 | } | |
2189 | ||
4b674448 JM |
2190 | /* Remove the specified attribute if present. */ |
2191 | inline void | |
2192 | remove_AT (die, attr_kind) | |
2193 | register dw_die_ref die; | |
2194 | register enum dwarf_attribute attr_kind; | |
2195 | { | |
2196 | register dw_attr_ref a; | |
2197 | register dw_attr_ref removed = NULL;; | |
2198 | if (die != NULL) | |
2199 | { | |
2200 | if (die->die_attr->dw_attr == attr_kind) | |
2201 | { | |
2202 | removed = die->die_attr; | |
2203 | if (die->die_attr_last == die->die_attr) | |
2204 | die->die_attr_last = NULL; | |
2205 | die->die_attr = die->die_attr->dw_attr_next; | |
2206 | } | |
2207 | else for (a = die->die_attr; a->dw_attr_next != NULL; | |
2208 | a = a->dw_attr_next) | |
2209 | if (a->dw_attr_next->dw_attr == attr_kind) | |
2210 | { | |
2211 | removed = a->dw_attr_next; | |
2212 | if (die->die_attr_last == a->dw_attr_next) | |
2213 | die->die_attr_last = a; | |
2214 | a->dw_attr_next = a->dw_attr_next->dw_attr_next; | |
2215 | return; | |
2216 | } | |
2217 | if (removed) | |
2218 | free (removed); | |
2219 | } | |
2220 | } | |
2221 | ||
2222 | /* Discard the children of this DIE. */ | |
2223 | inline void | |
2224 | remove_children (die) | |
2225 | register dw_die_ref die; | |
2226 | { | |
2227 | register dw_die_ref child_die = die->die_child; | |
2228 | die->die_child = NULL; | |
2229 | die->die_child_last = NULL; | |
2230 | while (child_die != NULL) | |
2231 | { | |
2232 | register dw_die_ref tmp_die = child_die; | |
2233 | register dw_attr_ref a; | |
2234 | child_die = child_die->die_sib; | |
2235 | ||
2236 | for (a = tmp_die->die_attr; a != NULL; ) | |
2237 | { | |
2238 | register dw_attr_ref tmp_a = a; | |
2239 | a = a->dw_attr_next; | |
2240 | free (tmp_a); | |
2241 | } | |
2242 | free (tmp_die); | |
2243 | } | |
2244 | } | |
2245 | ||
a3f97cbb JW |
2246 | /* Add a child DIE below its parent. */ |
2247 | inline void | |
2248 | add_child_die (die, child_die) | |
2249 | register dw_die_ref die; | |
2250 | register dw_die_ref child_die; | |
2251 | { | |
2252 | if (die != NULL && child_die != NULL) | |
2253 | { | |
2254 | assert (die != child_die); | |
2255 | child_die->die_parent = die; | |
2256 | child_die->die_sib = NULL; | |
2257 | if (die->die_child == NULL) | |
2258 | { | |
2259 | die->die_child = child_die; | |
2260 | die->die_child_last = child_die; | |
2261 | } | |
2262 | else | |
2263 | { | |
2264 | die->die_child_last->die_sib = child_die; | |
2265 | die->die_child_last = child_die; | |
2266 | } | |
2267 | } | |
2268 | } | |
2269 | ||
2270 | /* Return a pointer to a newly created DIE node. */ | |
2271 | inline dw_die_ref | |
2272 | new_die (tag_value, parent_die) | |
2273 | register enum dwarf_tag tag_value; | |
2274 | register dw_die_ref parent_die; | |
2275 | { | |
2276 | register dw_die_ref die = (dw_die_ref) xmalloc (sizeof (die_node)); | |
2277 | if (die != NULL) | |
2278 | { | |
2279 | die->die_tag = tag_value; | |
2280 | die->die_abbrev = 0; | |
2281 | die->die_offset = 0; | |
2282 | die->die_child = NULL; | |
2283 | die->die_parent = NULL; | |
2284 | die->die_sib = NULL; | |
2285 | die->die_child_last = NULL; | |
2286 | die->die_attr = NULL; | |
2287 | die->die_attr_last = NULL; | |
2288 | if (parent_die != NULL) | |
2289 | { | |
2290 | add_child_die (parent_die, die); | |
2291 | } | |
2292 | } | |
2293 | return die; | |
2294 | } | |
2295 | ||
2296 | /* Return the DIE associated with the given type specifier. */ | |
2297 | inline dw_die_ref | |
2298 | lookup_type_die (type) | |
2299 | register tree type; | |
2300 | { | |
2301 | register unsigned type_id = TYPE_UID (type); | |
2302 | return (type_id < type_die_table_in_use) | |
2303 | ? type_die_table[type_id] : NULL; | |
2304 | } | |
2305 | ||
2306 | /* Equate a DIE to a given type specifier. */ | |
2307 | static void | |
2308 | equate_type_number_to_die (type, type_die) | |
2309 | register tree type; | |
2310 | register dw_die_ref type_die; | |
2311 | { | |
2312 | register unsigned type_id = TYPE_UID (type); | |
2313 | register unsigned i; | |
2314 | register unsigned num_allocated; | |
2315 | if (type_id >= type_die_table_allocated) | |
2316 | { | |
2317 | num_allocated = (((type_id + 1) | |
2318 | + TYPE_DIE_TABLE_INCREMENT - 1) | |
2319 | / TYPE_DIE_TABLE_INCREMENT) | |
2320 | * TYPE_DIE_TABLE_INCREMENT; | |
2321 | type_die_table = (dw_die_ref *) xrealloc (type_die_table, | |
2322 | sizeof (dw_die_ref) * num_allocated); | |
2323 | bzero (&type_die_table[type_die_table_allocated], | |
2324 | (num_allocated - type_die_table_allocated) * sizeof (dw_die_ref)); | |
2325 | type_die_table_allocated = num_allocated; | |
2326 | } | |
2327 | if (type_id >= type_die_table_in_use) | |
2328 | { | |
2329 | type_die_table_in_use = (type_id + 1); | |
2330 | } | |
2331 | type_die_table[type_id] = type_die; | |
2332 | } | |
2333 | ||
2334 | /* Return the DIE associated with a given declaration. */ | |
2335 | inline dw_die_ref | |
2336 | lookup_decl_die (decl) | |
2337 | register tree decl; | |
2338 | { | |
2339 | register unsigned decl_id = DECL_UID (decl); | |
2340 | return (decl_id < decl_die_table_in_use) | |
2341 | ? decl_die_table[decl_id] : NULL; | |
2342 | } | |
2343 | ||
2344 | /* Equate a DIE to a particular declaration. */ | |
2345 | static void | |
2346 | equate_decl_number_to_die (decl, decl_die) | |
2347 | register tree decl; | |
2348 | register dw_die_ref decl_die; | |
2349 | { | |
2350 | register unsigned decl_id = DECL_UID (decl); | |
2351 | register unsigned i; | |
2352 | register unsigned num_allocated; | |
2353 | if (decl_id >= decl_die_table_allocated) | |
2354 | { | |
2355 | num_allocated = (((decl_id + 1) | |
2356 | + DECL_DIE_TABLE_INCREMENT - 1) | |
2357 | / DECL_DIE_TABLE_INCREMENT) | |
2358 | * DECL_DIE_TABLE_INCREMENT; | |
2359 | decl_die_table = (dw_die_ref *) xrealloc (decl_die_table, | |
2360 | sizeof (dw_die_ref) * num_allocated); | |
2361 | bzero (&decl_die_table[decl_die_table_allocated], | |
2362 | (num_allocated - decl_die_table_allocated) * sizeof (dw_die_ref)); | |
2363 | decl_die_table_allocated = num_allocated; | |
2364 | } | |
2365 | if (decl_id >= decl_die_table_in_use) | |
2366 | { | |
2367 | decl_die_table_in_use = (decl_id + 1); | |
2368 | } | |
2369 | decl_die_table[decl_id] = decl_die; | |
2370 | } | |
2371 | ||
2372 | /* Return a pointer to a newly allocated location description. Location | |
2373 | descriptions are simple expression terms that can be strung | |
2374 | together to form more complicated location (address) descriptions. */ | |
2375 | inline dw_loc_descr_ref | |
2376 | new_loc_descr (op, oprnd1, oprnd2) | |
2377 | register enum dwarf_location_atom op; | |
2378 | register unsigned long oprnd1; | |
2379 | register unsigned long oprnd2; | |
2380 | { | |
2381 | register dw_loc_descr_ref descr = | |
2382 | (dw_loc_descr_ref) xmalloc (sizeof (dw_loc_descr_node)); | |
2383 | if (descr != NULL) | |
2384 | { | |
2385 | descr->dw_loc_next = NULL; | |
2386 | descr->dw_loc_opc = op; | |
2387 | descr->dw_loc_oprnd1.val_class = dw_val_class_unsigned_const; | |
2388 | descr->dw_loc_oprnd1.v.val_unsigned = oprnd1; | |
2389 | descr->dw_loc_oprnd2.val_class = dw_val_class_unsigned_const; | |
2390 | descr->dw_loc_oprnd2.v.val_unsigned = oprnd2; | |
2391 | } | |
2392 | return descr; | |
2393 | } | |
2394 | ||
2395 | /* Add a location description term to a location description expression. */ | |
2396 | inline void | |
2397 | add_loc_descr (list_head, descr) | |
2398 | register dw_loc_descr_ref *list_head; | |
2399 | register dw_loc_descr_ref descr; | |
2400 | { | |
2401 | register dw_loc_descr_ref *d; | |
2402 | /* find the end of the chain. */ | |
2403 | for (d = list_head; (*d) != NULL; d = &(*d)->dw_loc_next) | |
2404 | { | |
2405 | /* nothing */ ; | |
2406 | } | |
2407 | *d = descr; | |
2408 | } | |
2409 | ||
2410 | /* Return a pointer to a newly allocated Call Frame Instruction. */ | |
2411 | inline dw_cfi_ref | |
2412 | new_cfi () | |
2413 | { | |
2414 | register dw_cfi_ref cfi = (dw_cfi_ref) xmalloc (sizeof (dw_cfi_node)); | |
2415 | if (cfi != NULL) | |
2416 | { | |
2417 | cfi->dw_cfi_next = NULL; | |
2418 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = 0; | |
2419 | cfi->dw_cfi_oprnd2.dw_cfi_reg_num = 0; | |
2420 | } | |
2421 | return cfi; | |
2422 | } | |
2423 | ||
2424 | /* Add a Call Frame Instruction to list of instructions. */ | |
2425 | inline void | |
2426 | add_cfi (list_head, cfi) | |
2427 | register dw_cfi_ref *list_head; | |
2428 | register dw_cfi_ref cfi; | |
2429 | { | |
2430 | register dw_cfi_ref *p; | |
2431 | /* find the end of the chain. */ | |
2432 | for (p = list_head; (*p) != NULL; p = &(*p)->dw_cfi_next) | |
2433 | { | |
2434 | /* nothing */ ; | |
2435 | } | |
2436 | *p = cfi; | |
2437 | } | |
2438 | \f | |
2439 | /********* Print DWARF Internal Representation (debugging aids) ***************/ | |
2440 | ||
2441 | /* Keep track of the number of spaces used to indent the | |
2442 | output of the debugging routines that print the structure of | |
2443 | the DIE internal representation. */ | |
2444 | static int print_indent; | |
2445 | ||
2446 | /* Indent the line the number of spaces given by print_indent. */ | |
2447 | inline void | |
2448 | print_spaces (outfile) | |
2449 | FILE *outfile; | |
2450 | { | |
2451 | fprintf (outfile, "%*s", print_indent, ""); | |
2452 | } | |
2453 | ||
2454 | /* Print the information assoaciated with a given DIE, and its children. | |
2455 | This routine is a debugging aid only. */ | |
2456 | static void | |
2457 | print_die (die, outfile) | |
2458 | dw_die_ref die; | |
2459 | FILE *outfile; | |
2460 | { | |
2461 | register dw_attr_ref a; | |
2462 | register dw_die_ref c; | |
2463 | print_spaces (outfile); | |
2464 | fprintf (outfile, "DIE %4u: %s\n", | |
2465 | die->die_offset, dwarf_tag_name (die->die_tag)); | |
2466 | print_spaces (outfile); | |
2467 | fprintf (outfile, " abbrev id: %u", die->die_abbrev); | |
2468 | fprintf (outfile, " offset: %u\n", die->die_offset); | |
2469 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2470 | { | |
2471 | print_spaces (outfile); | |
2472 | fprintf (outfile, " %s: ", dwarf_attr_name (a->dw_attr)); | |
2473 | switch (a->dw_attr_val.val_class) | |
2474 | { | |
2475 | case dw_val_class_addr: | |
2476 | fprintf (outfile, "address"); | |
2477 | break; | |
2478 | case dw_val_class_loc: | |
2479 | fprintf (outfile, "location descriptor"); | |
2480 | break; | |
2481 | case dw_val_class_const: | |
2482 | fprintf (outfile, "%d", a->dw_attr_val.v.val_int); | |
2483 | break; | |
2484 | case dw_val_class_unsigned_const: | |
2485 | fprintf (outfile, "%u", a->dw_attr_val.v.val_unsigned); | |
2486 | break; | |
2487 | case dw_val_class_double_const: | |
2488 | fprintf (outfile, "constant (%u,%u)", | |
2489 | a->dw_attr_val.v.val_dbl_const.dw_dbl_hi, | |
2490 | a->dw_attr_val.v.val_dbl_const.dw_dbl_low); | |
2491 | break; | |
2492 | case dw_val_class_flag: | |
2493 | fprintf (outfile, "%u", a->dw_attr_val.v.val_flag); | |
2494 | break; | |
2495 | case dw_val_class_die_ref: | |
2496 | if (a->dw_attr_val.v.val_die_ref != NULL) | |
2497 | { | |
2498 | fprintf (outfile, "die -> %u", | |
2499 | a->dw_attr_val.v.val_die_ref->die_offset); | |
2500 | } | |
2501 | else | |
2502 | { | |
2503 | fprintf (outfile, "die -> <null>"); | |
2504 | } | |
2505 | break; | |
2506 | case dw_val_class_lbl_id: | |
2507 | fprintf (outfile, "label: %s", a->dw_attr_val.v.val_lbl_id); | |
2508 | break; | |
2509 | case dw_val_class_section_offset: | |
2510 | fprintf (outfile, "section: %s", a->dw_attr_val.v.val_section); | |
2511 | break; | |
2512 | case dw_val_class_str: | |
2513 | if (a->dw_attr_val.v.val_str != NULL) | |
2514 | { | |
2515 | fprintf (outfile, "\"%s\"", a->dw_attr_val.v.val_str); | |
2516 | } | |
2517 | else | |
2518 | { | |
2519 | fprintf (outfile, "<null>"); | |
2520 | } | |
2521 | break; | |
2522 | } | |
2523 | fprintf (outfile, "\n"); | |
2524 | } | |
2525 | if (die->die_child != NULL) | |
2526 | { | |
2527 | print_indent += 4; | |
2528 | for (c = die->die_child; c != NULL; c = c->die_sib) | |
2529 | { | |
2530 | print_die (c, outfile); | |
2531 | } | |
2532 | print_indent -= 4; | |
2533 | } | |
2534 | } | |
2535 | ||
2536 | /* Print the contents of the source code line number correspondence table. | |
2537 | This routine is a debugging aid only. */ | |
2538 | static void | |
2539 | print_dwarf_line_table (outfile) | |
2540 | FILE *outfile; | |
2541 | { | |
2542 | register unsigned i; | |
2543 | register dw_line_info_ref line_info; | |
2544 | fprintf (outfile, "\n\nDWARF source line information\n"); | |
2545 | for (i = 1; i < line_info_table_in_use; ++i) | |
2546 | { | |
2547 | line_info = &line_info_table[i]; | |
2548 | fprintf (outfile, "%5d: ", i); | |
2549 | fprintf (outfile, "%-20s", file_table[line_info->dw_file_num]); | |
2550 | fprintf (outfile, "%6d", line_info->dw_line_num); | |
2551 | fprintf (outfile, "\n"); | |
2552 | } | |
2553 | fprintf (outfile, "\n\n"); | |
2554 | } | |
2555 | ||
2556 | /* Print the information collected for a given DIE. */ | |
2557 | void | |
2558 | debug_dwarf_die (die) | |
2559 | dw_die_ref die; | |
2560 | { | |
2561 | print_die (die, stderr); | |
2562 | } | |
2563 | ||
2564 | /* Print all DWARF informaiton collected for the compilation unit. | |
2565 | This routine is a debugging aid only. */ | |
2566 | void | |
2567 | debug_dwarf () | |
2568 | { | |
2569 | print_indent = 0; | |
2570 | print_die (comp_unit_die, stderr); | |
2571 | print_dwarf_line_table (stderr); | |
2572 | } | |
2573 | ||
2574 | \f | |
2575 | /***************** DWARF Information Construction Support *********************/ | |
2576 | ||
2577 | /* Traverse the DIE, and add a sibling attribute if it may have the | |
2578 | effect of speeding up access to siblings. To save some space, | |
2579 | avoid generating sibling attributes for DIE's without children. */ | |
2580 | static void | |
2581 | add_sibling_attributes(die) | |
2582 | register dw_die_ref die; | |
2583 | { | |
2584 | register dw_die_ref c; | |
2585 | register dw_attr_ref attr; | |
2586 | if (die != comp_unit_die && die->die_child != NULL) | |
2587 | { | |
2588 | attr = (dw_attr_ref) xmalloc (sizeof (dw_attr_node)); | |
2589 | if (attr != NULL) | |
2590 | { | |
2591 | attr->dw_attr_next = NULL; | |
2592 | attr->dw_attr = DW_AT_sibling; | |
2593 | attr->dw_attr_val.val_class = dw_val_class_die_ref; | |
2594 | attr->dw_attr_val.v.val_die_ref = die->die_sib; | |
2595 | } | |
2596 | /* add the sibling link to the front of the attribute list. */ | |
2597 | attr->dw_attr_next = die->die_attr; | |
2598 | if (die->die_attr == NULL) | |
2599 | { | |
2600 | die->die_attr_last = attr; | |
2601 | } | |
2602 | die->die_attr = attr; | |
2603 | } | |
2604 | for (c = die->die_child; c != NULL; c = c->die_sib) | |
2605 | { | |
2606 | add_sibling_attributes (c); | |
2607 | } | |
2608 | } | |
2609 | ||
2610 | /* The format of each DIE (and its attribute value pairs) | |
2611 | is encoded in an abbreviation table. This routine builds the | |
2612 | abbreviation table and assigns a unique abbreviation id for | |
2613 | each abbreviation entry. The children of each die are visited | |
2614 | recursively. */ | |
2615 | static void | |
2616 | build_abbrev_table (die) | |
2617 | register dw_die_ref die; | |
2618 | { | |
2619 | register unsigned long abbrev_id; | |
2620 | register unsigned long n_alloc; | |
2621 | register dw_die_ref c; | |
2622 | register dw_attr_ref d_attr, a_attr; | |
2623 | for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id) | |
2624 | { | |
2625 | register dw_die_ref abbrev = abbrev_die_table[abbrev_id]; | |
2626 | if (abbrev->die_tag == die->die_tag) | |
2627 | { | |
2628 | if ((abbrev->die_child != NULL) == (die->die_child != NULL)) | |
2629 | { | |
2630 | a_attr = abbrev->die_attr; | |
2631 | d_attr = die->die_attr; | |
2632 | while (a_attr != NULL && d_attr != NULL) | |
2633 | { | |
2634 | if ((a_attr->dw_attr != d_attr->dw_attr) | |
2635 | || (a_attr->dw_attr_val.val_class | |
2636 | != d_attr->dw_attr_val.val_class)) | |
2637 | { | |
2638 | break; | |
2639 | } | |
2640 | a_attr = a_attr->dw_attr_next; | |
2641 | d_attr = d_attr->dw_attr_next; | |
2642 | } | |
2643 | if (a_attr == NULL && d_attr == NULL) | |
2644 | { | |
2645 | break; | |
2646 | } | |
2647 | } | |
2648 | } | |
2649 | } | |
2650 | if (abbrev_id >= abbrev_die_table_in_use) | |
2651 | { | |
2652 | if (abbrev_die_table_in_use >= abbrev_die_table_allocated) | |
2653 | { | |
2654 | n_alloc = abbrev_die_table_allocated + ABBREV_DIE_TABLE_INCREMENT; | |
2655 | abbrev_die_table = (dw_die_ref *) | |
2656 | xmalloc (abbrev_die_table, | |
2657 | sizeof (dw_die_ref) * n_alloc); | |
2658 | bzero (&abbrev_die_table[abbrev_die_table_allocated], | |
2659 | (n_alloc - abbrev_die_table_allocated) * sizeof (dw_die_ref)); | |
2660 | abbrev_die_table_allocated = n_alloc; | |
2661 | } | |
2662 | ++abbrev_die_table_in_use; | |
2663 | abbrev_die_table[abbrev_id] = die; | |
2664 | } | |
2665 | die->die_abbrev = abbrev_id; | |
2666 | for (c = die->die_child; c != NULL; c = c->die_sib) | |
2667 | { | |
2668 | build_abbrev_table (c); | |
2669 | } | |
2670 | } | |
2671 | ||
2672 | \f | |
2673 | /********************** DWARF Information Sizing *****************************/ | |
2674 | ||
2675 | /* Return the size of an unsigned LEB128 quantity. */ | |
2676 | inline unsigned long | |
2677 | size_of_uleb128 (value) | |
2678 | register unsigned long value; | |
2679 | { | |
2680 | register unsigned long size = 0; | |
2681 | register unsigned byte; | |
2682 | do | |
2683 | { | |
2684 | byte = (value & 0x7f); | |
2685 | value >>= 7; | |
2686 | size += 1; | |
2687 | } | |
2688 | while (value != 0); | |
2689 | return size; | |
2690 | } | |
2691 | ||
2692 | /* Return the size of a signed LEB128 quantity. */ | |
2693 | inline unsigned long | |
2694 | size_of_sleb128 (value) | |
2695 | register long value; | |
2696 | { | |
2697 | register unsigned long size = 0; | |
2698 | register unsigned byte; | |
2699 | do | |
2700 | { | |
2701 | byte = (value & 0x7f); | |
2702 | value >>= 7; | |
2703 | size += 1; | |
2704 | } | |
2705 | while (!(((value == 0) && ((byte & 0x40) == 0)) | |
2706 | || ((value == -1) && ((byte & 0x40) != 0)))); | |
2707 | return size; | |
2708 | } | |
2709 | ||
2710 | /* Return the size of a string, including the null byte. */ | |
2711 | static unsigned long | |
2712 | size_of_string (str) | |
2713 | register char *str; | |
2714 | { | |
2715 | register unsigned long size = 0; | |
2716 | register unsigned long slen = strlen (str); | |
2717 | register unsigned long i; | |
2718 | register unsigned c; | |
2719 | for (i = 0; i < slen; ++i) | |
2720 | { | |
2721 | c = str[i]; | |
2722 | if (c == '\\') | |
2723 | { | |
2724 | ++i; | |
2725 | } | |
2726 | size += 1; | |
2727 | } | |
2728 | /* Null terminator. */ | |
2729 | size += 1; | |
2730 | return size; | |
2731 | } | |
2732 | ||
2733 | /* Return the size of a location descriptor. */ | |
2734 | static unsigned long | |
2735 | size_of_loc_descr (loc) | |
2736 | register dw_loc_descr_ref loc; | |
2737 | { | |
2738 | register unsigned long size = 1; | |
2739 | switch (loc->dw_loc_opc) | |
2740 | { | |
2741 | case DW_OP_addr: | |
2742 | size += PTR_SIZE; | |
2743 | break; | |
2744 | case DW_OP_const1u: | |
2745 | case DW_OP_const1s: | |
2746 | size += 1; | |
2747 | break; | |
2748 | case DW_OP_const2u: | |
2749 | case DW_OP_const2s: | |
2750 | size += 2; | |
2751 | break; | |
2752 | case DW_OP_const4u: | |
2753 | case DW_OP_const4s: | |
2754 | size += 4; | |
2755 | break; | |
2756 | case DW_OP_const8u: | |
2757 | case DW_OP_const8s: | |
2758 | size += 8; | |
2759 | break; | |
2760 | case DW_OP_constu: | |
2761 | size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned); | |
2762 | break; | |
2763 | case DW_OP_consts: | |
2764 | size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int); | |
2765 | break; | |
2766 | case DW_OP_pick: | |
2767 | size += 1; | |
2768 | break; | |
2769 | case DW_OP_plus_uconst: | |
2770 | size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned); | |
2771 | break; | |
2772 | case DW_OP_skip: | |
2773 | case DW_OP_bra: | |
2774 | size += 2; | |
2775 | break; | |
2776 | case DW_OP_breg0: | |
2777 | case DW_OP_breg1: | |
2778 | case DW_OP_breg2: | |
2779 | case DW_OP_breg3: | |
2780 | case DW_OP_breg4: | |
2781 | case DW_OP_breg5: | |
2782 | case DW_OP_breg6: | |
2783 | case DW_OP_breg7: | |
2784 | case DW_OP_breg8: | |
2785 | case DW_OP_breg9: | |
2786 | case DW_OP_breg10: | |
2787 | case DW_OP_breg11: | |
2788 | case DW_OP_breg12: | |
2789 | case DW_OP_breg13: | |
2790 | case DW_OP_breg14: | |
2791 | case DW_OP_breg15: | |
2792 | case DW_OP_breg16: | |
2793 | case DW_OP_breg17: | |
2794 | case DW_OP_breg18: | |
2795 | case DW_OP_breg19: | |
2796 | case DW_OP_breg20: | |
2797 | case DW_OP_breg21: | |
2798 | case DW_OP_breg22: | |
2799 | case DW_OP_breg23: | |
2800 | case DW_OP_breg24: | |
2801 | case DW_OP_breg25: | |
2802 | case DW_OP_breg26: | |
2803 | case DW_OP_breg27: | |
2804 | case DW_OP_breg28: | |
2805 | case DW_OP_breg29: | |
2806 | case DW_OP_breg30: | |
2807 | case DW_OP_breg31: | |
2808 | size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int); | |
2809 | break; | |
2810 | case DW_OP_regx: | |
2811 | size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned); | |
2812 | break; | |
2813 | case DW_OP_fbreg: | |
2814 | size += size_of_sleb128 (loc->dw_loc_oprnd1.v.val_int); | |
2815 | break; | |
2816 | case DW_OP_bregx: | |
2817 | size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned); | |
2818 | size += size_of_sleb128 (loc->dw_loc_oprnd2.v.val_int); | |
2819 | break; | |
2820 | case DW_OP_piece: | |
2821 | size += size_of_uleb128 (loc->dw_loc_oprnd1.v.val_unsigned); | |
2822 | break; | |
2823 | case DW_OP_deref_size: | |
2824 | case DW_OP_xderef_size: | |
2825 | size += 1; | |
2826 | break; | |
2827 | default: | |
2828 | break; | |
2829 | } | |
2830 | return size; | |
2831 | } | |
2832 | ||
2833 | /* Return the size of a DIE, as it is represented in the | |
2834 | .debug_info section. */ | |
2835 | static unsigned long | |
2836 | size_of_die (die) | |
2837 | register dw_die_ref die; | |
2838 | { | |
2839 | register unsigned long size = 0; | |
2840 | register dw_attr_ref a; | |
2841 | register dw_loc_descr_ref loc; | |
2842 | size += size_of_uleb128 (die->die_abbrev); | |
2843 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
2844 | { | |
2845 | switch (a->dw_attr_val.val_class) | |
2846 | { | |
2847 | case dw_val_class_addr: | |
2848 | size += 4; | |
2849 | break; | |
2850 | case dw_val_class_loc: | |
2851 | /* Block length. */ | |
2852 | size += 2; | |
2853 | for (loc = a->dw_attr_val.v.val_loc; loc != NULL; | |
2854 | loc = loc->dw_loc_next) | |
2855 | { | |
2856 | size += size_of_loc_descr (loc); | |
2857 | } | |
2858 | break; | |
2859 | case dw_val_class_const: | |
2860 | size += 4; | |
2861 | break; | |
2862 | case dw_val_class_unsigned_const: | |
2863 | size += 4; | |
2864 | break; | |
2865 | case dw_val_class_double_const: | |
2866 | size += 8; | |
2867 | break; | |
2868 | case dw_val_class_flag: | |
2869 | size += 1; | |
2870 | break; | |
2871 | case dw_val_class_die_ref: | |
2872 | size += 4; | |
2873 | break; | |
2874 | case dw_val_class_fde_ref: | |
2875 | size += 4; | |
2876 | break; | |
2877 | case dw_val_class_lbl_id: | |
2878 | size += 4; | |
2879 | break; | |
2880 | case dw_val_class_section_offset: | |
2881 | size += 4; | |
2882 | break; | |
2883 | case dw_val_class_str: | |
2884 | size += size_of_string (a->dw_attr_val.v.val_str); | |
2885 | break; | |
2886 | default: | |
2887 | abort (); | |
2888 | } | |
2889 | } | |
2890 | return size; | |
2891 | } | |
2892 | ||
2893 | /* Size the debgging information associted with a given DIE. | |
2894 | Visits the DIE's children recursively. Updates the global | |
2895 | variable next_die_offset, on each time through. Uses the | |
2896 | current value of next_die_offset to updete the die_offset | |
2897 | field in each DIE. */ | |
2898 | static void | |
2899 | calc_die_sizes (die) | |
2900 | dw_die_ref die; | |
2901 | { | |
2902 | register dw_die_ref c; | |
2903 | register unsigned long die_size; | |
2904 | die->die_offset = next_die_offset; | |
2905 | next_die_offset += size_of_die (die); | |
2906 | for (c = die->die_child; c != NULL; c = c->die_sib) | |
2907 | { | |
2908 | calc_die_sizes (c); | |
2909 | } | |
2910 | if (die->die_child != NULL) | |
2911 | { | |
2912 | /* Count the null byte used to terminate sibling lists. */ | |
2913 | next_die_offset += 1; | |
2914 | } | |
2915 | } | |
2916 | ||
2917 | /* Return the size of the line information prolog generated for the | |
2918 | compilation unit. */ | |
2919 | static unsigned long | |
2920 | size_of_line_prolog () | |
2921 | { | |
2922 | register unsigned long size; | |
2923 | register unsigned opc; | |
2924 | register unsigned n_op_args; | |
2925 | register unsigned long ft_index; | |
2926 | size = DWARF_LINE_PROLOG_HEADER_SIZE; | |
2927 | /* Count the size of the table giving number of args for each | |
2928 | standard opcode. */ | |
2929 | size += DWARF_LINE_OPCODE_BASE - 1; | |
2930 | /* Include directory table is empty (at present). Count only the | |
2931 | the null byte used to terminate the table. */ | |
2932 | size += 1; | |
2933 | for (ft_index = 1; ft_index < file_table_in_use; ++ft_index) | |
2934 | { | |
2935 | /* File name entry. */ | |
2936 | size += size_of_string (file_table[ft_index]); | |
2937 | /* Include directory index. */ | |
2938 | size += size_of_uleb128 (0); | |
2939 | /* Modification time. */ | |
2940 | size += size_of_uleb128 (0); | |
2941 | /* File length in bytes. */ | |
2942 | size += size_of_uleb128 (0); | |
2943 | } | |
2944 | /* Count the file table terminator. */ | |
2945 | size += 1; | |
2946 | return size; | |
2947 | } | |
2948 | ||
2949 | /* Return the size of the line information generated for this | |
2950 | compilation unit. */ | |
2951 | static unsigned long | |
2952 | size_of_line_info () | |
2953 | { | |
2954 | register unsigned long size; | |
2955 | register dw_line_info_ref line_info; | |
2956 | register unsigned long lt_index; | |
2957 | register unsigned long current_line; | |
2958 | register long line_offset; | |
2959 | register long line_delta; | |
2960 | register unsigned long current_file; | |
2961 | /* Version number. */ | |
2962 | size = 2; | |
2963 | /* Prolog length specifier. */ | |
2964 | size += 4; | |
2965 | /* Prolog. */ | |
2966 | size += size_of_line_prolog (); | |
2967 | /* Set address register instruction. */ | |
2968 | size += 1 + size_of_uleb128 (1 + PTR_SIZE) | |
2969 | + 1 + PTR_SIZE; | |
2970 | current_file = 1; | |
2971 | current_line = 1; | |
2972 | for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index) | |
2973 | { | |
2974 | /* Advance pc instruction. */ | |
2975 | size += 1 + 2; | |
2976 | line_info = &line_info_table[lt_index]; | |
2977 | if (line_info->dw_file_num != current_file) | |
2978 | { | |
2979 | /* Set file number instruction. */ | |
2980 | size += 1; | |
2981 | current_file = line_info->dw_file_num; | |
2982 | size += size_of_uleb128 (current_file); | |
2983 | } | |
2984 | if (line_info->dw_line_num != current_line) | |
2985 | { | |
2986 | line_offset = line_info->dw_line_num - current_line; | |
2987 | line_delta = line_offset - DWARF_LINE_BASE; | |
2988 | current_line = line_info->dw_line_num; | |
2989 | if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1)) | |
2990 | { | |
2991 | /* 1-byte special line number instruction. */ | |
2992 | size += 1; | |
2993 | } | |
2994 | else | |
2995 | { | |
2996 | /* Advance line instruction. */ | |
2997 | size += 1; | |
2998 | size += size_of_sleb128 (line_offset); | |
2999 | /* Generate line entry instruction. */ | |
3000 | size += 1; | |
3001 | } | |
3002 | } | |
3003 | } | |
bdb669cb JM |
3004 | /* Advance pc instruction. */ |
3005 | size += 1 + 2; | |
a3f97cbb JW |
3006 | /* End of line number info. marker. */ |
3007 | size += 1 + size_of_uleb128 (1) + 1; | |
3008 | return size; | |
3009 | } | |
3010 | ||
3011 | /* Return the size of the .debug_pubnames table generated for the | |
3012 | compilation unit. */ | |
3013 | static unsigned long | |
3014 | size_of_pubnames () | |
3015 | { | |
3016 | dw_die_ref die; | |
3017 | register unsigned long size; | |
3018 | size = DWARF_PUBNAMES_HEADER_SIZE; | |
3019 | for (die = comp_unit_die->die_child; die != NULL; die = die->die_sib) | |
3020 | { | |
3021 | if (is_extern_subr_die (die)) | |
3022 | { | |
3023 | char *low_pc = get_AT_low_pc (die); | |
3024 | if (low_pc != NULL) | |
3025 | { | |
3026 | size += 4; | |
3027 | size += size_of_string (low_pc); | |
3028 | } | |
3029 | } | |
3030 | } | |
3031 | size += 4; | |
3032 | return size; | |
3033 | } | |
3034 | ||
3035 | /* Return the size of the information in the .debug_aranges seciton. */ | |
3036 | static unsigned long | |
3037 | size_of_aranges () | |
3038 | { | |
3039 | register unsigned long size; | |
3040 | size = DWARF_ARANGES_HEADER_SIZE; | |
3041 | /* Count the address/length pair for this compilation unit. */ | |
3042 | size += 8; | |
3043 | /* Count the two zero words used to terminated the address range table. */ | |
3044 | size += 8; | |
3045 | return size; | |
3046 | } | |
3047 | \f | |
3048 | /**************** DWARF Debug Information Output *****************************/ | |
3049 | ||
3050 | /* Output an unsigned LEB128 quantity. */ | |
3051 | static void | |
3052 | output_uleb128 (value) | |
3053 | register unsigned long value; | |
3054 | { | |
3055 | fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP); | |
3056 | do | |
3057 | { | |
3058 | register unsigned byte = (value & 0x7f); | |
3059 | value >>= 7; | |
3060 | if (value != 0) | |
3061 | { | |
3062 | /* More bytes to follow. */ | |
3063 | byte |= 0x80; | |
3064 | } | |
3065 | fprintf (asm_out_file, "0x%x", byte); | |
3066 | if (value != 0) | |
3067 | { | |
3068 | fprintf (asm_out_file, ","); | |
3069 | } | |
3070 | } | |
3071 | while (value != 0); | |
3072 | } | |
3073 | ||
3074 | /* Output an signed LEB128 quantity. */ | |
3075 | static void | |
3076 | output_sleb128 (value) | |
3077 | register long value; | |
3078 | { | |
3079 | register int more; | |
3080 | register unsigned byte; | |
3081 | fprintf (asm_out_file, "\t%s\t", ASM_BYTE_OP); | |
3082 | do | |
3083 | { | |
3084 | byte = (value & 0x7f); | |
3085 | /* arithmetic shift */ | |
3086 | value >>= 7; | |
3087 | more = !((((value == 0) && ((byte & 0x40) == 0)) | |
3088 | || ((value == -1) && ((byte & 0x40) != 0)))); | |
3089 | if (more) | |
3090 | { | |
3091 | byte |= 0x80; | |
3092 | } | |
3093 | fprintf (asm_out_file, "0x%x", byte); | |
3094 | if (more) | |
3095 | { | |
3096 | fprintf (asm_out_file, ","); | |
3097 | } | |
3098 | } | |
3099 | while (more); | |
3100 | } | |
3101 | ||
3102 | /* Output the encoding of an attribute value. */ | |
3103 | static void | |
3104 | output_value_format (v) | |
3105 | dw_val_ref v; | |
3106 | { | |
3107 | enum dwarf_form form; | |
3108 | switch (v->val_class) | |
3109 | { | |
3110 | case dw_val_class_addr: | |
3111 | form = DW_FORM_addr; | |
3112 | break; | |
3113 | case dw_val_class_loc: | |
3114 | form = DW_FORM_block2; | |
3115 | break; | |
3116 | case dw_val_class_const: | |
3117 | form = DW_FORM_data4; | |
3118 | break; | |
3119 | case dw_val_class_unsigned_const: | |
3120 | form = DW_FORM_data4; | |
3121 | break; | |
3122 | case dw_val_class_double_const: | |
3123 | form = DW_FORM_data8; | |
3124 | break; | |
3125 | case dw_val_class_flag: | |
3126 | form = DW_FORM_flag; | |
3127 | break; | |
3128 | case dw_val_class_die_ref: | |
3129 | form = DW_FORM_ref4; | |
3130 | break; | |
3131 | case dw_val_class_fde_ref: | |
3132 | form = DW_FORM_data4; | |
3133 | break; | |
3134 | case dw_val_class_lbl_id: | |
3135 | form = DW_FORM_addr; | |
3136 | break; | |
3137 | case dw_val_class_section_offset: | |
3138 | form = DW_FORM_data4; | |
3139 | break; | |
3140 | case dw_val_class_str: | |
3141 | form = DW_FORM_string; | |
3142 | break; | |
3143 | default: | |
3144 | abort (); | |
3145 | } | |
3146 | output_uleb128 (form); | |
3147 | if (flag_verbose_asm) | |
3148 | { | |
3149 | fprintf (asm_out_file, "\t%s %s", | |
3150 | ASM_COMMENT_START, dwarf_form_name (form)); | |
3151 | } | |
3152 | fputc ('\n', asm_out_file); | |
3153 | } | |
3154 | ||
3155 | /* Output the .debug_abbrev section which defines the DIE abbreviation | |
3156 | table. */ | |
3157 | static void | |
3158 | output_abbrev_section () | |
3159 | { | |
3160 | unsigned long abbrev_id; | |
3161 | dw_attr_ref a_attr; | |
3162 | for (abbrev_id = 1; abbrev_id < abbrev_die_table_in_use; ++abbrev_id) | |
3163 | { | |
3164 | register dw_die_ref abbrev = abbrev_die_table[abbrev_id]; | |
3165 | output_uleb128 (abbrev_id); | |
3166 | if (flag_verbose_asm) | |
3167 | { | |
3168 | fprintf (asm_out_file, "\t%s abbrev code = %u", | |
3169 | ASM_COMMENT_START, abbrev_id); | |
3170 | } | |
3171 | fputc ('\n', asm_out_file); | |
3172 | output_uleb128 (abbrev->die_tag); | |
3173 | if (flag_verbose_asm) | |
3174 | { | |
3175 | fprintf (asm_out_file, "\t%s TAG: %s", | |
3176 | ASM_COMMENT_START, dwarf_tag_name (abbrev->die_tag)); | |
3177 | } | |
3178 | fputc ('\n', asm_out_file); | |
3179 | fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, | |
3180 | (abbrev->die_child != NULL) | |
3181 | ? DW_children_yes : DW_children_no); | |
3182 | if (flag_verbose_asm) | |
3183 | { | |
3184 | fprintf (asm_out_file, "\t%s %s", | |
3185 | ASM_COMMENT_START, | |
3186 | (abbrev->die_child != NULL) | |
3187 | ? "DW_children_yes" : "DW_children_no"); | |
3188 | } | |
3189 | fputc ('\n', asm_out_file); | |
3190 | for (a_attr = abbrev->die_attr; a_attr != NULL; | |
3191 | a_attr = a_attr->dw_attr_next) | |
3192 | { | |
3193 | output_uleb128 (a_attr->dw_attr); | |
3194 | if (flag_verbose_asm) | |
3195 | { | |
3196 | fprintf (asm_out_file, "\t%s %s", | |
3197 | ASM_COMMENT_START, | |
3198 | dwarf_attr_name (a_attr->dw_attr)); | |
3199 | } | |
3200 | fputc ('\n', asm_out_file); | |
3201 | output_value_format (&a_attr->dw_attr_val); | |
3202 | } | |
3203 | fprintf (asm_out_file, "\t%s\t0,0\n", ASM_BYTE_OP); | |
3204 | } | |
3205 | } | |
3206 | ||
3207 | /* Output location description stack opcode's operands (if any). */ | |
3208 | static void | |
3209 | output_loc_operands (loc) | |
3210 | register dw_loc_descr_ref loc; | |
3211 | { | |
3212 | register dw_val_ref val1 = &loc->dw_loc_oprnd1; | |
3213 | register dw_val_ref val2 = &loc->dw_loc_oprnd2; | |
3214 | switch (loc->dw_loc_opc) | |
3215 | { | |
3216 | case DW_OP_addr: | |
3217 | ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, val1->v.val_addr); | |
3218 | fputc ('\n', asm_out_file); | |
3219 | break; | |
3220 | case DW_OP_const1u: | |
3221 | case DW_OP_const1s: | |
3222 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag); | |
3223 | fputc ('\n', asm_out_file); | |
3224 | break; | |
3225 | case DW_OP_const2u: | |
3226 | case DW_OP_const2s: | |
3227 | ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int); | |
3228 | fputc ('\n', asm_out_file); | |
3229 | break; | |
3230 | case DW_OP_const4u: | |
3231 | case DW_OP_const4s: | |
3232 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, val1->v.val_int); | |
3233 | fputc ('\n', asm_out_file); | |
3234 | break; | |
3235 | case DW_OP_const8u: | |
3236 | case DW_OP_const8s: | |
3237 | ASM_OUTPUT_DWARF_DATA8 (asm_out_file, | |
3238 | val1->v.val_dbl_const.dw_dbl_hi, | |
3239 | val2->v.val_dbl_const.dw_dbl_low); | |
3240 | fputc ('\n', asm_out_file); | |
3241 | break; | |
3242 | case DW_OP_constu: | |
3243 | output_uleb128 (val1->v.val_unsigned); | |
3244 | fputc ('\n', asm_out_file); | |
3245 | break; | |
3246 | case DW_OP_consts: | |
3247 | output_sleb128 (val1->v.val_unsigned); | |
3248 | fputc ('\n', asm_out_file); | |
3249 | break; | |
3250 | case DW_OP_pick: | |
3251 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_int); | |
3252 | fputc ('\n', asm_out_file); | |
3253 | break; | |
3254 | case DW_OP_plus_uconst: | |
3255 | output_uleb128 (val1->v.val_unsigned); | |
3256 | fputc ('\n', asm_out_file); | |
3257 | break; | |
3258 | case DW_OP_skip: | |
3259 | case DW_OP_bra: | |
3260 | ASM_OUTPUT_DWARF_DATA2 (asm_out_file, val1->v.val_int); | |
3261 | fputc ('\n', asm_out_file); | |
3262 | break; | |
3263 | case DW_OP_breg0: | |
3264 | case DW_OP_breg1: | |
3265 | case DW_OP_breg2: | |
3266 | case DW_OP_breg3: | |
3267 | case DW_OP_breg4: | |
3268 | case DW_OP_breg5: | |
3269 | case DW_OP_breg6: | |
3270 | case DW_OP_breg7: | |
3271 | case DW_OP_breg8: | |
3272 | case DW_OP_breg9: | |
3273 | case DW_OP_breg10: | |
3274 | case DW_OP_breg11: | |
3275 | case DW_OP_breg12: | |
3276 | case DW_OP_breg13: | |
3277 | case DW_OP_breg14: | |
3278 | case DW_OP_breg15: | |
3279 | case DW_OP_breg16: | |
3280 | case DW_OP_breg17: | |
3281 | case DW_OP_breg18: | |
3282 | case DW_OP_breg19: | |
3283 | case DW_OP_breg20: | |
3284 | case DW_OP_breg21: | |
3285 | case DW_OP_breg22: | |
3286 | case DW_OP_breg23: | |
3287 | case DW_OP_breg24: | |
3288 | case DW_OP_breg25: | |
3289 | case DW_OP_breg26: | |
3290 | case DW_OP_breg27: | |
3291 | case DW_OP_breg28: | |
3292 | case DW_OP_breg29: | |
3293 | case DW_OP_breg30: | |
3294 | case DW_OP_breg31: | |
3295 | output_sleb128 (val1->v.val_int); | |
3296 | fputc ('\n', asm_out_file); | |
3297 | break; | |
3298 | case DW_OP_regx: | |
3299 | output_uleb128 (val1->v.val_unsigned); | |
3300 | fputc ('\n', asm_out_file); | |
3301 | break; | |
3302 | case DW_OP_fbreg: | |
3303 | output_sleb128 (val1->v.val_unsigned); | |
3304 | fputc ('\n', asm_out_file); | |
3305 | break; | |
3306 | case DW_OP_bregx: | |
3307 | output_uleb128 (val1->v.val_unsigned); | |
3308 | fputc ('\n', asm_out_file); | |
3309 | output_sleb128 (val2->v.val_unsigned); | |
3310 | fputc ('\n', asm_out_file); | |
3311 | break; | |
3312 | case DW_OP_piece: | |
3313 | output_uleb128 (val1->v.val_unsigned); | |
3314 | fputc ('\n', asm_out_file); | |
3315 | break; | |
3316 | case DW_OP_deref_size: | |
3317 | case DW_OP_xderef_size: | |
3318 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, val1->v.val_flag); | |
3319 | fputc ('\n', asm_out_file); | |
3320 | break; | |
3321 | default: | |
3322 | break; | |
3323 | } | |
3324 | } | |
3325 | ||
3326 | /* Compute the offset of a sibling. */ | |
3327 | static unsigned long | |
3328 | sibling_offset (die) | |
3329 | dw_die_ref die; | |
3330 | { | |
3331 | unsigned long offset; | |
3332 | if (die->die_child_last == NULL) | |
3333 | { | |
3334 | offset = die->die_offset + size_of_die (die); | |
3335 | } | |
3336 | else | |
3337 | { | |
3338 | offset = sibling_offset (die->die_child_last) + 1; | |
3339 | } | |
3340 | return offset; | |
3341 | } | |
3342 | ||
3343 | /* Output the DIE and its attributes. Called recursively to generate | |
3344 | the definitions of each child DIE. */ | |
3345 | static void | |
3346 | output_die (die) | |
3347 | register dw_die_ref die; | |
3348 | { | |
3349 | register dw_attr_ref a; | |
3350 | register dw_die_ref c; | |
3351 | register unsigned long ref_offset; | |
3352 | register unsigned long size; | |
3353 | register dw_loc_descr_ref loc; | |
3354 | output_uleb128 (die->die_abbrev); | |
3355 | if (flag_verbose_asm) | |
3356 | { | |
3357 | fprintf (asm_out_file, "\t%s DIE (0x%x) %s", | |
3358 | ASM_COMMENT_START, | |
3359 | die->die_offset, | |
3360 | dwarf_tag_name (die->die_tag)); | |
3361 | } | |
3362 | fputc ('\n', asm_out_file); | |
3363 | for (a = die->die_attr; a != NULL; a = a->dw_attr_next) | |
3364 | { | |
3365 | switch (a->dw_attr_val.val_class) | |
3366 | { | |
3367 | case dw_val_class_addr: | |
3368 | ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, | |
3369 | a->dw_attr_val.v.val_addr); | |
3370 | break; | |
3371 | case dw_val_class_loc: | |
3372 | size = 0; | |
3373 | for (loc = a->dw_attr_val.v.val_loc; loc != NULL; | |
3374 | loc = loc->dw_loc_next) | |
3375 | { | |
3376 | size += size_of_loc_descr (loc); | |
3377 | } | |
3378 | /* Output the block length for this list of location operations. */ | |
3379 | ASM_OUTPUT_DWARF_DATA2 (asm_out_file, size); | |
3380 | if (flag_verbose_asm) | |
3381 | { | |
3382 | fprintf (asm_out_file, "\t%s %s", | |
3383 | ASM_COMMENT_START, dwarf_attr_name (a->dw_attr)); | |
3384 | } | |
3385 | fputc ('\n', asm_out_file); | |
3386 | for (loc = a->dw_attr_val.v.val_loc; loc != NULL; | |
3387 | loc = loc->dw_loc_next) | |
3388 | { | |
3389 | /* Output the opcode. */ | |
3390 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, loc->dw_loc_opc); | |
3391 | if (flag_verbose_asm) | |
3392 | { | |
3393 | fprintf (asm_out_file, "\t%s %s", | |
3394 | ASM_COMMENT_START, | |
3395 | dwarf_stack_op_name (loc->dw_loc_opc)); | |
3396 | } | |
3397 | fputc ('\n', asm_out_file); | |
3398 | /* Output the operand(s) (if any). */ | |
3399 | output_loc_operands (loc); | |
3400 | } | |
3401 | break; | |
3402 | case dw_val_class_const: | |
3403 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, a->dw_attr_val.v.val_int); | |
3404 | break; | |
3405 | case dw_val_class_unsigned_const: | |
3406 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, a->dw_attr_val.v.val_unsigned); | |
3407 | break; | |
3408 | case dw_val_class_double_const: | |
3409 | ASM_OUTPUT_DWARF_DATA8 (asm_out_file, | |
3410 | a->dw_attr_val.v.val_dbl_const.dw_dbl_hi, | |
3411 | a->dw_attr_val.v.val_dbl_const.dw_dbl_low); | |
3412 | break; | |
3413 | case dw_val_class_flag: | |
3414 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, a->dw_attr_val.v.val_flag); | |
3415 | break; | |
3416 | case dw_val_class_die_ref: | |
3417 | if (a->dw_attr_val.v.val_die_ref != NULL) | |
3418 | { | |
3419 | ref_offset = a->dw_attr_val.v.val_die_ref->die_offset; | |
3420 | } | |
3421 | else if (a->dw_attr == DW_AT_sibling) | |
3422 | { | |
3423 | ref_offset = sibling_offset(die); | |
3424 | } | |
3425 | else | |
3426 | { | |
3427 | abort (); | |
3428 | } | |
3429 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, ref_offset); | |
3430 | break; | |
3431 | case dw_val_class_fde_ref: | |
3432 | ref_offset = fde_table[a->dw_attr_val.v.val_fde_index].dw_fde_offset; | |
3433 | fprintf (asm_out_file, "\t%s\t%s+0x%x", UNALIGNED_INT_ASM_OP, | |
3434 | stripattributes (FRAME_SECTION), ref_offset); | |
3435 | break; | |
3436 | case dw_val_class_lbl_id: | |
3437 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, a->dw_attr_val.v.val_lbl_id); | |
3438 | break; | |
3439 | case dw_val_class_section_offset: | |
3440 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, | |
3441 | stripattributes (a->dw_attr_val.v.val_section)); | |
3442 | break; | |
3443 | case dw_val_class_str: | |
3444 | ASM_OUTPUT_DWARF_STRING (asm_out_file, a->dw_attr_val.v.val_str); | |
3445 | break; | |
3446 | default: | |
3447 | abort (); | |
3448 | } | |
3449 | if (a->dw_attr_val.val_class != dw_val_class_loc) | |
3450 | { | |
3451 | if (flag_verbose_asm) | |
3452 | { | |
3453 | fprintf (asm_out_file, "\t%s %s", | |
3454 | ASM_COMMENT_START, dwarf_attr_name (a->dw_attr)); | |
3455 | } | |
3456 | fputc ('\n', asm_out_file); | |
3457 | } | |
3458 | } | |
3459 | for (c = die->die_child; c != NULL; c = c->die_sib) | |
3460 | { | |
3461 | output_die (c); | |
3462 | } | |
3463 | if (die->die_child != NULL) | |
3464 | { | |
3465 | /* Add null byte to terminate sibling list. */ | |
3466 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
3467 | fputc ('\n', asm_out_file); | |
3468 | } | |
3469 | } | |
3470 | ||
3471 | /* Output the compilation unit that appears at the beginning of the | |
3472 | .debug_info section, and precedes the DIE descriptions. */ | |
3473 | static void | |
3474 | output_compilation_unit_header () | |
3475 | { | |
3476 | /* ??? The dwarf standard says this must be a 4 byte integer, but the | |
3477 | SGI dwarf reader assumes this is the same size as a pointer. */ | |
3478 | fprintf (asm_out_file, "\t%s\t0x%x", | |
3479 | UNALIGNED_INT_ASM_OP, next_die_offset - 4); | |
3480 | if (flag_verbose_asm) | |
3481 | { | |
3482 | fprintf (asm_out_file, "\t%s Length of Compilation Unit Info.", | |
3483 | ASM_COMMENT_START); | |
3484 | } | |
3485 | fputc ('\n', asm_out_file); | |
3486 | fprintf (asm_out_file, "\t%s\t0x%x", UNALIGNED_SHORT_ASM_OP, DWARF_VERSION); | |
3487 | if (flag_verbose_asm) | |
3488 | { | |
3489 | fprintf (asm_out_file, "\t%s DWARF version number", | |
3490 | ASM_COMMENT_START); | |
3491 | } | |
3492 | fputc ('\n', asm_out_file); | |
3493 | fprintf (asm_out_file, "\t%s\t%s", UNALIGNED_INT_ASM_OP, | |
3494 | stripattributes (ABBREV_SECTION)); | |
3495 | if (flag_verbose_asm) | |
3496 | { | |
3497 | fprintf (asm_out_file, "\t%s Offset Into Abbrev. Section", | |
3498 | ASM_COMMENT_START); | |
3499 | } | |
3500 | fputc ('\n', asm_out_file); | |
3501 | fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, PTR_SIZE); | |
3502 | if (flag_verbose_asm) | |
3503 | { | |
3504 | fprintf (asm_out_file, "\t%s Pointer Size (in bytes)", | |
3505 | ASM_COMMENT_START); | |
3506 | } | |
3507 | fputc ('\n', asm_out_file); | |
3508 | } | |
3509 | ||
3510 | /* Return the size of a Call Frame Instruction. */ | |
3511 | static unsigned long | |
3512 | size_of_cfi (cfi) | |
3513 | dw_cfi_ref cfi; | |
3514 | { | |
3515 | register unsigned long size; | |
3516 | /* count the 1-byte opcode */ | |
3517 | size = 1; | |
3518 | switch (cfi->dw_cfi_opc) | |
3519 | { | |
3520 | case DW_CFA_offset: | |
3521 | size += size_of_uleb128(cfi->dw_cfi_oprnd2.dw_cfi_offset); | |
3522 | break; | |
3523 | case DW_CFA_set_loc: | |
3524 | size += PTR_SIZE; | |
3525 | break; | |
3526 | case DW_CFA_advance_loc1: | |
3527 | size += 1; | |
3528 | break; | |
3529 | case DW_CFA_advance_loc2: | |
3530 | size += 2; | |
3531 | break; | |
3532 | case DW_CFA_advance_loc4: | |
3533 | size += 4; | |
3534 | break; | |
3535 | #ifdef MIPS_DEBUGGING_INFO | |
3536 | case DW_CFA_MIPS_advance_loc8: | |
3537 | size += 8; | |
3538 | break; | |
3539 | #endif | |
3540 | case DW_CFA_offset_extended: | |
3541 | case DW_CFA_def_cfa: | |
3542 | size += size_of_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3543 | size += size_of_uleb128(cfi->dw_cfi_oprnd2.dw_cfi_offset); | |
3544 | break; | |
3545 | case DW_CFA_restore_extended: | |
3546 | case DW_CFA_undefined: | |
3547 | size += size_of_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3548 | break; | |
3549 | case DW_CFA_same_value: | |
3550 | case DW_CFA_def_cfa_register: | |
3551 | size += size_of_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3552 | break; | |
3553 | case DW_CFA_register: | |
3554 | size += size_of_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3555 | size += size_of_uleb128(cfi->dw_cfi_oprnd2.dw_cfi_reg_num); | |
3556 | break; | |
3557 | case DW_CFA_def_cfa_offset: | |
3558 | size += size_of_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_offset); | |
3559 | break; | |
3560 | default: | |
3561 | break; | |
3562 | } | |
3563 | return size; | |
3564 | } | |
3565 | ||
3566 | /* Return the size of an FDE sans the length word. */ | |
3567 | inline unsigned long | |
3568 | size_of_fde (fde, npad) | |
3569 | dw_fde_ref fde; | |
3570 | unsigned long *npad; | |
3571 | { | |
3572 | register dw_cfi_ref cfi; | |
3573 | register unsigned long aligned_size; | |
3574 | register unsigned long size; | |
3575 | size = DWARF_FDE_HEADER_SIZE; | |
3576 | for (cfi = fde->dw_fde_cfi; cfi != NULL; cfi = cfi->dw_cfi_next) | |
3577 | { | |
3578 | size += size_of_cfi(cfi); | |
3579 | } | |
3580 | /* Round the size up to an 8 byte boundary. */ | |
3581 | aligned_size = (size + 7) & ~7; | |
3582 | *npad = aligned_size - size; | |
3583 | return aligned_size; | |
3584 | } | |
3585 | ||
3586 | /* Calculate the size of the FDE table, and establish the offset | |
3587 | of each FDE in the .debug_frame section. */ | |
3588 | static void | |
3589 | calc_fde_sizes () | |
3590 | { | |
3591 | register unsigned long i; | |
3592 | register dw_fde_ref fde; | |
3593 | register unsigned long fde_size; | |
3594 | unsigned long fde_pad; | |
3595 | for (i = 0; i < fde_table_in_use; ++i) | |
3596 | { | |
3597 | fde = &fde_table[i]; | |
3598 | fde->dw_fde_offset = next_fde_offset; | |
3599 | fde_size = size_of_fde (fde, &fde_pad); | |
3600 | next_fde_offset += fde_size; | |
3601 | } | |
3602 | } | |
3603 | ||
3604 | /* Output a Call Frame Information opcode and its operand(s). */ | |
3605 | static void | |
3606 | output_cfi (cfi, fde) | |
3607 | register dw_cfi_ref cfi; | |
3608 | register dw_fde_ref fde; | |
3609 | { | |
3610 | if (cfi->dw_cfi_opc == DW_CFA_advance_loc) | |
3611 | { | |
3612 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, | |
3613 | cfi->dw_cfi_opc | |
3614 | | (cfi->dw_cfi_oprnd1.dw_cfi_offset & 0x3f)); | |
3615 | if (flag_verbose_asm) | |
3616 | { | |
3617 | fprintf (asm_out_file, "\t%s DW_CFA_advance_loc", ASM_COMMENT_START); | |
3618 | } | |
3619 | fputc ('\n', asm_out_file); | |
3620 | } | |
3621 | else if (cfi->dw_cfi_opc == DW_CFA_offset) | |
3622 | { | |
3623 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, | |
3624 | cfi->dw_cfi_opc | |
3625 | | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)); | |
3626 | if (flag_verbose_asm) | |
3627 | { | |
3628 | fprintf (asm_out_file, "\t%s DW_CFA_offset", ASM_COMMENT_START); | |
3629 | } | |
3630 | fputc ('\n', asm_out_file); | |
3631 | output_uleb128(cfi->dw_cfi_oprnd2.dw_cfi_offset); | |
3632 | fputc ('\n', asm_out_file); | |
3633 | } | |
3634 | else if (cfi->dw_cfi_opc == DW_CFA_restore) | |
3635 | { | |
3636 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, | |
3637 | cfi->dw_cfi_opc | |
3638 | | (cfi->dw_cfi_oprnd1.dw_cfi_reg_num & 0x3f)); | |
3639 | if (flag_verbose_asm) | |
3640 | { | |
3641 | fprintf (asm_out_file, "\t%s DW_CFA_restore", ASM_COMMENT_START); | |
3642 | } | |
3643 | fputc ('\n', asm_out_file); | |
3644 | } | |
3645 | else | |
3646 | { | |
3647 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, cfi->dw_cfi_opc); | |
3648 | if (flag_verbose_asm) | |
3649 | { | |
3650 | fprintf (asm_out_file, "\t%s %s", | |
3651 | ASM_COMMENT_START, | |
3652 | dwarf_cfi_name (cfi->dw_cfi_opc)); | |
3653 | } | |
3654 | fputc ('\n', asm_out_file); | |
3655 | switch (cfi->dw_cfi_opc) | |
3656 | { | |
3657 | case DW_CFA_set_loc: | |
3658 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, | |
3659 | cfi->dw_cfi_oprnd1.dw_cfi_addr); | |
3660 | fputc ('\n', asm_out_file); | |
3661 | break; | |
3662 | case DW_CFA_advance_loc1: | |
3663 | /* TODO: not currently implemented. */ | |
3664 | abort (); | |
3665 | break; | |
3666 | case DW_CFA_advance_loc2: | |
3667 | ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, | |
3668 | cfi->dw_cfi_oprnd1.dw_cfi_addr, | |
3669 | fde->dw_fde_begin); | |
3670 | fputc ('\n', asm_out_file); | |
3671 | break; | |
3672 | case DW_CFA_advance_loc4: | |
3673 | ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, | |
3674 | cfi->dw_cfi_oprnd1.dw_cfi_addr, | |
3675 | fde->dw_fde_begin); | |
3676 | fputc ('\n', asm_out_file); | |
3677 | break; | |
3678 | #ifdef MIPS_DEBUGGING_INFO | |
3679 | case DW_CFA_MIPS_advance_loc8: | |
3680 | /* TODO: not currently implemented. */ | |
3681 | abort (); | |
3682 | break; | |
3683 | #endif | |
3684 | case DW_CFA_offset_extended: | |
3685 | case DW_CFA_def_cfa: | |
3686 | output_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3687 | fputc ('\n', asm_out_file); | |
3688 | output_uleb128(cfi->dw_cfi_oprnd2.dw_cfi_offset); | |
3689 | fputc ('\n', asm_out_file); | |
3690 | break; | |
3691 | case DW_CFA_restore_extended: | |
3692 | case DW_CFA_undefined: | |
3693 | output_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3694 | fputc ('\n', asm_out_file); | |
3695 | break; | |
3696 | case DW_CFA_same_value: | |
3697 | case DW_CFA_def_cfa_register: | |
3698 | output_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3699 | fputc ('\n', asm_out_file); | |
3700 | break; | |
3701 | case DW_CFA_register: | |
3702 | output_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_reg_num); | |
3703 | fputc ('\n', asm_out_file); | |
3704 | output_uleb128(cfi->dw_cfi_oprnd2.dw_cfi_reg_num); | |
3705 | fputc ('\n', asm_out_file); | |
3706 | break; | |
3707 | case DW_CFA_def_cfa_offset: | |
3708 | output_uleb128(cfi->dw_cfi_oprnd1.dw_cfi_offset); | |
3709 | fputc ('\n', asm_out_file); | |
3710 | break; | |
3711 | default: | |
3712 | break; | |
3713 | } | |
3714 | } | |
3715 | } | |
3716 | ||
3717 | /* Output the call frame information used to used to record information | |
3718 | that relates to calculating the frame pointer, and records the | |
3719 | location of saved registers. */ | |
3720 | static void | |
3721 | output_call_frame_info () | |
3722 | { | |
3723 | register unsigned long i, j; | |
3724 | register dw_fde_ref fde; | |
3725 | register unsigned long fde_size; | |
3726 | dw_cfi_node cfi_node; | |
3727 | register dw_cfi_ref cfi; | |
3728 | unsigned long fde_pad; | |
3729 | ||
3730 | /* Output the CIE. */ | |
3731 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, DWARF_CIE_SIZE - 4); | |
3732 | if (flag_verbose_asm) | |
3733 | { | |
3734 | fprintf (asm_out_file, "\t%s Length of Common Information Entry", | |
3735 | ASM_COMMENT_START); | |
3736 | } | |
3737 | fputc ('\n', asm_out_file); | |
3738 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, DW_CIE_ID); | |
3739 | if (flag_verbose_asm) | |
3740 | { | |
3741 | fprintf (asm_out_file, "\t%s CIE Identifier Tag", | |
3742 | ASM_COMMENT_START); | |
3743 | } | |
3744 | fputc ('\n', asm_out_file); | |
3745 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_CIE_VERSION); | |
3746 | if (flag_verbose_asm) | |
3747 | { | |
3748 | fprintf (asm_out_file, "\t%s CIE Version", | |
3749 | ASM_COMMENT_START); | |
3750 | } | |
3751 | fputc ('\n', asm_out_file); | |
3752 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
3753 | if (flag_verbose_asm) | |
3754 | { | |
3755 | fprintf (asm_out_file, "\t%s CIE Augmentation (none)", | |
3756 | ASM_COMMENT_START); | |
3757 | } | |
3758 | fputc ('\n', asm_out_file); | |
3759 | output_uleb128 (1); | |
3760 | if (flag_verbose_asm) | |
3761 | { | |
3762 | fprintf (asm_out_file, "\t%s CIE Code Alignment Factor", | |
3763 | ASM_COMMENT_START); | |
3764 | } | |
3765 | fputc ('\n', asm_out_file); | |
3766 | output_sleb128 (DWARF_CIE_DATA_ALIGNMENT); | |
3767 | if (flag_verbose_asm) | |
3768 | { | |
3769 | fprintf (asm_out_file, "\t%s CIE Data Alignment Factor", | |
3770 | ASM_COMMENT_START); | |
3771 | } | |
3772 | fputc ('\n', asm_out_file); | |
3773 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_FRAME_RA_COL); | |
3774 | if (flag_verbose_asm) | |
3775 | { | |
3776 | fprintf (asm_out_file, "\t%s CIE RA Column", | |
3777 | ASM_COMMENT_START); | |
3778 | } | |
3779 | fputc ('\n', asm_out_file); | |
3780 | ||
3781 | /* Output the CFA instructions common to all FDE's. */ | |
3782 | ||
3783 | #ifdef MIPS_DEBUGGING_INFO | |
3784 | ||
3785 | /* Set the RA on entry to be the contents of r31. */ | |
3786 | bzero (&cfi_node, sizeof (dw_cfi_node)); | |
3787 | cfi = &cfi_node; | |
3788 | cfi->dw_cfi_opc = DW_CFA_register; | |
3789 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = DW_FRAME_RA_COL; | |
3790 | cfi->dw_cfi_oprnd2.dw_cfi_reg_num = DW_FRAME_REG31; | |
3791 | output_cfi (cfi); | |
3792 | ||
3793 | #endif | |
3794 | ||
3795 | /* Pad the CIE out to an address sized boundary. */ | |
3796 | for (i = DWARF_CIE_HEADER_SIZE; i < DWARF_CIE_SIZE; ++i) | |
3797 | { | |
3798 | /* Pad out to a pointer size boundary */ | |
3799 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_CFA_nop); | |
3800 | if (flag_verbose_asm) | |
3801 | { | |
3802 | fprintf (asm_out_file, "\t%s CIE DW_CFA_nop (pad)", | |
3803 | ASM_COMMENT_START); | |
3804 | } | |
3805 | fputc ('\n', asm_out_file); | |
3806 | } | |
3807 | ||
3808 | /* Loop through all of the FDE's. */ | |
3809 | for (i = 0; i < fde_table_in_use; ++i) | |
3810 | { | |
3811 | fde = &fde_table[i]; | |
3812 | fde_size = size_of_fde (fde, &fde_pad); | |
3813 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, fde_size - 4); | |
3814 | if (flag_verbose_asm) | |
3815 | { | |
3816 | fprintf (asm_out_file, "\t%s FDE Length", | |
3817 | ASM_COMMENT_START); | |
3818 | } | |
3819 | fputc ('\n', asm_out_file); | |
ba7b35df | 3820 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (FRAME_SECTION)); |
a3f97cbb JW |
3821 | if (flag_verbose_asm) |
3822 | { | |
3823 | fprintf (asm_out_file, "\t%s FDE CIE offset", | |
3824 | ASM_COMMENT_START); | |
3825 | } | |
3826 | fputc ('\n', asm_out_file); | |
3827 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, fde->dw_fde_begin); | |
3828 | if (flag_verbose_asm) | |
3829 | { | |
3830 | fprintf (asm_out_file, "\t%s FDE initial location", | |
3831 | ASM_COMMENT_START); | |
3832 | } | |
3833 | fputc ('\n', asm_out_file); | |
3834 | ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, | |
3835 | fde->dw_fde_end, fde->dw_fde_begin); | |
3836 | if (flag_verbose_asm) | |
3837 | { | |
3838 | fprintf (asm_out_file, "\t%s FDE address range", | |
3839 | ASM_COMMENT_START); | |
3840 | } | |
3841 | fputc ('\n', asm_out_file); | |
3842 | ||
3843 | /* Loop through the Call Frame Instructions associated with | |
3844 | this FDE. */ | |
3845 | for (cfi = fde->dw_fde_cfi; cfi != NULL; cfi = cfi->dw_cfi_next) | |
3846 | { | |
3847 | output_cfi (cfi, fde); | |
3848 | } | |
3849 | ||
3850 | /* Pad to a double word boundary. */ | |
3851 | for (j = 0; j < fde_pad; ++j) | |
3852 | { | |
3853 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_CFA_nop); | |
3854 | if (flag_verbose_asm) | |
3855 | { | |
3856 | fprintf (asm_out_file, "\t%s CIE DW_CFA_nop (pad)", | |
3857 | ASM_COMMENT_START); | |
3858 | } | |
3859 | fputc ('\n', asm_out_file); | |
3860 | } | |
3861 | } | |
3862 | } | |
3863 | ||
3864 | /* Output the public names table used to speed up access to externally | |
3865 | visible names. For now, only generate entries for externally | |
3866 | visible procedures. */ | |
3867 | static void | |
3868 | output_pubnames () | |
3869 | { | |
3870 | dw_die_ref die; | |
3871 | register unsigned long pubnames_length = size_of_pubnames (); | |
3872 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, pubnames_length); | |
3873 | if (flag_verbose_asm) | |
3874 | { | |
3875 | fprintf (asm_out_file, "\t%s Length of Public Names Info.", | |
3876 | ASM_COMMENT_START); | |
3877 | } | |
3878 | fputc ('\n', asm_out_file); | |
3879 | ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION); | |
3880 | if (flag_verbose_asm) | |
3881 | { | |
3882 | fprintf (asm_out_file, "\t%s DWARF Version", | |
3883 | ASM_COMMENT_START); | |
3884 | } | |
3885 | fputc ('\n', asm_out_file); | |
3886 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (DEBUG_SECTION)); | |
3887 | if (flag_verbose_asm) | |
3888 | { | |
3889 | fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.", | |
3890 | ASM_COMMENT_START); | |
3891 | } | |
3892 | fputc ('\n', asm_out_file); | |
3893 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, next_die_offset); | |
3894 | if (flag_verbose_asm) | |
3895 | { | |
3896 | fprintf (asm_out_file, "\t%s Compilation Unit Length", | |
3897 | ASM_COMMENT_START); | |
3898 | } | |
3899 | fputc ('\n', asm_out_file); | |
3900 | for (die = comp_unit_die->die_child; die != NULL; die = die->die_sib) | |
3901 | { | |
3902 | if (is_extern_subr_die (die)) | |
3903 | { | |
3904 | char *low_pc = get_AT_low_pc (die); | |
3905 | if (low_pc != NULL) | |
3906 | { | |
3907 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, die->die_offset); | |
3908 | if (flag_verbose_asm) | |
3909 | { | |
3910 | fprintf (asm_out_file, "\t%s DIE offset", | |
3911 | ASM_COMMENT_START); | |
3912 | } | |
3913 | fputc ('\n', asm_out_file); | |
3914 | ASM_OUTPUT_DWARF_STRING (asm_out_file, low_pc); | |
3915 | if (flag_verbose_asm) | |
3916 | { | |
3917 | fprintf (asm_out_file, "%s external name", | |
3918 | ASM_COMMENT_START); | |
3919 | } | |
3920 | fputc ('\n', asm_out_file); | |
3921 | } | |
3922 | } | |
3923 | } | |
3924 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); | |
3925 | fputc ('\n', asm_out_file); | |
3926 | } | |
3927 | ||
3928 | /* Output the information that goes into the .debug_aranges table. | |
3929 | Namely, define the beginning and ending address range of the | |
3930 | text section generated for this compilation unit. */ | |
3931 | static void | |
3932 | output_aranges () | |
3933 | { | |
3934 | dw_die_ref die; | |
3935 | register unsigned long aranges_length = size_of_aranges (); | |
3936 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, aranges_length); | |
3937 | if (flag_verbose_asm) | |
3938 | { | |
3939 | fprintf (asm_out_file, "\t%s Length of Address Ranges Info.", | |
3940 | ASM_COMMENT_START); | |
3941 | } | |
3942 | fputc ('\n', asm_out_file); | |
3943 | ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION); | |
3944 | if (flag_verbose_asm) | |
3945 | { | |
3946 | fprintf (asm_out_file, "\t%s DWARF Version", | |
3947 | ASM_COMMENT_START); | |
3948 | } | |
3949 | fputc ('\n', asm_out_file); | |
3950 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, stripattributes (DEBUG_SECTION)); | |
3951 | if (flag_verbose_asm) | |
3952 | { | |
3953 | fprintf (asm_out_file, "\t%s Offset of Compilation Unit Info.", | |
3954 | ASM_COMMENT_START); | |
3955 | } | |
3956 | fputc ('\n', asm_out_file); | |
3957 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, PTR_SIZE); | |
3958 | if (flag_verbose_asm) | |
3959 | { | |
3960 | fprintf (asm_out_file, "\t%s Size of Address", | |
3961 | ASM_COMMENT_START); | |
3962 | } | |
3963 | fputc ('\n', asm_out_file); | |
3964 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
3965 | if (flag_verbose_asm) | |
3966 | { | |
3967 | fprintf (asm_out_file, "\t%s Size of Segment Descriptor", | |
3968 | ASM_COMMENT_START); | |
3969 | } | |
3970 | fputc ('\n', asm_out_file); | |
3971 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4); | |
3972 | if (flag_verbose_asm) | |
3973 | { | |
3974 | fprintf (asm_out_file, "\t%s Pad to 8 byte boundary", | |
3975 | ASM_COMMENT_START); | |
3976 | } | |
3977 | fputc ('\n', asm_out_file); | |
bdb669cb | 3978 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_SECTION); |
a3f97cbb JW |
3979 | if (flag_verbose_asm) |
3980 | { | |
3981 | fprintf (asm_out_file, "\t%s Address", ASM_COMMENT_START); | |
3982 | } | |
3983 | fputc ('\n', asm_out_file); | |
bdb669cb | 3984 | ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_SECTION); |
a3f97cbb JW |
3985 | if (flag_verbose_asm) |
3986 | { | |
3987 | fprintf (asm_out_file, "%s Length", ASM_COMMENT_START); | |
3988 | } | |
3989 | fputc ('\n', asm_out_file); | |
3990 | /* Output the terminator words. */ | |
3991 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); | |
3992 | fputc ('\n', asm_out_file); | |
3993 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0); | |
3994 | fputc ('\n', asm_out_file); | |
3995 | } | |
3996 | ||
3997 | /* Output the source line number correspondence information. This | |
3998 | information goes into the .debug_line section. */ | |
3999 | static void | |
4000 | output_line_info () | |
4001 | { | |
4002 | register unsigned long line_info_len; | |
4003 | register unsigned long line_info_prolog_len; | |
4004 | char line_label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
4005 | char prev_line_label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
4006 | register unsigned opc; | |
4007 | register unsigned n_op_args; | |
4008 | register dw_line_info_ref line_info; | |
4009 | register unsigned long ft_index; | |
4010 | register unsigned long lt_index; | |
4011 | register unsigned long current_line; | |
4012 | register long line_offset; | |
4013 | register long line_delta; | |
4014 | register unsigned long current_file; | |
4015 | line_info_len = size_of_line_info (); | |
4016 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, line_info_len); | |
4017 | if (flag_verbose_asm) | |
4018 | { | |
4019 | fprintf (asm_out_file, "\t%s Length of Source Line Info.", | |
4020 | ASM_COMMENT_START); | |
4021 | } | |
4022 | fputc ('\n', asm_out_file); | |
4023 | ASM_OUTPUT_DWARF_DATA2 (asm_out_file, DWARF_VERSION); | |
4024 | if (flag_verbose_asm) | |
4025 | { | |
4026 | fprintf (asm_out_file, "\t%s DWARF Version", | |
4027 | ASM_COMMENT_START); | |
4028 | } | |
4029 | fputc ('\n', asm_out_file); | |
4030 | line_info_prolog_len = size_of_line_prolog (); | |
4031 | ASM_OUTPUT_DWARF_DATA4 (asm_out_file, line_info_prolog_len); | |
4032 | if (flag_verbose_asm) | |
4033 | { | |
4034 | fprintf (asm_out_file, "\t%s Prolog Length", | |
4035 | ASM_COMMENT_START); | |
4036 | } | |
4037 | fputc ('\n', asm_out_file); | |
4038 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_LINE_MIN_INSTR_LENGTH); | |
4039 | if (flag_verbose_asm) | |
4040 | { | |
4041 | fprintf (asm_out_file, "\t%s Minimum Instruction Length", | |
4042 | ASM_COMMENT_START); | |
4043 | } | |
4044 | fputc ('\n', asm_out_file); | |
4045 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DWARF_LINE_DEFAULT_IS_STMT_START); | |
4046 | if (flag_verbose_asm) | |
4047 | { | |
4048 | fprintf (asm_out_file, "\t%s Default is_stmt_start flag", | |
4049 | ASM_COMMENT_START); | |
4050 | } | |
4051 | fputc ('\n', asm_out_file); | |
4052 | fprintf (asm_out_file, "\t%s\t%d", ASM_BYTE_OP, DWARF_LINE_BASE); | |
4053 | if (flag_verbose_asm) | |
4054 | { | |
4055 | fprintf (asm_out_file, "\t%s Line Base Value (Special Opcodes)", | |
4056 | ASM_COMMENT_START); | |
4057 | } | |
4058 | fputc ('\n', asm_out_file); | |
4059 | fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_RANGE); | |
4060 | if (flag_verbose_asm) | |
4061 | { | |
4062 | fprintf (asm_out_file, "\t%s Line Range Value (Special Opcodes)", | |
4063 | ASM_COMMENT_START); | |
4064 | } | |
4065 | fputc ('\n', asm_out_file); | |
4066 | fprintf (asm_out_file, "\t%s\t%u", ASM_BYTE_OP, DWARF_LINE_OPCODE_BASE); | |
4067 | if (flag_verbose_asm) | |
4068 | { | |
4069 | fprintf (asm_out_file, "\t%s Special Opcode Base", | |
4070 | ASM_COMMENT_START); | |
4071 | } | |
4072 | fputc ('\n', asm_out_file); | |
4073 | for (opc = 1; opc < DWARF_LINE_OPCODE_BASE; ++opc) | |
4074 | { | |
4075 | switch (opc) | |
4076 | { | |
4077 | case DW_LNS_advance_pc: | |
4078 | case DW_LNS_advance_line: | |
4079 | case DW_LNS_set_file: | |
4080 | case DW_LNS_set_column: | |
4081 | case DW_LNS_fixed_advance_pc: | |
4082 | n_op_args = 1; | |
4083 | break; | |
4084 | default: | |
4085 | n_op_args = 0; | |
4086 | break; | |
4087 | } | |
4088 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, n_op_args); | |
4089 | if (flag_verbose_asm) | |
4090 | { | |
4091 | fprintf (asm_out_file, "\t%s opcode: 0x%x has %d args", | |
4092 | ASM_COMMENT_START, opc, n_op_args); | |
4093 | } | |
4094 | fputc ('\n', asm_out_file); | |
4095 | } | |
4096 | if (flag_verbose_asm) | |
4097 | { | |
4098 | fprintf (asm_out_file, "%s Include Directory Table\n", | |
4099 | ASM_COMMENT_START); | |
4100 | } | |
4101 | /* Include directory table is empty, at present */ | |
4102 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
4103 | fputc ('\n', asm_out_file); | |
4104 | if (flag_verbose_asm) | |
4105 | { | |
4106 | fprintf (asm_out_file, "%s File Name Table\n", ASM_COMMENT_START); | |
4107 | } | |
4108 | for (ft_index = 1; ft_index < file_table_in_use; ++ft_index) | |
4109 | { | |
4110 | ASM_OUTPUT_DWARF_STRING (asm_out_file, file_table[ft_index]); | |
4111 | if (flag_verbose_asm) | |
4112 | { | |
4113 | fprintf (asm_out_file, "%s File Entry: 0x%x", | |
4114 | ASM_COMMENT_START, ft_index); | |
4115 | } | |
4116 | fputc ('\n', asm_out_file); | |
4117 | /* Include directory index */ | |
4118 | output_uleb128 (0); | |
4119 | fputc ('\n', asm_out_file); | |
4120 | /* Modification time */ | |
4121 | output_uleb128 (0); | |
4122 | fputc ('\n', asm_out_file); | |
4123 | /* File length in bytes */ | |
4124 | output_uleb128 (0); | |
4125 | fputc ('\n', asm_out_file); | |
4126 | } | |
4127 | /* Terminate the file name table */ | |
4128 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
4129 | fputc ('\n', asm_out_file); | |
4130 | ||
4131 | /* Set the address register to the first location in the text section */ | |
4132 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
4133 | if (flag_verbose_asm) | |
4134 | { | |
4135 | fprintf (asm_out_file, "\t%s DW_LNE_set_address", ASM_COMMENT_START); | |
4136 | } | |
4137 | fputc ('\n', asm_out_file); | |
4138 | output_uleb128 (1 + PTR_SIZE); | |
4139 | fputc ('\n', asm_out_file); | |
4140 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_set_address); | |
4141 | fputc ('\n', asm_out_file); | |
bdb669cb | 4142 | ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_SECTION); |
a3f97cbb JW |
4143 | fputc ('\n', asm_out_file); |
4144 | ||
4145 | /* Generate the line number to PC correspondence table, encoded as | |
4146 | a series of state machine operations. */ | |
4147 | current_file = 1; | |
4148 | current_line = 1; | |
bdb669cb | 4149 | strcpy (prev_line_label, TEXT_SECTION); |
a3f97cbb JW |
4150 | for (lt_index = 1; lt_index < line_info_table_in_use; ++lt_index) |
4151 | { | |
4152 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc); | |
4153 | if (flag_verbose_asm) | |
4154 | { | |
4155 | fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc", | |
4156 | ASM_COMMENT_START); | |
4157 | } | |
4158 | fputc ('\n', asm_out_file); | |
4159 | sprintf (line_label, LINE_CODE_LABEL_FMT, lt_index); | |
4160 | ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, line_label, prev_line_label); | |
4161 | fputc ('\n', asm_out_file); | |
4162 | line_info = &line_info_table[lt_index]; | |
4163 | if (line_info->dw_file_num != current_file) | |
4164 | { | |
4165 | current_file = line_info->dw_file_num; | |
4166 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_set_file); | |
4167 | if (flag_verbose_asm) | |
4168 | { | |
4169 | fprintf (asm_out_file, | |
4170 | "\t%s DW_LNS_set_file", ASM_COMMENT_START); | |
4171 | } | |
4172 | fputc ('\n', asm_out_file); | |
4173 | output_uleb128 (current_file); | |
4174 | if (flag_verbose_asm) | |
4175 | { | |
4176 | fprintf (asm_out_file, "\t%s \"%s\"", | |
4177 | ASM_COMMENT_START, file_table[current_file]); | |
4178 | } | |
4179 | fputc ('\n', asm_out_file); | |
4180 | } | |
4181 | if (line_info->dw_line_num != current_line) | |
4182 | { | |
4183 | line_offset = line_info->dw_line_num - current_line; | |
4184 | line_delta = line_offset - DWARF_LINE_BASE; | |
4185 | current_line = line_info->dw_line_num; | |
4186 | if (line_delta >= 0 && line_delta < (DWARF_LINE_RANGE - 1)) | |
4187 | { | |
4188 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, | |
4189 | DWARF_LINE_OPCODE_BASE + line_delta); | |
4190 | if (flag_verbose_asm) | |
4191 | { | |
4192 | fprintf (asm_out_file, | |
4193 | "\t%s line %d", ASM_COMMENT_START, current_line); | |
4194 | } | |
4195 | fputc ('\n', asm_out_file); | |
4196 | } | |
4197 | else | |
4198 | { | |
4199 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_advance_line); | |
4200 | if (flag_verbose_asm) | |
4201 | { | |
4202 | fprintf (asm_out_file, | |
4203 | "\t%s advance to line %d", | |
4204 | ASM_COMMENT_START, current_line); | |
4205 | } | |
4206 | fputc ('\n', asm_out_file); | |
4207 | output_sleb128 (line_offset); | |
4208 | fputc ('\n', asm_out_file); | |
4209 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_copy); | |
4210 | fputc ('\n', asm_out_file); | |
4211 | } | |
4212 | } | |
4213 | strcpy (prev_line_label, line_label); | |
4214 | } | |
4215 | ||
bdb669cb | 4216 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNS_fixed_advance_pc); |
a3f97cbb JW |
4217 | if (flag_verbose_asm) |
4218 | { | |
bdb669cb JM |
4219 | fprintf (asm_out_file, "\t%s DW_LNS_fixed_advance_pc", |
4220 | ASM_COMMENT_START); | |
a3f97cbb JW |
4221 | } |
4222 | fputc ('\n', asm_out_file); | |
bdb669cb | 4223 | ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, TEXT_END_LABEL, prev_line_label); |
a3f97cbb | 4224 | fputc ('\n', asm_out_file); |
bdb669cb | 4225 | |
a3f97cbb JW |
4226 | /* Output the marker for the end of the line number info. */ |
4227 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 0); | |
4228 | if (flag_verbose_asm) | |
4229 | { | |
4230 | fprintf (asm_out_file, "\t%s DW_LNE_end_sequence", ASM_COMMENT_START); | |
4231 | } | |
4232 | fputc ('\n', asm_out_file); | |
4233 | output_uleb128 (1); | |
4234 | fputc ('\n', asm_out_file); | |
4235 | ASM_OUTPUT_DWARF_DATA1 (asm_out_file, DW_LNE_end_sequence); | |
4236 | fputc ('\n', asm_out_file); | |
4237 | } | |
4238 | \f | |
4239 | /**************** attribute support utilities ********************************/ | |
4240 | ||
4241 | /* | |
4242 | * Given a pointer to a BLOCK node return non-zero if (and only if) the node | |
4243 | * in question represents the outermost pair of curly braces (i.e. the "body | |
4244 | * block") of a function or method. | |
4245 | * | |
4246 | * For any BLOCK node representing a "body block" of a function or method, the | |
4247 | * BLOCK_SUPERCONTEXT of the node will point to another BLOCK node which | |
4248 | * represents the outermost (function) scope for the function or method (i.e. | |
4249 | * the one which includes the formal parameters). The BLOCK_SUPERCONTEXT of | |
4250 | * *that* node in turn will point to the relevant FUNCTION_DECL node. | |
4251 | */ | |
4252 | inline int | |
4253 | is_body_block (stmt) | |
4254 | register tree stmt; | |
4255 | { | |
4256 | if (TREE_CODE (stmt) == BLOCK) | |
4257 | { | |
4258 | register tree parent = BLOCK_SUPERCONTEXT (stmt); | |
4259 | ||
4260 | if (TREE_CODE (parent) == BLOCK) | |
4261 | { | |
4262 | register tree grandparent = BLOCK_SUPERCONTEXT (parent); | |
4263 | ||
4264 | if (TREE_CODE (grandparent) == FUNCTION_DECL) | |
4265 | return 1; | |
4266 | } | |
4267 | } | |
4268 | return 0; | |
4269 | } | |
4270 | ||
4271 | /* Reset the base type to DIE table, and build a special predefined | |
4272 | base type entry for the "int" signed integer base type. The | |
4273 | "int" base type is used to construct subscript index range | |
4274 | definitions, in situations where an anonymous integer type | |
4275 | is required. */ | |
4276 | inline void | |
4277 | init_base_type_table () | |
4278 | { | |
4279 | register int i; | |
4280 | register base_type_ref bt; | |
4281 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4282 | { | |
4283 | base_type_die_table[i] = NULL; | |
4284 | } | |
4285 | assert (comp_unit_die != 0); | |
4286 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4287 | { | |
4288 | bt = &base_type_table[i]; | |
4289 | if (strcmp (bt->bt_name, "int") == 0) | |
4290 | { | |
4291 | int_base_type_die = new_die (DW_TAG_base_type, comp_unit_die); | |
4292 | base_type_die_table[i] = int_base_type_die; | |
4293 | add_AT_string (int_base_type_die, DW_AT_name, bt->bt_name); | |
4294 | add_AT_unsigned (int_base_type_die, | |
4295 | DW_AT_byte_size, bt->bt_size / 8); | |
4296 | add_AT_unsigned (int_base_type_die, DW_AT_encoding, bt->bt_type); | |
4297 | break; | |
4298 | } | |
4299 | } | |
4300 | } | |
4301 | ||
4302 | /* Given a pointer to a tree node for some base type, return a pointer to | |
4303 | a DIE that describes the given type. | |
4304 | ||
4305 | This routine must only be called for GCC type nodes that correspond to | |
4306 | Dwarf base (fundamental) types. */ | |
4307 | static dw_die_ref | |
4308 | base_type_die (type) | |
4309 | register tree type; | |
4310 | { | |
4311 | register dw_die_ref base_type_result = NULL; | |
4312 | register char *type_name = NULL; | |
4313 | register int type_index = 0; | |
4314 | register base_type_ref bt; | |
4315 | register int i; | |
4316 | ||
4317 | if (TREE_CODE (type) == ERROR_MARK) | |
4318 | return 0; | |
4319 | ||
4320 | switch (TREE_CODE (type)) | |
4321 | { | |
4322 | case VOID_TYPE: | |
4323 | case ERROR_MARK: | |
4324 | break; | |
4325 | ||
4326 | case INTEGER_TYPE: | |
4327 | /* Carefully distinguish all the standard types of C, without messing | |
4328 | up if the language is not C. Note that we check only for the names | |
4329 | that contain spaces; other names might occur by coincidence in other | |
4330 | languages. */ | |
4331 | if (TYPE_NAME (type) != 0 | |
4332 | && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL | |
4333 | && DECL_NAME (TYPE_NAME (type)) != 0 | |
4334 | && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE) | |
4335 | { | |
4336 | type_name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type))); | |
4337 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4338 | { | |
4339 | bt = &base_type_table[i]; | |
4340 | if (strcmp (type_name, bt->bt_name) == 0) | |
4341 | { | |
4342 | type_index = i; | |
4343 | break; | |
4344 | } | |
4345 | } | |
4346 | } | |
4347 | ||
4348 | /* Most integer types will be sorted out above, however, for the sake | |
4349 | of special `array index' integer types, the following code is also | |
4350 | provided. */ | |
4351 | if (type_index == 0) | |
4352 | { | |
4353 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4354 | { | |
4355 | bt = &base_type_table[i]; | |
4356 | if (bt->bt_size == TYPE_PRECISION (type) | |
4357 | && (TREE_UNSIGNED (type) == 0) == bt->bt_is_signed) | |
4358 | { | |
4359 | type_index = i; | |
4360 | break; | |
4361 | } | |
4362 | } | |
4363 | } | |
4364 | break; | |
4365 | ||
4366 | case REAL_TYPE: | |
4367 | /* Carefully distinguish all the standard types of C, without messing | |
4368 | up if the language is not C. */ | |
4369 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4370 | { | |
4371 | bt = &base_type_table[i]; | |
4372 | if ((bt->bt_type == DW_ATE_float) | |
4373 | && (bt->bt_size == TYPE_PRECISION (type))) | |
4374 | { | |
4375 | type_index = i; | |
4376 | break; | |
4377 | } | |
4378 | } | |
4379 | break; | |
4380 | ||
4381 | case COMPLEX_TYPE: | |
4382 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4383 | { | |
4384 | bt = &base_type_table[i]; | |
4385 | if ((bt->bt_type == DW_ATE_complex_float) | |
4386 | && (bt->bt_size == TYPE_PRECISION (type))) | |
4387 | { | |
4388 | type_index = i; | |
4389 | break; | |
4390 | } | |
4391 | } | |
4392 | break; | |
4393 | ||
4394 | case CHAR_TYPE: | |
4395 | /* GNU Pascal/Ada CHAR type. Not used in C. */ | |
4396 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4397 | { | |
4398 | bt = &base_type_table[i]; | |
4399 | if (bt->bt_type == DW_ATE_signed_char | |
4400 | || bt->bt_type == DW_ATE_unsigned_char) | |
4401 | { | |
4402 | if (bt->bt_size == TYPE_PRECISION (type) | |
4403 | && ((TREE_UNSIGNED (type) == 0) == bt->bt_is_signed)) | |
4404 | { | |
4405 | type_index = i; | |
4406 | break; | |
4407 | } | |
4408 | } | |
4409 | } | |
4410 | break; | |
4411 | ||
4412 | case BOOLEAN_TYPE: | |
4413 | /* GNU FORTRAN/Ada BOOLEAN type. */ | |
4414 | for (i = 0; i < NUM_BASE_TYPES; ++i) | |
4415 | { | |
4416 | bt = &base_type_table[i]; | |
4417 | if (bt->bt_type == DW_ATE_boolean | |
4418 | && bt->bt_size == TYPE_PRECISION (type)) | |
4419 | { | |
4420 | type_index = i; | |
4421 | break; | |
4422 | } | |
4423 | } | |
4424 | break; | |
4425 | ||
4426 | default: | |
4427 | abort (); /* No other TREE_CODEs are Dwarf fundamental | |
4428 | types. */ | |
4429 | } | |
4430 | ||
4431 | if (type_index == 0) | |
4432 | { | |
4433 | base_type_result = NULL; | |
4434 | } | |
4435 | else | |
4436 | { | |
4437 | base_type_result = base_type_die_table[type_index]; | |
4438 | if (base_type_result == NULL) | |
4439 | { | |
4440 | bt = &base_type_table[type_index]; | |
4441 | base_type_result = new_die (DW_TAG_base_type, comp_unit_die); | |
4442 | base_type_die_table[type_index] = base_type_result; | |
4443 | add_AT_string (base_type_result, DW_AT_name, bt->bt_name); | |
4444 | add_AT_unsigned (base_type_result, DW_AT_byte_size, bt->bt_size / 8); | |
4445 | add_AT_unsigned (base_type_result, DW_AT_encoding, bt->bt_type); | |
4446 | } | |
4447 | ||
4448 | } | |
4449 | ||
4450 | return base_type_result; | |
4451 | } | |
4452 | ||
4453 | /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to | |
4454 | the Dwarf "root" type for the given input type. The Dwarf "root" type of | |
4455 | a given type is generally the same as the given type, except that if the | |
4456 | given type is a pointer or reference type, then the root type of the given | |
4457 | type is the root type of the "basis" type for the pointer or reference | |
4458 | type. (This definition of the "root" type is recursive.) Also, the root | |
4459 | type of a `const' qualified type or a `volatile' qualified type is the | |
4460 | root type of the given type without the qualifiers. */ | |
4461 | static tree | |
4462 | root_type (type) | |
4463 | register tree type; | |
4464 | { | |
4465 | if (TREE_CODE (type) == ERROR_MARK) | |
4466 | return error_mark_node; | |
4467 | ||
4468 | switch (TREE_CODE (type)) | |
4469 | { | |
4470 | case ERROR_MARK: | |
4471 | return error_mark_node; | |
4472 | ||
4473 | case POINTER_TYPE: | |
4474 | case REFERENCE_TYPE: | |
4475 | return type_main_variant (root_type (TREE_TYPE (type))); | |
4476 | ||
4477 | default: | |
4478 | return type_main_variant (type); | |
4479 | } | |
4480 | } | |
4481 | ||
4482 | /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the | |
4483 | given input type is a Dwarf "fundamental" type. Otherwise return null. */ | |
4484 | inline int | |
4485 | is_base_type (type) | |
4486 | register tree type; | |
4487 | { | |
4488 | switch (TREE_CODE (type)) | |
4489 | { | |
4490 | case ERROR_MARK: | |
4491 | case VOID_TYPE: | |
4492 | case INTEGER_TYPE: | |
4493 | case REAL_TYPE: | |
4494 | case COMPLEX_TYPE: | |
4495 | case BOOLEAN_TYPE: | |
4496 | case CHAR_TYPE: | |
4497 | return 1; | |
4498 | ||
4499 | case SET_TYPE: | |
4500 | case ARRAY_TYPE: | |
4501 | case RECORD_TYPE: | |
4502 | case UNION_TYPE: | |
4503 | case QUAL_UNION_TYPE: | |
4504 | case ENUMERAL_TYPE: | |
4505 | case FUNCTION_TYPE: | |
4506 | case METHOD_TYPE: | |
4507 | case POINTER_TYPE: | |
4508 | case REFERENCE_TYPE: | |
4509 | case FILE_TYPE: | |
4510 | case OFFSET_TYPE: | |
4511 | case LANG_TYPE: | |
4512 | return 0; | |
4513 | ||
4514 | default: | |
4515 | abort (); | |
4516 | } | |
4517 | return 0; | |
4518 | } | |
4519 | ||
4520 | /* Given a pointer to an arbitrary ..._TYPE tree node, return a debugging | |
4521 | entry that chains various modifiers in front of the given type. */ | |
4522 | static dw_die_ref | |
4523 | modified_type_die (type, is_const_type, is_volatile_type, context_die) | |
4524 | register tree type; | |
4525 | register int is_const_type; | |
4526 | register int is_volatile_type; | |
4527 | register dw_die_ref context_die; | |
4528 | { | |
4529 | register enum tree_code code = TREE_CODE (type); | |
4530 | register dw_die_ref mod_type_die = NULL; | |
4531 | register dw_die_ref sub_die = NULL; | |
4532 | register tree item_type; | |
4533 | ||
4534 | if (code != ERROR_MARK) | |
4535 | { | |
bdb669cb JM |
4536 | type = build_type_variant (type, is_const_type, is_volatile_type); |
4537 | ||
4538 | mod_type_die = lookup_type_die (type); | |
4539 | if (mod_type_die) | |
4540 | return mod_type_die; | |
4541 | ||
a3f97cbb JW |
4542 | if (is_const_type) |
4543 | { | |
4544 | mod_type_die = new_die (DW_TAG_const_type, context_die); | |
bdb669cb JM |
4545 | sub_die = modified_type_die |
4546 | (build_type_variant (type, 0, is_volatile_type), | |
4547 | 0, is_volatile_type, context_die); | |
a3f97cbb JW |
4548 | } |
4549 | else if (is_volatile_type) | |
4550 | { | |
4551 | mod_type_die = new_die (DW_TAG_volatile_type, context_die); | |
bdb669cb JM |
4552 | sub_die = modified_type_die |
4553 | (TYPE_MAIN_VARIANT (type), 0, 0, context_die); | |
a3f97cbb JW |
4554 | } |
4555 | else if (code == POINTER_TYPE) | |
4556 | { | |
4557 | mod_type_die = new_die (DW_TAG_pointer_type, context_die); | |
4558 | add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE); | |
4559 | add_AT_unsigned (mod_type_die, DW_AT_address_class, 0); | |
4560 | item_type = TREE_TYPE (type); | |
4561 | sub_die = modified_type_die (item_type, | |
4562 | TYPE_READONLY (item_type), | |
4563 | TYPE_VOLATILE (item_type), | |
4564 | context_die); | |
4565 | } | |
4566 | else if (code == REFERENCE_TYPE) | |
4567 | { | |
4568 | mod_type_die = new_die (DW_TAG_reference_type, context_die); | |
4569 | add_AT_unsigned (mod_type_die, DW_AT_byte_size, PTR_SIZE); | |
4570 | add_AT_unsigned (mod_type_die, DW_AT_address_class, 0); | |
4571 | item_type = TREE_TYPE (type); | |
4572 | sub_die = modified_type_die (item_type, | |
4573 | TYPE_READONLY (item_type), | |
4574 | TYPE_VOLATILE (item_type), | |
4575 | context_die); | |
4576 | } | |
4577 | else if (is_base_type (type)) | |
4578 | { | |
4579 | mod_type_die = base_type_die (type); | |
4580 | } | |
4581 | else | |
4582 | { | |
4b674448 JM |
4583 | gen_type_die (type, context_die); |
4584 | ||
a3f97cbb JW |
4585 | /* We have to get the type_main_variant here (and pass that to the |
4586 | `lookup_type_die' routine) because the ..._TYPE node we have | |
4587 | might simply be a *copy* of some original type node (where the | |
4588 | copy was created to help us keep track of typedef names) and | |
4589 | that copy might have a different TYPE_UID from the original | |
4590 | ..._TYPE node. (Note that when `equate_type_number_to_die' is | |
4591 | labeling a given type DIE for future reference, it always only | |
4592 | handles DIEs representing *main variants*, and it never even | |
4593 | knows about non-main-variants.). */ | |
4594 | mod_type_die = lookup_type_die (type_main_variant (type)); | |
a3f97cbb | 4595 | if (mod_type_die == NULL) |
4b674448 | 4596 | abort (); |
a3f97cbb JW |
4597 | } |
4598 | } | |
4599 | if (sub_die != NULL) | |
4600 | { | |
4601 | add_AT_die_ref (mod_type_die, DW_AT_type, sub_die); | |
4602 | } | |
bdb669cb | 4603 | equate_type_number_to_die (type, mod_type_die); |
a3f97cbb JW |
4604 | return mod_type_die; |
4605 | } | |
4606 | ||
a3f97cbb JW |
4607 | /* Given a pointer to an arbitrary ..._TYPE tree node, return true if it is |
4608 | an enumerated type. */ | |
4609 | inline int | |
4610 | type_is_enum (type) | |
4611 | register tree type; | |
4612 | { | |
4613 | return TREE_CODE (type) == ENUMERAL_TYPE; | |
4614 | } | |
4615 | ||
4616 | /* Return the register number described by a given RTL node. */ | |
4617 | static unsigned | |
4618 | reg_number (rtl) | |
4619 | register rtx rtl; | |
4620 | { | |
4621 | register unsigned regno = REGNO (rtl); | |
4622 | ||
4623 | if (regno >= FIRST_PSEUDO_REGISTER) | |
4624 | { | |
4625 | warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n", | |
4626 | regno); | |
4627 | regno = 0; | |
4628 | } | |
4629 | regno = DBX_REGISTER_NUMBER (regno); | |
4630 | return regno; | |
4631 | } | |
4632 | ||
4633 | /* Return a location descriptor that designates a machine register. */ | |
4634 | static dw_loc_descr_ref | |
4635 | reg_loc_descriptor (rtl) | |
4636 | register rtx rtl; | |
4637 | { | |
4638 | register dw_loc_descr_ref loc_result = NULL; | |
4639 | register unsigned reg = reg_number (rtl); | |
4640 | if (reg >= 0 && reg <= 31) | |
4641 | { | |
4642 | loc_result = new_loc_descr (DW_OP_reg0 + reg, 0); | |
4643 | } | |
4644 | else | |
4645 | { | |
4646 | loc_result = new_loc_descr (DW_OP_regx, reg, 0); | |
4647 | } | |
4648 | return loc_result; | |
4649 | } | |
4650 | ||
4651 | /* Return a location descriptor that designates a base+offset location. */ | |
4652 | static dw_loc_descr_ref | |
4653 | based_loc_descr (reg, offset) | |
4654 | unsigned reg; | |
4655 | long int offset; | |
4656 | { | |
4657 | register dw_loc_descr_ref loc_result; | |
4658 | register unsigned fp_reg = (frame_pointer_needed) | |
4659 | ? FRAME_POINTER_REGNUM | |
4660 | : STACK_POINTER_REGNUM; | |
4661 | if (reg == fp_reg) | |
4662 | { | |
4663 | loc_result = new_loc_descr (DW_OP_fbreg, | |
4664 | offset - current_funcdef_frame_size, 0); | |
4665 | } | |
4666 | else if (reg >= 0 && reg <= 31) | |
4667 | { | |
4668 | loc_result = new_loc_descr (DW_OP_breg0 + reg, offset); | |
4669 | } | |
4670 | else | |
4671 | { | |
4672 | loc_result = new_loc_descr (DW_OP_bregx, reg, offset); | |
4673 | } | |
4674 | return loc_result; | |
4675 | } | |
4676 | ||
4677 | /* Return true if this RTL expression describes a base+offset calculation. */ | |
4678 | inline int | |
4679 | is_based_loc (rtl) | |
4680 | register rtx rtl; | |
4681 | { | |
4682 | return GET_CODE (rtl) == PLUS | |
4683 | && ((GET_CODE (XEXP (rtl, 0)) == REG | |
4684 | && GET_CODE (XEXP (rtl, 1)) == CONST_INT)); | |
4685 | } | |
4686 | ||
4687 | /* The following routine converts the RTL for a variable or parameter | |
4688 | (resident in memory) into an equivalent Dwarf representation of a | |
4689 | mechanism for getting the address of that same variable onto the top of a | |
4690 | hypothetical "address evaluation" stack. | |
4691 | When creating memory location descriptors, we are effectively transforming | |
4692 | the RTL for a memory-resident object into its Dwarf postfix expression | |
4693 | equivalent. This routine recursively descends an RTL tree, turning | |
4694 | it into Dwarf postfix code as it goes. */ | |
4695 | static dw_loc_descr_ref | |
4696 | mem_loc_descriptor (rtl) | |
4697 | register rtx rtl; | |
4698 | { | |
4699 | dw_loc_descr_ref mem_loc_result = NULL; | |
4700 | /* Note that for a dynamically sized array, the location we will generate a | |
4701 | description of here will be the lowest numbered location which is | |
4702 | actually within the array. That's *not* necessarily the same as the | |
4703 | zeroth element of the array. */ | |
4704 | switch (GET_CODE (rtl)) | |
4705 | { | |
4706 | case SUBREG: | |
4707 | /* The case of a subreg may arise when we have a local (register) | |
4708 | variable or a formal (register) parameter which doesn't quite fill | |
4709 | up an entire register. For now, just assume that it is | |
4710 | legitimate to make the Dwarf info refer to the whole register which | |
4711 | contains the given subreg. */ | |
4712 | rtl = XEXP (rtl, 0); | |
4713 | /* Drop thru. */ | |
4714 | ||
4715 | case REG: | |
4716 | /* Whenever a register number forms a part of the description of the | |
4717 | method for calculating the (dynamic) address of a memory resident | |
4718 | object, DWARF rules require the register number be referred to as | |
4719 | a "base register". This distinction is not based in any way upon | |
4720 | what category of register the hardware believes the given register | |
4721 | belongs to. This is strictly DWARF terminology we're dealing with | |
4722 | here. Note that in cases where the location of a memory-resident | |
4723 | data object could be expressed as: OP_ADD (OP_BASEREG (basereg), | |
4724 | OP_CONST (0)) the actual DWARF location descriptor that we generate | |
4725 | may just be OP_BASEREG (basereg). This may look deceptively like | |
4726 | the object in question was allocated to a register (rather than in | |
4727 | memory) so DWARF consumers need to be aware of the subtle | |
4728 | distinction between OP_REG and OP_BASEREG. */ | |
4729 | mem_loc_result = based_loc_descr (reg_number (rtl), 0); | |
4730 | break; | |
4731 | ||
4732 | case MEM: | |
4733 | mem_loc_result = mem_loc_descriptor (XEXP (rtl, 0)); | |
4734 | add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_deref, 0, 0)); | |
4735 | break; | |
4736 | ||
4737 | case CONST: | |
4738 | case SYMBOL_REF: | |
4739 | mem_loc_result = new_loc_descr (DW_OP_addr, 0, 0); | |
4740 | mem_loc_result->dw_loc_oprnd1.val_class = dw_val_class_addr; | |
4741 | mem_loc_result->dw_loc_oprnd1.v.val_addr = addr_to_string (rtl); | |
4742 | break; | |
4743 | ||
4744 | case PLUS: | |
4745 | if (is_based_loc (rtl)) | |
4746 | { | |
4747 | mem_loc_result = based_loc_descr ( | |
4748 | reg_number (XEXP (rtl, 0)), | |
4749 | INTVAL (XEXP (rtl, 1))); | |
4750 | } | |
4751 | else | |
4752 | { | |
4753 | add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 0))); | |
4754 | add_loc_descr (&mem_loc_result, mem_loc_descriptor (XEXP (rtl, 1))); | |
4755 | add_loc_descr (&mem_loc_result, new_loc_descr (DW_OP_plus, 0, 0)); | |
4756 | } | |
4757 | break; | |
4758 | ||
4759 | case CONST_INT: | |
4760 | mem_loc_result = new_loc_descr (DW_OP_constu, INTVAL (rtl), 0); | |
4761 | break; | |
4762 | ||
4763 | default: | |
4764 | abort (); | |
4765 | } | |
4766 | return mem_loc_result; | |
4767 | } | |
4768 | ||
4769 | /* Output a proper Dwarf location descriptor for a variable or parameter | |
4770 | which is either allocated in a register or in a memory location. For a | |
4771 | register, we just generate an OP_REG and the register number. For a | |
4772 | memory location we provide a Dwarf postfix expression describing how to | |
4773 | generate the (dynamic) address of the object onto the address stack. */ | |
4774 | static dw_loc_descr_ref | |
4775 | loc_descriptor (rtl) | |
4776 | register rtx rtl; | |
4777 | { | |
4778 | dw_loc_descr_ref loc_result = NULL; | |
4779 | switch (GET_CODE (rtl)) | |
4780 | { | |
4781 | case SUBREG: | |
4782 | ||
4783 | /* The case of a subreg may arise when we have a local (register) | |
4784 | variable or a formal (register) parameter which doesn't quite fill | |
4785 | up an entire register. For now, just assume that it is | |
4786 | legitimate to make the Dwarf info refer to the whole register which | |
4787 | contains the given subreg. */ | |
4788 | ||
4789 | rtl = XEXP (rtl, 0); | |
4790 | loc_result = new_loc_descr (DW_OP_regx, reg_number (rtl), 0); | |
4791 | break; | |
4792 | ||
4793 | case REG: | |
4794 | loc_result = new_loc_descr (DW_OP_regx, reg_number (rtl), 0); | |
4795 | break; | |
4796 | ||
4797 | case MEM: | |
4798 | loc_result = mem_loc_descriptor (XEXP (rtl, 0)); | |
4799 | break; | |
4800 | ||
4801 | default: | |
4802 | abort (); /* Should never happen */ | |
4803 | } | |
4804 | return loc_result; | |
4805 | } | |
4806 | ||
4807 | /* Given an unsigned value, round it up to the lowest multiple of `boundary' | |
4808 | which is not less than the value itself. */ | |
4809 | inline unsigned | |
4810 | ceiling (value, boundary) | |
4811 | register unsigned value; | |
4812 | register unsigned boundary; | |
4813 | { | |
4814 | return (((value + boundary - 1) / boundary) * boundary); | |
4815 | } | |
4816 | ||
4817 | /* Given a pointer to what is assumed to be a FIELD_DECL node, return a | |
4818 | pointer to the declared type for the relevant field variable, or return | |
4819 | `integer_type_node' if the given node turns out to be an | |
4820 | ERROR_MARK node. */ | |
4821 | inline tree | |
4822 | field_type (decl) | |
4823 | register tree decl; | |
4824 | { | |
4825 | register tree type; | |
4826 | ||
4827 | if (TREE_CODE (decl) == ERROR_MARK) | |
4828 | return integer_type_node; | |
4829 | ||
4830 | type = DECL_BIT_FIELD_TYPE (decl); | |
4831 | if (type == NULL) | |
4832 | type = TREE_TYPE (decl); | |
4833 | ||
4834 | return type; | |
4835 | } | |
4836 | ||
4837 | /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE | |
4838 | node, return the alignment in bits for the type, or else return | |
4839 | BITS_PER_WORD if the node actually turns out to be an | |
4840 | ERROR_MARK node. */ | |
4841 | inline unsigned | |
4842 | simple_type_align_in_bits (type) | |
4843 | register tree type; | |
4844 | { | |
4845 | return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD; | |
4846 | } | |
4847 | ||
4848 | /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE | |
4849 | node, return the size in bits for the type if it is a constant, or else | |
4850 | return the alignment for the type if the type's size is not constant, or | |
4851 | else return BITS_PER_WORD if the type actually turns out to be an | |
4852 | ERROR_MARK node. */ | |
4853 | inline unsigned | |
4854 | simple_type_size_in_bits (type) | |
4855 | register tree type; | |
4856 | { | |
4857 | if (TREE_CODE (type) == ERROR_MARK) | |
4858 | return BITS_PER_WORD; | |
4859 | else | |
4860 | { | |
4861 | register tree type_size_tree = TYPE_SIZE (type); | |
4862 | ||
4863 | if (TREE_CODE (type_size_tree) != INTEGER_CST) | |
4864 | return TYPE_ALIGN (type); | |
4865 | ||
4866 | return (unsigned) TREE_INT_CST_LOW (type_size_tree); | |
4867 | } | |
4868 | } | |
4869 | ||
4870 | /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and | |
4871 | return the byte offset of the lowest addressed byte of the "containing | |
4872 | object" for the given FIELD_DECL, or return 0 if we are unable to | |
4873 | determine what that offset is, either because the argument turns out to | |
4874 | be a pointer to an ERROR_MARK node, or because the offset is actually | |
4875 | variable. (We can't handle the latter case just yet). */ | |
4876 | static unsigned | |
4877 | field_byte_offset (decl) | |
4878 | register tree decl; | |
4879 | { | |
4880 | register unsigned type_align_in_bytes; | |
4881 | register unsigned type_align_in_bits; | |
4882 | register unsigned type_size_in_bits; | |
4883 | register unsigned object_offset_in_align_units; | |
4884 | register unsigned object_offset_in_bits; | |
4885 | register unsigned object_offset_in_bytes; | |
4886 | register tree type; | |
4887 | register tree bitpos_tree; | |
4888 | register tree field_size_tree; | |
4889 | register unsigned bitpos_int; | |
4890 | register unsigned deepest_bitpos; | |
4891 | register unsigned field_size_in_bits; | |
4892 | ||
4893 | if (TREE_CODE (decl) == ERROR_MARK) | |
4894 | return 0; | |
4895 | ||
4896 | if (TREE_CODE (decl) != FIELD_DECL) | |
4897 | abort (); | |
4898 | ||
4899 | type = field_type (decl); | |
4900 | ||
4901 | bitpos_tree = DECL_FIELD_BITPOS (decl); | |
4902 | field_size_tree = DECL_SIZE (decl); | |
4903 | ||
4904 | /* We cannot yet cope with fields whose positions or sizes are variable, so | |
4905 | for now, when we see such things, we simply return 0. Someday, we may | |
4906 | be able to handle such cases, but it will be damn difficult. */ | |
4907 | if (TREE_CODE (bitpos_tree) != INTEGER_CST) | |
4908 | return 0; | |
4909 | bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree); | |
4910 | ||
4911 | if (TREE_CODE (field_size_tree) != INTEGER_CST) | |
4912 | return 0; | |
4913 | field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree); | |
4914 | ||
4915 | type_size_in_bits = simple_type_size_in_bits (type); | |
4916 | ||
4917 | type_align_in_bits = simple_type_align_in_bits (type); | |
4918 | type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT; | |
4919 | ||
4920 | /* Note that the GCC front-end doesn't make any attempt to keep track of | |
4921 | the starting bit offset (relative to the start of the containing | |
4922 | structure type) of the hypothetical "containing object" for a bit- | |
4923 | field. Thus, when computing the byte offset value for the start of the | |
4924 | "containing object" of a bit-field, we must deduce this information on | |
4925 | our own. This can be rather tricky to do in some cases. For example, | |
4926 | handling the following structure type definition when compiling for an | |
4927 | i386/i486 target (which only aligns long long's to 32-bit boundaries) | |
4928 | can be very tricky: | |
4929 | ||
4930 | struct S { int field1; long long field2:31; }; | |
4931 | ||
4932 | Fortunately, there is a simple rule-of-thumb which can be | |
4933 | used in such cases. When compiling for an i386/i486, GCC will allocate | |
4934 | 8 bytes for the structure shown above. It decides to do this based upon | |
4935 | one simple rule for bit-field allocation. Quite simply, GCC allocates | |
4936 | each "containing object" for each bit-field at the first (i.e. lowest | |
4937 | addressed) legitimate alignment boundary (based upon the required | |
4938 | minimum alignment for the declared type of the field) which it can | |
4939 | possibly use, subject to the condition that there is still enough | |
4940 | available space remaining in the containing object (when allocated at | |
4941 | the selected point) to fully accommodate all of the bits of the | |
4942 | bit-field itself. This simple rule makes it obvious why GCC allocates | |
4943 | 8 bytes for each object of the structure type shown above. When looking | |
4944 | for a place to allocate the "containing object" for `field2', the | |
4945 | compiler simply tries to allocate a 64-bit "containing object" at each | |
4946 | successive 32-bit boundary (starting at zero) until it finds a place to | |
4947 | allocate that 64- bit field such that at least 31 contiguous (and | |
4948 | previously unallocated) bits remain within that selected 64 bit field. | |
4949 | (As it turns out, for the example above, the compiler finds that it is | |
4950 | OK to allocate the "containing object" 64-bit field at bit-offset zero | |
4951 | within the structure type.) Here we attempt to work backwards from the | |
4952 | limited set of facts we're given, and we try to deduce from those facts, | |
4953 | where GCC must have believed that the containing object started (within | |
4954 | the structure type). The value we deduce is then used (by the callers of | |
4955 | this routine) to generate DW_AT_location and DW_AT_bit_offset attributes | |
4956 | for fields (both bit-fields and, in the case of DW_AT_location, regular | |
4957 | fields as well). */ | |
4958 | ||
4959 | /* Figure out the bit-distance from the start of the structure to the | |
4960 | "deepest" bit of the bit-field. */ | |
4961 | deepest_bitpos = bitpos_int + field_size_in_bits; | |
4962 | ||
4963 | /* This is the tricky part. Use some fancy footwork to deduce where the | |
4964 | lowest addressed bit of the containing object must be. */ | |
4965 | object_offset_in_bits | |
4966 | = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits; | |
4967 | ||
4968 | /* Compute the offset of the containing object in "alignment units". */ | |
4969 | object_offset_in_align_units = object_offset_in_bits / type_align_in_bits; | |
4970 | ||
4971 | /* Compute the offset of the containing object in bytes. */ | |
4972 | object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes; | |
4973 | ||
4974 | return object_offset_in_bytes; | |
4975 | } | |
4976 | ||
4977 | ||
4978 | \f | |
4979 | /****************************** attributes *********************************/ | |
4980 | ||
4981 | /* The following routines define various Dwarf attributes | |
4982 | (and any data associated with them). */ | |
4983 | ||
4984 | ||
4985 | /* Output the form of location attributes suitable for whole variables and | |
4986 | whole parameters. Note that the location attributes for struct fields are | |
4987 | generated by the routine `data_member_location_attribute' below. */ | |
4988 | static void | |
4989 | add_location_attribute (die, rtl) | |
4990 | dw_die_ref die; | |
4991 | register rtx rtl; | |
4992 | { | |
4993 | dw_loc_descr_ref loc_descr = NULL; | |
4994 | ||
4995 | /* Handle a special case. If we are about to output a location descriptor | |
4996 | for a variable or parameter which has been optimized out of existence, | |
4997 | don't do that. Instead we output a null location descriptor value as | |
4998 | part of the location attribute. A variable which has been optimized out | |
4999 | of existence will have a DECL_RTL value which denotes a pseudo-reg. | |
5000 | Currently, in some rare cases, variables can have DECL_RTL values which | |
5001 | look like (MEM (REG pseudo-reg#)). These cases are due to bugs | |
5002 | elsewhere in the compiler. We treat such cases as if the variable(s) in | |
5003 | question had been optimized out of existence. Note that in all cases | |
5004 | where we wish to express the fact that a variable has been optimized out | |
5005 | of existence, we do not simply suppress the generation of the entire | |
5006 | location attribute because the absence of a location attribute in | |
5007 | certain kinds of DIEs is used to indicate something else entirely... | |
5008 | i.e. that the DIE represents an object declaration, but not a | |
5009 | definition. So sayeth the PLSIG. */ | |
5010 | if (!is_pseudo_reg (rtl) | |
5011 | && (GET_CODE (rtl) != MEM | |
5012 | || !is_pseudo_reg (XEXP (rtl, 0)))) | |
5013 | { | |
5014 | loc_descr = loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX)); | |
5015 | } | |
5016 | ||
5017 | #ifdef MIPS_DEBUGGING_INFO | |
5018 | /* ??? SGI's dwarf reader is buggy, and will not accept a zero size | |
5019 | location descriptor. Lets just use r0 for now to represent a | |
5020 | variable that has been optimized away. */ | |
5021 | if (loc_descr == NULL) | |
5022 | { | |
5023 | loc_descr = loc_descriptor (gen_rtx (REG, word_mode, 0)); | |
5024 | } | |
5025 | #endif | |
5026 | ||
5027 | add_AT_loc (die, DW_AT_location, loc_descr); | |
5028 | } | |
5029 | ||
5030 | /* Attach the specialized form of location attribute used for data | |
5031 | members of struct and union types. In the special case of a | |
5032 | FIELD_DECL node which represents a bit-field, the "offset" part | |
5033 | of this special location descriptor must indicate the distance | |
5034 | in bytes from the lowest-addressed byte of the containing struct | |
5035 | or union type to the lowest-addressed byte of the "containing | |
5036 | object" for the bit-field. (See the `field_byte_offset' function | |
5037 | above).. For any given bit-field, the "containing object" is a | |
5038 | hypothetical object (of some integral or enum type) within which | |
5039 | the given bit-field lives. The type of this hypothetical | |
5040 | "containing object" is always the same as the declared type of | |
5041 | the individual bit-field itself (for GCC anyway... the DWARF | |
5042 | spec doesn't actually mandate this). Note that it is the size | |
5043 | (in bytes) of the hypothetical "containing object" which will | |
5044 | be given in the DW_AT_byte_size attribute for this bit-field. | |
5045 | (See the `byte_size_attribute' function below.) It is also used | |
5046 | when calculating the value of the DW_AT_bit_offset attribute. | |
5047 | (See the `bit_offset_attribute' function below). */ | |
5048 | static void | |
5049 | add_data_member_location_attribute (die, decl) | |
5050 | register dw_die_ref die; | |
5051 | register tree decl; | |
5052 | { | |
5053 | register unsigned long offset = field_byte_offset (decl); | |
5054 | register dw_loc_descr_ref loc_descr; | |
5055 | register enum dwarf_location_atom op; | |
5056 | ||
5057 | /* The DWARF2 standard says that we should assume that the structure address | |
5058 | is already on the stack, so we can specify a structure field address | |
5059 | by using DW_OP_plus_uconst. */ | |
5060 | #ifdef MIPS_DEBUGGING_INFO | |
5061 | /* ??? The SGI dwarf reader does not handle the DW_OP_plus_uconst operator | |
5062 | correctly. It works only if we leave the offset on the stack. */ | |
5063 | op = DW_OP_constu; | |
5064 | #else | |
5065 | op = DW_OP_plus_uconst; | |
5066 | #endif | |
5067 | loc_descr = new_loc_descr (op, offset, 0); | |
5068 | add_AT_loc (die, DW_AT_data_member_location, loc_descr); | |
5069 | } | |
5070 | ||
5071 | /* Attach an DW_AT_const_value attribute for a variable or a parameter which | |
5072 | does not have a "location" either in memory or in a register. These | |
5073 | things can arise in GNU C when a constant is passed as an actual parameter | |
5074 | to an inlined function. They can also arise in C++ where declared | |
5075 | constants do not necessarily get memory "homes". */ | |
5076 | static void | |
5077 | add_const_value_attribute (die, rtl) | |
5078 | register dw_die_ref die; | |
5079 | register rtx rtl; | |
5080 | { | |
5081 | switch (GET_CODE (rtl)) | |
5082 | { | |
5083 | case CONST_INT: | |
5084 | /* Note that a CONST_INT rtx could represent either an integer or a | |
5085 | floating-point constant. A CONST_INT is used whenever the constant | |
5086 | will fit into a single word. In all such cases, the original mode | |
5087 | of the constant value is wiped out, and the CONST_INT rtx is | |
5088 | assigned VOIDmode. */ | |
5089 | add_AT_unsigned (die, DW_AT_const_value, (unsigned) INTVAL (rtl)); | |
5090 | break; | |
5091 | ||
5092 | case CONST_DOUBLE: | |
5093 | /* Note that a CONST_DOUBLE rtx could represent either an integer or a | |
5094 | floating-point constant. A CONST_DOUBLE is used whenever the | |
5095 | constant requires more than one word in order to be adequately | |
5096 | represented. In all such cases, the original mode of the constant | |
5097 | value is preserved as the mode of the CONST_DOUBLE rtx, but for | |
5098 | simplicity we always just output CONST_DOUBLEs using 8 bytes. */ | |
5099 | add_AT_double (die, DW_AT_const_value, | |
5100 | (unsigned) CONST_DOUBLE_HIGH (rtl), | |
5101 | (unsigned) CONST_DOUBLE_LOW (rtl)); | |
5102 | break; | |
5103 | ||
5104 | case CONST_STRING: | |
5105 | add_AT_string (die, DW_AT_const_value, XSTR (rtl, 0)); | |
5106 | break; | |
5107 | ||
5108 | case SYMBOL_REF: | |
5109 | case LABEL_REF: | |
5110 | case CONST: | |
5111 | add_AT_addr (die, DW_AT_const_value, addr_to_string (rtl)); | |
5112 | break; | |
5113 | ||
5114 | case PLUS: | |
5115 | /* In cases where an inlined instance of an inline function is passed | |
5116 | the address of an `auto' variable (which is local to the caller) we | |
5117 | can get a situation where the DECL_RTL of the artificial local | |
5118 | variable (for the inlining) which acts as a stand-in for the | |
5119 | corresponding formal parameter (of the inline function) will look | |
5120 | like (plus:SI (reg:SI FRAME_PTR) (const_int ...)). This is not | |
5121 | exactly a compile-time constant expression, but it isn't the address | |
5122 | of the (artificial) local variable either. Rather, it represents the | |
5123 | *value* which the artificial local variable always has during its | |
5124 | lifetime. We currently have no way to represent such quasi-constant | |
5125 | values in Dwarf, so for now we just punt and generate an | |
5126 | DW_AT_const_value attribute with null address. */ | |
5127 | add_AT_addr (die, DW_AT_const_value, addr_to_string (const0_rtx)); | |
5128 | break; | |
5129 | ||
5130 | default: | |
5131 | /* No other kinds of rtx should be possible here. */ | |
5132 | abort (); | |
5133 | } | |
5134 | ||
5135 | } | |
5136 | ||
5137 | /* Generate *either* an DW_AT_location attribute or else an DW_AT_const_value | |
5138 | data attribute for a variable or a parameter. We generate the | |
5139 | DW_AT_const_value attribute only in those cases where the given variable | |
5140 | or parameter does not have a true "location" either in memory or in a | |
5141 | register. This can happen (for example) when a constant is passed as an | |
5142 | actual argument in a call to an inline function. (It's possible that | |
5143 | these things can crop up in other ways also.) Note that one type of | |
5144 | constant value which can be passed into an inlined function is a constant | |
5145 | pointer. This can happen for example if an actual argument in an inlined | |
5146 | function call evaluates to a compile-time constant address. */ | |
5147 | static void | |
5148 | add_location_or_const_value_attribute (die, decl) | |
5149 | register dw_die_ref die; | |
5150 | register tree decl; | |
5151 | { | |
5152 | register rtx rtl; | |
5153 | register tree declared_type; | |
5154 | register tree passed_type; | |
5155 | ||
5156 | if (TREE_CODE (decl) == ERROR_MARK) | |
5157 | { | |
5158 | return; | |
5159 | } | |
5160 | if ((TREE_CODE (decl) != VAR_DECL) | |
5161 | && (TREE_CODE (decl) != PARM_DECL)) | |
5162 | { | |
5163 | /* Should never happen. */ | |
5164 | abort (); | |
5165 | return; | |
5166 | } | |
5167 | /* Here we have to decide where we are going to say the parameter "lives" | |
5168 | (as far as the debugger is concerned). We only have a couple of | |
5169 | choices. GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. | |
5170 | DECL_RTL normally indicates where the parameter lives during most of the | |
5171 | activa- tion of the function. If optimization is enabled however, this | |
5172 | could be either NULL or else a pseudo-reg. Both of those cases indicate | |
5173 | that the parameter doesn't really live anywhere (as far as the code | |
5174 | generation parts of GCC are concerned) during most of the function's | |
5175 | activation. That will happen (for example) if the parameter is never | |
5176 | referenced within the function. We could just generate a location | |
5177 | descriptor here for all non-NULL non-pseudo values of DECL_RTL and | |
5178 | ignore all of the rest, but we can be a little nicer than that if we | |
5179 | also consider DECL_INCOMING_RTL in cases where DECL_RTL is NULL or is a | |
5180 | pseudo-reg. Note however that we can only get away with using | |
5181 | DECL_INCOMING_RTL as a backup substitute for DECL_RTL in certain limited | |
5182 | cases. In cases where DECL_ARG_TYPE(decl) indicates the same type as | |
5183 | TREE_TYPE(decl) we can be sure that the parameter was passed using the | |
5184 | same type as it is declared to have within the function, and that its | |
5185 | DECL_INCOMING_RTL points us to a place where a value of that type is | |
5186 | passed. In cases where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are | |
5187 | different types however, we cannot (in general) use DECL_INCOMING_RTL as | |
5188 | a backup substitute for DECL_RTL because in these cases, | |
5189 | DECL_INCOMING_RTL points us to a value of some type which is *different* | |
5190 | from the type of the parameter itself. Thus, if we tried to use | |
5191 | DECL_INCOMING_RTL to generate a location attribute in such cases, the | |
5192 | debugger would end up (for example) trying to fetch a `float' from a | |
5193 | place which actually contains the first part of a `double'. That would | |
5194 | lead to really incorrect and confusing output at debug-time, and we | |
5195 | don't want that now do we? So in general, we DO NOT use | |
5196 | DECL_INCOMING_RTL as a backup for DECL_RTL in cases where | |
5197 | DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a couple of cute | |
5198 | exceptions however. On little-endian machines we can get away with | |
5199 | using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is not the same as | |
5200 | TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is an integral type | |
5201 | which is smaller than TREE_TYPE(decl). These cases arise when (on a | |
5202 | little-endian machine) a non-prototyped function has a parameter | |
5203 | declared to be of type `short' or `char'. In such cases, | |
5204 | TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be | |
5205 | `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the | |
5206 | passed `int' value. If the debugger then uses that address to fetch a | |
5207 | `short' or a `char' (on a little-endian machine) the result will be the | |
5208 | correct data, so we allow for such exceptional cases below. Note that | |
5209 | our goal here is to describe the place where the given formal parameter | |
5210 | lives during most of the function's activation (i.e. between the end of | |
5211 | the prologue and the start of the epilogue). We'll do that as best as | |
5212 | we can. Note however that if the given formal parameter is modified | |
5213 | sometime during the execution of the function, then a stack backtrace | |
5214 | (at debug-time) will show the function as having been called with the | |
5215 | *new* value rather than the value which was originally passed in. This | |
5216 | happens rarely enough that it is not a major problem, but it *is* a | |
5217 | problem, and I'd like to fix it. A future version of dwarfout.c may | |
5218 | generate two additional attributes for any given DW_TAG_formal_parameter | |
5219 | DIE which will describe the "passed type" and the "passed location" for | |
5220 | the given formal parameter in addition to the attributes we now generate | |
5221 | to indicate the "declared type" and the "active location" for each | |
5222 | parameter. This additional set of attributes could be used by debuggers | |
5223 | for stack backtraces. Separately, note that sometimes DECL_RTL can be | |
5224 | NULL and DECL_INCOMING_RTL can be NULL also. This happens (for example) | |
5225 | for inlined-instances of inline function formal parameters which are | |
5226 | never referenced. This really shouldn't be happening. All PARM_DECL | |
5227 | nodes should get valid non-NULL DECL_INCOMING_RTL values, but | |
5228 | integrate.c doesn't currently generate these values for inlined | |
5229 | instances of inline function parameters, so when we see such cases, we | |
5230 | are just SOL (shit-out-of-luck) for the time being (until integrate.c | |
5231 | gets fixed). */ | |
5232 | ||
5233 | /* Use DECL_RTL as the "location" unless we find something better. */ | |
5234 | rtl = DECL_RTL (decl); | |
5235 | ||
5236 | if (TREE_CODE (decl) == PARM_DECL) | |
5237 | { | |
5238 | if (rtl == NULL_RTX || is_pseudo_reg (rtl)) | |
5239 | { | |
5240 | declared_type = type_main_variant (TREE_TYPE (decl)); | |
5241 | passed_type = type_main_variant (DECL_ARG_TYPE (decl)); | |
5242 | /* This decl represents a formal parameter which was | |
5243 | optimized out. | |
5244 | ||
5245 | Note that DECL_INCOMING_RTL may be NULL in here, but we handle | |
5246 | all* cases where (rtl == NULL_RTX) just below. */ | |
5247 | if (declared_type == passed_type) | |
5248 | { | |
5249 | rtl = DECL_INCOMING_RTL (decl); | |
5250 | } | |
5251 | else if (!BYTES_BIG_ENDIAN) | |
5252 | { | |
5253 | if (TREE_CODE (declared_type) == INTEGER_TYPE) | |
5254 | { | |
5255 | if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type)) | |
5256 | { | |
5257 | rtl = DECL_INCOMING_RTL (decl); | |
5258 | } | |
5259 | } | |
5260 | } | |
5261 | if (rtl == NULL_RTX) | |
5262 | { | |
5263 | return; | |
5264 | } | |
5265 | } | |
5266 | } | |
5267 | switch (GET_CODE (rtl)) | |
5268 | { | |
5269 | case CONST_INT: | |
5270 | case CONST_DOUBLE: | |
5271 | case CONST_STRING: | |
5272 | case SYMBOL_REF: | |
5273 | case LABEL_REF: | |
5274 | case CONST: | |
5275 | case PLUS: | |
5276 | /* DECL_RTL could be (plus (reg ...) (const_int ...)) */ | |
5277 | add_const_value_attribute (die, rtl); | |
5278 | break; | |
5279 | ||
5280 | case MEM: | |
5281 | case REG: | |
5282 | case SUBREG: | |
5283 | add_location_attribute (die, rtl); | |
5284 | break; | |
5285 | ||
5286 | default: | |
5287 | abort (); /* Should never happen. */ | |
5288 | } | |
5289 | } | |
5290 | ||
5291 | /* Generate an DW_AT_name attribute given some string value to be included as | |
5292 | the value of the attribute. */ | |
5293 | inline void | |
5294 | add_name_attribute (die, name_string) | |
5295 | register dw_die_ref die; | |
5296 | register char *name_string; | |
5297 | { | |
5298 | if (name_string && *name_string) | |
5299 | { | |
5300 | add_AT_string (die, DW_AT_name, name_string); | |
5301 | } | |
5302 | } | |
5303 | ||
5304 | /* Given a tree node describing an array bound (either lower or upper) output | |
5305 | a representation for that bound. */ | |
5306 | static void | |
5307 | add_bound_info (subrange_die, bound_attr, bound) | |
5308 | register dw_die_ref subrange_die; | |
5309 | register enum dwarf_attribute bound_attr; | |
5310 | register tree bound; | |
5311 | { | |
5312 | register dw_loc_descr_ref bound_loc = NULL; | |
5313 | register unsigned bound_value = 0; | |
5314 | switch (TREE_CODE (bound)) | |
5315 | { | |
5316 | case ERROR_MARK: | |
5317 | return; | |
5318 | ||
5319 | /* All fixed-bounds are represented by INTEGER_CST nodes. */ | |
5320 | case INTEGER_CST: | |
5321 | bound_value = TREE_INT_CST_LOW (bound); | |
5322 | /* TODO: we need to check for C language below, or some flag | |
5323 | derived from the language. C implies a lower bound of 0. */ | |
5324 | if (!(bound_attr == DW_AT_lower_bound && bound_value == 0)) | |
5325 | { | |
5326 | add_AT_unsigned (subrange_die, bound_attr, bound_value); | |
5327 | } | |
5328 | break; | |
5329 | ||
5330 | /* Dynamic bounds may be represented by NOP_EXPR nodes containing | |
5331 | SAVE_EXPR nodes. */ | |
5332 | case NOP_EXPR: | |
5333 | bound = TREE_OPERAND (bound, 0); | |
5334 | /* ... fall thru... */ | |
5335 | ||
5336 | case SAVE_EXPR: | |
5337 | /* If optimization is turned on, the SAVE_EXPRs that describe how to | |
5338 | access the upper bound values are essentially bogus. They only | |
5339 | describe (at best) how to get at these values at the points in the | |
5340 | generated code right after they have just been computed. Worse yet, | |
5341 | in the typical case, the upper bound values will not even *be* | |
5342 | computed in the optimized code, so these SAVE_EXPRs are entirely | |
5343 | bogus. In order to compensate for this fact, we check here to see if | |
5344 | optimization is enabled, and if so, we effectively create an empty | |
5345 | location description for the (unknown and unknowable) upper bound. | |
5346 | This should not cause too much trouble for existing (stupid?) | |
5347 | debuggers because they have to deal with empty upper bounds location | |
5348 | descriptions anyway in order to be able to deal with incomplete array | |
5349 | types. Of course an intelligent debugger (GDB?) should be able to | |
5350 | comprehend that a missing upper bound specification in a array type | |
5351 | used for a storage class `auto' local array variable indicates that | |
5352 | the upper bound is both unknown (at compile- time) and unknowable (at | |
5353 | run-time) due to optimization. */ | |
5354 | if (!optimize) | |
5355 | { | |
5356 | bound_loc = mem_loc_descriptor ( | |
5357 | eliminate_regs (SAVE_EXPR_RTL (bound), | |
5358 | 0, NULL_RTX)); | |
5359 | } | |
5360 | else | |
5361 | { | |
5362 | bound_loc = NULL; | |
5363 | } | |
5364 | add_AT_loc (subrange_die, bound_attr, bound_loc); | |
5365 | break; | |
5366 | ||
5367 | default: | |
5368 | abort (); | |
5369 | } | |
5370 | } | |
5371 | ||
5372 | /* Note that the block of subscript information for an array type also | |
5373 | includes information about the element type of type given array type. */ | |
5374 | static void | |
5375 | add_subscript_info (type_die, type) | |
5376 | register dw_die_ref type_die; | |
5377 | register tree type; | |
5378 | { | |
5379 | register unsigned dimension_number; | |
5380 | register tree lower, upper; | |
5381 | register dw_die_ref subrange_die; | |
5382 | ||
5383 | /* The GNU compilers represent multidimensional array types as sequences of | |
5384 | one dimensional array types whose element types are themselves array | |
5385 | types. Here we squish that down, so that each multidimensional array | |
5386 | type gets only one array_type DIE in the Dwarf debugging info. The draft | |
5387 | Dwarf specification say that we are allowed to do this kind of | |
5388 | compression in C (because there is no difference between an array or | |
5389 | arrays and a multidimensional array in C) but for other source languages | |
5390 | (e.g. Ada) we probably shouldn't do this. */ | |
5391 | /* ??? The SGI dwarf reader fails for multidimensional arrays with a | |
5392 | const enum type. E.g. const enum machine_mode insn_operand_mode[2][10]. | |
5393 | We work around this by disabling this feature. See also | |
5394 | gen_array_type_die. */ | |
5395 | #ifndef MIPS_DEBUGGING_INFO | |
5396 | for (dimension_number = 0; | |
5397 | TREE_CODE (type) == ARRAY_TYPE; | |
5398 | type = TREE_TYPE (type), dimension_number++) | |
5399 | { | |
5400 | #endif | |
5401 | register tree domain = TYPE_DOMAIN (type); | |
5402 | ||
5403 | /* Arrays come in three flavors: Unspecified bounds, fixed bounds, | |
5404 | and (in GNU C only) variable bounds. Handle all three forms | |
5405 | here. */ | |
5406 | subrange_die = new_die (DW_TAG_subrange_type, type_die); | |
5407 | if (domain) | |
5408 | { | |
5409 | /* We have an array type with specified bounds. */ | |
5410 | lower = TYPE_MIN_VALUE (domain); | |
5411 | upper = TYPE_MAX_VALUE (domain); | |
5412 | ||
5413 | /* TODO: establish DW_AT_type for the basis type a byte_size | |
5414 | attribute if the byte size is non-standard */ | |
5415 | add_bound_info (subrange_die, DW_AT_lower_bound, lower); | |
5416 | add_bound_info (subrange_die, DW_AT_upper_bound, upper); | |
5417 | } | |
5418 | else | |
5419 | { | |
5420 | /* We have an array type with an unspecified length. For C and C++ | |
5421 | we can assume that this really means that (a) the index type is | |
5422 | an integral type, and (b) the lower bound is zero. Note that | |
5423 | Dwarf defines the representation of an unspecified (upper) bound | |
5424 | as being a zero-length location description. */ | |
5425 | ||
5426 | /* define the (assumed) index type. */ | |
5427 | add_AT_die_ref (subrange_die, DW_AT_type, int_base_type_die); | |
5428 | ||
5429 | /* Add the (assumed) lower bound (constant) value. */ | |
5430 | add_AT_unsigned (subrange_die, DW_AT_lower_bound, 0); | |
5431 | ||
5432 | /* Add the (empty) location description for the upper bound. */ | |
5433 | add_AT_loc (subrange_die, DW_AT_upper_bound, NULL); | |
5434 | } | |
5435 | #ifndef MIPS_DEBUGGING_INFO | |
5436 | } | |
5437 | #endif | |
5438 | } | |
5439 | ||
5440 | static void | |
5441 | add_byte_size_attribute (die, tree_node) | |
5442 | dw_die_ref die; | |
5443 | register tree tree_node; | |
5444 | { | |
5445 | register unsigned size; | |
5446 | ||
5447 | switch (TREE_CODE (tree_node)) | |
5448 | { | |
5449 | case ERROR_MARK: | |
5450 | size = 0; | |
5451 | break; | |
5452 | case ENUMERAL_TYPE: | |
5453 | case RECORD_TYPE: | |
5454 | case UNION_TYPE: | |
5455 | case QUAL_UNION_TYPE: | |
5456 | size = int_size_in_bytes (tree_node); | |
5457 | break; | |
5458 | case FIELD_DECL: | |
5459 | /* For a data member of a struct or union, the DW_AT_byte_size is | |
5460 | generally given as the number of bytes normally allocated for an | |
5461 | object of the *declared* type of the member itself. This is true | |
5462 | even for bit-fields. */ | |
5463 | size = simple_type_size_in_bits (field_type (tree_node)) / BITS_PER_UNIT; | |
5464 | break; | |
5465 | default: | |
5466 | abort (); | |
5467 | } | |
5468 | ||
5469 | /* Note that `size' might be -1 when we get to this point. If it is, that | |
5470 | indicates that the byte size of the entity in question is variable. We | |
5471 | have no good way of expressing this fact in Dwarf at the present time, | |
5472 | so just let the -1 pass on through. */ | |
5473 | ||
5474 | add_AT_unsigned (die, DW_AT_byte_size, size); | |
5475 | } | |
5476 | ||
5477 | /* For a FIELD_DECL node which represents a bit-field, output an attribute | |
5478 | which specifies the distance in bits from the highest order bit of the | |
5479 | "containing object" for the bit-field to the highest order bit of the | |
5480 | bit-field itself. | |
5481 | ||
5482 | For any given bit-field, the "containing object" is a hypothetical object (of | |
5483 | some integral or enum type) within which the given bit-field lives. The | |
5484 | type of this hypothetical "containing object" is always the same as the | |
5485 | declared type of the individual bit-field itself. | |
5486 | The determination of the exact location of the "containing object" for a | |
5487 | bit-field is rather complicated. It's handled by the `field_byte_offset' | |
5488 | function (above). | |
5489 | ||
5490 | Note that it is the size (in bytes) of the hypothetical "containing object" | |
5491 | which will be given in the DW_AT_byte_size attribute for this bit-field. | |
5492 | (See `byte_size_attribute' above). */ | |
5493 | inline void | |
5494 | add_bit_offset_attribute (die, decl) | |
5495 | register dw_die_ref die; | |
5496 | register tree decl; | |
5497 | { | |
5498 | register unsigned object_offset_in_bytes = field_byte_offset (decl); | |
5499 | register tree type = DECL_BIT_FIELD_TYPE (decl); | |
5500 | register tree bitpos_tree = DECL_FIELD_BITPOS (decl); | |
5501 | register unsigned bitpos_int; | |
5502 | register unsigned highest_order_object_bit_offset; | |
5503 | register unsigned highest_order_field_bit_offset; | |
5504 | register unsigned bit_offset; | |
5505 | ||
5506 | assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */ | |
5507 | assert (type); /* Must be a bit field. */ | |
5508 | ||
5509 | /* We can't yet handle bit-fields whose offsets are variable, so if we | |
5510 | encounter such things, just return without generating any attribute | |
5511 | whatsoever. */ | |
5512 | if (TREE_CODE (bitpos_tree) != INTEGER_CST) | |
5513 | { | |
5514 | return; | |
5515 | } | |
5516 | bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree); | |
5517 | ||
5518 | /* Note that the bit offset is always the distance (in bits) from the | |
5519 | highest-order bit of the "containing object" to the highest-order bit of | |
5520 | the bit-field itself. Since the "high-order end" of any object or field | |
5521 | is different on big-endian and little-endian machines, the computation | |
5522 | below must take account of these differences. */ | |
5523 | highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT; | |
5524 | highest_order_field_bit_offset = bitpos_int; | |
5525 | ||
5526 | if (!BYTES_BIG_ENDIAN) | |
5527 | { | |
5528 | highest_order_field_bit_offset | |
5529 | += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)); | |
5530 | ||
5531 | highest_order_object_bit_offset += simple_type_size_in_bits (type); | |
5532 | } | |
5533 | bit_offset = | |
5534 | (!BYTES_BIG_ENDIAN | |
5535 | ? highest_order_object_bit_offset - highest_order_field_bit_offset | |
5536 | : highest_order_field_bit_offset - highest_order_object_bit_offset); | |
5537 | ||
5538 | add_AT_unsigned (die, DW_AT_bit_offset, bit_offset); | |
5539 | } | |
5540 | ||
5541 | /* For a FIELD_DECL node which represents a bit field, output an attribute | |
5542 | which specifies the length in bits of the given field. */ | |
5543 | inline void | |
5544 | add_bit_size_attribute (die, decl) | |
5545 | register dw_die_ref die; | |
5546 | register tree decl; | |
5547 | { | |
5548 | assert (TREE_CODE (decl) == FIELD_DECL); /* Must be a field. */ | |
5549 | assert (DECL_BIT_FIELD_TYPE (decl)); /* Must be a bit field. */ | |
5550 | add_AT_unsigned (die, DW_AT_bit_size, | |
5551 | (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl))); | |
5552 | } | |
5553 | ||
a3f97cbb JW |
5554 | /* If the compiled language is GNU C, then add a 'prototyped' |
5555 | attribute, if arg types are given for the parameters of a function. */ | |
5556 | inline void | |
5557 | add_prototyped_attribute (die, func_type) | |
5558 | register dw_die_ref die; | |
5559 | register tree func_type; | |
5560 | { | |
5561 | if ((strcmp (language_string, "GNU C") == 0) | |
5562 | && (TYPE_ARG_TYPES (func_type) != NULL)) | |
5563 | { | |
5564 | add_AT_flag (die, DW_AT_prototyped, 0); | |
5565 | } | |
5566 | } | |
5567 | ||
5568 | ||
5569 | /* Add an 'abstract_origin' attribute below a given DIE. The DIE is found | |
5570 | by looking in either the type declaration or object declaration | |
5571 | equate table. */ | |
5572 | inline void | |
5573 | add_abstract_origin_attribute (die, origin) | |
5574 | register dw_die_ref die; | |
5575 | register tree origin; | |
5576 | { | |
5577 | dw_die_ref origin_die = NULL; | |
5578 | if (TREE_CODE_CLASS (TREE_CODE (origin)) == 'd') | |
5579 | { | |
5580 | origin_die = lookup_decl_die (origin); | |
5581 | } | |
5582 | else if (TREE_CODE_CLASS (TREE_CODE (origin)) == 't') | |
5583 | { | |
5584 | origin_die = lookup_type_die (origin); | |
5585 | } | |
5586 | add_AT_die_ref (die, DW_AT_abstract_origin, origin_die); | |
5587 | } | |
5588 | ||
bdb669cb JM |
5589 | /* We do not currently support the pure_virtual attribute. */ |
5590 | ||
a3f97cbb JW |
5591 | inline void |
5592 | add_pure_or_virtual_attribute (die, func_decl) | |
5593 | register dw_die_ref die; | |
5594 | register tree func_decl; | |
5595 | { | |
5596 | if (DECL_VIRTUAL_P (func_decl)) | |
5597 | { | |
bdb669cb | 5598 | add_AT_unsigned (die, DW_AT_virtuality, DW_VIRTUALITY_virtual); |
a3f97cbb JW |
5599 | } |
5600 | } | |
5601 | \f | |
5602 | /********************* utility routines for DIEs *************************/ | |
5603 | ||
5604 | /* Add an DW_AT_name attribute and source coordinate attribute for the | |
5605 | given decl, but only if it actually has a name. */ | |
5606 | static void | |
5607 | add_name_and_src_coords_attributes (die, decl) | |
5608 | register dw_die_ref die; | |
5609 | register tree decl; | |
5610 | { | |
5611 | register tree decl_name = DECL_NAME (decl); | |
5612 | register unsigned file_index; | |
5613 | if (decl_name && IDENTIFIER_POINTER (decl_name)) | |
5614 | { | |
5615 | add_name_attribute (die, IDENTIFIER_POINTER (decl_name)); | |
5616 | file_index = lookup_filename (DECL_SOURCE_FILE (decl)); | |
5617 | add_AT_unsigned (die, DW_AT_decl_file, file_index); | |
5618 | add_AT_unsigned (die, DW_AT_decl_line, DECL_SOURCE_LINE (decl)); | |
5619 | } | |
5620 | } | |
5621 | ||
5622 | /* Push a new declaration scope. */ | |
5623 | static void | |
5624 | push_decl_scope (scope) | |
5625 | tree scope; | |
5626 | { | |
5627 | /* Make room in the decl_scope_table, if necessary. */ | |
5628 | if (decl_scope_table_allocated == decl_scope_depth) | |
5629 | { | |
5630 | decl_scope_table_allocated += DECL_SCOPE_TABLE_INCREMENT; | |
5631 | decl_scope_table = (tree *) xrealloc (decl_scope_table, | |
5632 | decl_scope_table_allocated * sizeof (tree)); | |
5633 | } | |
5634 | decl_scope_table[decl_scope_depth++] = scope; | |
5635 | } | |
5636 | ||
5637 | /* Return the DIE for the scope the immediately contains this declaration. */ | |
5638 | static dw_die_ref | |
5639 | scope_die_for_type (type, context_die) | |
5640 | register tree type; | |
5641 | register dw_die_ref context_die; | |
5642 | { | |
5643 | register dw_die_ref scope_die = NULL; | |
5644 | register tree containing_scope; | |
5645 | register unsigned long i; | |
5646 | ||
5647 | /* Walk back up the declaration tree looking for a place to define | |
5648 | this type. */ | |
5649 | containing_scope = TYPE_CONTEXT (type); | |
5650 | if (containing_scope == NULL) | |
5651 | { | |
5652 | scope_die = comp_unit_die; | |
5653 | } | |
5654 | else | |
5655 | { | |
5656 | for (i = decl_scope_depth - 1, scope_die = context_die; | |
5657 | i >= 0 | |
5658 | && scope_die != NULL | |
5659 | && decl_scope_table[i] != containing_scope; | |
5660 | --i, scope_die = scope_die->die_parent) | |
5661 | { | |
5662 | /* nothing */ ; | |
5663 | } | |
5664 | if (scope_die == NULL) | |
5665 | { | |
5666 | scope_die = context_die; | |
5667 | } | |
5668 | } | |
5669 | return scope_die; | |
5670 | } | |
5671 | ||
5672 | /* Pop a declaration scope. */ | |
5673 | inline void | |
5674 | pop_decl_scope () | |
5675 | { | |
5676 | assert (decl_scope_depth > 0); | |
5677 | --decl_scope_depth; | |
5678 | } | |
5679 | ||
5680 | /* Many forms of DIEs require a "type description" attribute. This | |
5681 | routine locates the proper "type descriptor" die for the type given | |
5682 | by 'type', and adds an DW_AT_type attribute below the given die. */ | |
5683 | static void | |
5684 | add_type_attribute (object_die, type, decl_const, decl_volatile, context_die) | |
5685 | register dw_die_ref object_die; | |
5686 | register tree type; | |
5687 | register int decl_const; | |
5688 | register int decl_volatile; | |
5689 | register dw_die_ref context_die; | |
5690 | { | |
5691 | register enum tree_code code = TREE_CODE (type); | |
5692 | register dw_die_ref scope_die = NULL; | |
5693 | register dw_die_ref type_die = NULL; | |
5694 | ||
5695 | if (code == ERROR_MARK) | |
5696 | { | |
5697 | return; | |
5698 | } | |
5699 | ||
5700 | /* Handle a special case. For functions whose return type is void, we | |
5701 | generate *no* type attribute. (Note that no object may have type | |
5702 | `void', so this only applies to function return types). */ | |
5703 | if (code == VOID_TYPE) | |
5704 | { | |
5705 | return; | |
5706 | } | |
5707 | ||
5708 | scope_die = scope_die_for_type (type, context_die); | |
5709 | type_die = modified_type_die (type, | |
5710 | decl_const || TYPE_READONLY (type), | |
5711 | decl_volatile || TYPE_VOLATILE (type), | |
5712 | scope_die); | |
5713 | if (type_die != NULL) | |
5714 | { | |
5715 | add_AT_die_ref (object_die, DW_AT_type, type_die); | |
5716 | } | |
5717 | } | |
5718 | ||
5719 | /* Given a tree pointer to a struct, class, union, or enum type node, return | |
5720 | a pointer to the (string) tag name for the given type, or zero if the type | |
5721 | was declared without a tag. */ | |
5722 | static char * | |
5723 | type_tag (type) | |
5724 | register tree type; | |
5725 | { | |
5726 | register char *name = 0; | |
5727 | ||
5728 | if (TYPE_NAME (type) != 0) | |
5729 | { | |
5730 | register tree t = 0; | |
5731 | ||
5732 | /* Find the IDENTIFIER_NODE for the type name. */ | |
5733 | if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE) | |
5734 | t = TYPE_NAME (type); | |
bdb669cb | 5735 | |
a3f97cbb JW |
5736 | /* The g++ front end makes the TYPE_NAME of *each* tagged type point to |
5737 | a TYPE_DECL node, regardless of whether or not a `typedef' was | |
bdb669cb | 5738 | involved. */ |
a3f97cbb JW |
5739 | else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL) |
5740 | t = DECL_NAME (TYPE_NAME (type)); | |
bdb669cb | 5741 | |
a3f97cbb JW |
5742 | /* Now get the name as a string, or invent one. */ |
5743 | if (t != 0) | |
5744 | { | |
5745 | name = IDENTIFIER_POINTER (t); | |
5746 | } | |
5747 | } | |
5748 | return (name == 0 || *name == '\0') ? 0 : name; | |
5749 | } | |
5750 | ||
5751 | /* Return the type associated with a data member, make a special check | |
5752 | for bit field types. */ | |
5753 | inline tree | |
5754 | member_declared_type (member) | |
5755 | register tree member; | |
5756 | { | |
5757 | return (DECL_BIT_FIELD_TYPE (member)) | |
5758 | ? DECL_BIT_FIELD_TYPE (member) | |
5759 | : TREE_TYPE (member); | |
5760 | } | |
5761 | ||
5762 | /* Get the function's label, as described by its RTL. This may be different | |
5763 | from the DECL_NAME name used in the source file. */ | |
5764 | static char * | |
5765 | function_start_label (decl) | |
5766 | register tree decl; | |
5767 | { | |
5768 | rtx x; | |
5769 | char *fnname; | |
5770 | x = DECL_RTL (decl); | |
5771 | if (GET_CODE (x) != MEM) | |
5772 | { | |
5773 | abort (); | |
5774 | } | |
5775 | x = XEXP (x, 0); | |
5776 | if (GET_CODE (x) != SYMBOL_REF) | |
5777 | { | |
5778 | abort (); | |
5779 | } | |
5780 | fnname = XSTR (x, 0); | |
5781 | return fnname; | |
5782 | } | |
5783 | \f | |
5784 | /******************************* DIE Generation *************************/ | |
5785 | ||
5786 | /* These routines generate the internnal representation of the DIE's for | |
5787 | the compilation unit. Debugging information is collected by walking | |
5788 | the declaration trees passed in from dwarfout_file_scope_decl(). */ | |
5789 | ||
5790 | static void | |
5791 | gen_array_type_die (type, context_die) | |
5792 | register tree type; | |
5793 | register dw_die_ref context_die; | |
5794 | { | |
5795 | register dw_die_ref scope_die = scope_die_for_type (type, context_die); | |
bdb669cb | 5796 | register dw_die_ref array_die = lookup_type_die (type); |
a3f97cbb | 5797 | register tree element_type; |
bdb669cb JM |
5798 | |
5799 | if (array_die) | |
5800 | return; | |
5801 | ||
5802 | array_die = new_die (DW_TAG_array_type, scope_die); | |
a3f97cbb JW |
5803 | #if 0 |
5804 | /* We default the array ordering. SDB will probably do | |
5805 | the right things even if DW_AT_ordering is not present. It's not even | |
5806 | an issue until we start to get into multidimensional arrays anyway. If | |
5807 | SDB is ever caught doing the Wrong Thing for multi-dimensional arrays, | |
5808 | then we'll have to put the DW_AT_ordering attribute back in. (But if | |
5809 | and when we find out that we need to put these in, we will only do so | |
5810 | for multidimensional arrays. */ | |
5811 | add_AT_unsigned (array_die, DW_AT_ordering, DW_ORD_row_major); | |
5812 | #endif | |
5813 | ||
5814 | add_subscript_info (array_die, type); | |
5815 | ||
5816 | equate_type_number_to_die (type, array_die); | |
5817 | ||
5818 | /* Add representation of the type of the elements of this array type. */ | |
5819 | element_type = TREE_TYPE (type); | |
5820 | /* ??? The SGI dwarf reader fails for multidimensional arrays with a | |
5821 | const enum type. E.g. const enum machine_mode insn_operand_mode[2][10]. | |
5822 | We work around this by disabling this feature. See also | |
5823 | add_subscript_info. */ | |
5824 | #ifndef MIPS_DEBUGGING_INFO | |
5825 | while (TREE_CODE (element_type) == ARRAY_TYPE) | |
5826 | { | |
5827 | element_type = TREE_TYPE (element_type); | |
5828 | } | |
5829 | #endif | |
5830 | gen_type_die (element_type, context_die); | |
5831 | ||
5832 | add_type_attribute (array_die, element_type, 0, 0, context_die); | |
5833 | } | |
5834 | ||
5835 | static void | |
5836 | gen_set_type_die (type, context_die) | |
5837 | register tree type; | |
5838 | register dw_die_ref context_die; | |
5839 | { | |
bdb669cb JM |
5840 | register dw_die_ref type_die = lookup_type_die (type); |
5841 | if (type_die) | |
5842 | return; | |
a3f97cbb JW |
5843 | type_die = new_die (DW_TAG_set_type, scope_die_for_type (type, context_die)); |
5844 | equate_type_number_to_die (type, type_die); | |
a3f97cbb JW |
5845 | add_type_attribute (type_die, TREE_TYPE (type), 0, 0, context_die); |
5846 | } | |
5847 | ||
5848 | static void | |
5849 | gen_entry_point_die (decl, context_die) | |
5850 | register tree decl; | |
5851 | register dw_die_ref context_die; | |
5852 | { | |
5853 | register tree origin = decl_ultimate_origin (decl); | |
5854 | register dw_die_ref decl_die = new_die (DW_TAG_entry_point, context_die); | |
5855 | if (origin != NULL) | |
5856 | { | |
5857 | add_abstract_origin_attribute (decl_die, origin); | |
5858 | } | |
5859 | else | |
5860 | { | |
5861 | add_name_and_src_coords_attributes (decl_die, decl); | |
a3f97cbb JW |
5862 | add_type_attribute (decl_die, TREE_TYPE (TREE_TYPE (decl)), |
5863 | 0, 0, context_die); | |
5864 | } | |
5865 | if (DECL_ABSTRACT (decl)) | |
5866 | { | |
5867 | equate_decl_number_to_die (decl, decl_die); | |
5868 | } | |
5869 | else | |
5870 | { | |
5871 | add_AT_lbl_id (decl_die, DW_AT_low_pc, function_start_label (decl)); | |
5872 | } | |
5873 | } | |
5874 | ||
5875 | /* Generate a DIE to represent an inlined instance of an enumeration type. */ | |
5876 | static void | |
5877 | gen_inlined_enumeration_type_die (type, context_die) | |
5878 | register tree type; | |
5879 | register dw_die_ref context_die; | |
5880 | { | |
5881 | register dw_die_ref type_die; | |
5882 | type_die = new_die (DW_TAG_enumeration_type, | |
5883 | scope_die_for_type (type, context_die)); | |
5884 | assert (TREE_ASM_WRITTEN (type)); | |
5885 | add_abstract_origin_attribute (type_die, type); | |
5886 | } | |
5887 | ||
5888 | /* Generate a DIE to represent an inlined instance of a structure type. */ | |
5889 | static void | |
5890 | gen_inlined_structure_type_die (type, context_die) | |
5891 | register tree type; | |
5892 | register dw_die_ref context_die; | |
5893 | { | |
5894 | register dw_die_ref type_die; | |
5895 | type_die = new_die (DW_TAG_structure_type, | |
5896 | scope_die_for_type (type, context_die)); | |
5897 | assert (TREE_ASM_WRITTEN (type)); | |
5898 | add_abstract_origin_attribute (type_die, type); | |
5899 | } | |
5900 | ||
5901 | /* Generate a DIE to represent an inlined instance of a union type. */ | |
5902 | static void | |
5903 | gen_inlined_union_type_die (type, context_die) | |
5904 | register tree type; | |
5905 | register dw_die_ref context_die; | |
5906 | { | |
5907 | register dw_die_ref type_die; | |
5908 | type_die = new_die (DW_TAG_union_type, | |
5909 | scope_die_for_type (type, context_die)); | |
5910 | assert (TREE_ASM_WRITTEN (type)); | |
5911 | add_abstract_origin_attribute (type_die, type); | |
5912 | } | |
5913 | ||
5914 | /* Generate a DIE to represent an enumeration type. Note that these DIEs | |
5915 | include all of the information about the enumeration values also. Each | |
5916 | enumerated type name/value is listed as a child of the enumerated type DIE */ | |
5917 | static void | |
5918 | gen_enumeration_type_die (type, is_complete, context_die) | |
5919 | register tree type; | |
5920 | register unsigned is_complete; | |
5921 | register dw_die_ref context_die; | |
5922 | { | |
5923 | register dw_die_ref type_die; | |
5924 | register dw_die_ref enum_die; | |
5925 | register tree link; | |
5926 | type_die = lookup_type_die (type); | |
5927 | if (type_die == NULL) | |
5928 | { | |
5929 | type_die = new_die (DW_TAG_enumeration_type, | |
5930 | scope_die_for_type (type, context_die)); | |
5931 | equate_type_number_to_die (type, type_die); | |
5932 | add_name_attribute (type_die, type_tag (type)); | |
a3f97cbb JW |
5933 | } |
5934 | if (is_complete) | |
5935 | { | |
5936 | /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the | |
5937 | given enum type is incomplete, do not generate the DW_AT_byte_size | |
5938 | attribute or the DW_AT_element_list attribute. */ | |
5939 | if (TYPE_SIZE (type)) | |
5940 | { | |
5941 | add_byte_size_attribute (type_die, type); | |
5942 | for (link = TYPE_FIELDS (type); | |
5943 | link != NULL; link = TREE_CHAIN (link)) | |
5944 | { | |
5945 | enum_die = new_die (DW_TAG_enumerator, type_die); | |
5946 | add_name_attribute (enum_die, | |
5947 | IDENTIFIER_POINTER (TREE_PURPOSE (link))); | |
5948 | add_AT_unsigned (enum_die, DW_AT_const_value, | |
5949 | (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link))); | |
5950 | } | |
5951 | } | |
5952 | } | |
5953 | } | |
5954 | ||
5955 | ||
5956 | /* Generate a DIE to represent either a real live formal parameter decl or to | |
5957 | represent just the type of some formal parameter position in some function | |
5958 | type. | |
5959 | Note that this routine is a bit unusual because its argument may be a | |
5960 | ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which | |
5961 | represents an inlining of some PARM_DECL) or else some sort of a ..._TYPE | |
5962 | node. If it's the former then this function is being called to output a | |
5963 | DIE to represent a formal parameter object (or some inlining thereof). If | |
5964 | it's the latter, then this function is only being called to output a | |
5965 | DW_TAG_formal_parameter DIE to stand as a placeholder for some formal | |
5966 | argument type of some subprogram type. */ | |
5967 | static void | |
5968 | gen_formal_parameter_die (node, context_die) | |
5969 | register tree node; | |
5970 | register dw_die_ref context_die; | |
5971 | { | |
5972 | register dw_die_ref parm_die = new_die (DW_TAG_formal_parameter, | |
5973 | context_die); | |
5974 | register tree origin; | |
5975 | switch (TREE_CODE_CLASS (TREE_CODE (node))) | |
5976 | { | |
5977 | /* We were called with some kind of a ..._DECL node. */ | |
5978 | case 'd': | |
5979 | origin = decl_ultimate_origin (node); | |
5980 | if (origin != NULL) | |
5981 | { | |
5982 | add_abstract_origin_attribute (parm_die, origin); | |
5983 | } | |
5984 | else | |
5985 | { | |
5986 | add_name_and_src_coords_attributes (parm_die, node); | |
5987 | add_type_attribute (parm_die, TREE_TYPE (node), | |
5988 | TREE_READONLY (node), | |
5989 | TREE_THIS_VOLATILE (node), | |
5990 | context_die); | |
bdb669cb JM |
5991 | if (DECL_ARTIFICIAL (node)) |
5992 | add_AT_flag (parm_die, DW_AT_artificial, 1); | |
a3f97cbb JW |
5993 | } |
5994 | if (DECL_ABSTRACT (node)) | |
5995 | { | |
5996 | equate_decl_number_to_die (node, parm_die); | |
5997 | } | |
5998 | else | |
5999 | { | |
6000 | add_location_or_const_value_attribute (parm_die, node); | |
6001 | } | |
6002 | break; | |
6003 | ||
6004 | /* We were called with some kind of a ..._TYPE node. */ | |
6005 | case 't': | |
6006 | add_type_attribute (parm_die, node, 0, 0, context_die); | |
6007 | break; | |
6008 | ||
6009 | /* Should never happen. */ | |
6010 | default: | |
6011 | abort (); | |
6012 | } | |
6013 | } | |
6014 | ||
6015 | /* Generate a special type of DIE used as a stand-in for a trailing ellipsis | |
6016 | at the end of an (ANSI prototyped) formal parameters list. */ | |
6017 | static void | |
6018 | gen_unspecified_parameters_die (decl_or_type, context_die) | |
6019 | register tree decl_or_type; | |
6020 | register dw_die_ref context_die; | |
6021 | { | |
6022 | register dw_die_ref parm_die = new_die (DW_TAG_unspecified_parameters, | |
6023 | context_die); | |
6024 | /* This kludge is here only for the sake of being compatible with what the | |
6025 | USL CI5 C compiler does. The specification of Dwarf Version 1 doesn't | |
6026 | say that DW_TAG_unspecified_parameters DIEs should contain any | |
6027 | attributes other than the DW_AT_sibling attribute, but they are | |
6028 | certainly allowed to contain additional attributes, and the CI5 compiler | |
6029 | generates DW_AT_name, DW_AT_base_type, and DW_AT_location attributes | |
6030 | within DW_TAG_unspecified_parameters DIEs which appear in the child | |
6031 | lists for DIEs representing function definitions, so we do likewise | |
6032 | here. */ | |
6033 | if (TREE_CODE (decl_or_type) == FUNCTION_DECL | |
6034 | && DECL_INITIAL (decl_or_type)) | |
6035 | { | |
6036 | add_name_attribute (parm_die, "..."); | |
6037 | add_AT_die_ref (parm_die, DW_AT_type, int_base_type_die); | |
6038 | } | |
6039 | } | |
6040 | ||
6041 | /* Generate a list of nameless DW_TAG_formal_parameter DIEs (and perhaps a | |
6042 | DW_TAG_unspecified_parameters DIE) to represent the types of the formal | |
6043 | parameters as specified in some function type specification (except for | |
6044 | those which appear as part of a function *definition*). | |
6045 | Note that we must be careful here to output all of the parameter DIEs before* | |
6046 | we output any DIEs needed to represent the types of the formal parameters. | |
6047 | This keeps svr4 SDB happy because it (incorrectly) thinks that the first | |
6048 | non-parameter DIE it sees ends the formal parameter list. */ | |
6049 | static void | |
6050 | gen_formal_types_die (function_or_method_type, context_die) | |
6051 | register tree function_or_method_type; | |
6052 | register dw_die_ref context_die; | |
6053 | { | |
6054 | register tree link; | |
6055 | register tree formal_type = NULL; | |
6056 | register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type); | |
6057 | ||
bdb669cb | 6058 | #if 0 |
a3f97cbb JW |
6059 | /* In the case where we are generating a formal types list for a C++ |
6060 | non-static member function type, skip over the first thing on the | |
6061 | TYPE_ARG_TYPES list because it only represents the type of the hidden | |
6062 | `this pointer'. The debugger should be able to figure out (without | |
6063 | being explicitly told) that this non-static member function type takes a | |
6064 | `this pointer' and should be able to figure what the type of that hidden | |
6065 | parameter is from the DW_AT_member attribute of the parent | |
6066 | DW_TAG_subroutine_type DIE. */ | |
6067 | if (TREE_CODE (function_or_method_type) == METHOD_TYPE) | |
6068 | first_parm_type = TREE_CHAIN (first_parm_type); | |
bdb669cb | 6069 | #endif |
a3f97cbb JW |
6070 | |
6071 | /* Make our first pass over the list of formal parameter types and output a | |
6072 | DW_TAG_formal_parameter DIE for each one. */ | |
6073 | for (link = first_parm_type; link; link = TREE_CHAIN (link)) | |
6074 | { | |
6075 | formal_type = TREE_VALUE (link); | |
6076 | if (formal_type == void_type_node) | |
6077 | break; | |
6078 | ||
6079 | /* Output a (nameless) DIE to represent the formal parameter itself. */ | |
6080 | gen_formal_parameter_die (formal_type, context_die); | |
6081 | } | |
6082 | ||
6083 | /* If this function type has an ellipsis, add a | |
6084 | DW_TAG_unspecified_parameters DIE to the end of the parameter list. */ | |
6085 | if (formal_type != void_type_node) | |
6086 | gen_unspecified_parameters_die (function_or_method_type, context_die); | |
6087 | ||
6088 | /* Make our second (and final) pass over the list of formal parameter types | |
6089 | and output DIEs to represent those types (as necessary). */ | |
6090 | for (link = TYPE_ARG_TYPES (function_or_method_type); | |
6091 | link; | |
6092 | link = TREE_CHAIN (link)) | |
6093 | { | |
6094 | formal_type = TREE_VALUE (link); | |
6095 | if (formal_type == void_type_node) | |
6096 | break; | |
6097 | ||
b50c02f9 | 6098 | gen_type_die (formal_type, context_die); |
a3f97cbb JW |
6099 | } |
6100 | } | |
6101 | ||
6102 | /* Generate a DIE to represent a declared function (either file-scope or | |
6103 | block-local). */ | |
6104 | static void | |
6105 | gen_subprogram_die (decl, context_die) | |
6106 | register tree decl; | |
6107 | register dw_die_ref context_die; | |
6108 | { | |
6109 | char label_id[MAX_ARTIFICIAL_LABEL_BYTES]; | |
6110 | register tree origin = decl_ultimate_origin (decl); | |
4b674448 | 6111 | register dw_die_ref subr_die; |
a3f97cbb JW |
6112 | register dw_loc_descr_ref fp_loc = NULL; |
6113 | register unsigned fp_reg; | |
6114 | register tree type; | |
6115 | register tree fn_arg_types; | |
6116 | register tree outer_scope; | |
6117 | register tree label; | |
bdb669cb | 6118 | dw_die_ref old_die = lookup_decl_die (decl); |
a3f97cbb | 6119 | |
a3f97cbb JW |
6120 | if (origin != NULL) |
6121 | { | |
4b674448 | 6122 | subr_die = new_die (DW_TAG_subprogram, context_die); |
a3f97cbb JW |
6123 | add_abstract_origin_attribute (subr_die, origin); |
6124 | } | |
bdb669cb JM |
6125 | else if (old_die) |
6126 | { | |
4b674448 JM |
6127 | register unsigned file_index |
6128 | = lookup_filename (DECL_SOURCE_FILE (decl)); | |
bdb669cb JM |
6129 | if (get_AT_flag (old_die, DW_AT_declaration) != 1) |
6130 | abort (); | |
4b674448 JM |
6131 | |
6132 | /* If the definition comes from the same place as the declaration, | |
6133 | use the old DIE. */ | |
6134 | if (get_AT_unsigned (old_die, DW_AT_decl_file) == file_index | |
6135 | && (get_AT_unsigned (old_die, DW_AT_decl_line) | |
6136 | == DECL_SOURCE_LINE (decl))) | |
bdb669cb | 6137 | { |
4b674448 JM |
6138 | subr_die = old_die; |
6139 | ||
6140 | /* Clear out the declaration attribute and the parm types. */ | |
6141 | remove_AT (subr_die, DW_AT_declaration); | |
6142 | remove_children (subr_die); | |
6143 | } | |
6144 | else | |
6145 | { | |
6146 | subr_die = new_die (DW_TAG_subprogram, context_die); | |
6147 | add_AT_die_ref (subr_die, DW_AT_specification, old_die); | |
bdb669cb JM |
6148 | if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index) |
6149 | add_AT_unsigned (subr_die, DW_AT_decl_file, file_index); | |
6150 | if (get_AT_unsigned (old_die, DW_AT_decl_line) | |
6151 | != DECL_SOURCE_LINE (decl)) | |
6152 | add_AT_unsigned | |
6153 | (subr_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl)); | |
6154 | } | |
6155 | } | |
a3f97cbb JW |
6156 | else |
6157 | { | |
4b674448 | 6158 | subr_die = new_die (DW_TAG_subprogram, context_die); |
ba7b35df JW |
6159 | if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) |
6160 | { | |
6161 | add_AT_flag (subr_die, DW_AT_external, 1); | |
6162 | } | |
a3f97cbb JW |
6163 | add_name_and_src_coords_attributes (subr_die, decl); |
6164 | if (DECL_INLINE (decl)) | |
6165 | { | |
6166 | add_AT_unsigned (subr_die, DW_AT_inline, DW_INL_inlined); | |
6167 | } | |
ba7b35df | 6168 | type = TREE_TYPE (decl); |
a3f97cbb | 6169 | add_prototyped_attribute (subr_die, type); |
a3f97cbb JW |
6170 | add_type_attribute (subr_die, TREE_TYPE (type), 0, 0, context_die); |
6171 | add_pure_or_virtual_attribute (subr_die, decl); | |
bdb669cb JM |
6172 | |
6173 | /* The first time we see a member function, it is in the context of | |
6174 | the class to which it belongs. We make sure of this by emitting | |
6175 | the class first. The next time is the definition, which is | |
6176 | handled above. The two may come from the same source text. */ | |
6177 | if (! DECL_INITIAL (decl)) | |
6178 | add_AT_flag (subr_die, DW_AT_declaration, 1); | |
a3f97cbb | 6179 | } |
bdb669cb | 6180 | if (DECL_ABSTRACT (decl) || ! DECL_INITIAL (decl)) |
a3f97cbb JW |
6181 | { |
6182 | equate_decl_number_to_die (decl, subr_die); | |
6183 | } | |
6184 | else if (!DECL_EXTERNAL (decl)) | |
6185 | { | |
ba7b35df JW |
6186 | if (origin == NULL) |
6187 | equate_decl_number_to_die (decl, subr_die); | |
a3f97cbb JW |
6188 | add_AT_lbl_id (subr_die, DW_AT_low_pc, function_start_label (decl)); |
6189 | sprintf (label_id, FUNC_END_LABEL_FMT, current_funcdef_number); | |
6190 | add_AT_lbl_id (subr_die, DW_AT_high_pc, label_id); | |
6191 | ||
6192 | #ifdef MIPS_DEBUGGING_INFO | |
6193 | ||
6194 | /* Add a reference to the FDE for this routine. */ | |
6195 | add_AT_fde_ref (subr_die, DW_AT_MIPS_fde, current_funcdef_fde); | |
6196 | #endif | |
6197 | ||
6198 | /* Define the frame pointer location for this routine. */ | |
6199 | fp_reg = (frame_pointer_needed) ? FRAME_POINTER_REGNUM | |
6200 | : STACK_POINTER_REGNUM; | |
6201 | assert (fp_reg >= 0 && fp_reg <= 31); | |
6202 | fp_loc = new_loc_descr (DW_OP_breg0 + fp_reg, current_funcdef_frame_size); | |
6203 | add_AT_loc (subr_die, DW_AT_frame_base, fp_loc); | |
6204 | ||
6205 | #ifdef DWARF_GNU_EXTENSIONS | |
6206 | sprintf (label_id, BODY_BEGIN_LABEL_FMT, current_funcdef_number); | |
6207 | add_AT_lbl_id (subr_die, DW_AT_body_begin, label_id); | |
6208 | sprintf (label_id, BODY_END_LABEL_FMT, current_funcdef_number); | |
6209 | add_AT_lbl_id (subr_die, DW_AT_body_end, label_id); | |
6210 | #endif | |
6211 | ||
6212 | } | |
6213 | ||
6214 | /* Now output descriptions of the arguments for this function. This gets | |
6215 | (unnecessarily?) complex because of the fact that the DECL_ARGUMENT list | |
6216 | for a FUNCTION_DECL doesn't indicate cases where there was a trailing | |
6217 | `...' at the end of the formal parameter list. In order to find out if | |
6218 | there was a trailing ellipsis or not, we must instead look at the type | |
6219 | associated with the FUNCTION_DECL. This will be a node of type | |
6220 | FUNCTION_TYPE. If the chain of type nodes hanging off of this | |
6221 | FUNCTION_TYPE node ends with a void_type_node then there should *not* be | |
6222 | an ellipsis at the end. */ | |
6223 | ||
6224 | /* In the case where we are describing a mere function declaration, all we | |
6225 | need to do here (and all we *can* do here) is to describe the *types* of | |
6226 | its formal parameters. */ | |
6227 | if (DECL_INITIAL (decl) == NULL_TREE) | |
6228 | { | |
6229 | gen_formal_types_die (TREE_TYPE (decl), subr_die); | |
6230 | } | |
6231 | else | |
6232 | { | |
6233 | /* Generate DIEs to represent all known formal parameters */ | |
6234 | register tree arg_decls = DECL_ARGUMENTS (decl); | |
6235 | register tree parm; | |
6236 | ||
6237 | /* When generating DIEs, generate the unspecified_parameters DIE | |
6238 | instead if we come across the arg "__builtin_va_alist" */ | |
6239 | for (parm = arg_decls; parm; parm = TREE_CHAIN (parm)) | |
6240 | { | |
6241 | if (TREE_CODE (parm) == PARM_DECL) | |
6242 | { | |
6243 | if (DECL_NAME (parm) && | |
6244 | !strcmp (IDENTIFIER_POINTER (DECL_NAME (parm)), | |
6245 | "__builtin_va_alist")) | |
6246 | { | |
6247 | gen_unspecified_parameters_die (parm, subr_die); | |
6248 | } | |
6249 | else | |
6250 | { | |
6251 | gen_decl_die (parm, subr_die); | |
6252 | } | |
6253 | } | |
6254 | } | |
6255 | ||
6256 | /* Decide whether we need a unspecified_parameters DIE at the end. | |
6257 | There are 2 more cases to do this for: 1) the ansi ... declaration - | |
6258 | this is detectable when the end of the arg list is not a | |
6259 | void_type_node 2) an unprototyped function declaration (not a | |
6260 | definition). This just means that we have no info about the | |
6261 | parameters at all. */ | |
6262 | fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl)); | |
6263 | if (fn_arg_types) | |
6264 | { | |
6265 | /* this is the prototyped case, check for ... */ | |
6266 | if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node) | |
6267 | { | |
6268 | gen_unspecified_parameters_die (decl, subr_die); | |
6269 | } | |
6270 | } | |
6271 | else | |
6272 | { | |
6273 | /* this is unprotoyped, check for undefined (just declaration) */ | |
6274 | if (!DECL_INITIAL (decl)) | |
6275 | { | |
6276 | gen_unspecified_parameters_die (decl, subr_die); | |
6277 | } | |
6278 | } | |
6279 | } | |
6280 | ||
6281 | /* Output Dwarf info for all of the stuff within the body of the function | |
6282 | (if it has one - it may be just a declaration). */ | |
6283 | outer_scope = DECL_INITIAL (decl); | |
6284 | ||
6285 | if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK) | |
6286 | { | |
6287 | /* Note that here, `outer_scope' is a pointer to the outermost BLOCK | |
6288 | node created to represent a function. This outermost BLOCK actually | |
6289 | represents the outermost binding contour for the function, i.e. the | |
6290 | contour in which the function's formal parameters and labels get | |
6291 | declared. Curiously, it appears that the front end doesn't actually | |
6292 | put the PARM_DECL nodes for the current function onto the BLOCK_VARS | |
6293 | list for this outer scope. (They are strung off of the | |
6294 | DECL_ARGUMENTS list for the function instead.) The BLOCK_VARS list | |
6295 | for the `outer_scope' does provide us with a list of the LABEL_DECL | |
6296 | nodes for the function however, and we output DWARF info for those | |
6297 | here. Just within the `outer_scope' there will be another BLOCK node | |
6298 | representing the function's outermost pair of curly braces. We | |
6299 | musn't generate a lexical_block DIE for this outermost pair of curly | |
6300 | braces because that is not really an independent scope according to | |
6301 | ANSI C rules. Rather, it is the same scope in which the parameters | |
6302 | were declared. */ | |
6303 | for (label = BLOCK_VARS (outer_scope); | |
6304 | label; | |
6305 | label = TREE_CHAIN (label)) | |
6306 | { | |
6307 | gen_decl_die (label, subr_die); | |
6308 | } | |
6309 | ||
6310 | /* Note here that `BLOCK_SUBBLOCKS (outer_scope)' points to a list of | |
6311 | BLOCK nodes which is always only one element long. That one element | |
6312 | represents the outermost pair of curley braces for the function | |
6313 | body. */ | |
6314 | decls_for_scope (BLOCK_SUBBLOCKS (outer_scope), subr_die); | |
6315 | } | |
6316 | } | |
6317 | ||
6318 | /* Generate a DIE to represent a declared data object. */ | |
6319 | static void | |
6320 | gen_variable_die (decl, context_die) | |
6321 | register tree decl; | |
6322 | register dw_die_ref context_die; | |
6323 | { | |
6324 | register tree origin = decl_ultimate_origin (decl); | |
6325 | register dw_die_ref var_die = new_die (DW_TAG_variable, context_die); | |
bdb669cb JM |
6326 | dw_die_ref old_die = lookup_decl_die (decl); |
6327 | ||
a3f97cbb JW |
6328 | if (origin != NULL) |
6329 | { | |
6330 | add_abstract_origin_attribute (var_die, origin); | |
6331 | } | |
bdb669cb JM |
6332 | else if (old_die) |
6333 | { | |
6334 | if (get_AT_flag (old_die, DW_AT_declaration) != 1) | |
6335 | abort (); | |
6336 | add_AT_die_ref (var_die, DW_AT_specification, old_die); | |
6337 | if (DECL_NAME (decl)) | |
6338 | { | |
6339 | register unsigned file_index | |
6340 | = lookup_filename (DECL_SOURCE_FILE (decl)); | |
6341 | if (get_AT_unsigned (old_die, DW_AT_decl_file) != file_index) | |
6342 | add_AT_unsigned (var_die, DW_AT_decl_file, file_index); | |
6343 | if (get_AT_unsigned (old_die, DW_AT_decl_line) | |
6344 | != DECL_SOURCE_LINE (decl)) | |
6345 | add_AT_unsigned | |
6346 | (var_die, DW_AT_decl_line, DECL_SOURCE_LINE (decl)); | |
6347 | } | |
6348 | } | |
a3f97cbb JW |
6349 | else |
6350 | { | |
6351 | add_name_and_src_coords_attributes (var_die, decl); | |
a3f97cbb JW |
6352 | add_type_attribute (var_die, TREE_TYPE (decl), |
6353 | TREE_READONLY (decl), | |
6354 | TREE_THIS_VOLATILE (decl), context_die); | |
bdb669cb JM |
6355 | if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)) |
6356 | { | |
6357 | add_AT_flag (var_die, DW_AT_external, 1); | |
6358 | } | |
a3f97cbb JW |
6359 | } |
6360 | if (DECL_ABSTRACT (decl)) | |
6361 | { | |
6362 | equate_decl_number_to_die (decl, var_die); | |
6363 | } | |
6364 | else if (!DECL_EXTERNAL (decl)) | |
6365 | { | |
bdb669cb | 6366 | equate_decl_number_to_die (decl, var_die); |
a3f97cbb JW |
6367 | add_location_or_const_value_attribute (var_die, decl); |
6368 | } | |
bdb669cb JM |
6369 | else if (decl_class_context (decl)) |
6370 | { | |
6371 | equate_decl_number_to_die (decl, var_die); | |
6372 | add_AT_flag (var_die, DW_AT_declaration, 1); | |
6373 | } | |
a3f97cbb JW |
6374 | } |
6375 | ||
6376 | /* Generate a DIE to represent a label identifier. */ | |
6377 | static void | |
6378 | gen_label_die (decl, context_die) | |
6379 | register tree decl; | |
6380 | register dw_die_ref context_die; | |
6381 | { | |
6382 | register tree origin = decl_ultimate_origin (decl); | |
6383 | register dw_die_ref lbl_die = new_die (DW_TAG_label, context_die); | |
6384 | register rtx insn; | |
6385 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
6386 | if (origin != NULL) | |
6387 | { | |
6388 | add_abstract_origin_attribute (lbl_die, origin); | |
6389 | } | |
6390 | else | |
6391 | { | |
6392 | add_name_and_src_coords_attributes (lbl_die, decl); | |
6393 | } | |
6394 | if (DECL_ABSTRACT (decl)) | |
6395 | { | |
6396 | equate_decl_number_to_die (decl, lbl_die); | |
6397 | } | |
6398 | else | |
6399 | { | |
6400 | insn = DECL_RTL (decl); | |
6401 | if (GET_CODE (insn) == CODE_LABEL) | |
6402 | { | |
6403 | /* When optimization is enabled (via -O) some parts of the compiler | |
6404 | (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which | |
6405 | represent source-level labels which were explicitly declared by | |
6406 | the user. This really shouldn't be happening though, so catch | |
6407 | it if it ever does happen. */ | |
6408 | if (INSN_DELETED_P (insn)) | |
6409 | { | |
6410 | abort (); /* Should never happen. */ | |
6411 | } | |
6412 | sprintf (label, INSN_LABEL_FMT, current_funcdef_number, | |
6413 | (unsigned) INSN_UID (insn)); | |
6414 | add_AT_lbl_id (lbl_die, DW_AT_low_pc, label); | |
6415 | } | |
6416 | } | |
6417 | } | |
6418 | ||
6419 | /* Generate a DIE for a lexical block. */ | |
6420 | static void | |
6421 | gen_lexical_block_die (stmt, context_die) | |
6422 | register tree stmt; | |
6423 | register dw_die_ref context_die; | |
6424 | { | |
6425 | register dw_die_ref stmt_die = new_die (DW_TAG_lexical_block, context_die); | |
6426 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
6427 | if (!BLOCK_ABSTRACT (stmt)) | |
6428 | { | |
6429 | sprintf (label, BLOCK_BEGIN_LABEL_FMT, next_block_number); | |
6430 | add_AT_lbl_id (stmt_die, DW_AT_low_pc, label); | |
6431 | sprintf (label, BLOCK_END_LABEL_FMT, next_block_number); | |
6432 | add_AT_lbl_id (stmt_die, DW_AT_high_pc, label); | |
6433 | } | |
6434 | decls_for_scope (stmt, stmt_die); | |
6435 | } | |
6436 | ||
6437 | /* Generate a DIE for an inlined subprogram. */ | |
6438 | static void | |
6439 | gen_inlined_subroutine_die (stmt, context_die) | |
6440 | register tree stmt; | |
6441 | register dw_die_ref context_die; | |
6442 | { | |
6443 | register dw_die_ref subr_die = new_die (DW_TAG_inlined_subroutine, | |
6444 | context_die); | |
6445 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
6446 | add_abstract_origin_attribute (subr_die, block_ultimate_origin (stmt)); | |
6447 | if (!BLOCK_ABSTRACT (stmt)) | |
6448 | { | |
6449 | sprintf (label, BLOCK_BEGIN_LABEL_FMT, next_block_number); | |
6450 | add_AT_lbl_id (subr_die, DW_AT_low_pc, label); | |
6451 | sprintf (label, BLOCK_END_LABEL_FMT, next_block_number); | |
6452 | add_AT_lbl_id (subr_die, DW_AT_high_pc, label); | |
6453 | } | |
6454 | decls_for_scope (stmt, subr_die); | |
6455 | } | |
6456 | ||
6457 | /* Generate a DIE for a field in a record, or structure. */ | |
6458 | static void | |
6459 | gen_field_die (decl, context_die) | |
6460 | register tree decl; | |
6461 | register dw_die_ref context_die; | |
6462 | { | |
6463 | register dw_die_ref decl_die = new_die (DW_TAG_member, context_die); | |
6464 | add_name_and_src_coords_attributes (decl_die, decl); | |
a3f97cbb JW |
6465 | add_type_attribute (decl_die, member_declared_type (decl), |
6466 | TREE_READONLY (decl), TREE_THIS_VOLATILE (decl), | |
6467 | context_die); | |
6468 | /* If this is a bit field... */ | |
6469 | if (DECL_BIT_FIELD_TYPE (decl)) | |
6470 | { | |
6471 | add_byte_size_attribute (decl_die, decl); | |
6472 | add_bit_size_attribute (decl_die, decl); | |
6473 | add_bit_offset_attribute (decl_die, decl); | |
6474 | } | |
6475 | add_data_member_location_attribute (decl_die, decl); | |
6476 | } | |
6477 | ||
6478 | /* Don't generate either pointer_type DIEs or reference_type DIEs. | |
6479 | Use modified type DIE's instead. | |
6480 | We keep this code here just in case these types of DIEs may be needed to | |
6481 | represent certain things in other languages (e.g. Pascal) someday. */ | |
6482 | static void | |
6483 | gen_pointer_type_die (type, context_die) | |
6484 | register tree type; | |
6485 | register dw_die_ref context_die; | |
6486 | { | |
bdb669cb JM |
6487 | register dw_die_ref ptr_die = lookup_type_die (type); |
6488 | if (ptr_die) | |
6489 | return; | |
6490 | ptr_die = new_die (DW_TAG_pointer_type, context_die); | |
a3f97cbb | 6491 | equate_type_number_to_die (type, ptr_die); |
a3f97cbb JW |
6492 | add_type_attribute (ptr_die, TREE_TYPE (type), 0, 0, context_die); |
6493 | } | |
6494 | ||
6495 | /* Don't generate either pointer_type DIEs or reference_type DIEs. | |
6496 | Use modified type DIE's instead. | |
6497 | We keep this code here just in case these types of DIEs may be needed to | |
6498 | represent certain things in other languages (e.g. Pascal) someday. */ | |
6499 | static void | |
6500 | gen_reference_type_die (type, context_die) | |
6501 | register tree type; | |
6502 | register dw_die_ref context_die; | |
6503 | { | |
bdb669cb JM |
6504 | register dw_die_ref ref_die = lookup_type_die (type); |
6505 | if (ref_die) | |
6506 | return; | |
6507 | ref_die = new_die (DW_TAG_reference_type, context_die); | |
a3f97cbb | 6508 | equate_type_number_to_die (type, ref_die); |
a3f97cbb JW |
6509 | add_type_attribute (ref_die, TREE_TYPE (type), 0, 0, context_die); |
6510 | } | |
6511 | ||
6512 | /* Generate a DIE for a pointer to a member type. */ | |
6513 | static void | |
6514 | gen_ptr_to_mbr_type_die (type, context_die) | |
6515 | register tree type; | |
6516 | register dw_die_ref context_die; | |
6517 | { | |
bdb669cb JM |
6518 | register dw_die_ref ptr_die = lookup_type_die (type); |
6519 | if (ptr_die) | |
6520 | return; | |
6521 | ptr_die = new_die (DW_TAG_ptr_to_member_type, context_die); | |
a3f97cbb | 6522 | equate_type_number_to_die (type, ptr_die); |
a3f97cbb | 6523 | add_AT_die_ref (ptr_die, DW_AT_containing_type, |
bdb669cb | 6524 | lookup_type_die (TYPE_OFFSET_BASETYPE (type))); |
a3f97cbb JW |
6525 | add_type_attribute (ptr_die, TREE_TYPE (type), 0, 0, context_die); |
6526 | } | |
6527 | ||
6528 | /* Generate the DIE for the compilation unit. */ | |
6529 | static void | |
6530 | gen_compile_unit_die (main_input_filename) | |
6531 | register char *main_input_filename; | |
6532 | { | |
6533 | char producer[250]; | |
a3f97cbb JW |
6534 | char *wd = getpwd (); |
6535 | ||
6536 | comp_unit_die = new_die (DW_TAG_compile_unit, NULL); | |
6537 | ||
bdb669cb JM |
6538 | add_name_attribute (comp_unit_die, main_input_filename); |
6539 | ||
6540 | if (wd) | |
a3f97cbb | 6541 | { |
bdb669cb | 6542 | add_AT_string (comp_unit_die, DW_AT_comp_dir, wd); |
a3f97cbb JW |
6543 | } |
6544 | ||
6545 | sprintf (producer, "%s %s", language_string, version_string); | |
6546 | ||
6547 | #ifdef MIPS_DEBUGGING_INFO | |
6548 | /* The MIPS/SGI compilers place the 'cc' command line options in the producer | |
6549 | string. The SGI debugger looks for -g, -g1, -g2, or -g3; if they do | |
6550 | not appear in the producer string, the debugger reaches the conclusion | |
6551 | that the object file is stripped and has no debugging information. | |
6552 | To get the MIPS/SGI debugger to believe that there is debugging | |
6553 | information in the object file, we add a -g to the producer string. */ | |
6554 | if (write_symbols != NO_DEBUG) | |
6555 | { | |
bdb669cb | 6556 | strcat (producer, " -g"); |
a3f97cbb JW |
6557 | } |
6558 | ||
6559 | #endif | |
6560 | ||
6561 | add_AT_string (comp_unit_die, DW_AT_producer, producer); | |
6562 | if (strcmp (language_string, "GNU C++") == 0) | |
6563 | { | |
6564 | add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_C_plus_plus); | |
6565 | } | |
6566 | else if (strcmp (language_string, "GNU Ada") == 0) | |
6567 | { | |
6568 | add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_Ada83); | |
6569 | } | |
6570 | else if (flag_traditional) | |
6571 | { | |
6572 | add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_C); | |
6573 | } | |
6574 | else | |
6575 | { | |
6576 | add_AT_unsigned (comp_unit_die, DW_AT_language, DW_LANG_C89); | |
6577 | } | |
bdb669cb | 6578 | add_AT_lbl_id (comp_unit_die, DW_AT_low_pc, TEXT_SECTION); |
a3f97cbb | 6579 | add_AT_lbl_id (comp_unit_die, DW_AT_high_pc, TEXT_END_LABEL); |
a3f97cbb JW |
6580 | if (debug_info_level >= DINFO_LEVEL_NORMAL) |
6581 | { | |
6582 | add_AT_section_offset (comp_unit_die, DW_AT_stmt_list, LINE_SECTION); | |
6583 | if (debug_info_level >= DINFO_LEVEL_VERBOSE) | |
6584 | { | |
6585 | add_AT_unsigned (comp_unit_die, DW_AT_macro_info, 0); | |
6586 | } | |
6587 | } | |
6588 | } | |
6589 | ||
6590 | /* Generate a DIE for a string type. */ | |
6591 | static void | |
6592 | gen_string_type_die (type, context_die) | |
6593 | register tree type; | |
6594 | register dw_die_ref context_die; | |
6595 | { | |
bdb669cb JM |
6596 | register dw_die_ref type_die = lookup_type_die (type); |
6597 | if (type_die) | |
6598 | return; | |
a3f97cbb JW |
6599 | type_die = new_die (DW_TAG_string_type, |
6600 | scope_die_for_type (type, context_die)); | |
bdb669cb | 6601 | equate_type_number_to_die (type, type_die); |
a3f97cbb JW |
6602 | |
6603 | /* Fudge the string length attribute for now. */ | |
6604 | ||
6605 | /* TODO: add string length info. | |
6606 | string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type))); | |
6607 | bound_representation (upper_bound, 0, 'u'); */ | |
6608 | } | |
6609 | ||
6610 | /* Genearate a DIE for a class member. */ | |
6611 | static void | |
6612 | gen_member_die (type, context_die) | |
6613 | register tree type; | |
6614 | register dw_die_ref context_die; | |
6615 | { | |
6616 | register tree normal_member; | |
a3f97cbb JW |
6617 | register tree first_func_member; |
6618 | register tree func_member; | |
6619 | /* If this is not an incomplete type, output descriptions of each of its | |
6620 | members. Note that as we output the DIEs necessary to represent the | |
6621 | members of this record or union type, we will also be trying to output | |
6622 | DIEs to represent the *types* of those members. However the `type' | |
6623 | function (above) will specifically avoid generating type DIEs for member | |
6624 | types *within* the list of member DIEs for this (containing) type execpt | |
6625 | for those types (of members) which are explicitly marked as also being | |
6626 | members of this (containing) type themselves. The g++ front- end can | |
6627 | force any given type to be treated as a member of some other | |
6628 | (containing) type by setting the TYPE_CONTEXT of the given (member) type | |
6629 | to point to the TREE node representing the appropriate (containing) | |
6630 | type. */ | |
6631 | ||
6632 | /* First output info about the data members and type members. */ | |
6633 | for (normal_member = TYPE_FIELDS (type); | |
6634 | normal_member; | |
6635 | normal_member = TREE_CHAIN (normal_member)) | |
6636 | { | |
6637 | gen_decl_die (normal_member, context_die); | |
6638 | } | |
6639 | ||
6640 | /* Now output info about the function members (if any). */ | |
bdb669cb JM |
6641 | for (func_member = TYPE_METHODS (type); |
6642 | func_member; | |
6643 | func_member = TREE_CHAIN (func_member)) | |
a3f97cbb | 6644 | { |
bdb669cb | 6645 | gen_decl_die (func_member, context_die); |
a3f97cbb JW |
6646 | } |
6647 | } | |
6648 | ||
6649 | /* Generate a DIE for a structure or union type. */ | |
6650 | static void | |
6651 | gen_struct_or_union_type_die (type, is_complete, context_die) | |
6652 | register tree type; | |
6653 | register unsigned is_complete; | |
6654 | register dw_die_ref context_die; | |
6655 | { | |
6656 | register dw_die_ref type_die; | |
6657 | type_die = lookup_type_die (type); | |
6658 | if (type_die == NULL) | |
6659 | { | |
6660 | type_die = new_die (TREE_CODE (type) == RECORD_TYPE | |
6661 | ? DW_TAG_structure_type : DW_TAG_union_type, | |
6662 | scope_die_for_type (type, context_die)); | |
6663 | equate_type_number_to_die (type, type_die); | |
6664 | add_name_attribute (type_die, type_tag (type)); | |
a3f97cbb | 6665 | } |
4b674448 JM |
6666 | else if (is_complete) |
6667 | remove_AT (type_die, DW_AT_declaration); | |
6668 | else | |
6669 | return; | |
a3f97cbb JW |
6670 | |
6671 | /* If this type has been completed, then give it a byte_size attribute and | |
6672 | then give a list of members. */ | |
6673 | if (is_complete) | |
6674 | { | |
6675 | /* Prevent infinite recursion in cases where the type of some member of | |
6676 | this type is expressed in terms of this type itself. */ | |
6677 | TREE_ASM_WRITTEN (type) = 1; | |
6678 | if (TYPE_SIZE (type)) | |
6679 | { | |
6680 | add_byte_size_attribute (type_die, type); | |
6681 | gen_member_die (type, type_die); | |
6682 | } | |
6683 | } | |
4b674448 JM |
6684 | else |
6685 | add_AT_flag (type_die, DW_AT_declaration, 1); | |
a3f97cbb JW |
6686 | } |
6687 | ||
6688 | /* Generate a DIE for a subroutine _type_. */ | |
6689 | static void | |
6690 | gen_subroutine_type_die (type, context_die) | |
6691 | register tree type; | |
6692 | register dw_die_ref context_die; | |
6693 | { | |
6694 | register tree return_type = TREE_TYPE (type); | |
bdb669cb JM |
6695 | register dw_die_ref subr_die = lookup_type_die (type); |
6696 | if (subr_die) | |
6697 | return; | |
6698 | subr_die = new_die (DW_TAG_subroutine_type, context_die); | |
a3f97cbb JW |
6699 | equate_type_number_to_die (type, subr_die); |
6700 | add_prototyped_attribute (subr_die, type); | |
a3f97cbb JW |
6701 | add_type_attribute (subr_die, return_type, 0, 0, context_die); |
6702 | gen_formal_types_die (type, context_die); | |
6703 | } | |
6704 | ||
6705 | /* Generate a DIE for a type definition */ | |
6706 | static void | |
6707 | gen_typedef_die (decl, context_die) | |
6708 | register tree decl; | |
6709 | register dw_die_ref context_die; | |
6710 | { | |
6711 | register tree origin = decl_ultimate_origin (decl); | |
6712 | register dw_die_ref type_die; | |
6713 | type_die = new_die (DW_TAG_typedef, | |
6714 | scope_die_for_type (decl, context_die)); | |
6715 | if (origin != NULL) | |
6716 | { | |
6717 | add_abstract_origin_attribute (type_die, origin); | |
6718 | } | |
6719 | else | |
6720 | { | |
6721 | add_name_and_src_coords_attributes (type_die, decl); | |
a3f97cbb JW |
6722 | add_type_attribute (type_die, TREE_TYPE (decl), |
6723 | TREE_READONLY (decl), | |
6724 | TREE_THIS_VOLATILE (decl), | |
6725 | context_die); | |
6726 | } | |
6727 | if (DECL_ABSTRACT (decl)) | |
6728 | { | |
6729 | equate_decl_number_to_die (decl, type_die); | |
6730 | } | |
6731 | } | |
6732 | ||
6733 | /* Generate a type description DIE. */ | |
6734 | static void | |
6735 | gen_type_die (type, context_die) | |
6736 | register tree type; | |
6737 | register dw_die_ref context_die; | |
6738 | { | |
6739 | register unsigned is_complete; | |
6740 | if (type == 0 || type == error_mark_node) | |
6741 | { | |
6742 | return; | |
6743 | } | |
6744 | ||
6745 | /* We are going to output a DIE to represent the unqualified version of of | |
6746 | this type (i.e. without any const or volatile qualifiers) so get the | |
6747 | main variant (i.e. the unqualified version) of this type now. */ | |
6748 | type = type_main_variant (type); | |
6749 | ||
6750 | if (TREE_ASM_WRITTEN (type)) | |
6751 | { | |
6752 | return; | |
6753 | } | |
6754 | ||
6755 | switch (TREE_CODE (type)) | |
6756 | { | |
6757 | case ERROR_MARK: | |
6758 | break; | |
6759 | ||
6760 | case POINTER_TYPE: | |
6761 | case REFERENCE_TYPE: | |
6762 | /* For these types, all that is required is that we output a DIE (or a | |
6763 | set of DIEs) to represent the "basis" type. */ | |
6764 | gen_type_die (TREE_TYPE (type), context_die); | |
6765 | break; | |
6766 | ||
6767 | case OFFSET_TYPE: | |
6768 | /* This code is used for C++ pointer-to-data-member types. */ | |
6769 | /* Output a description of the relevant class type. */ | |
6770 | gen_type_die (TYPE_OFFSET_BASETYPE (type), context_die); | |
6771 | /* Output a description of the type of the object pointed to. */ | |
6772 | gen_type_die (TREE_TYPE (type), context_die); | |
6773 | /* Now output a DIE to represent this pointer-to-data-member type | |
6774 | itself. */ | |
6775 | gen_ptr_to_mbr_type_die (type, context_die); | |
6776 | break; | |
6777 | ||
6778 | case SET_TYPE: | |
6779 | gen_type_die (TYPE_DOMAIN (type), context_die); | |
6780 | gen_set_type_die (type, context_die); | |
6781 | break; | |
6782 | ||
6783 | case FILE_TYPE: | |
6784 | gen_type_die (TREE_TYPE (type), context_die); | |
6785 | abort (); /* No way to represent these in Dwarf yet! */ | |
6786 | break; | |
6787 | ||
6788 | case FUNCTION_TYPE: | |
6789 | /* Force out return type (in case it wasn't forced out already). */ | |
6790 | gen_type_die (TREE_TYPE (type), context_die); | |
6791 | gen_subroutine_type_die (type, context_die); | |
6792 | break; | |
6793 | ||
6794 | case METHOD_TYPE: | |
6795 | /* Force out return type (in case it wasn't forced out already). */ | |
6796 | gen_type_die (TREE_TYPE (type), context_die); | |
6797 | gen_subroutine_type_die (type, context_die); | |
6798 | break; | |
6799 | ||
6800 | case ARRAY_TYPE: | |
6801 | if (TYPE_STRING_FLAG (type) && TREE_CODE (TREE_TYPE (type)) == CHAR_TYPE) | |
6802 | { | |
6803 | gen_type_die (TREE_TYPE (type), context_die); | |
6804 | gen_string_type_die (type, context_die); | |
6805 | } | |
6806 | else | |
6807 | { | |
6808 | gen_array_type_die (type, context_die); | |
6809 | } | |
6810 | break; | |
6811 | ||
6812 | case ENUMERAL_TYPE: | |
6813 | case RECORD_TYPE: | |
6814 | case UNION_TYPE: | |
6815 | case QUAL_UNION_TYPE: | |
6816 | /* For a non-file-scope tagged type, we can always go ahead and output | |
6817 | a Dwarf description of this type right now, even if the type in | |
6818 | question is still incomplete, because if this local type *was* ever | |
6819 | completed anywhere within its scope, that complete definition would | |
6820 | already have been attached to this RECORD_TYPE, UNION_TYPE, | |
6821 | QUAL_UNION_TYPE or ENUMERAL_TYPE node by the time we reach this | |
6822 | point. That's true because of the way the front-end does its | |
6823 | processing of file-scope declarations (of functions and class types) | |
6824 | within which other types might be nested. The C and C++ front-ends | |
6825 | always gobble up such "local scope" things en-mass before they try | |
6826 | to output *any* debugging information for any of the stuff contained | |
6827 | inside them and thus, we get the benefit here of what is (in effect) | |
6828 | a pre-resolution of forward references to tagged types in local | |
6829 | scopes. Note however that for file-scope tagged types we cannot | |
6830 | assume that such pre-resolution of forward references has taken | |
6831 | place. A given file-scope tagged type may appear to be incomplete | |
6832 | when we reach this point, but it may yet be given a full definition | |
6833 | (at file-scope) later on during compilation. In order to avoid | |
6834 | generating a premature (and possibly incorrect) set of Dwarf DIEs | |
6835 | for such (as yet incomplete) file-scope tagged types, we generate | |
6836 | nothing at all for as-yet incomplete file-scope tagged types here | |
6837 | unless we are making our special "finalization" pass for file-scope | |
6838 | things at the very end of compilation. At that time, we will | |
6839 | certainly know as much about each file-scope tagged type as we are | |
6840 | ever going to know, so at that point in time, we can safely generate | |
6841 | correct Dwarf descriptions for these file-scope tagged types. */ | |
6842 | is_complete = TYPE_SIZE (type) != 0 | |
6843 | || TYPE_CONTEXT (type) != NULL | |
6844 | || finalizing; | |
6845 | if (TREE_CODE (type) == ENUMERAL_TYPE) | |
6846 | { | |
6847 | gen_enumeration_type_die (type, is_complete, context_die); | |
6848 | } | |
6849 | else | |
6850 | { | |
6851 | gen_struct_or_union_type_die (type, is_complete, context_die); | |
6852 | } | |
4b674448 JM |
6853 | |
6854 | /* Don't set TREE_ASM_WRITTEN on an incomplete struct; we want to fix | |
6855 | it up if it is ever completed. */ | |
6856 | if (! is_complete) | |
6857 | return; | |
a3f97cbb JW |
6858 | break; |
6859 | ||
6860 | case VOID_TYPE: | |
6861 | case INTEGER_TYPE: | |
6862 | case REAL_TYPE: | |
6863 | case COMPLEX_TYPE: | |
6864 | case BOOLEAN_TYPE: | |
6865 | case CHAR_TYPE: | |
6866 | /* No DIEs needed for fundamental types. */ | |
6867 | break; | |
6868 | ||
6869 | case LANG_TYPE: | |
6870 | /* No Dwarf representation currently defined. */ | |
6871 | break; | |
6872 | ||
6873 | default: | |
6874 | abort (); | |
6875 | } | |
6876 | ||
6877 | TREE_ASM_WRITTEN (type) = 1; | |
6878 | } | |
6879 | ||
6880 | /* Generate a DIE for a tagged type instantiation. */ | |
6881 | static void | |
6882 | gen_tagged_type_instantiation_die (type, context_die) | |
6883 | register tree type; | |
6884 | register dw_die_ref context_die; | |
6885 | { | |
6886 | if (type == 0 || type == error_mark_node) | |
6887 | { | |
6888 | return; | |
6889 | } | |
6890 | ||
6891 | /* We are going to output a DIE to represent the unqualified version of of | |
6892 | this type (i.e. without any const or volatile qualifiers) so make sure | |
6893 | that we have the main variant (i.e. the unqualified version) of this | |
6894 | type now. */ | |
6895 | assert (type == type_main_variant (type)); | |
6896 | assert (TREE_ASM_WRITTEN (type)); | |
6897 | ||
6898 | switch (TREE_CODE (type)) | |
6899 | { | |
6900 | case ERROR_MARK: | |
6901 | break; | |
6902 | ||
6903 | case ENUMERAL_TYPE: | |
6904 | gen_inlined_enumeration_type_die (type, context_die); | |
6905 | break; | |
6906 | ||
6907 | case RECORD_TYPE: | |
6908 | gen_inlined_structure_type_die (type, context_die); | |
6909 | break; | |
6910 | ||
6911 | case UNION_TYPE: | |
6912 | case QUAL_UNION_TYPE: | |
6913 | gen_inlined_union_type_die (type, context_die); | |
6914 | break; | |
6915 | ||
6916 | default: | |
6917 | abort (); /* Should never happen. */ | |
6918 | } | |
6919 | } | |
6920 | ||
6921 | /* Generate a DW_TAG_lexical_block DIE followed by DIEs to represent all of the | |
6922 | things which are local to the given block. */ | |
6923 | static void | |
6924 | gen_block_die (stmt, context_die) | |
6925 | register tree stmt; | |
6926 | register dw_die_ref context_die; | |
6927 | { | |
6928 | register int must_output_die = 0; | |
6929 | register tree origin; | |
6930 | register tree decl; | |
6931 | register enum tree_code origin_code; | |
6932 | ||
6933 | /* Ignore blocks never really used to make RTL. */ | |
6934 | ||
6935 | if (!stmt || !TREE_USED (stmt)) | |
6936 | { | |
6937 | return; | |
6938 | } | |
6939 | ||
6940 | /* Determine the "ultimate origin" of this block. This block may be an | |
6941 | inlined instance of an inlined instance of inline function, so we have | |
6942 | to trace all of the way back through the origin chain to find out what | |
6943 | sort of node actually served as the original seed for the creation of | |
6944 | the current block. */ | |
6945 | origin = block_ultimate_origin (stmt); | |
6946 | origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK; | |
6947 | ||
6948 | /* Determine if we need to output any Dwarf DIEs at all to represent this | |
6949 | block. */ | |
6950 | if (origin_code == FUNCTION_DECL) | |
6951 | { | |
6952 | /* The outer scopes for inlinings *must* always be represented. We | |
6953 | generate DW_TAG_inlined_subroutine DIEs for them. (See below.) */ | |
6954 | must_output_die = 1; | |
6955 | } | |
6956 | else | |
6957 | { | |
6958 | /* In the case where the current block represents an inlining of the | |
6959 | "body block" of an inline function, we must *NOT* output any DIE for | |
6960 | this block because we have already output a DIE to represent the | |
6961 | whole inlined function scope and the "body block" of any function | |
6962 | doesn't really represent a different scope according to ANSI C | |
6963 | rules. So we check here to make sure that this block does not | |
6964 | represent a "body block inlining" before trying to set the | |
6965 | `must_output_die' flag. */ | |
6966 | if (origin == NULL || !is_body_block (origin)) | |
6967 | { | |
6968 | /* Determine if this block directly contains any "significant" | |
6969 | local declarations which we will need to output DIEs for. */ | |
6970 | if (debug_info_level > DINFO_LEVEL_TERSE) | |
6971 | { | |
6972 | /* We are not in terse mode so *any* local declaration counts | |
6973 | as being a "significant" one. */ | |
6974 | must_output_die = (BLOCK_VARS (stmt) != NULL); | |
6975 | } | |
6976 | else | |
6977 | { | |
6978 | /* We are in terse mode, so only local (nested) function | |
6979 | definitions count as "significant" local declarations. */ | |
6980 | for (decl = BLOCK_VARS (stmt); | |
6981 | decl != NULL; decl = TREE_CHAIN (decl)) | |
6982 | { | |
6983 | if (TREE_CODE (decl) == FUNCTION_DECL | |
6984 | && DECL_INITIAL (decl)) | |
6985 | { | |
6986 | must_output_die = 1; | |
6987 | break; | |
6988 | } | |
6989 | } | |
6990 | } | |
6991 | } | |
6992 | } | |
6993 | ||
6994 | /* It would be a waste of space to generate a Dwarf DW_TAG_lexical_block | |
6995 | DIE for any block which contains no significant local declarations at | |
6996 | all. Rather, in such cases we just call `decls_for_scope' so that any | |
6997 | needed Dwarf info for any sub-blocks will get properly generated. Note | |
6998 | that in terse mode, our definition of what constitutes a "significant" | |
6999 | local declaration gets restricted to include only inlined function | |
7000 | instances and local (nested) function definitions. */ | |
7001 | if (must_output_die) | |
7002 | { | |
7003 | if (origin_code == FUNCTION_DECL) | |
7004 | { | |
7005 | gen_inlined_subroutine_die (stmt, context_die); | |
7006 | } | |
7007 | else | |
7008 | { | |
7009 | gen_lexical_block_die (stmt, context_die); | |
7010 | } | |
7011 | } | |
7012 | else | |
7013 | decls_for_scope (stmt, context_die); | |
7014 | } | |
7015 | ||
7016 | /* Generate all of the decls declared within a given scope and (recursively) | |
7017 | all of it's sub-blocks. */ | |
7018 | static void | |
7019 | decls_for_scope (stmt, context_die) | |
7020 | register tree stmt; | |
7021 | register dw_die_ref context_die; | |
7022 | { | |
7023 | register tree decl; | |
7024 | register tree subblocks; | |
7025 | /* Ignore blocks never really used to make RTL. */ | |
7026 | if (!stmt || !TREE_USED (stmt)) | |
7027 | { | |
7028 | return; | |
7029 | } | |
7030 | if (!BLOCK_ABSTRACT (stmt)) | |
7031 | { | |
7032 | next_block_number++; | |
7033 | } | |
7034 | ||
7035 | /* Output the DIEs to represent all of the data objects, functions, | |
7036 | typedefs, and tagged types declared directly within this block but not | |
7037 | within any nested sub-blocks. */ | |
7038 | for (decl = BLOCK_VARS (stmt); | |
7039 | decl != NULL; decl = TREE_CHAIN (decl)) | |
7040 | { | |
7041 | gen_decl_die (decl, context_die); | |
7042 | } | |
7043 | ||
7044 | /* Output the DIEs to represent all sub-blocks (and the items declared | |
7045 | therein) of this block. */ | |
7046 | for (subblocks = BLOCK_SUBBLOCKS (stmt); | |
7047 | subblocks != NULL; | |
7048 | subblocks = BLOCK_CHAIN (subblocks)) | |
7049 | { | |
7050 | gen_block_die (subblocks, context_die); | |
7051 | } | |
7052 | } | |
7053 | ||
7054 | /* Generate Dwarf debug information for a decl described by DECL. */ | |
7055 | static void | |
7056 | gen_decl_die (decl, context_die) | |
7057 | register tree decl; | |
7058 | register dw_die_ref context_die; | |
7059 | { | |
7060 | register tree origin; | |
7061 | /* Make a note of the decl node we are going to be working on. We may need | |
7062 | to give the user the source coordinates of where it appeared in case we | |
7063 | notice (later on) that something about it looks screwy. */ | |
7064 | dwarf_last_decl = decl; | |
7065 | ||
7066 | if (TREE_CODE (decl) == ERROR_MARK) | |
7067 | { | |
7068 | return; | |
7069 | } | |
7070 | ||
7071 | /* If this ..._DECL node is marked to be ignored, then ignore it. But don't | |
7072 | ignore a function definition, since that would screw up our count of | |
7073 | blocks, and that it turn will completely screw up the the labels we will | |
7074 | reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for | |
7075 | subsequent blocks). */ | |
7076 | if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL) | |
7077 | { | |
7078 | return; | |
7079 | } | |
7080 | ||
7081 | push_decl_scope (DECL_CONTEXT (decl)); | |
7082 | switch (TREE_CODE (decl)) | |
7083 | { | |
7084 | case CONST_DECL: | |
7085 | /* The individual enumerators of an enum type get output when we output | |
7086 | the Dwarf representation of the relevant enum type itself. */ | |
7087 | break; | |
7088 | ||
7089 | case FUNCTION_DECL: | |
7090 | /* If we are in terse mode, don't output any DIEs to represent mere | |
bdb669cb JM |
7091 | function declarations, unless they are class members. */ |
7092 | if (DECL_INITIAL (decl) == NULL_TREE && DECL_CONTEXT (decl) == NULL_TREE) | |
a3f97cbb JW |
7093 | { |
7094 | break; | |
7095 | } | |
bdb669cb | 7096 | |
a3f97cbb JW |
7097 | /* Before we describe the FUNCTION_DECL itself, make sure that we have |
7098 | described its return type. */ | |
7099 | gen_type_die (TREE_TYPE (TREE_TYPE (decl)), context_die); | |
7100 | ||
7101 | /* Now output a DIE to represent the function itself. */ | |
7102 | gen_subprogram_die (decl, context_die); | |
7103 | break; | |
7104 | ||
7105 | case TYPE_DECL: | |
7106 | /* If we are in terse mode, don't generate any DIEs to represent any | |
7107 | actual typedefs. Note that even when we are in terse mode, we must | |
7108 | still output DIEs to represent those tagged types which are used | |
7109 | (directly or indirectly) in the specification of either a return | |
7110 | type or a formal parameter type of some function. */ | |
7111 | if (debug_info_level <= DINFO_LEVEL_TERSE) | |
7112 | { | |
7113 | if (DECL_NAME (decl) != NULL | |
7114 | || !TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl))) | |
7115 | { | |
7116 | break; | |
7117 | } | |
7118 | } | |
7119 | ||
7120 | /* In the special case of a null-named TYPE_DECL node (representing the | |
7121 | declaration of some type tag), if the given TYPE_DECL is marked as | |
7122 | having been instantiated from some other (original) TYPE_DECL node | |
7123 | (e.g. one which was generated within the original definition of an | |
7124 | inline function) we have to generate a special (abbreviated) | |
7125 | DW_TAG_structure_type, DW_TAG_union_type, or DW_TAG_enumeration-type | |
7126 | DIE here. */ | |
7127 | if (!DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl)) | |
7128 | { | |
7129 | gen_tagged_type_instantiation_die (TREE_TYPE (decl), context_die); | |
7130 | break; | |
7131 | } | |
7132 | gen_type_die (TREE_TYPE (decl), context_die); | |
7133 | ||
7134 | /* Note that unlike the gcc front end (which generates a NULL named | |
7135 | TYPE_DECL node for each complete tagged type, each array type, and | |
7136 | each function type node created) the g++ front end generates a | |
7137 | _named_ TYPE_DECL node for each tagged type node created. | |
bdb669cb JM |
7138 | These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to |
7139 | generate a DW_TAG_typedef DIE for them. */ | |
7140 | if (DECL_NAME (decl) && ! DECL_ARTIFICIAL (decl)) | |
a3f97cbb JW |
7141 | { |
7142 | /* Output a DIE to represent the typedef itself. */ | |
7143 | gen_typedef_die (decl, context_die); | |
7144 | } | |
7145 | break; | |
7146 | ||
7147 | case LABEL_DECL: | |
7148 | if (debug_info_level >= DINFO_LEVEL_NORMAL) | |
7149 | { | |
7150 | gen_label_die (decl, context_die); | |
7151 | } | |
7152 | break; | |
7153 | ||
7154 | case VAR_DECL: | |
7155 | /* If we are in terse mode, don't generate any DIEs to represent any | |
7156 | variable declarations or definitions. */ | |
7157 | if (debug_info_level <= DINFO_LEVEL_TERSE) | |
7158 | { | |
7159 | break; | |
7160 | } | |
7161 | ||
7162 | /* Output any DIEs that are needed to specify the type of this data | |
7163 | object. */ | |
7164 | gen_type_die (TREE_TYPE (decl), context_die); | |
7165 | ||
7166 | /* Now output the DIE to represent the data object itself. This gets | |
7167 | complicated because of the possibility that the VAR_DECL really | |
7168 | represents an inlined instance of a formal parameter for an inline | |
7169 | function. */ | |
7170 | origin = decl_ultimate_origin (decl); | |
7171 | if (origin != NULL && TREE_CODE (origin) == PARM_DECL) | |
7172 | { | |
7173 | gen_formal_parameter_die (decl, context_die); | |
7174 | } | |
7175 | else | |
7176 | { | |
7177 | gen_variable_die (decl, context_die); | |
7178 | } | |
7179 | break; | |
7180 | ||
7181 | case FIELD_DECL: | |
7182 | /* Ignore the nameless fields that are used to skip bits. */ | |
7183 | if (DECL_NAME (decl) != 0) | |
7184 | { | |
7185 | gen_type_die (member_declared_type (decl), context_die); | |
7186 | gen_field_die (decl, context_die); | |
7187 | } | |
7188 | break; | |
7189 | ||
7190 | case PARM_DECL: | |
7191 | gen_type_die (TREE_TYPE (decl), context_die); | |
7192 | gen_formal_parameter_die (decl, context_die); | |
7193 | break; | |
7194 | ||
7195 | default: | |
7196 | abort (); | |
7197 | } | |
7198 | pop_decl_scope (); | |
7199 | } | |
7200 | \f | |
7201 | /***************** Debug Information Generation Hooks ***********************/ | |
7202 | void | |
7203 | dwarfout_file_scope_decl (decl, set_finalizing) | |
7204 | register tree decl; | |
7205 | register int set_finalizing; | |
7206 | { | |
7207 | if (TREE_CODE (decl) == ERROR_MARK) | |
7208 | { | |
7209 | return; | |
7210 | } | |
7211 | ||
7212 | /* If this ..._DECL node is marked to be ignored, then ignore it. We gotta | |
7213 | hope that the node in question doesn't represent a function definition. | |
7214 | If it does, then totally ignoring it is bound to screw up our count of | |
7215 | blocks, and that it turn will completely screw up the the labels we will | |
7216 | reference in subsequent DW_AT_low_pc and DW_AT_high_pc attributes (for | |
7217 | subsequent blocks). (It's too bad that BLOCK nodes don't carry their | |
7218 | own sequence numbers with them!) */ | |
7219 | if (DECL_IGNORED_P (decl)) | |
7220 | { | |
7221 | if (TREE_CODE (decl) == FUNCTION_DECL | |
7222 | && DECL_INITIAL (decl) != NULL) | |
7223 | { | |
7224 | abort (); | |
7225 | } | |
7226 | return; | |
7227 | } | |
7228 | ||
7229 | switch (TREE_CODE (decl)) | |
7230 | { | |
7231 | case FUNCTION_DECL: | |
7232 | /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of a | |
7233 | builtin function. Explicit programmer-supplied declarations of | |
7234 | these same functions should NOT be ignored however. */ | |
7235 | if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl)) | |
7236 | { | |
7237 | return; | |
7238 | } | |
7239 | ||
7240 | /* What we would really like to do here is to filter out all mere | |
7241 | file-scope declarations of file-scope functions which are never | |
7242 | referenced later within this translation unit (and keep all of ones | |
7243 | that *are* referenced later on) but we aren't clarvoiant, so we have | |
7244 | no idea which functions will be referenced in the future (i.e. later | |
7245 | on within the current translation unit). So here we just ignore all | |
7246 | file-scope function declarations which are not also definitions. If | |
7247 | and when the debugger needs to know something about these funcstion, | |
7248 | it wil have to hunt around and find the DWARF information associated | |
7249 | with the definition of the function. Note that we can't just check | |
7250 | `DECL_EXTERNAL' to find out which FUNCTION_DECL nodes represent | |
7251 | definitions and which ones represent mere declarations. We have to | |
7252 | check `DECL_INITIAL' instead. That's because the C front-end | |
7253 | supports some weird semantics for "extern inline" function | |
7254 | definitions. These can get inlined within the current translation | |
7255 | unit (an thus, we need to generate DWARF info for their abstract | |
7256 | instances so that the DWARF info for the concrete inlined instances | |
7257 | can have something to refer to) but the compiler never generates any | |
7258 | out-of-lines instances of such things (despite the fact that they | |
7259 | *are* definitions). The important point is that the C front-end | |
7260 | marks these "extern inline" functions as DECL_EXTERNAL, but we need | |
7261 | to generate DWARf for them anyway. Note that the C++ front-end also | |
7262 | plays some similar games for inline function definitions appearing | |
7263 | within include files which also contain | |
7264 | `#pragma interface' pragmas. */ | |
7265 | if (DECL_INITIAL (decl) == NULL_TREE) | |
7266 | { | |
7267 | return; | |
7268 | } | |
7269 | break; | |
7270 | ||
7271 | case VAR_DECL: | |
7272 | /* Ignore this VAR_DECL if it refers to a file-scope extern data object | |
7273 | declaration and if the declaration was never even referenced from | |
7274 | within this entire compilation unit. We suppress these DIEs in | |
7275 | order to save space in the .debug section (by eliminating entries | |
7276 | which are probably useless). Note that we must not suppress | |
7277 | block-local extern declarations (whether used or not) because that | |
7278 | would screw-up the debugger's name lookup mechanism and cause it to | |
7279 | miss things which really ought to be in scope at a given point. */ | |
7280 | if (DECL_EXTERNAL (decl) && !TREE_USED (decl)) | |
7281 | { | |
7282 | return; | |
7283 | } | |
7284 | ||
7285 | /* If we are in terse mode, don't generate any DIEs to represent any | |
7286 | variable declarations or definitions. */ | |
7287 | if (debug_info_level <= DINFO_LEVEL_TERSE) | |
7288 | { | |
7289 | return; | |
7290 | } | |
7291 | break; | |
7292 | ||
7293 | case TYPE_DECL: | |
7294 | /* Don't bother trying to generate any DIEs to represent any of the | |
7295 | normal built-in types for the language we are compiling, except in | |
7296 | cases where the types in question are *not* DWARF fundamental types. | |
7297 | We make an exception in the case of non-fundamental types for the | |
7298 | sake of objective C (and perhaps C++) because the GNU front-ends for | |
7299 | these languages may in fact create certain "built-in" types which | |
7300 | are (for example) RECORD_TYPEs. In such cases, we really need to | |
7301 | output these (non-fundamental) types because other DIEs may contain | |
7302 | references to them. */ | |
7303 | if (DECL_SOURCE_LINE (decl) == 0 | |
7304 | && is_base_type (TREE_TYPE (decl))) | |
7305 | { | |
7306 | return; | |
7307 | } | |
7308 | ||
7309 | /* If we are in terse mode, don't generate any DIEs to represent any | |
7310 | actual typedefs. Note that even when we are in terse mode, we must | |
7311 | still output DIEs to represent those tagged types which are used | |
7312 | (directly or indirectly) in the specification of either a return | |
7313 | type or a formal parameter type of some function. */ | |
7314 | if (debug_info_level <= DINFO_LEVEL_TERSE) | |
7315 | { | |
7316 | if (DECL_NAME (decl) != NULL | |
7317 | || !TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl))) | |
7318 | { | |
7319 | return; | |
7320 | } | |
7321 | } | |
7322 | break; | |
7323 | ||
7324 | default: | |
7325 | return; | |
7326 | } | |
7327 | ||
7328 | finalizing = set_finalizing; | |
7329 | gen_decl_die (decl, comp_unit_die); | |
7330 | ||
7331 | if (TREE_CODE (decl) == FUNCTION_DECL | |
7332 | && DECL_INITIAL (decl) != NULL) | |
7333 | { | |
7334 | current_funcdef_number++; | |
7335 | } | |
7336 | ||
7337 | } | |
7338 | ||
7339 | /* Output a marker (i.e. a label) for the beginning of the generated code for | |
7340 | a lexical block. */ | |
7341 | void | |
7342 | dwarfout_begin_block (blocknum) | |
7343 | register unsigned blocknum; | |
7344 | { | |
7345 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7346 | ||
7347 | function_section (current_function_decl); | |
7348 | sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum); | |
7349 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7350 | } | |
7351 | ||
7352 | /* Output a marker (i.e. a label) for the end of the generated code for a | |
7353 | lexical block. */ | |
7354 | void | |
7355 | dwarfout_end_block (blocknum) | |
7356 | register unsigned blocknum; | |
7357 | { | |
7358 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7359 | ||
7360 | function_section (current_function_decl); | |
7361 | sprintf (label, BLOCK_END_LABEL_FMT, blocknum); | |
7362 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7363 | } | |
7364 | ||
7365 | /* Output a marker (i.e. a label) at a point in the assembly code which | |
7366 | corresponds to a given source level label. */ | |
7367 | void | |
7368 | dwarfout_label (insn) | |
7369 | register rtx insn; | |
7370 | { | |
7371 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7372 | if (debug_info_level >= DINFO_LEVEL_NORMAL) | |
7373 | { | |
7374 | function_section (current_function_decl); | |
7375 | sprintf (label, INSN_LABEL_FMT, current_funcdef_number, | |
7376 | (unsigned) INSN_UID (insn)); | |
7377 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7378 | } | |
7379 | } | |
7380 | ||
7381 | /* Output a marker (i.e. a label) for the point in the generated code where | |
7382 | the real body of the function begins (after parameters have been moved to | |
7383 | their home locations). */ | |
7384 | void | |
7385 | dwarfout_begin_function () | |
7386 | { | |
7387 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7388 | register long int offset; | |
7389 | register dw_fde_ref fde; | |
7390 | register dw_cfi_ref cfi; | |
7391 | ||
7392 | function_section (current_function_decl); | |
7393 | sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number); | |
7394 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7395 | ||
7396 | /* Expand the fde table if necessary. */ | |
7397 | if (fde_table_in_use == fde_table_allocated) | |
7398 | { | |
7399 | fde_table_allocated += FDE_TABLE_INCREMENT; | |
7400 | fde_table = (dw_fde_ref) xrealloc (fde_table, | |
7401 | fde_table_allocated * sizeof (dw_fde_node)); | |
7402 | } | |
7403 | ||
7404 | /* Record the FDE associated with this function. */ | |
7405 | current_funcdef_fde = fde_table_in_use; | |
7406 | ||
7407 | /* Add the new FDE at the end of the fde_table. */ | |
7408 | fde = &fde_table[fde_table_in_use++]; | |
7409 | fde->dw_fde_begin = xstrdup (function_start_label (current_function_decl)); | |
7410 | fde->dw_fde_end_prolog = xstrdup (label); | |
7411 | fde->dw_fde_begin_epilogue = NULL; | |
7412 | fde->dw_fde_end = NULL; | |
7413 | fde->dw_fde_cfi = NULL; | |
7414 | ||
7415 | #ifdef MIPS_DEBUGGING_INFO | |
7416 | ||
7417 | /* On entry, the Call Frame Address is in the stack pointer register. */ | |
7418 | cfi = new_cfi (); | |
7419 | cfi->dw_cfi_opc = DW_CFA_def_cfa; | |
7420 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = STACK_POINTER_REGNUM; | |
7421 | cfi->dw_cfi_oprnd2.dw_cfi_offset = 0; | |
7422 | add_cfi (&fde->dw_fde_cfi, cfi); | |
7423 | ||
7424 | /* Set the location counter to the end of the function prolog. */ | |
7425 | cfi = new_cfi (); | |
7426 | cfi->dw_cfi_opc = DW_CFA_advance_loc4; | |
7427 | cfi->dw_cfi_oprnd1.dw_cfi_addr = xstrdup (label); | |
7428 | add_cfi (&fde->dw_fde_cfi, cfi); | |
7429 | ||
7430 | /* Define the CFA as either an explicit frame pointer register, | |
7431 | or an offset from the stack pointer. */ | |
7432 | cfi = new_cfi (); | |
7433 | cfi->dw_cfi_opc = DW_CFA_def_cfa; | |
7434 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = (frame_pointer_needed) | |
7435 | ? FRAME_POINTER_REGNUM | |
7436 | : STACK_POINTER_REGNUM; | |
7437 | offset = current_frame_info.total_size; | |
7438 | cfi->dw_cfi_oprnd2.dw_cfi_offset = offset; | |
7439 | add_cfi (&fde->dw_fde_cfi, cfi); | |
7440 | ||
7441 | /* record the frame size for later definition of the DW_AT_frame_base | |
7442 | attribute. */ | |
7443 | current_funcdef_frame_size = offset; | |
7444 | ||
7445 | /* Define the rule for restoring the stack pointer. */ | |
7446 | if (frame_pointer_needed) | |
7447 | { | |
7448 | /* Restore the stack register from the frame pointer. */ | |
7449 | cfi = new_cfi (); | |
7450 | cfi->dw_cfi_opc = DW_CFA_register; | |
7451 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = STACK_POINTER_REGNUM; | |
7452 | cfi->dw_cfi_oprnd2.dw_cfi_reg_num = FRAME_POINTER_REGNUM; | |
7453 | add_cfi (&fde->dw_fde_cfi, cfi); | |
7454 | } | |
7455 | ||
7456 | /* If RA is saved on the stack, define it here. */ | |
7457 | if (regs_ever_live[31]) | |
7458 | { | |
7459 | offset = current_frame_info.gp_save_offset / DWARF_CIE_DATA_ALIGNMENT; | |
7460 | assert (offset >= 0); | |
7461 | cfi = new_cfi (); | |
7462 | cfi->dw_cfi_opc = DW_CFA_offset_extended; | |
7463 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = DW_FRAME_RA_COL; | |
7464 | cfi->dw_cfi_oprnd2.dw_cfi_offset = offset; | |
7465 | add_cfi (&fde->dw_fde_cfi, cfi); | |
7466 | } | |
7467 | ||
7468 | /* If FP is saved on the stack, define it here. */ | |
7469 | if (current_frame_info.mask & (1 << 30)) | |
7470 | { | |
7471 | offset = (current_frame_info.gp_save_offset | |
ba7b35df | 7472 | - (((current_frame_info.mask >> 31) & 1) * UNITS_PER_WORD)) |
a3f97cbb JW |
7473 | / DWARF_CIE_DATA_ALIGNMENT; |
7474 | assert (offset >= 0); | |
7475 | cfi = new_cfi (); | |
7476 | cfi->dw_cfi_opc = DW_CFA_offset; | |
7477 | cfi->dw_cfi_oprnd1.dw_cfi_reg_num = FRAME_POINTER_REGNUM; | |
7478 | cfi->dw_cfi_oprnd2.dw_cfi_offset = offset; | |
7479 | add_cfi (&fde->dw_fde_cfi, cfi); | |
7480 | } | |
7481 | ||
7482 | #endif | |
7483 | ||
7484 | } | |
7485 | ||
7486 | /* Output a marker (i.e. a label) for the point in the generated code where | |
7487 | the real body of the function ends (just before the epilogue code). */ | |
7488 | void | |
7489 | dwarfout_end_function () | |
7490 | { | |
7491 | dw_fde_ref fde; | |
7492 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7493 | function_section (current_function_decl); | |
7494 | sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number); | |
7495 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7496 | /* Record the ending code location in the FDE. */ | |
7497 | fde = &fde_table[fde_table_in_use - 1]; | |
7498 | fde->dw_fde_begin_epilogue = xstrdup(label); | |
7499 | } | |
7500 | ||
7501 | /* Output a marker (i.e. a label) for the absolute end of the generated code | |
7502 | for a function definition. This gets called *after* the epilogue code has | |
7503 | been generated. */ | |
7504 | void | |
7505 | dwarfout_end_epilogue () | |
7506 | { | |
7507 | dw_fde_ref fde; | |
7508 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7509 | /* Output a label to mark the endpoint of the code generated for this | |
7510 | function. */ | |
7511 | sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number); | |
7512 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7513 | fde = &fde_table[fde_table_in_use - 1]; | |
7514 | fde->dw_fde_end = xstrdup (label); | |
7515 | } | |
7516 | ||
7517 | /* Lookup a filename (in the list of filenames that we know about here in | |
7518 | dwarfout.c) and return its "index". The index of each (known) filename is | |
7519 | just a unique number which is associated with only that one filename. | |
7520 | We need such numbers for the sake of generating labels | |
7521 | (in the .debug_sfnames section) and references to those | |
7522 | files numbers (in the .debug_srcinfo and.debug_macinfo sections). | |
7523 | If the filename given as an argument is not found in our current list, | |
7524 | add it to the list and assign it the next available unique index number. | |
7525 | In order to speed up searches, we remember the index of the filename | |
7526 | was looked up last. This handles the majority of all searches. */ | |
7527 | static unsigned | |
7528 | lookup_filename (file_name) | |
7529 | char *file_name; | |
7530 | { | |
7531 | static unsigned last_file_lookup_index = 0; | |
7532 | register char *fn; | |
7533 | register unsigned i; | |
7534 | ||
7535 | /* Check to see if the file name that was searched on the previous call | |
7536 | matches this file name. If so, return the index. */ | |
7537 | if (last_file_lookup_index != 0) | |
7538 | { | |
7539 | fn = file_table[last_file_lookup_index]; | |
7540 | if (strcmp (file_name, fn) == 0) | |
7541 | { | |
7542 | return last_file_lookup_index; | |
7543 | } | |
7544 | } | |
7545 | ||
7546 | /* Didn't match the previous lookup, search the table */ | |
7547 | for (i = 1; i < file_table_in_use; ++i) | |
7548 | { | |
7549 | fn = file_table[i]; | |
7550 | if (strcmp (file_name, fn) == 0) | |
7551 | { | |
7552 | last_file_lookup_index = i; | |
7553 | return i; | |
7554 | } | |
7555 | } | |
7556 | ||
7557 | /* Prepare to add a new table entry by making sure there is enough space in | |
7558 | the table to do so. If not, expand the current table. */ | |
7559 | if (file_table_in_use == file_table_allocated) | |
7560 | { | |
7561 | file_table_allocated += FILE_TABLE_INCREMENT; | |
7562 | file_table | |
7563 | = (char **) | |
7564 | xrealloc (file_table, file_table_allocated * sizeof (char *)); | |
7565 | } | |
7566 | ||
7567 | /* add the new entry to the end of the filename table. */ | |
7568 | file_table[file_table_in_use] = xstrdup (file_name); | |
7569 | last_file_lookup_index = file_table_in_use++; | |
7570 | return last_file_lookup_index; | |
7571 | } | |
7572 | ||
7573 | /* Output a label to mark the beginning of a source code line entry | |
7574 | and record information relating to this source line, in | |
7575 | 'line_info_table' for later output of the .debug_line section. */ | |
7576 | void | |
7577 | dwarfout_line (filename, line) | |
7578 | register char *filename; | |
7579 | register unsigned line; | |
7580 | { | |
7581 | char label[MAX_ARTIFICIAL_LABEL_BYTES]; | |
7582 | register unsigned this_file_entry_num = lookup_filename (filename); | |
7583 | register dw_line_info_ref line_info; | |
7584 | if (debug_info_level >= DINFO_LEVEL_NORMAL) | |
7585 | { | |
7586 | function_section (current_function_decl); | |
7587 | sprintf (label, LINE_CODE_LABEL_FMT, line_info_table_in_use); | |
7588 | ASM_OUTPUT_LABEL (asm_out_file, label); | |
7589 | fputc ('\n', asm_out_file); | |
7590 | ||
7591 | /* expand the line info table if necessary */ | |
7592 | if (line_info_table_in_use == line_info_table_allocated) | |
7593 | { | |
7594 | line_info_table_allocated += LINE_INFO_TABLE_INCREMENT; | |
7595 | line_info_table | |
7596 | = (dw_line_info_ref) | |
7597 | xrealloc (line_info_table, | |
7598 | line_info_table_allocated * sizeof (dw_line_info_entry)); | |
7599 | } | |
7600 | /* add the new entry at the end of the line_info_table. */ | |
7601 | line_info = &line_info_table[line_info_table_in_use++]; | |
7602 | line_info->dw_file_num = lookup_filename (filename); | |
7603 | line_info->dw_line_num = line; | |
7604 | } | |
7605 | } | |
7606 | ||
7607 | /* Record the beginning of a new source file, for later output | |
7608 | of the .debug_macinfo section. At present, unimplemented. */ | |
7609 | void | |
7610 | dwarfout_start_new_source_file (filename) | |
7611 | register char *filename; | |
7612 | { | |
7613 | } | |
7614 | ||
7615 | /* Record the resumption of a source file, for later output | |
7616 | of the .debug_macinfo section. At present, unimplemented. */ | |
7617 | void | |
7618 | dwarfout_resume_previous_source_file (lineno) | |
7619 | register unsigned lineno; | |
7620 | { | |
7621 | } | |
7622 | ||
7623 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
7624 | the tail part of the directive line, i.e. the part which is past the | |
7625 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
7626 | void | |
7627 | dwarfout_define (lineno, buffer) | |
7628 | register unsigned lineno; | |
7629 | register char *buffer; | |
7630 | { | |
7631 | static int initialized = 0; | |
7632 | if (!initialized) | |
7633 | { | |
7634 | dwarfout_start_new_source_file (primary_filename); | |
7635 | initialized = 1; | |
7636 | } | |
7637 | } | |
7638 | ||
7639 | /* Called from check_newline in c-parse.y. The `buffer' parameter contains | |
7640 | the tail part of the directive line, i.e. the part which is past the | |
7641 | initial whitespace, #, whitespace, directive-name, whitespace part. */ | |
7642 | void | |
7643 | dwarfout_undef (lineno, buffer) | |
7644 | register unsigned lineno; | |
7645 | register char *buffer; | |
7646 | { | |
7647 | } | |
7648 | ||
7649 | /* Set up for Dwarf output at the start of compilation. */ | |
7650 | void | |
7651 | dwarfout_init (asm_out_file, main_input_filename) | |
7652 | register FILE *asm_out_file; | |
7653 | register char *main_input_filename; | |
7654 | { | |
7655 | ||
7656 | /* Remember the name of the primary input file. */ | |
7657 | primary_filename = main_input_filename; | |
7658 | ||
7659 | /* Allocate the initial hunk of the file_table. */ | |
7660 | file_table = (char **) xmalloc (FILE_TABLE_INCREMENT * sizeof (char *)); | |
7661 | bzero (file_table, FILE_TABLE_INCREMENT * sizeof (char *)); | |
7662 | file_table_allocated = FILE_TABLE_INCREMENT; | |
7663 | /* skip the first entry - file numbers begin at 1 */ | |
7664 | file_table_in_use = 1; | |
7665 | ||
7666 | /* Allocate the initial hunk of the type_die_table. */ | |
7667 | type_die_table | |
7668 | = (dw_die_ref *) xmalloc (TYPE_DIE_TABLE_INCREMENT * sizeof (dw_die_ref)); | |
7669 | bzero (type_die_table, TYPE_DIE_TABLE_INCREMENT * sizeof (dw_die_ref)); | |
7670 | type_die_table_allocated = TYPE_DIE_TABLE_INCREMENT; | |
7671 | type_die_table_in_use = 0; | |
7672 | ||
7673 | /* Allocate the initial hunk of the decl_die_table. */ | |
7674 | decl_die_table | |
7675 | = (dw_die_ref *) xmalloc (DECL_DIE_TABLE_INCREMENT * sizeof (dw_die_ref)); | |
7676 | bzero (decl_die_table, DECL_DIE_TABLE_INCREMENT * sizeof (dw_die_ref)); | |
7677 | decl_die_table_allocated = DECL_DIE_TABLE_INCREMENT; | |
7678 | decl_die_table_in_use = 0; | |
7679 | ||
7680 | /* Allocate the initial hunk of the decl_scope_table. */ | |
7681 | decl_scope_table | |
7682 | = (tree *) xmalloc (DECL_SCOPE_TABLE_INCREMENT * sizeof (tree)); | |
7683 | bzero (decl_scope_table, DECL_SCOPE_TABLE_INCREMENT * sizeof (tree)); | |
7684 | decl_scope_table_allocated = DECL_SCOPE_TABLE_INCREMENT; | |
7685 | decl_scope_depth = 0; | |
7686 | ||
7687 | /* Allocate the initial hunk of the abbrev_die_table. */ | |
7688 | abbrev_die_table | |
7689 | = (dw_die_ref *) xmalloc (ABBREV_DIE_TABLE_INCREMENT | |
7690 | * sizeof (dw_die_ref)); | |
7691 | bzero (abbrev_die_table, ABBREV_DIE_TABLE_INCREMENT * sizeof (dw_die_ref)); | |
7692 | abbrev_die_table_allocated = ABBREV_DIE_TABLE_INCREMENT; | |
7693 | /* zero-th entry is allocated, but unused */ | |
7694 | abbrev_die_table_in_use = 1; | |
7695 | ||
7696 | /* Allocate the initial hunk of the line_info_table. */ | |
7697 | line_info_table | |
7698 | = (dw_line_info_ref) xmalloc (LINE_INFO_TABLE_INCREMENT | |
7699 | * sizeof (dw_line_info_entry)); | |
7700 | bzero (line_info_table, LINE_INFO_TABLE_INCREMENT | |
7701 | * sizeof (dw_line_info_entry)); | |
7702 | line_info_table_allocated = LINE_INFO_TABLE_INCREMENT; | |
7703 | /* zero-th entry is allocated, but unused */ | |
7704 | line_info_table_in_use = 1; | |
7705 | ||
7706 | /* Allocate the initial hunk of the fde_table. */ | |
7707 | fde_table = (dw_fde_ref) xmalloc (FDE_TABLE_INCREMENT * sizeof (dw_fde_node)); | |
7708 | bzero (fde_table, FDE_TABLE_INCREMENT * sizeof (dw_fde_node)); | |
7709 | fde_table_allocated = FDE_TABLE_INCREMENT; | |
7710 | fde_table_in_use = 0; | |
7711 | ||
bdb669cb | 7712 | #if 0 |
a3f97cbb JW |
7713 | /* Output a starting label for the .text section. */ |
7714 | fputc ('\n', asm_out_file); | |
7715 | ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION); | |
7716 | ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL); | |
7717 | ||
7718 | /* Output a starting label for the .data section. */ | |
7719 | fputc ('\n', asm_out_file); | |
7720 | ASM_OUTPUT_SECTION (asm_out_file, DATA_SECTION); | |
7721 | ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL); | |
7722 | ||
7723 | /* Output a starting label for the .rodata section. */ | |
7724 | fputc ('\n', asm_out_file); | |
7725 | ASM_OUTPUT_SECTION (asm_out_file, RODATA_SECTION); | |
7726 | ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL); | |
7727 | ||
7728 | /* Output a starting label for the .bss section. */ | |
7729 | fputc ('\n', asm_out_file); | |
7730 | ASM_OUTPUT_SECTION (asm_out_file, BSS_SECTION); | |
7731 | ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL); | |
bdb669cb | 7732 | #endif |
a3f97cbb JW |
7733 | |
7734 | /* Generate the initial DIE for the .debug section. Note that the (string) | |
7735 | value given in the DW_AT_name attribute of the DW_TAG_compile_unit DIE | |
7736 | will (typically) be a relative pathname and that this pathname should be | |
7737 | taken as being relative to the directory from which the compiler was | |
7738 | invoked when the given (base) source file was compiled. */ | |
7739 | gen_compile_unit_die (main_input_filename); | |
7740 | ||
7741 | /* clear the association between base types and their DIE's */ | |
7742 | init_base_type_table (); | |
a3f97cbb JW |
7743 | } |
7744 | ||
7745 | /* Output stuff that dwarf requires at the end of every file, | |
7746 | and generate the DWARF-2 debugging info. */ | |
7747 | void | |
7748 | dwarfout_finish () | |
7749 | { | |
a3f97cbb JW |
7750 | /* Traverse the DIE tree and add sibling attributes to those DIE's |
7751 | that have children. */ | |
7752 | add_sibling_attributes (comp_unit_die); | |
7753 | ||
7754 | /* Output a terminator label for the .text section. */ | |
7755 | fputc ('\n', asm_out_file); | |
7756 | ASM_OUTPUT_SECTION (asm_out_file, TEXT_SECTION); | |
7757 | ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL); | |
7758 | ||
bdb669cb | 7759 | #if 0 |
a3f97cbb JW |
7760 | /* Output a terminator label for the .data section. */ |
7761 | fputc ('\n', asm_out_file); | |
7762 | ASM_OUTPUT_SECTION (asm_out_file, DATA_SECTION); | |
7763 | ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL); | |
7764 | ||
7765 | /* Output a terminator label for the .rodata section. */ | |
7766 | fputc ('\n', asm_out_file); | |
7767 | ASM_OUTPUT_SECTION (asm_out_file, RODATA_SECTION); | |
7768 | ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL); | |
7769 | ||
7770 | /* Output a terminator label for the .bss section. */ | |
7771 | fputc ('\n', asm_out_file); | |
7772 | ASM_OUTPUT_SECTION (asm_out_file, BSS_SECTION); | |
7773 | ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL); | |
bdb669cb | 7774 | #endif |
a3f97cbb JW |
7775 | |
7776 | /* Output the abbreviation table. */ | |
7777 | fputc ('\n', asm_out_file); | |
7778 | ASM_OUTPUT_SECTION (asm_out_file, ABBREV_SECTION); | |
7779 | build_abbrev_table (comp_unit_die); | |
7780 | output_abbrev_section (); | |
7781 | ||
7782 | /* Output the source line correspondence table. */ | |
7783 | fputc ('\n', asm_out_file); | |
7784 | ASM_OUTPUT_SECTION (asm_out_file, LINE_SECTION); | |
7785 | output_line_info (); | |
7786 | ||
7787 | /* Initialize the beginning DIE offset - and calculate sizes/offsets. */ | |
7788 | next_die_offset = DWARF_COMPILE_UNIT_HEADER_SIZE; | |
7789 | calc_die_sizes (comp_unit_die); | |
7790 | ||
7791 | /* Initialize the beginning FDE offset - and calculate sizes/offsets. */ | |
7792 | next_fde_offset = DWARF_CIE_SIZE; | |
7793 | calc_fde_sizes (); | |
7794 | ||
7795 | /* Output debugging information. */ | |
7796 | fputc ('\n', asm_out_file); | |
7797 | ASM_OUTPUT_SECTION (asm_out_file, DEBUG_SECTION); | |
7798 | output_compilation_unit_header (); | |
7799 | output_die (comp_unit_die); | |
7800 | ||
7801 | if (fde_table_in_use) | |
7802 | { | |
7803 | /* Output call frame information. */ | |
7804 | fputc ('\n', asm_out_file); | |
7805 | ASM_OUTPUT_SECTION (asm_out_file, FRAME_SECTION); | |
7806 | output_call_frame_info (); | |
7807 | ||
7808 | /* Output public names table. */ | |
7809 | fputc ('\n', asm_out_file); | |
7810 | ASM_OUTPUT_SECTION (asm_out_file, PUBNAMES_SECTION); | |
7811 | output_pubnames (); | |
7812 | ||
7813 | /* Output the address range information. */ | |
7814 | fputc ('\n', asm_out_file); | |
7815 | ASM_OUTPUT_SECTION (asm_out_file, ARANGES_SECTION); | |
7816 | output_aranges (); | |
7817 | } | |
7818 | } | |
7819 | #endif /* DWARF_DEBUGGING_INFO && DWARF_VERSION == 2 */ |