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