]> gcc.gnu.org Git - gcc.git/blob - gcc/dwarfout.c
Daily bump.
[gcc.git] / gcc / dwarfout.c
1 /* Output Dwarf format symbol table information from the GNU C compiler.
2 Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998,
3 1999, 2000, 2001 Free Software Foundation, Inc.
4 Contributed by Ron Guilmette (rfg@monkeys.com) of Network Computing Devices.
5
6 This file is part of GCC.
7
8 GCC is free software; you can redistribute it and/or modify it under
9 the terms of the GNU General Public License as published by the Free
10 Software Foundation; either version 2, or (at your option) any later
11 version.
12
13 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
14 WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
16 for more details.
17
18 You should have received a copy of the GNU General Public License
19 along with GCC; see the file COPYING. If not, write to the Free
20 Software Foundation, 59 Temple Place - Suite 330, Boston, MA
21 02111-1307, USA. */
22
23 /*
24
25 Notes on the GNU Implementation of DWARF Debugging Information
26 --------------------------------------------------------------
27 Last Major Update: Sun Jul 17 08:17:42 PDT 1994 by rfg@segfault.us.com
28 ------------------------------------------------------------
29
30 This file describes special and unique aspects of the GNU implementation of
31 the DWARF Version 1 debugging information language, as provided in the GNU
32 version 2.x compiler(s).
33
34 For general information about the DWARF debugging information language,
35 you should obtain the DWARF version 1.1 specification document (and perhaps
36 also the DWARF version 2 draft specification document) developed by the
37 (now defunct) UNIX International Programming Languages Special Interest Group.
38
39 To obtain a copy of the DWARF Version 1 and/or DWARF Version 2
40 specification, visit the web page for the DWARF Version 2 committee, at
41
42 http://www.eagercon.com/dwarf/dwarf2std.htm
43
44 The generation of DWARF debugging information by the GNU version 2.x C
45 compiler has now been tested rather extensively for m88k, i386, i860, and
46 Sparc targets. The DWARF output of the GNU C compiler appears to inter-
47 operate well with the standard SVR4 SDB debugger on these kinds of target
48 systems (but of course, there are no guarantees).
49
50 DWARF 1 generation for the GNU g++ compiler is implemented, but limited.
51 C++ users should definitely use DWARF 2 instead.
52
53 Future plans for the dwarfout.c module of the GNU compiler(s) includes the
54 addition of full support for GNU FORTRAN. (This should, in theory, be a
55 lot simpler to add than adding support for g++... but we'll see.)
56
57 Many features of the DWARF version 2 specification have been adapted to
58 (and used in) the GNU implementation of DWARF (version 1). In most of
59 these cases, a DWARF version 2 approach is used in place of (or in addition
60 to) DWARF version 1 stuff simply because it is apparent that DWARF version
61 1 is not sufficiently expressive to provide the kinds of information which
62 may be necessary to support really robust debugging. In all of these cases
63 however, the use of DWARF version 2 features should not interfere in any
64 way with the interoperability (of GNU compilers) with generally available
65 "classic" (pre version 1) DWARF consumer tools (e.g. SVR4 SDB).
66
67 The DWARF generation enhancement for the GNU compiler(s) was initially
68 donated to the Free Software Foundation by Network Computing Devices.
69 (Thanks NCD!) Additional development and maintenance of dwarfout.c has
70 been largely supported (i.e. funded) by Intel Corporation. (Thanks Intel!)
71
72 If you have questions or comments about the DWARF generation feature, please
73 send mail to me <rfg@netcom.com>. I will be happy to investigate any bugs
74 reported and I may even provide fixes (but of course, I can make no promises).
75
76 The DWARF debugging information produced by GCC may deviate in a few minor
77 (but perhaps significant) respects from the DWARF debugging information
78 currently produced by other C compilers. A serious attempt has been made
79 however to conform to the published specifications, to existing practice,
80 and to generally accepted norms in the GNU implementation of DWARF.
81
82 ** IMPORTANT NOTE ** ** IMPORTANT NOTE ** ** IMPORTANT NOTE **
83
84 Under normal circumstances, the DWARF information generated by the GNU
85 compilers (in an assembly language file) is essentially impossible for
86 a human being to read. This fact can make it very difficult to debug
87 certain DWARF-related problems. In order to overcome this difficulty,
88 a feature has been added to dwarfout.c (enabled by the -dA
89 option) which causes additional comments to be placed into the assembly
90 language output file, out to the right-hand side of most bits of DWARF
91 material. The comments indicate (far more clearly that the obscure
92 DWARF hex codes do) what is actually being encoded in DWARF. Thus, the
93 -dA option can be highly useful for those who must study the
94 DWARF output from the GNU compilers in detail.
95
96 ---------
97
98 (Footnote: Within this file, the term `Debugging Information Entry' will
99 be abbreviated as `DIE'.)
100
101
102 Release Notes (aka known bugs)
103 -------------------------------
104
105 In one very obscure case involving dynamically sized arrays, the DWARF
106 "location information" for such an array may make it appear that the
107 array has been totally optimized out of existence, when in fact it
108 *must* actually exist. (This only happens when you are using *both* -g
109 *and* -O.) This is due to aggressive dead store elimination in the
110 compiler, and to the fact that the DECL_RTL expressions associated with
111 variables are not always updated to correctly reflect the effects of
112 GCC's aggressive dead store elimination.
113
114 -------------------------------
115
116 When attempting to set a breakpoint at the "start" of a function compiled
117 with -g1, the debugger currently has no way of knowing exactly where the
118 end of the prologue code for the function is. Thus, for most targets,
119 all the debugger can do is to set the breakpoint at the AT_low_pc address
120 for the function. But if you stop there and then try to look at one or
121 more of the formal parameter values, they may not have been "homed" yet,
122 so you may get inaccurate answers (or perhaps even addressing errors).
123
124 Some people may consider this simply a non-feature, but I consider it a
125 bug, and I hope to provide some GNU-specific attributes (on function
126 DIEs) which will specify the address of the end of the prologue and the
127 address of the beginning of the epilogue in a future release.
128
129 -------------------------------
130
131 It is believed at this time that old bugs relating to the AT_bit_offset
132 values for bit-fields have been fixed.
133
134 There may still be some very obscure bugs relating to the DWARF description
135 of type `long long' bit-fields for target machines (e.g. 80x86 machines)
136 where the alignment of type `long long' data objects is different from
137 (and less than) the size of a type `long long' data object.
138
139 Please report any problems with the DWARF description of bit-fields as you
140 would any other GCC bug. (Procedures for bug reporting are given in the
141 GNU C compiler manual.)
142
143 --------------------------------
144
145 At this time, GCC does not know how to handle the GNU C "nested functions"
146 extension. (See the GCC manual for more info on this extension to ANSI C.)
147
148 --------------------------------
149
150 The GNU compilers now represent inline functions (and inlined instances
151 thereof) in exactly the manner described by the current DWARF version 2
152 (draft) specification. The version 1 specification for handling inline
153 functions (and inlined instances) was known to be brain-damaged (by the
154 PLSIG) when the version 1 spec was finalized, but it was simply too late
155 in the cycle to get it removed before the version 1 spec was formally
156 released to the public (by UI).
157
158 --------------------------------
159
160 At this time, GCC does not generate the kind of really precise information
161 about the exact declared types of entities with signed integral types which
162 is required by the current DWARF draft specification.
163
164 Specifically, the current DWARF draft specification seems to require that
165 the type of an non-unsigned integral bit-field member of a struct or union
166 type be represented as either a "signed" type or as a "plain" type,
167 depending upon the exact set of keywords that were used in the
168 type specification for the given bit-field member. It was felt (by the
169 UI/PLSIG) that this distinction between "plain" and "signed" integral types
170 could have some significance (in the case of bit-fields) because ANSI C
171 does not constrain the signedness of a plain bit-field, whereas it does
172 constrain the signedness of an explicitly "signed" bit-field. For this
173 reason, the current DWARF specification calls for compilers to produce
174 type information (for *all* integral typed entities... not just bit-fields)
175 which explicitly indicates the signedness of the relevant type to be
176 "signed" or "plain" or "unsigned".
177
178 Unfortunately, the GNU DWARF implementation is currently incapable of making
179 such distinctions.
180
181 --------------------------------
182
183
184 Known Interoperability Problems
185 -------------------------------
186
187 Although the GNU implementation of DWARF conforms (for the most part) with
188 the current UI/PLSIG DWARF version 1 specification (with many compatible
189 version 2 features added in as "vendor specific extensions" just for good
190 measure) there are a few known cases where GCC's DWARF output can cause
191 some confusion for "classic" (pre version 1) DWARF consumers such as the
192 System V Release 4 SDB debugger. These cases are described in this section.
193
194 --------------------------------
195
196 The DWARF version 1 specification includes the fundamental type codes
197 FT_ext_prec_float, FT_complex, FT_dbl_prec_complex, and FT_ext_prec_complex.
198 Since GNU C is only a C compiler (and since C doesn't provide any "complex"
199 data types) the only one of these fundamental type codes which GCC ever
200 generates is FT_ext_prec_float. This fundamental type code is generated
201 by GCC for the `long double' data type. Unfortunately, due to an apparent
202 bug in the SVR4 SDB debugger, SDB can become very confused wherever any
203 attempt is made to print a variable, parameter, or field whose type was
204 given in terms of FT_ext_prec_float.
205
206 (Actually, SVR4 SDB fails to understand *any* of the four fundamental type
207 codes mentioned here. This will fact will cause additional problems when
208 there is a GNU FORTRAN front-end.)
209
210 --------------------------------
211
212 In general, it appears that SVR4 SDB is not able to effectively ignore
213 fundamental type codes in the "implementation defined" range. This can
214 cause problems when a program being debugged uses the `long long' data
215 type (or the signed or unsigned varieties thereof) because these types
216 are not defined by ANSI C, and thus, GCC must use its own private fundamental
217 type codes (from the implementation-defined range) to represent these types.
218
219 --------------------------------
220
221
222 General GNU DWARF extensions
223 ----------------------------
224
225 In the current DWARF version 1 specification, no mechanism is specified by
226 which accurate information about executable code from include files can be
227 properly (and fully) described. (The DWARF version 2 specification *does*
228 specify such a mechanism, but it is about 10 times more complicated than
229 it needs to be so I'm not terribly anxious to try to implement it right
230 away.)
231
232 In the GNU implementation of DWARF version 1, a fully downward-compatible
233 extension has been implemented which permits the GNU compilers to specify
234 which executable lines come from which files. This extension places
235 additional information (about source file names) in GNU-specific sections
236 (which should be totally ignored by all non-GNU DWARF consumers) so that
237 this extended information can be provided (to GNU DWARF consumers) in a way
238 which is totally transparent (and invisible) to non-GNU DWARF consumers
239 (e.g. the SVR4 SDB debugger). The additional information is placed *only*
240 in specialized GNU-specific sections, where it should never even be seen
241 by non-GNU DWARF consumers.
242
243 To understand this GNU DWARF extension, imagine that the sequence of entries
244 in the .lines section is broken up into several subsections. Each contiguous
245 sequence of .line entries which relates to a sequence of lines (or statements)
246 from one particular file (either a `base' file or an `include' file) could
247 be called a `line entries chunk' (LEC).
248
249 For each LEC there is one entry in the .debug_srcinfo section.
250
251 Each normal entry in the .debug_srcinfo section consists of two 4-byte
252 words of data as follows:
253
254 (1) The starting address (relative to the entire .line section)
255 of the first .line entry in the relevant LEC.
256
257 (2) The starting address (relative to the entire .debug_sfnames
258 section) of a NUL terminated string representing the
259 relevant filename. (This filename name be either a
260 relative or an absolute filename, depending upon how the
261 given source file was located during compilation.)
262
263 Obviously, each .debug_srcinfo entry allows you to find the relevant filename,
264 and it also points you to the first .line entry that was generated as a result
265 of having compiled a given source line from the given source file.
266
267 Each subsequent .line entry should also be assumed to have been produced
268 as a result of compiling yet more lines from the same file. The end of
269 any given LEC is easily found by looking at the first 4-byte pointer in
270 the *next* .debug_srcinfo entry. That next .debug_srcinfo entry points
271 to a new and different LEC, so the preceding LEC (implicitly) must have
272 ended with the last .line section entry which occurs at the 2 1/2 words
273 just before the address given in the first pointer of the new .debug_srcinfo
274 entry.
275
276 The following picture may help to clarify this feature. Let's assume that
277 `LE' stands for `.line entry'. Also, assume that `* 'stands for a pointer.
278
279
280 .line section .debug_srcinfo section .debug_sfnames section
281 ----------------------------------------------------------------
282
283 LE <---------------------- *
284 LE * -----------------> "foobar.c" <---
285 LE |
286 LE |
287 LE <---------------------- * |
288 LE * -----------------> "foobar.h" <| |
289 LE | |
290 LE | |
291 LE <---------------------- * | |
292 LE * -----------------> "inner.h" | |
293 LE | |
294 LE <---------------------- * | |
295 LE * ------------------------------- |
296 LE |
297 LE |
298 LE |
299 LE |
300 LE <---------------------- * |
301 LE * -----------------------------------
302 LE
303 LE
304 LE
305
306 In effect, each entry in the .debug_srcinfo section points to *both* a
307 filename (in the .debug_sfnames section) and to the start of a block of
308 consecutive LEs (in the .line section).
309
310 Note that just like in the .line section, there are specialized first and
311 last entries in the .debug_srcinfo section for each object file. These
312 special first and last entries for the .debug_srcinfo section are very
313 different from the normal .debug_srcinfo section entries. They provide
314 additional information which may be helpful to a debugger when it is
315 interpreting the data in the .debug_srcinfo, .debug_sfnames, and .line
316 sections.
317
318 The first entry in the .debug_srcinfo section for each compilation unit
319 consists of five 4-byte words of data. The contents of these five words
320 should be interpreted (by debuggers) as follows:
321
322 (1) The starting address (relative to the entire .line section)
323 of the .line section for this compilation unit.
324
325 (2) The starting address (relative to the entire .debug_sfnames
326 section) of the .debug_sfnames section for this compilation
327 unit.
328
329 (3) The starting address (in the execution virtual address space)
330 of the .text section for this compilation unit.
331
332 (4) The ending address plus one (in the execution virtual address
333 space) of the .text section for this compilation unit.
334
335 (5) The date/time (in seconds since midnight 1/1/70) at which the
336 compilation of this compilation unit occurred. This value
337 should be interpreted as an unsigned quantity because gcc
338 might be configured to generate a default value of 0xffffffff
339 in this field (in cases where it is desired to have object
340 files created at different times from identical source files
341 be byte-for-byte identical). By default, these timestamps
342 are *not* generated by dwarfout.c (so that object files
343 compiled at different times will be byte-for-byte identical).
344 If you wish to enable this "timestamp" feature however, you
345 can simply place a #define for the symbol `DWARF_TIMESTAMPS'
346 in your target configuration file and then rebuild the GNU
347 compiler(s).
348
349 Note that the first string placed into the .debug_sfnames section for each
350 compilation unit is the name of the directory in which compilation occurred.
351 This string ends with a `/' (to help indicate that it is the pathname of a
352 directory). Thus, the second word of each specialized initial .debug_srcinfo
353 entry for each compilation unit may be used as a pointer to the (string)
354 name of the compilation directory, and that string may in turn be used to
355 "absolutize" any relative pathnames which may appear later on in the
356 .debug_sfnames section entries for the same compilation unit.
357
358 The fifth and last word of each specialized starting entry for a compilation
359 unit in the .debug_srcinfo section may (depending upon your configuration)
360 indicate the date/time of compilation, and this may be used (by a debugger)
361 to determine if any of the source files which contributed code to this
362 compilation unit are newer than the object code for the compilation unit
363 itself. If so, the debugger may wish to print an "out-of-date" warning
364 about the compilation unit.
365
366 The .debug_srcinfo section associated with each compilation will also have
367 a specialized terminating entry. This terminating .debug_srcinfo section
368 entry will consist of the following two 4-byte words of data:
369
370 (1) The offset, measured from the start of the .line section to
371 the beginning of the terminating entry for the .line section.
372
373 (2) A word containing the value 0xffffffff.
374
375 --------------------------------
376
377 In the current DWARF version 1 specification, no mechanism is specified by
378 which information about macro definitions and un-definitions may be provided
379 to the DWARF consumer.
380
381 The DWARF version 2 (draft) specification does specify such a mechanism.
382 That specification was based on the GNU ("vendor specific extension")
383 which provided some support for macro definitions and un-definitions,
384 but the "official" DWARF version 2 (draft) specification mechanism for
385 handling macros and the GNU implementation have diverged somewhat. I
386 plan to update the GNU implementation to conform to the "official"
387 DWARF version 2 (draft) specification as soon as I get time to do that.
388
389 Note that in the GNU implementation, additional information about macro
390 definitions and un-definitions is *only* provided when the -g3 level of
391 debug-info production is selected. (The default level is -g2 and the
392 plain old -g option is considered to be identical to -g2.)
393
394 GCC records information about macro definitions and undefinitions primarily
395 in a section called the .debug_macinfo section. Normal entries in the
396 .debug_macinfo section consist of the following three parts:
397
398 (1) A special "type" byte.
399
400 (2) A 3-byte line-number/filename-offset field.
401
402 (3) A NUL terminated string.
403
404 The interpretation of the second and third parts is dependent upon the
405 value of the leading (type) byte.
406
407 The type byte may have one of four values depending upon the type of the
408 .debug_macinfo entry which follows. The 1-byte MACINFO type codes presently
409 used, and their meanings are as follows:
410
411 MACINFO_start A base file or an include file starts here.
412 MACINFO_resume The current base or include file ends here.
413 MACINFO_define A #define directive occurs here.
414 MACINFO_undef A #undef directive occur here.
415
416 (Note that the MACINFO_... codes mentioned here are simply symbolic names
417 for constants which are defined in the GNU dwarf.h file.)
418
419 For MACINFO_define and MACINFO_undef entries, the second (3-byte) field
420 contains the number of the source line (relative to the start of the current
421 base source file or the current include files) when the #define or #undef
422 directive appears. For a MACINFO_define entry, the following string field
423 contains the name of the macro which is defined, followed by its definition.
424 Note that the definition is always separated from the name of the macro
425 by at least one whitespace character. For a MACINFO_undef entry, the
426 string which follows the 3-byte line number field contains just the name
427 of the macro which is being undef'ed.
428
429 For a MACINFO_start entry, the 3-byte field following the type byte contains
430 the offset, relative to the start of the .debug_sfnames section for the
431 current compilation unit, of a string which names the new source file which
432 is beginning its inclusion at this point. Following that 3-byte field,
433 each MACINFO_start entry always contains a zero length NUL terminated
434 string.
435
436 For a MACINFO_resume entry, the 3-byte field following the type byte contains
437 the line number WITHIN THE INCLUDING FILE at which the inclusion of the
438 current file (whose inclusion ends here) was initiated. Following that
439 3-byte field, each MACINFO_resume entry always contains a zero length NUL
440 terminated string.
441
442 Each set of .debug_macinfo entries for each compilation unit is terminated
443 by a special .debug_macinfo entry consisting of a 4-byte zero value followed
444 by a single NUL byte.
445
446 --------------------------------
447
448 In the current DWARF draft specification, no provision is made for providing
449 a separate level of (limited) debugging information necessary to support
450 tracebacks (only) through fully-debugged code (e.g. code in system libraries).
451
452 A proposal to define such a level was submitted (by me) to the UI/PLSIG.
453 This proposal was rejected by the UI/PLSIG for inclusion into the DWARF
454 version 1 specification for two reasons. First, it was felt (by the PLSIG)
455 that the issues involved in supporting a "traceback only" subset of DWARF
456 were not well understood. Second, and perhaps more importantly, the PLSIG
457 is already having enough trouble agreeing on what it means to be "conforming"
458 to the DWARF specification, and it was felt that trying to specify multiple
459 different *levels* of conformance would only complicate our discussions of
460 this already divisive issue. Nonetheless, the GNU implementation of DWARF
461 provides an abbreviated "traceback only" level of debug-info production for
462 use with fully-debugged "system library" code. This level should only be
463 used for fully debugged system library code, and even then, it should only
464 be used where there is a very strong need to conserve disk space. This
465 abbreviated level of debug-info production can be used by specifying the
466 -g1 option on the compilation command line.
467
468 --------------------------------
469
470 As mentioned above, the GNU implementation of DWARF currently uses the DWARF
471 version 2 (draft) approach for inline functions (and inlined instances
472 thereof). This is used in preference to the version 1 approach because
473 (quite simply) the version 1 approach is highly brain-damaged and probably
474 unworkable.
475
476 --------------------------------
477
478
479 GNU DWARF Representation of GNU C Extensions to ANSI C
480 ------------------------------------------------------
481
482 The file dwarfout.c has been designed and implemented so as to provide
483 some reasonable DWARF representation for each and every declarative
484 construct which is accepted by the GNU C compiler. Since the GNU C
485 compiler accepts a superset of ANSI C, this means that there are some
486 cases in which the DWARF information produced by GCC must take some
487 liberties in improvising DWARF representations for declarations which
488 are only valid in (extended) GNU C.
489
490 In particular, GNU C provides at least three significant extensions to
491 ANSI C when it comes to declarations. These are (1) inline functions,
492 and (2) dynamic arrays, and (3) incomplete enum types. (See the GCC
493 manual for more information on these GNU extensions to ANSI C.) When
494 used, these GNU C extensions are represented (in the generated DWARF
495 output of GCC) in the most natural and intuitively obvious ways.
496
497 In the case of inline functions, the DWARF representation is exactly as
498 called for in the DWARF version 2 (draft) specification for an identical
499 function written in C++; i.e. we "reuse" the representation of inline
500 functions which has been defined for C++ to support this GNU C extension.
501
502 In the case of dynamic arrays, we use the most obvious representational
503 mechanism available; i.e. an array type in which the upper bound of
504 some dimension (usually the first and only dimension) is a variable
505 rather than a constant. (See the DWARF version 1 specification for more
506 details.)
507
508 In the case of incomplete enum types, such types are represented simply
509 as TAG_enumeration_type DIEs which DO NOT contain either AT_byte_size
510 attributes or AT_element_list attributes.
511
512 --------------------------------
513
514
515 Future Directions
516 -----------------
517
518 The codes, formats, and other paraphernalia necessary to provide proper
519 support for symbolic debugging for the C++ language are still being worked
520 on by the UI/PLSIG. The vast majority of the additions to DWARF which will
521 be needed to completely support C++ have already been hashed out and agreed
522 upon, but a few small issues (e.g. anonymous unions, access declarations)
523 are still being discussed. Also, we in the PLSIG are still discussing
524 whether or not we need to do anything special for C++ templates. (At this
525 time it is not yet clear whether we even need to do anything special for
526 these.)
527
528 With regard to FORTRAN, the UI/PLSIG has defined what is believed to be a
529 complete and sufficient set of codes and rules for adequately representing
530 all of FORTRAN 77, and most of Fortran 90 in DWARF. While some support for
531 this has been implemented in dwarfout.c, further implementation and testing
532 is needed.
533
534 GNU DWARF support for other languages (i.e. Pascal and Modula) is a moot
535 issue until there are GNU front-ends for these other languages.
536
537 As currently defined, DWARF only describes a (binary) language which can
538 be used to communicate symbolic debugging information from a compiler
539 through an assembler and a linker, to a debugger. There is no clear
540 specification of what processing should be (or must be) done by the
541 assembler and/or the linker. Fortunately, the role of the assembler
542 is easily inferred (by anyone knowledgeable about assemblers) just by
543 looking at examples of assembly-level DWARF code. Sadly though, the
544 allowable (or required) processing steps performed by a linker are
545 harder to infer and (perhaps) even harder to agree upon. There are
546 several forms of very useful `post-processing' steps which intelligent
547 linkers *could* (in theory) perform on object files containing DWARF,
548 but any and all such link-time transformations are currently both disallowed
549 and unspecified.
550
551 In particular, possible link-time transformations of DWARF code which could
552 provide significant benefits include (but are not limited to):
553
554 Commonization of duplicate DIEs obtained from multiple input
555 (object) files.
556
557 Cross-compilation type checking based upon DWARF type information
558 for objects and functions.
559
560 Other possible `compacting' transformations designed to save disk
561 space and to reduce linker & debugger I/O activity.
562
563 */
564
565 #include "config.h"
566
567 #ifdef DWARF_DEBUGGING_INFO
568 #include "system.h"
569 #include "dwarf.h"
570 #include "tree.h"
571 #include "flags.h"
572 #include "rtl.h"
573 #include "hard-reg-set.h"
574 #include "insn-config.h"
575 #include "reload.h"
576 #include "output.h"
577 #include "dwarf2asm.h"
578 #include "toplev.h"
579 #include "tm_p.h"
580 #include "debug.h"
581 #include "langhooks.h"
582
583 /* NOTE: In the comments in this file, many references are made to
584 so called "Debugging Information Entries". For the sake of brevity,
585 this term is abbreviated to `DIE' throughout the remainder of this
586 file. */
587
588 /* Note that the implementation of C++ support herein is (as yet) unfinished.
589 If you want to try to complete it, more power to you. */
590
591 /* How to start an assembler comment. */
592 #ifndef ASM_COMMENT_START
593 #define ASM_COMMENT_START ";#"
594 #endif
595
596 /* How to print out a register name. */
597 #ifndef PRINT_REG
598 #define PRINT_REG(RTX, CODE, FILE) \
599 fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
600 #endif
601
602 /* Define a macro which returns non-zero for any tagged type which is
603 used (directly or indirectly) in the specification of either some
604 function's return type or some formal parameter of some function.
605 We use this macro when we are operating in "terse" mode to help us
606 know what tagged types have to be represented in Dwarf (even in
607 terse mode) and which ones don't.
608
609 A flag bit with this meaning really should be a part of the normal
610 GCC ..._TYPE nodes, but at the moment, there is no such bit defined
611 for these nodes. For now, we have to just fake it. It it safe for
612 us to simply return zero for all complete tagged types (which will
613 get forced out anyway if they were used in the specification of some
614 formal or return type) and non-zero for all incomplete tagged types.
615 */
616
617 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
618
619 /* Define a macro which returns non-zero for a TYPE_DECL which was
620 implicitly generated for a tagged type.
621
622 Note that unlike the gcc front end (which generates a NULL named
623 TYPE_DECL node for each complete tagged type, each array type, and
624 each function type node created) the g++ front end generates a
625 _named_ TYPE_DECL node for each tagged type node created.
626 These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
627 generate a DW_TAG_typedef DIE for them. */
628 #define TYPE_DECL_IS_STUB(decl) \
629 (DECL_NAME (decl) == NULL \
630 || (DECL_ARTIFICIAL (decl) \
631 && is_tagged_type (TREE_TYPE (decl)) \
632 && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
633
634 /* Maximum size (in bytes) of an artificially generated label. */
635
636 #define MAX_ARTIFICIAL_LABEL_BYTES 30
637 \f
638 /* Structure to keep track of source filenames. */
639
640 struct filename_entry {
641 unsigned number;
642 const char * name;
643 };
644
645 typedef struct filename_entry filename_entry;
646
647 /* Pointer to an array of elements, each one having the structure above. */
648
649 static filename_entry *filename_table;
650
651 /* Total number of entries in the table (i.e. array) pointed to by
652 `filename_table'. This is the *total* and includes both used and
653 unused slots. */
654
655 static unsigned ft_entries_allocated;
656
657 /* Number of entries in the filename_table which are actually in use. */
658
659 static unsigned ft_entries;
660
661 /* Size (in elements) of increments by which we may expand the filename
662 table. Actually, a single hunk of space of this size should be enough
663 for most typical programs. */
664
665 #define FT_ENTRIES_INCREMENT 64
666
667 /* Local pointer to the name of the main input file. Initialized in
668 dwarfout_init. */
669
670 static const char *primary_filename;
671
672 /* Counter to generate unique names for DIEs. */
673
674 static unsigned next_unused_dienum = 1;
675
676 /* Number of the DIE which is currently being generated. */
677
678 static unsigned current_dienum;
679
680 /* Number to use for the special "pubname" label on the next DIE which
681 represents a function or data object defined in this compilation
682 unit which has "extern" linkage. */
683
684 static int next_pubname_number = 0;
685
686 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
687
688 /* Pointer to a dynamically allocated list of pre-reserved and still
689 pending sibling DIE numbers. Note that this list will grow as needed. */
690
691 static unsigned *pending_sibling_stack;
692
693 /* Counter to keep track of the number of pre-reserved and still pending
694 sibling DIE numbers. */
695
696 static unsigned pending_siblings;
697
698 /* The currently allocated size of the above list (expressed in number of
699 list elements). */
700
701 static unsigned pending_siblings_allocated;
702
703 /* Size (in elements) of increments by which we may expand the pending
704 sibling stack. Actually, a single hunk of space of this size should
705 be enough for most typical programs. */
706
707 #define PENDING_SIBLINGS_INCREMENT 64
708
709 /* Non-zero if we are performing our file-scope finalization pass and if
710 we should force out Dwarf descriptions of any and all file-scope
711 tagged types which are still incomplete types. */
712
713 static int finalizing = 0;
714
715 /* A pointer to the base of a list of pending types which we haven't
716 generated DIEs for yet, but which we will have to come back to
717 later on. */
718
719 static tree *pending_types_list;
720
721 /* Number of elements currently allocated for the pending_types_list. */
722
723 static unsigned pending_types_allocated;
724
725 /* Number of elements of pending_types_list currently in use. */
726
727 static unsigned pending_types;
728
729 /* Size (in elements) of increments by which we may expand the pending
730 types list. Actually, a single hunk of space of this size should
731 be enough for most typical programs. */
732
733 #define PENDING_TYPES_INCREMENT 64
734
735 /* A pointer to the base of a list of incomplete types which might be
736 completed at some later time. */
737
738 static tree *incomplete_types_list;
739
740 /* Number of elements currently allocated for the incomplete_types_list. */
741 static unsigned incomplete_types_allocated;
742
743 /* Number of elements of incomplete_types_list currently in use. */
744 static unsigned incomplete_types;
745
746 /* Size (in elements) of increments by which we may expand the incomplete
747 types list. Actually, a single hunk of space of this size should
748 be enough for most typical programs. */
749 #define INCOMPLETE_TYPES_INCREMENT 64
750
751 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
752 This is used in a hack to help us get the DIEs describing types of
753 formal parameters to come *after* all of the DIEs describing the formal
754 parameters themselves. That's necessary in order to be compatible
755 with what the brain-damaged svr4 SDB debugger requires. */
756
757 static tree fake_containing_scope;
758
759 /* The number of the current function definition that we are generating
760 debugging information for. These numbers range from 1 up to the maximum
761 number of function definitions contained within the current compilation
762 unit. These numbers are used to create unique labels for various things
763 contained within various function definitions. */
764
765 static unsigned current_funcdef_number = 1;
766
767 /* A pointer to the ..._DECL node which we have most recently been working
768 on. We keep this around just in case something about it looks screwy
769 and we want to tell the user what the source coordinates for the actual
770 declaration are. */
771
772 static tree dwarf_last_decl;
773
774 /* A flag indicating that we are emitting the member declarations of a
775 class, so member functions and variables should not be entirely emitted.
776 This is a kludge to avoid passing a second argument to output_*_die. */
777
778 static int in_class;
779
780 /* Forward declarations for functions defined in this file. */
781
782 static void dwarfout_init PARAMS ((const char *));
783 static void dwarfout_finish PARAMS ((const char *));
784 static void dwarfout_define PARAMS ((unsigned int, const char *));
785 static void dwarfout_undef PARAMS ((unsigned int, const char *));
786 static void dwarfout_start_source_file PARAMS ((unsigned, const char *));
787 static void dwarfout_start_source_file_check PARAMS ((unsigned, const char *));
788 static void dwarfout_end_source_file PARAMS ((unsigned));
789 static void dwarfout_end_source_file_check PARAMS ((unsigned));
790 static void dwarfout_begin_block PARAMS ((unsigned, unsigned));
791 static void dwarfout_end_block PARAMS ((unsigned, unsigned));
792 static void dwarfout_end_epilogue PARAMS ((void));
793 static void dwarfout_source_line PARAMS ((unsigned int, const char *));
794 static void dwarfout_end_prologue PARAMS ((unsigned int));
795 static void dwarfout_end_function PARAMS ((unsigned int));
796 static void dwarfout_function_decl PARAMS ((tree));
797 static void dwarfout_global_decl PARAMS ((tree));
798 static void dwarfout_deferred_inline_function PARAMS ((tree));
799 static void dwarfout_file_scope_decl PARAMS ((tree , int));
800 static const char *dwarf_tag_name PARAMS ((unsigned));
801 static const char *dwarf_attr_name PARAMS ((unsigned));
802 static const char *dwarf_stack_op_name PARAMS ((unsigned));
803 static const char *dwarf_typemod_name PARAMS ((unsigned));
804 static const char *dwarf_fmt_byte_name PARAMS ((unsigned));
805 static const char *dwarf_fund_type_name PARAMS ((unsigned));
806 static tree decl_ultimate_origin PARAMS ((tree));
807 static tree block_ultimate_origin PARAMS ((tree));
808 static tree decl_class_context PARAMS ((tree));
809 #if 0
810 static void output_unsigned_leb128 PARAMS ((unsigned long));
811 static void output_signed_leb128 PARAMS ((long));
812 #endif
813 static int fundamental_type_code PARAMS ((tree));
814 static tree root_type_1 PARAMS ((tree, int));
815 static tree root_type PARAMS ((tree));
816 static void write_modifier_bytes_1 PARAMS ((tree, int, int, int));
817 static void write_modifier_bytes PARAMS ((tree, int, int));
818 static inline int type_is_fundamental PARAMS ((tree));
819 static void equate_decl_number_to_die_number PARAMS ((tree));
820 static inline void equate_type_number_to_die_number PARAMS ((tree));
821 static void output_reg_number PARAMS ((rtx));
822 static void output_mem_loc_descriptor PARAMS ((rtx));
823 static void output_loc_descriptor PARAMS ((rtx));
824 static void output_bound_representation PARAMS ((tree, unsigned, int));
825 static void output_enumeral_list PARAMS ((tree));
826 static inline HOST_WIDE_INT ceiling PARAMS ((HOST_WIDE_INT, unsigned int));
827 static inline tree field_type PARAMS ((tree));
828 static inline unsigned int simple_type_align_in_bits PARAMS ((tree));
829 static inline unsigned HOST_WIDE_INT simple_type_size_in_bits PARAMS ((tree));
830 static HOST_WIDE_INT field_byte_offset PARAMS ((tree));
831 static inline void sibling_attribute PARAMS ((void));
832 static void location_attribute PARAMS ((rtx));
833 static void data_member_location_attribute PARAMS ((tree));
834 static void const_value_attribute PARAMS ((rtx));
835 static void location_or_const_value_attribute PARAMS ((tree));
836 static inline void name_attribute PARAMS ((const char *));
837 static inline void fund_type_attribute PARAMS ((unsigned));
838 static void mod_fund_type_attribute PARAMS ((tree, int, int));
839 static inline void user_def_type_attribute PARAMS ((tree));
840 static void mod_u_d_type_attribute PARAMS ((tree, int, int));
841 #ifdef USE_ORDERING_ATTRIBUTE
842 static inline void ordering_attribute PARAMS ((unsigned));
843 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
844 static void subscript_data_attribute PARAMS ((tree));
845 static void byte_size_attribute PARAMS ((tree));
846 static inline void bit_offset_attribute PARAMS ((tree));
847 static inline void bit_size_attribute PARAMS ((tree));
848 static inline void element_list_attribute PARAMS ((tree));
849 static inline void stmt_list_attribute PARAMS ((const char *));
850 static inline void low_pc_attribute PARAMS ((const char *));
851 static inline void high_pc_attribute PARAMS ((const char *));
852 static inline void body_begin_attribute PARAMS ((const char *));
853 static inline void body_end_attribute PARAMS ((const char *));
854 static inline void language_attribute PARAMS ((unsigned));
855 static inline void member_attribute PARAMS ((tree));
856 #if 0
857 static inline void string_length_attribute PARAMS ((tree));
858 #endif
859 static inline void comp_dir_attribute PARAMS ((const char *));
860 static inline void sf_names_attribute PARAMS ((const char *));
861 static inline void src_info_attribute PARAMS ((const char *));
862 static inline void mac_info_attribute PARAMS ((const char *));
863 static inline void prototyped_attribute PARAMS ((tree));
864 static inline void producer_attribute PARAMS ((const char *));
865 static inline void inline_attribute PARAMS ((tree));
866 static inline void containing_type_attribute PARAMS ((tree));
867 static inline void abstract_origin_attribute PARAMS ((tree));
868 #ifdef DWARF_DECL_COORDINATES
869 static inline void src_coords_attribute PARAMS ((unsigned, unsigned));
870 #endif /* defined(DWARF_DECL_COORDINATES) */
871 static inline void pure_or_virtual_attribute PARAMS ((tree));
872 static void name_and_src_coords_attributes PARAMS ((tree));
873 static void type_attribute PARAMS ((tree, int, int));
874 static const char *type_tag PARAMS ((tree));
875 static inline void dienum_push PARAMS ((void));
876 static inline void dienum_pop PARAMS ((void));
877 static inline tree member_declared_type PARAMS ((tree));
878 static const char *function_start_label PARAMS ((tree));
879 static void output_array_type_die PARAMS ((void *));
880 static void output_set_type_die PARAMS ((void *));
881 #if 0
882 static void output_entry_point_die PARAMS ((void *));
883 #endif
884 static void output_inlined_enumeration_type_die PARAMS ((void *));
885 static void output_inlined_structure_type_die PARAMS ((void *));
886 static void output_inlined_union_type_die PARAMS ((void *));
887 static void output_enumeration_type_die PARAMS ((void *));
888 static void output_formal_parameter_die PARAMS ((void *));
889 static void output_global_subroutine_die PARAMS ((void *));
890 static void output_global_variable_die PARAMS ((void *));
891 static void output_label_die PARAMS ((void *));
892 static void output_lexical_block_die PARAMS ((void *));
893 static void output_inlined_subroutine_die PARAMS ((void *));
894 static void output_local_variable_die PARAMS ((void *));
895 static void output_member_die PARAMS ((void *));
896 #if 0
897 static void output_pointer_type_die PARAMS ((void *));
898 static void output_reference_type_die PARAMS ((void *));
899 #endif
900 static void output_ptr_to_mbr_type_die PARAMS ((void *));
901 static void output_compile_unit_die PARAMS ((void *));
902 static void output_string_type_die PARAMS ((void *));
903 static void output_inheritance_die PARAMS ((void *));
904 static void output_structure_type_die PARAMS ((void *));
905 static void output_local_subroutine_die PARAMS ((void *));
906 static void output_subroutine_type_die PARAMS ((void *));
907 static void output_typedef_die PARAMS ((void *));
908 static void output_union_type_die PARAMS ((void *));
909 static void output_unspecified_parameters_die PARAMS ((void *));
910 static void output_padded_null_die PARAMS ((void *));
911 static void output_die PARAMS ((void (*)(void *), void *));
912 static void end_sibling_chain PARAMS ((void));
913 static void output_formal_types PARAMS ((tree));
914 static void pend_type PARAMS ((tree));
915 static int type_ok_for_scope PARAMS ((tree, tree));
916 static void output_pending_types_for_scope PARAMS ((tree));
917 static void output_type PARAMS ((tree, tree));
918 static void output_tagged_type_instantiation PARAMS ((tree));
919 static void output_block PARAMS ((tree, int));
920 static void output_decls_for_scope PARAMS ((tree, int));
921 static void output_decl PARAMS ((tree, tree));
922 static void shuffle_filename_entry PARAMS ((filename_entry *));
923 static void generate_new_sfname_entry PARAMS ((void));
924 static unsigned lookup_filename PARAMS ((const char *));
925 static void generate_srcinfo_entry PARAMS ((unsigned, unsigned));
926 static void generate_macinfo_entry PARAMS ((unsigned int, rtx,
927 const char *));
928 static int is_pseudo_reg PARAMS ((rtx));
929 static tree type_main_variant PARAMS ((tree));
930 static int is_tagged_type PARAMS ((tree));
931 static int is_redundant_typedef PARAMS ((tree));
932 static void add_incomplete_type PARAMS ((tree));
933 static void retry_incomplete_types PARAMS ((void));
934 \f
935 /* Definitions of defaults for assembler-dependent names of various
936 pseudo-ops and section names.
937
938 Theses may be overridden in your tm.h file (if necessary) for your
939 particular assembler. The default values provided here correspond to
940 what is expected by "standard" AT&T System V.4 assemblers. */
941
942 #ifndef FILE_ASM_OP
943 #define FILE_ASM_OP "\t.file\t"
944 #endif
945 #ifndef VERSION_ASM_OP
946 #define VERSION_ASM_OP "\t.version\t"
947 #endif
948 #ifndef SET_ASM_OP
949 #define SET_ASM_OP "\t.set\t"
950 #endif
951
952 /* Pseudo-ops for pushing the current section onto the section stack (and
953 simultaneously changing to a new section) and for poping back to the
954 section we were in immediately before this one. Note that most svr4
955 assemblers only maintain a one level stack... you can push all the
956 sections you want, but you can only pop out one level. (The sparc
957 svr4 assembler is an exception to this general rule.) That's
958 OK because we only use at most one level of the section stack herein. */
959
960 #ifndef PUSHSECTION_ASM_OP
961 #define PUSHSECTION_ASM_OP "\t.section\t"
962 #endif
963 #ifndef POPSECTION_ASM_OP
964 #define POPSECTION_ASM_OP "\t.previous"
965 #endif
966
967 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
968 to print the PUSHSECTION_ASM_OP and the section name. The default here
969 works for almost all svr4 assemblers, except for the sparc, where the
970 section name must be enclosed in double quotes. (See sparcv4.h.) */
971
972 #ifndef PUSHSECTION_FORMAT
973 #define PUSHSECTION_FORMAT "%s%s\n"
974 #endif
975
976 #ifndef DEBUG_SECTION
977 #define DEBUG_SECTION ".debug"
978 #endif
979 #ifndef LINE_SECTION
980 #define LINE_SECTION ".line"
981 #endif
982 #ifndef DEBUG_SFNAMES_SECTION
983 #define DEBUG_SFNAMES_SECTION ".debug_sfnames"
984 #endif
985 #ifndef DEBUG_SRCINFO_SECTION
986 #define DEBUG_SRCINFO_SECTION ".debug_srcinfo"
987 #endif
988 #ifndef DEBUG_MACINFO_SECTION
989 #define DEBUG_MACINFO_SECTION ".debug_macinfo"
990 #endif
991 #ifndef DEBUG_PUBNAMES_SECTION
992 #define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
993 #endif
994 #ifndef DEBUG_ARANGES_SECTION
995 #define DEBUG_ARANGES_SECTION ".debug_aranges"
996 #endif
997 #ifndef TEXT_SECTION_NAME
998 #define TEXT_SECTION_NAME ".text"
999 #endif
1000 #ifndef DATA_SECTION_NAME
1001 #define DATA_SECTION_NAME ".data"
1002 #endif
1003 #ifndef DATA1_SECTION_NAME
1004 #define DATA1_SECTION_NAME ".data1"
1005 #endif
1006 #ifndef RODATA_SECTION_NAME
1007 #define RODATA_SECTION_NAME ".rodata"
1008 #endif
1009 #ifndef RODATA1_SECTION_NAME
1010 #define RODATA1_SECTION_NAME ".rodata1"
1011 #endif
1012 #ifndef BSS_SECTION_NAME
1013 #define BSS_SECTION_NAME ".bss"
1014 #endif
1015 \f
1016 /* Definitions of defaults for formats and names of various special
1017 (artificial) labels which may be generated within this file (when
1018 the -g options is used and DWARF_DEBUGGING_INFO is in effect.
1019
1020 If necessary, these may be overridden from within your tm.h file,
1021 but typically, you should never need to override these.
1022
1023 These labels have been hacked (temporarily) so that they all begin with
1024 a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
1025 stock m88k/svr4 assembler, both of which need to see .L at the start of
1026 a label in order to prevent that label from going into the linker symbol
1027 table). When I get time, I'll have to fix this the right way so that we
1028 will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
1029 but that will require a rather massive set of changes. For the moment,
1030 the following definitions out to produce the right results for all svr4
1031 and svr3 assemblers. -- rfg
1032 */
1033
1034 #ifndef TEXT_BEGIN_LABEL
1035 #define TEXT_BEGIN_LABEL "*.L_text_b"
1036 #endif
1037 #ifndef TEXT_END_LABEL
1038 #define TEXT_END_LABEL "*.L_text_e"
1039 #endif
1040
1041 #ifndef DATA_BEGIN_LABEL
1042 #define DATA_BEGIN_LABEL "*.L_data_b"
1043 #endif
1044 #ifndef DATA_END_LABEL
1045 #define DATA_END_LABEL "*.L_data_e"
1046 #endif
1047
1048 #ifndef DATA1_BEGIN_LABEL
1049 #define DATA1_BEGIN_LABEL "*.L_data1_b"
1050 #endif
1051 #ifndef DATA1_END_LABEL
1052 #define DATA1_END_LABEL "*.L_data1_e"
1053 #endif
1054
1055 #ifndef RODATA_BEGIN_LABEL
1056 #define RODATA_BEGIN_LABEL "*.L_rodata_b"
1057 #endif
1058 #ifndef RODATA_END_LABEL
1059 #define RODATA_END_LABEL "*.L_rodata_e"
1060 #endif
1061
1062 #ifndef RODATA1_BEGIN_LABEL
1063 #define RODATA1_BEGIN_LABEL "*.L_rodata1_b"
1064 #endif
1065 #ifndef RODATA1_END_LABEL
1066 #define RODATA1_END_LABEL "*.L_rodata1_e"
1067 #endif
1068
1069 #ifndef BSS_BEGIN_LABEL
1070 #define BSS_BEGIN_LABEL "*.L_bss_b"
1071 #endif
1072 #ifndef BSS_END_LABEL
1073 #define BSS_END_LABEL "*.L_bss_e"
1074 #endif
1075
1076 #ifndef LINE_BEGIN_LABEL
1077 #define LINE_BEGIN_LABEL "*.L_line_b"
1078 #endif
1079 #ifndef LINE_LAST_ENTRY_LABEL
1080 #define LINE_LAST_ENTRY_LABEL "*.L_line_last"
1081 #endif
1082 #ifndef LINE_END_LABEL
1083 #define LINE_END_LABEL "*.L_line_e"
1084 #endif
1085
1086 #ifndef DEBUG_BEGIN_LABEL
1087 #define DEBUG_BEGIN_LABEL "*.L_debug_b"
1088 #endif
1089 #ifndef SFNAMES_BEGIN_LABEL
1090 #define SFNAMES_BEGIN_LABEL "*.L_sfnames_b"
1091 #endif
1092 #ifndef SRCINFO_BEGIN_LABEL
1093 #define SRCINFO_BEGIN_LABEL "*.L_srcinfo_b"
1094 #endif
1095 #ifndef MACINFO_BEGIN_LABEL
1096 #define MACINFO_BEGIN_LABEL "*.L_macinfo_b"
1097 #endif
1098
1099 #ifndef DEBUG_ARANGES_BEGIN_LABEL
1100 #define DEBUG_ARANGES_BEGIN_LABEL "*.L_debug_aranges_begin"
1101 #endif
1102 #ifndef DEBUG_ARANGES_END_LABEL
1103 #define DEBUG_ARANGES_END_LABEL "*.L_debug_aranges_end"
1104 #endif
1105
1106 #ifndef DIE_BEGIN_LABEL_FMT
1107 #define DIE_BEGIN_LABEL_FMT "*.L_D%u"
1108 #endif
1109 #ifndef DIE_END_LABEL_FMT
1110 #define DIE_END_LABEL_FMT "*.L_D%u_e"
1111 #endif
1112 #ifndef PUB_DIE_LABEL_FMT
1113 #define PUB_DIE_LABEL_FMT "*.L_P%u"
1114 #endif
1115 #ifndef BLOCK_BEGIN_LABEL_FMT
1116 #define BLOCK_BEGIN_LABEL_FMT "*.L_B%u"
1117 #endif
1118 #ifndef BLOCK_END_LABEL_FMT
1119 #define BLOCK_END_LABEL_FMT "*.L_B%u_e"
1120 #endif
1121 #ifndef SS_BEGIN_LABEL_FMT
1122 #define SS_BEGIN_LABEL_FMT "*.L_s%u"
1123 #endif
1124 #ifndef SS_END_LABEL_FMT
1125 #define SS_END_LABEL_FMT "*.L_s%u_e"
1126 #endif
1127 #ifndef EE_BEGIN_LABEL_FMT
1128 #define EE_BEGIN_LABEL_FMT "*.L_e%u"
1129 #endif
1130 #ifndef EE_END_LABEL_FMT
1131 #define EE_END_LABEL_FMT "*.L_e%u_e"
1132 #endif
1133 #ifndef MT_BEGIN_LABEL_FMT
1134 #define MT_BEGIN_LABEL_FMT "*.L_t%u"
1135 #endif
1136 #ifndef MT_END_LABEL_FMT
1137 #define MT_END_LABEL_FMT "*.L_t%u_e"
1138 #endif
1139 #ifndef LOC_BEGIN_LABEL_FMT
1140 #define LOC_BEGIN_LABEL_FMT "*.L_l%u"
1141 #endif
1142 #ifndef LOC_END_LABEL_FMT
1143 #define LOC_END_LABEL_FMT "*.L_l%u_e"
1144 #endif
1145 #ifndef BOUND_BEGIN_LABEL_FMT
1146 #define BOUND_BEGIN_LABEL_FMT "*.L_b%u_%u_%c"
1147 #endif
1148 #ifndef BOUND_END_LABEL_FMT
1149 #define BOUND_END_LABEL_FMT "*.L_b%u_%u_%c_e"
1150 #endif
1151 #ifndef DERIV_BEGIN_LABEL_FMT
1152 #define DERIV_BEGIN_LABEL_FMT "*.L_d%u"
1153 #endif
1154 #ifndef DERIV_END_LABEL_FMT
1155 #define DERIV_END_LABEL_FMT "*.L_d%u_e"
1156 #endif
1157 #ifndef SL_BEGIN_LABEL_FMT
1158 #define SL_BEGIN_LABEL_FMT "*.L_sl%u"
1159 #endif
1160 #ifndef SL_END_LABEL_FMT
1161 #define SL_END_LABEL_FMT "*.L_sl%u_e"
1162 #endif
1163 #ifndef BODY_BEGIN_LABEL_FMT
1164 #define BODY_BEGIN_LABEL_FMT "*.L_b%u"
1165 #endif
1166 #ifndef BODY_END_LABEL_FMT
1167 #define BODY_END_LABEL_FMT "*.L_b%u_e"
1168 #endif
1169 #ifndef FUNC_END_LABEL_FMT
1170 #define FUNC_END_LABEL_FMT "*.L_f%u_e"
1171 #endif
1172 #ifndef TYPE_NAME_FMT
1173 #define TYPE_NAME_FMT "*.L_T%u"
1174 #endif
1175 #ifndef DECL_NAME_FMT
1176 #define DECL_NAME_FMT "*.L_E%u"
1177 #endif
1178 #ifndef LINE_CODE_LABEL_FMT
1179 #define LINE_CODE_LABEL_FMT "*.L_LC%u"
1180 #endif
1181 #ifndef SFNAMES_ENTRY_LABEL_FMT
1182 #define SFNAMES_ENTRY_LABEL_FMT "*.L_F%u"
1183 #endif
1184 #ifndef LINE_ENTRY_LABEL_FMT
1185 #define LINE_ENTRY_LABEL_FMT "*.L_LE%u"
1186 #endif
1187 \f
1188 /* Definitions of defaults for various types of primitive assembly language
1189 output operations.
1190
1191 If necessary, these may be overridden from within your tm.h file,
1192 but typically, you shouldn't need to override these. */
1193
1194 #ifndef ASM_OUTPUT_PUSH_SECTION
1195 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
1196 fprintf ((FILE), PUSHSECTION_FORMAT, PUSHSECTION_ASM_OP, SECTION)
1197 #endif
1198
1199 #ifndef ASM_OUTPUT_POP_SECTION
1200 #define ASM_OUTPUT_POP_SECTION(FILE) \
1201 fprintf ((FILE), "%s\n", POPSECTION_ASM_OP)
1202 #endif
1203
1204 #ifndef ASM_OUTPUT_DWARF_DELTA2
1205 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2) \
1206 dw2_asm_output_delta (2, LABEL1, LABEL2, NULL)
1207 #endif
1208
1209 #ifndef ASM_OUTPUT_DWARF_DELTA4
1210 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2) \
1211 dw2_asm_output_delta (4, LABEL1, LABEL2, NULL)
1212 #endif
1213
1214 #ifndef ASM_OUTPUT_DWARF_TAG
1215 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG) \
1216 dw2_asm_output_data (2, TAG, "%s", dwarf_tag_name (TAG));
1217 #endif
1218
1219 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
1220 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR) \
1221 dw2_asm_output_data (2, ATTR, "%s", dwarf_attr_name (ATTR))
1222 #endif
1223
1224 #ifndef ASM_OUTPUT_DWARF_STACK_OP
1225 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP) \
1226 dw2_asm_output_data (1, OP, "%s", dwarf_stack_op_name (OP))
1227 #endif
1228
1229 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
1230 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT) \
1231 dw2_asm_output_data (2, FT, "%s", dwarf_fund_type_name (FT))
1232 #endif
1233
1234 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
1235 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT) \
1236 dw2_asm_output_data (1, FMT, "%s", dwarf_fmt_byte_name (FMT));
1237 #endif
1238
1239 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
1240 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD) \
1241 dw2_asm_output_data (1, MOD, "%s", dwarf_typemod_name (MOD));
1242 #endif
1243 \f
1244 #ifndef ASM_OUTPUT_DWARF_ADDR
1245 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL) \
1246 dw2_asm_output_addr (4, LABEL, NULL)
1247 #endif
1248
1249 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
1250 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX) \
1251 dw2_asm_output_addr_rtx (4, RTX, NULL)
1252 #endif
1253
1254 #ifndef ASM_OUTPUT_DWARF_REF
1255 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL) \
1256 dw2_asm_output_addr (4, LABEL, NULL)
1257 #endif
1258
1259 #ifndef ASM_OUTPUT_DWARF_DATA1
1260 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
1261 dw2_asm_output_data (1, VALUE, NULL)
1262 #endif
1263
1264 #ifndef ASM_OUTPUT_DWARF_DATA2
1265 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
1266 dw2_asm_output_data (2, VALUE, NULL)
1267 #endif
1268
1269 #ifndef ASM_OUTPUT_DWARF_DATA4
1270 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
1271 dw2_asm_output_data (4, VALUE, NULL)
1272 #endif
1273
1274 #ifndef ASM_OUTPUT_DWARF_DATA8
1275 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE) \
1276 dw2_asm_output_data (8, VALUE, NULL)
1277 #endif
1278
1279 /* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
1280 NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
1281 based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
1282 defined, we call it, then issue the line feed. If not, we supply a
1283 default definition of calling ASM_OUTPUT_ASCII */
1284
1285 #ifndef ASM_OUTPUT_DWARF_STRING
1286 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
1287 ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
1288 #else
1289 #define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
1290 ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n")
1291 #endif
1292
1293 \f
1294 /* The debug hooks structure. */
1295 const struct gcc_debug_hooks dwarf_debug_hooks =
1296 {
1297 dwarfout_init,
1298 dwarfout_finish,
1299 dwarfout_define,
1300 dwarfout_undef,
1301 dwarfout_start_source_file_check,
1302 dwarfout_end_source_file_check,
1303 dwarfout_begin_block,
1304 dwarfout_end_block,
1305 debug_true_tree, /* ignore_block */
1306 dwarfout_source_line, /* source_line */
1307 dwarfout_source_line, /* begin_prologue */
1308 dwarfout_end_prologue,
1309 dwarfout_end_epilogue,
1310 debug_nothing_tree, /* begin_function */
1311 dwarfout_end_function,
1312 dwarfout_function_decl,
1313 dwarfout_global_decl,
1314 dwarfout_deferred_inline_function,
1315 debug_nothing_tree, /* outlining_inline_function */
1316 debug_nothing_rtx /* label */
1317 };
1318 \f
1319 /************************ general utility functions **************************/
1320
1321 static inline int
1322 is_pseudo_reg (rtl)
1323 rtx rtl;
1324 {
1325 return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
1326 || ((GET_CODE (rtl) == SUBREG)
1327 && (REGNO (SUBREG_REG (rtl)) >= FIRST_PSEUDO_REGISTER)));
1328 }
1329
1330 static inline tree
1331 type_main_variant (type)
1332 tree type;
1333 {
1334 type = TYPE_MAIN_VARIANT (type);
1335
1336 /* There really should be only one main variant among any group of variants
1337 of a given type (and all of the MAIN_VARIANT values for all members of
1338 the group should point to that one type) but sometimes the C front-end
1339 messes this up for array types, so we work around that bug here. */
1340
1341 if (TREE_CODE (type) == ARRAY_TYPE)
1342 {
1343 while (type != TYPE_MAIN_VARIANT (type))
1344 type = TYPE_MAIN_VARIANT (type);
1345 }
1346
1347 return type;
1348 }
1349
1350 /* Return non-zero if the given type node represents a tagged type. */
1351
1352 static inline int
1353 is_tagged_type (type)
1354 tree type;
1355 {
1356 enum tree_code code = TREE_CODE (type);
1357
1358 return (code == RECORD_TYPE || code == UNION_TYPE
1359 || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
1360 }
1361
1362 static const char *
1363 dwarf_tag_name (tag)
1364 unsigned tag;
1365 {
1366 switch (tag)
1367 {
1368 case TAG_padding: return "TAG_padding";
1369 case TAG_array_type: return "TAG_array_type";
1370 case TAG_class_type: return "TAG_class_type";
1371 case TAG_entry_point: return "TAG_entry_point";
1372 case TAG_enumeration_type: return "TAG_enumeration_type";
1373 case TAG_formal_parameter: return "TAG_formal_parameter";
1374 case TAG_global_subroutine: return "TAG_global_subroutine";
1375 case TAG_global_variable: return "TAG_global_variable";
1376 case TAG_label: return "TAG_label";
1377 case TAG_lexical_block: return "TAG_lexical_block";
1378 case TAG_local_variable: return "TAG_local_variable";
1379 case TAG_member: return "TAG_member";
1380 case TAG_pointer_type: return "TAG_pointer_type";
1381 case TAG_reference_type: return "TAG_reference_type";
1382 case TAG_compile_unit: return "TAG_compile_unit";
1383 case TAG_string_type: return "TAG_string_type";
1384 case TAG_structure_type: return "TAG_structure_type";
1385 case TAG_subroutine: return "TAG_subroutine";
1386 case TAG_subroutine_type: return "TAG_subroutine_type";
1387 case TAG_typedef: return "TAG_typedef";
1388 case TAG_union_type: return "TAG_union_type";
1389 case TAG_unspecified_parameters: return "TAG_unspecified_parameters";
1390 case TAG_variant: return "TAG_variant";
1391 case TAG_common_block: return "TAG_common_block";
1392 case TAG_common_inclusion: return "TAG_common_inclusion";
1393 case TAG_inheritance: return "TAG_inheritance";
1394 case TAG_inlined_subroutine: return "TAG_inlined_subroutine";
1395 case TAG_module: return "TAG_module";
1396 case TAG_ptr_to_member_type: return "TAG_ptr_to_member_type";
1397 case TAG_set_type: return "TAG_set_type";
1398 case TAG_subrange_type: return "TAG_subrange_type";
1399 case TAG_with_stmt: return "TAG_with_stmt";
1400
1401 /* GNU extensions. */
1402
1403 case TAG_format_label: return "TAG_format_label";
1404 case TAG_namelist: return "TAG_namelist";
1405 case TAG_function_template: return "TAG_function_template";
1406 case TAG_class_template: return "TAG_class_template";
1407
1408 default: return "TAG_<unknown>";
1409 }
1410 }
1411
1412 static const char *
1413 dwarf_attr_name (attr)
1414 unsigned attr;
1415 {
1416 switch (attr)
1417 {
1418 case AT_sibling: return "AT_sibling";
1419 case AT_location: return "AT_location";
1420 case AT_name: return "AT_name";
1421 case AT_fund_type: return "AT_fund_type";
1422 case AT_mod_fund_type: return "AT_mod_fund_type";
1423 case AT_user_def_type: return "AT_user_def_type";
1424 case AT_mod_u_d_type: return "AT_mod_u_d_type";
1425 case AT_ordering: return "AT_ordering";
1426 case AT_subscr_data: return "AT_subscr_data";
1427 case AT_byte_size: return "AT_byte_size";
1428 case AT_bit_offset: return "AT_bit_offset";
1429 case AT_bit_size: return "AT_bit_size";
1430 case AT_element_list: return "AT_element_list";
1431 case AT_stmt_list: return "AT_stmt_list";
1432 case AT_low_pc: return "AT_low_pc";
1433 case AT_high_pc: return "AT_high_pc";
1434 case AT_language: return "AT_language";
1435 case AT_member: return "AT_member";
1436 case AT_discr: return "AT_discr";
1437 case AT_discr_value: return "AT_discr_value";
1438 case AT_string_length: return "AT_string_length";
1439 case AT_common_reference: return "AT_common_reference";
1440 case AT_comp_dir: return "AT_comp_dir";
1441 case AT_const_value_string: return "AT_const_value_string";
1442 case AT_const_value_data2: return "AT_const_value_data2";
1443 case AT_const_value_data4: return "AT_const_value_data4";
1444 case AT_const_value_data8: return "AT_const_value_data8";
1445 case AT_const_value_block2: return "AT_const_value_block2";
1446 case AT_const_value_block4: return "AT_const_value_block4";
1447 case AT_containing_type: return "AT_containing_type";
1448 case AT_default_value_addr: return "AT_default_value_addr";
1449 case AT_default_value_data2: return "AT_default_value_data2";
1450 case AT_default_value_data4: return "AT_default_value_data4";
1451 case AT_default_value_data8: return "AT_default_value_data8";
1452 case AT_default_value_string: return "AT_default_value_string";
1453 case AT_friends: return "AT_friends";
1454 case AT_inline: return "AT_inline";
1455 case AT_is_optional: return "AT_is_optional";
1456 case AT_lower_bound_ref: return "AT_lower_bound_ref";
1457 case AT_lower_bound_data2: return "AT_lower_bound_data2";
1458 case AT_lower_bound_data4: return "AT_lower_bound_data4";
1459 case AT_lower_bound_data8: return "AT_lower_bound_data8";
1460 case AT_private: return "AT_private";
1461 case AT_producer: return "AT_producer";
1462 case AT_program: return "AT_program";
1463 case AT_protected: return "AT_protected";
1464 case AT_prototyped: return "AT_prototyped";
1465 case AT_public: return "AT_public";
1466 case AT_pure_virtual: return "AT_pure_virtual";
1467 case AT_return_addr: return "AT_return_addr";
1468 case AT_abstract_origin: return "AT_abstract_origin";
1469 case AT_start_scope: return "AT_start_scope";
1470 case AT_stride_size: return "AT_stride_size";
1471 case AT_upper_bound_ref: return "AT_upper_bound_ref";
1472 case AT_upper_bound_data2: return "AT_upper_bound_data2";
1473 case AT_upper_bound_data4: return "AT_upper_bound_data4";
1474 case AT_upper_bound_data8: return "AT_upper_bound_data8";
1475 case AT_virtual: return "AT_virtual";
1476
1477 /* GNU extensions */
1478
1479 case AT_sf_names: return "AT_sf_names";
1480 case AT_src_info: return "AT_src_info";
1481 case AT_mac_info: return "AT_mac_info";
1482 case AT_src_coords: return "AT_src_coords";
1483 case AT_body_begin: return "AT_body_begin";
1484 case AT_body_end: return "AT_body_end";
1485
1486 default: return "AT_<unknown>";
1487 }
1488 }
1489
1490 static const char *
1491 dwarf_stack_op_name (op)
1492 unsigned op;
1493 {
1494 switch (op)
1495 {
1496 case OP_REG: return "OP_REG";
1497 case OP_BASEREG: return "OP_BASEREG";
1498 case OP_ADDR: return "OP_ADDR";
1499 case OP_CONST: return "OP_CONST";
1500 case OP_DEREF2: return "OP_DEREF2";
1501 case OP_DEREF4: return "OP_DEREF4";
1502 case OP_ADD: return "OP_ADD";
1503 default: return "OP_<unknown>";
1504 }
1505 }
1506
1507 static const char *
1508 dwarf_typemod_name (mod)
1509 unsigned mod;
1510 {
1511 switch (mod)
1512 {
1513 case MOD_pointer_to: return "MOD_pointer_to";
1514 case MOD_reference_to: return "MOD_reference_to";
1515 case MOD_const: return "MOD_const";
1516 case MOD_volatile: return "MOD_volatile";
1517 default: return "MOD_<unknown>";
1518 }
1519 }
1520
1521 static const char *
1522 dwarf_fmt_byte_name (fmt)
1523 unsigned fmt;
1524 {
1525 switch (fmt)
1526 {
1527 case FMT_FT_C_C: return "FMT_FT_C_C";
1528 case FMT_FT_C_X: return "FMT_FT_C_X";
1529 case FMT_FT_X_C: return "FMT_FT_X_C";
1530 case FMT_FT_X_X: return "FMT_FT_X_X";
1531 case FMT_UT_C_C: return "FMT_UT_C_C";
1532 case FMT_UT_C_X: return "FMT_UT_C_X";
1533 case FMT_UT_X_C: return "FMT_UT_X_C";
1534 case FMT_UT_X_X: return "FMT_UT_X_X";
1535 case FMT_ET: return "FMT_ET";
1536 default: return "FMT_<unknown>";
1537 }
1538 }
1539
1540 static const char *
1541 dwarf_fund_type_name (ft)
1542 unsigned ft;
1543 {
1544 switch (ft)
1545 {
1546 case FT_char: return "FT_char";
1547 case FT_signed_char: return "FT_signed_char";
1548 case FT_unsigned_char: return "FT_unsigned_char";
1549 case FT_short: return "FT_short";
1550 case FT_signed_short: return "FT_signed_short";
1551 case FT_unsigned_short: return "FT_unsigned_short";
1552 case FT_integer: return "FT_integer";
1553 case FT_signed_integer: return "FT_signed_integer";
1554 case FT_unsigned_integer: return "FT_unsigned_integer";
1555 case FT_long: return "FT_long";
1556 case FT_signed_long: return "FT_signed_long";
1557 case FT_unsigned_long: return "FT_unsigned_long";
1558 case FT_pointer: return "FT_pointer";
1559 case FT_float: return "FT_float";
1560 case FT_dbl_prec_float: return "FT_dbl_prec_float";
1561 case FT_ext_prec_float: return "FT_ext_prec_float";
1562 case FT_complex: return "FT_complex";
1563 case FT_dbl_prec_complex: return "FT_dbl_prec_complex";
1564 case FT_void: return "FT_void";
1565 case FT_boolean: return "FT_boolean";
1566 case FT_ext_prec_complex: return "FT_ext_prec_complex";
1567 case FT_label: return "FT_label";
1568
1569 /* GNU extensions. */
1570
1571 case FT_long_long: return "FT_long_long";
1572 case FT_signed_long_long: return "FT_signed_long_long";
1573 case FT_unsigned_long_long: return "FT_unsigned_long_long";
1574
1575 case FT_int8: return "FT_int8";
1576 case FT_signed_int8: return "FT_signed_int8";
1577 case FT_unsigned_int8: return "FT_unsigned_int8";
1578 case FT_int16: return "FT_int16";
1579 case FT_signed_int16: return "FT_signed_int16";
1580 case FT_unsigned_int16: return "FT_unsigned_int16";
1581 case FT_int32: return "FT_int32";
1582 case FT_signed_int32: return "FT_signed_int32";
1583 case FT_unsigned_int32: return "FT_unsigned_int32";
1584 case FT_int64: return "FT_int64";
1585 case FT_signed_int64: return "FT_signed_int64";
1586 case FT_unsigned_int64: return "FT_unsigned_int64";
1587 case FT_int128: return "FT_int128";
1588 case FT_signed_int128: return "FT_signed_int128";
1589 case FT_unsigned_int128: return "FT_unsigned_int128";
1590
1591 case FT_real32: return "FT_real32";
1592 case FT_real64: return "FT_real64";
1593 case FT_real96: return "FT_real96";
1594 case FT_real128: return "FT_real128";
1595
1596 default: return "FT_<unknown>";
1597 }
1598 }
1599
1600 /* Determine the "ultimate origin" of a decl. The decl may be an
1601 inlined instance of an inlined instance of a decl which is local
1602 to an inline function, so we have to trace all of the way back
1603 through the origin chain to find out what sort of node actually
1604 served as the original seed for the given block. */
1605
1606 static tree
1607 decl_ultimate_origin (decl)
1608 tree decl;
1609 {
1610 #ifdef ENABLE_CHECKING
1611 if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
1612 /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
1613 most distant ancestor, this should never happen. */
1614 abort ();
1615 #endif
1616
1617 return DECL_ABSTRACT_ORIGIN (decl);
1618 }
1619
1620 /* Determine the "ultimate origin" of a block. The block may be an
1621 inlined instance of an inlined instance of a block which is local
1622 to an inline function, so we have to trace all of the way back
1623 through the origin chain to find out what sort of node actually
1624 served as the original seed for the given block. */
1625
1626 static tree
1627 block_ultimate_origin (block)
1628 tree block;
1629 {
1630 tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
1631
1632 if (immediate_origin == NULL)
1633 return NULL;
1634 else
1635 {
1636 tree ret_val;
1637 tree lookahead = immediate_origin;
1638
1639 do
1640 {
1641 ret_val = lookahead;
1642 lookahead = (TREE_CODE (ret_val) == BLOCK)
1643 ? BLOCK_ABSTRACT_ORIGIN (ret_val)
1644 : NULL;
1645 }
1646 while (lookahead != NULL && lookahead != ret_val);
1647 return ret_val;
1648 }
1649 }
1650
1651 /* Get the class to which DECL belongs, if any. In g++, the DECL_CONTEXT
1652 of a virtual function may refer to a base class, so we check the 'this'
1653 parameter. */
1654
1655 static tree
1656 decl_class_context (decl)
1657 tree decl;
1658 {
1659 tree context = NULL_TREE;
1660 if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
1661 context = DECL_CONTEXT (decl);
1662 else
1663 context = TYPE_MAIN_VARIANT
1664 (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
1665
1666 if (context && !TYPE_P (context))
1667 context = NULL_TREE;
1668
1669 return context;
1670 }
1671
1672 #if 0
1673 static void
1674 output_unsigned_leb128 (value)
1675 unsigned long value;
1676 {
1677 unsigned long orig_value = value;
1678
1679 do
1680 {
1681 unsigned byte = (value & 0x7f);
1682
1683 value >>= 7;
1684 if (value != 0) /* more bytes to follow */
1685 byte |= 0x80;
1686 dw2_asm_output_data (1, byte, "\t%s ULEB128 number - value = %lu",
1687 orig_value);
1688 }
1689 while (value != 0);
1690 }
1691
1692 static void
1693 output_signed_leb128 (value)
1694 long value;
1695 {
1696 long orig_value = value;
1697 int negative = (value < 0);
1698 int more;
1699
1700 do
1701 {
1702 unsigned byte = (value & 0x7f);
1703
1704 value >>= 7;
1705 if (negative)
1706 value |= 0xfe000000; /* manually sign extend */
1707 if (((value == 0) && ((byte & 0x40) == 0))
1708 || ((value == -1) && ((byte & 0x40) == 1)))
1709 more = 0;
1710 else
1711 {
1712 byte |= 0x80;
1713 more = 1;
1714 }
1715 dw2_asm_output_data (1, byte, "\t%s SLEB128 number - value = %ld",
1716 orig_value);
1717 }
1718 while (more);
1719 }
1720 #endif
1721 \f
1722 /**************** utility functions for attribute functions ******************/
1723
1724 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
1725 type code for the given type.
1726
1727 This routine must only be called for GCC type nodes that correspond to
1728 Dwarf fundamental types.
1729
1730 The current Dwarf draft specification calls for Dwarf fundamental types
1731 to accurately reflect the fact that a given type was either a "plain"
1732 integral type or an explicitly "signed" integral type. Unfortunately,
1733 we can't always do this, because GCC may already have thrown away the
1734 information about the precise way in which the type was originally
1735 specified, as in:
1736
1737 typedef signed int my_type;
1738
1739 struct s { my_type f; };
1740
1741 Since we may be stuck here without enough information to do exactly
1742 what is called for in the Dwarf draft specification, we do the best
1743 that we can under the circumstances and always use the "plain" integral
1744 fundamental type codes for int, short, and long types. That's probably
1745 good enough. The additional accuracy called for in the current DWARF
1746 draft specification is probably never even useful in practice. */
1747
1748 static int
1749 fundamental_type_code (type)
1750 tree type;
1751 {
1752 if (TREE_CODE (type) == ERROR_MARK)
1753 return 0;
1754
1755 switch (TREE_CODE (type))
1756 {
1757 case ERROR_MARK:
1758 return FT_void;
1759
1760 case VOID_TYPE:
1761 return FT_void;
1762
1763 case INTEGER_TYPE:
1764 /* Carefully distinguish all the standard types of C,
1765 without messing up if the language is not C.
1766 Note that we check only for the names that contain spaces;
1767 other names might occur by coincidence in other languages. */
1768 if (TYPE_NAME (type) != 0
1769 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1770 && DECL_NAME (TYPE_NAME (type)) != 0
1771 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1772 {
1773 const char *const name =
1774 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1775
1776 if (!strcmp (name, "unsigned char"))
1777 return FT_unsigned_char;
1778 if (!strcmp (name, "signed char"))
1779 return FT_signed_char;
1780 if (!strcmp (name, "unsigned int"))
1781 return FT_unsigned_integer;
1782 if (!strcmp (name, "short int"))
1783 return FT_short;
1784 if (!strcmp (name, "short unsigned int"))
1785 return FT_unsigned_short;
1786 if (!strcmp (name, "long int"))
1787 return FT_long;
1788 if (!strcmp (name, "long unsigned int"))
1789 return FT_unsigned_long;
1790 if (!strcmp (name, "long long int"))
1791 return FT_long_long; /* Not grok'ed by svr4 SDB */
1792 if (!strcmp (name, "long long unsigned int"))
1793 return FT_unsigned_long_long; /* Not grok'ed by svr4 SDB */
1794 }
1795
1796 /* Most integer types will be sorted out above, however, for the
1797 sake of special `array index' integer types, the following code
1798 is also provided. */
1799
1800 if (TYPE_PRECISION (type) == INT_TYPE_SIZE)
1801 return (TREE_UNSIGNED (type) ? FT_unsigned_integer : FT_integer);
1802
1803 if (TYPE_PRECISION (type) == LONG_TYPE_SIZE)
1804 return (TREE_UNSIGNED (type) ? FT_unsigned_long : FT_long);
1805
1806 if (TYPE_PRECISION (type) == LONG_LONG_TYPE_SIZE)
1807 return (TREE_UNSIGNED (type) ? FT_unsigned_long_long : FT_long_long);
1808
1809 if (TYPE_PRECISION (type) == SHORT_TYPE_SIZE)
1810 return (TREE_UNSIGNED (type) ? FT_unsigned_short : FT_short);
1811
1812 if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
1813 return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
1814
1815 if (TYPE_MODE (type) == TImode)
1816 return (TREE_UNSIGNED (type) ? FT_unsigned_int128 : FT_int128);
1817
1818 /* In C++, __java_boolean is an INTEGER_TYPE with precision == 1 */
1819 if (TYPE_PRECISION (type) == 1)
1820 return FT_boolean;
1821
1822 abort ();
1823
1824 case REAL_TYPE:
1825 /* Carefully distinguish all the standard types of C,
1826 without messing up if the language is not C. */
1827 if (TYPE_NAME (type) != 0
1828 && TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
1829 && DECL_NAME (TYPE_NAME (type)) != 0
1830 && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
1831 {
1832 const char *const name =
1833 IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
1834
1835 /* Note that here we can run afoul of a serious bug in "classic"
1836 svr4 SDB debuggers. They don't seem to understand the
1837 FT_ext_prec_float type (even though they should). */
1838
1839 if (!strcmp (name, "long double"))
1840 return FT_ext_prec_float;
1841 }
1842
1843 if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
1844 {
1845 /* On the SH, when compiling with -m3e or -m4-single-only, both
1846 float and double are 32 bits. But since the debugger doesn't
1847 know about the subtarget, it always thinks double is 64 bits.
1848 So we have to tell the debugger that the type is float to
1849 make the output of the 'print' command etc. readable. */
1850 if (DOUBLE_TYPE_SIZE == FLOAT_TYPE_SIZE && FLOAT_TYPE_SIZE == 32)
1851 return FT_float;
1852 return FT_dbl_prec_float;
1853 }
1854 if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
1855 return FT_float;
1856
1857 /* Note that here we can run afoul of a serious bug in "classic"
1858 svr4 SDB debuggers. They don't seem to understand the
1859 FT_ext_prec_float type (even though they should). */
1860
1861 if (TYPE_PRECISION (type) == LONG_DOUBLE_TYPE_SIZE)
1862 return FT_ext_prec_float;
1863 abort ();
1864
1865 case COMPLEX_TYPE:
1866 return FT_complex; /* GNU FORTRAN COMPLEX type. */
1867
1868 case CHAR_TYPE:
1869 return FT_char; /* GNU Pascal CHAR type. Not used in C. */
1870
1871 case BOOLEAN_TYPE:
1872 return FT_boolean; /* GNU FORTRAN BOOLEAN type. */
1873
1874 default:
1875 abort (); /* No other TREE_CODEs are Dwarf fundamental types. */
1876 }
1877 return 0;
1878 }
1879 \f
1880 /* Given a pointer to an arbitrary ..._TYPE tree node, return a pointer to
1881 the Dwarf "root" type for the given input type. The Dwarf "root" type
1882 of a given type is generally the same as the given type, except that if
1883 the given type is a pointer or reference type, then the root type of
1884 the given type is the root type of the "basis" type for the pointer or
1885 reference type. (This definition of the "root" type is recursive.)
1886 Also, the root type of a `const' qualified type or a `volatile'
1887 qualified type is the root type of the given type without the
1888 qualifiers. */
1889
1890 static tree
1891 root_type_1 (type, count)
1892 tree type;
1893 int count;
1894 {
1895 /* Give up after searching 1000 levels, in case this is a recursive
1896 pointer type. Such types are possible in Ada, but it is not possible
1897 to represent them in DWARF1 debug info. */
1898 if (count > 1000)
1899 return error_mark_node;
1900
1901 switch (TREE_CODE (type))
1902 {
1903 case ERROR_MARK:
1904 return error_mark_node;
1905
1906 case POINTER_TYPE:
1907 case REFERENCE_TYPE:
1908 return root_type_1 (TREE_TYPE (type), count+1);
1909
1910 default:
1911 return type;
1912 }
1913 }
1914
1915 static tree
1916 root_type (type)
1917 tree type;
1918 {
1919 type = root_type_1 (type, 0);
1920 if (type != error_mark_node)
1921 type = type_main_variant (type);
1922 return type;
1923 }
1924
1925 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
1926 of zero or more Dwarf "type-modifier" bytes applicable to the type. */
1927
1928 static void
1929 write_modifier_bytes_1 (type, decl_const, decl_volatile, count)
1930 tree type;
1931 int decl_const;
1932 int decl_volatile;
1933 int count;
1934 {
1935 if (TREE_CODE (type) == ERROR_MARK)
1936 return;
1937
1938 /* Give up after searching 1000 levels, in case this is a recursive
1939 pointer type. Such types are possible in Ada, but it is not possible
1940 to represent them in DWARF1 debug info. */
1941 if (count > 1000)
1942 return;
1943
1944 if (TYPE_READONLY (type) || decl_const)
1945 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
1946 if (TYPE_VOLATILE (type) || decl_volatile)
1947 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_volatile);
1948 switch (TREE_CODE (type))
1949 {
1950 case POINTER_TYPE:
1951 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
1952 write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
1953 return;
1954
1955 case REFERENCE_TYPE:
1956 ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
1957 write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
1958 return;
1959
1960 case ERROR_MARK:
1961 default:
1962 return;
1963 }
1964 }
1965
1966 static void
1967 write_modifier_bytes (type, decl_const, decl_volatile)
1968 tree type;
1969 int decl_const;
1970 int decl_volatile;
1971 {
1972 write_modifier_bytes_1 (type, decl_const, decl_volatile, 0);
1973 }
1974 \f
1975 /* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
1976 given input type is a Dwarf "fundamental" type. Otherwise return zero. */
1977
1978 static inline int
1979 type_is_fundamental (type)
1980 tree type;
1981 {
1982 switch (TREE_CODE (type))
1983 {
1984 case ERROR_MARK:
1985 case VOID_TYPE:
1986 case INTEGER_TYPE:
1987 case REAL_TYPE:
1988 case COMPLEX_TYPE:
1989 case BOOLEAN_TYPE:
1990 case CHAR_TYPE:
1991 return 1;
1992
1993 case SET_TYPE:
1994 case ARRAY_TYPE:
1995 case RECORD_TYPE:
1996 case UNION_TYPE:
1997 case QUAL_UNION_TYPE:
1998 case ENUMERAL_TYPE:
1999 case FUNCTION_TYPE:
2000 case METHOD_TYPE:
2001 case POINTER_TYPE:
2002 case REFERENCE_TYPE:
2003 case FILE_TYPE:
2004 case OFFSET_TYPE:
2005 case LANG_TYPE:
2006 case VECTOR_TYPE:
2007 return 0;
2008
2009 default:
2010 abort ();
2011 }
2012 return 0;
2013 }
2014
2015 /* Given a pointer to some ..._DECL tree node, generate an assembly language
2016 equate directive which will associate a symbolic name with the current DIE.
2017
2018 The name used is an artificial label generated from the DECL_UID number
2019 associated with the given decl node. The name it gets equated to is the
2020 symbolic label that we (previously) output at the start of the DIE that
2021 we are currently generating.
2022
2023 Calling this function while generating some "decl related" form of DIE
2024 makes it possible to later refer to the DIE which represents the given
2025 decl simply by re-generating the symbolic name from the ..._DECL node's
2026 UID number. */
2027
2028 static void
2029 equate_decl_number_to_die_number (decl)
2030 tree decl;
2031 {
2032 /* In the case where we are generating a DIE for some ..._DECL node
2033 which represents either some inline function declaration or some
2034 entity declared within an inline function declaration/definition,
2035 setup a symbolic name for the current DIE so that we have a name
2036 for this DIE that we can easily refer to later on within
2037 AT_abstract_origin attributes. */
2038
2039 char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
2040 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
2041
2042 sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
2043 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
2044 ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
2045 }
2046
2047 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
2048 equate directive which will associate a symbolic name with the current DIE.
2049
2050 The name used is an artificial label generated from the TYPE_UID number
2051 associated with the given type node. The name it gets equated to is the
2052 symbolic label that we (previously) output at the start of the DIE that
2053 we are currently generating.
2054
2055 Calling this function while generating some "type related" form of DIE
2056 makes it easy to later refer to the DIE which represents the given type
2057 simply by re-generating the alternative name from the ..._TYPE node's
2058 UID number. */
2059
2060 static inline void
2061 equate_type_number_to_die_number (type)
2062 tree type;
2063 {
2064 char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
2065 char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
2066
2067 /* We are generating a DIE to represent the main variant of this type
2068 (i.e the type without any const or volatile qualifiers) so in order
2069 to get the equate to come out right, we need to get the main variant
2070 itself here. */
2071
2072 type = type_main_variant (type);
2073
2074 sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
2075 sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
2076 ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
2077 }
2078
2079 static void
2080 output_reg_number (rtl)
2081 rtx rtl;
2082 {
2083 unsigned regno = REGNO (rtl);
2084
2085 if (regno >= DWARF_FRAME_REGISTERS)
2086 {
2087 warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
2088 regno);
2089 regno = 0;
2090 }
2091 dw2_assemble_integer (4, GEN_INT (DBX_REGISTER_NUMBER (regno)));
2092 if (flag_debug_asm)
2093 {
2094 fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
2095 PRINT_REG (rtl, 0, asm_out_file);
2096 }
2097 fputc ('\n', asm_out_file);
2098 }
2099
2100 /* The following routine is a nice and simple transducer. It converts the
2101 RTL for a variable or parameter (resident in memory) into an equivalent
2102 Dwarf representation of a mechanism for getting the address of that same
2103 variable onto the top of a hypothetical "address evaluation" stack.
2104
2105 When creating memory location descriptors, we are effectively trans-
2106 forming the RTL for a memory-resident object into its Dwarf postfix
2107 expression equivalent. This routine just recursively descends an
2108 RTL tree, turning it into Dwarf postfix code as it goes. */
2109
2110 static void
2111 output_mem_loc_descriptor (rtl)
2112 rtx rtl;
2113 {
2114 /* Note that for a dynamically sized array, the location we will
2115 generate a description of here will be the lowest numbered location
2116 which is actually within the array. That's *not* necessarily the
2117 same as the zeroth element of the array. */
2118
2119 #ifdef ASM_SIMPLIFY_DWARF_ADDR
2120 rtl = ASM_SIMPLIFY_DWARF_ADDR (rtl);
2121 #endif
2122
2123 switch (GET_CODE (rtl))
2124 {
2125 case SUBREG:
2126
2127 /* The case of a subreg may arise when we have a local (register)
2128 variable or a formal (register) parameter which doesn't quite
2129 fill up an entire register. For now, just assume that it is
2130 legitimate to make the Dwarf info refer to the whole register
2131 which contains the given subreg. */
2132
2133 rtl = SUBREG_REG (rtl);
2134 /* Drop thru. */
2135
2136 case REG:
2137
2138 /* Whenever a register number forms a part of the description of
2139 the method for calculating the (dynamic) address of a memory
2140 resident object, DWARF rules require the register number to
2141 be referred to as a "base register". This distinction is not
2142 based in any way upon what category of register the hardware
2143 believes the given register belongs to. This is strictly
2144 DWARF terminology we're dealing with here.
2145
2146 Note that in cases where the location of a memory-resident data
2147 object could be expressed as:
2148
2149 OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
2150
2151 the actual DWARF location descriptor that we generate may just
2152 be OP_BASEREG (basereg). This may look deceptively like the
2153 object in question was allocated to a register (rather than
2154 in memory) so DWARF consumers need to be aware of the subtle
2155 distinction between OP_REG and OP_BASEREG. */
2156
2157 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
2158 output_reg_number (rtl);
2159 break;
2160
2161 case MEM:
2162 output_mem_loc_descriptor (XEXP (rtl, 0));
2163 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_DEREF4);
2164 break;
2165
2166 case CONST:
2167 case SYMBOL_REF:
2168 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADDR);
2169 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2170 break;
2171
2172 case PLUS:
2173 output_mem_loc_descriptor (XEXP (rtl, 0));
2174 output_mem_loc_descriptor (XEXP (rtl, 1));
2175 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2176 break;
2177
2178 case CONST_INT:
2179 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
2180 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
2181 break;
2182
2183 case MULT:
2184 /* If a pseudo-reg is optimized away, it is possible for it to
2185 be replaced with a MEM containing a multiply. Use a GNU extension
2186 to describe it. */
2187 output_mem_loc_descriptor (XEXP (rtl, 0));
2188 output_mem_loc_descriptor (XEXP (rtl, 1));
2189 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_MULT);
2190 break;
2191
2192 default:
2193 abort ();
2194 }
2195 }
2196
2197 /* Output a proper Dwarf location descriptor for a variable or parameter
2198 which is either allocated in a register or in a memory location. For
2199 a register, we just generate an OP_REG and the register number. For a
2200 memory location we provide a Dwarf postfix expression describing how to
2201 generate the (dynamic) address of the object onto the address stack. */
2202
2203 static void
2204 output_loc_descriptor (rtl)
2205 rtx rtl;
2206 {
2207 switch (GET_CODE (rtl))
2208 {
2209 case SUBREG:
2210
2211 /* The case of a subreg may arise when we have a local (register)
2212 variable or a formal (register) parameter which doesn't quite
2213 fill up an entire register. For now, just assume that it is
2214 legitimate to make the Dwarf info refer to the whole register
2215 which contains the given subreg. */
2216
2217 rtl = SUBREG_REG (rtl);
2218 /* Drop thru. */
2219
2220 case REG:
2221 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
2222 output_reg_number (rtl);
2223 break;
2224
2225 case MEM:
2226 output_mem_loc_descriptor (XEXP (rtl, 0));
2227 break;
2228
2229 default:
2230 abort (); /* Should never happen */
2231 }
2232 }
2233
2234 /* Given a tree node describing an array bound (either lower or upper)
2235 output a representation for that bound. */
2236
2237 static void
2238 output_bound_representation (bound, dim_num, u_or_l)
2239 tree bound;
2240 unsigned dim_num; /* For multi-dimensional arrays. */
2241 char u_or_l; /* Designates upper or lower bound. */
2242 {
2243 switch (TREE_CODE (bound))
2244 {
2245
2246 case ERROR_MARK:
2247 return;
2248
2249 /* All fixed-bounds are represented by INTEGER_CST nodes. */
2250
2251 case INTEGER_CST:
2252 if (host_integerp (bound, 0))
2253 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, tree_low_cst (bound, 0));
2254 break;
2255
2256 default:
2257
2258 /* Dynamic bounds may be represented by NOP_EXPR nodes containing
2259 SAVE_EXPR nodes, in which case we can do something, or as
2260 an expression, which we cannot represent. */
2261 {
2262 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2263 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2264
2265 sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
2266 current_dienum, dim_num, u_or_l);
2267
2268 sprintf (end_label, BOUND_END_LABEL_FMT,
2269 current_dienum, dim_num, u_or_l);
2270
2271 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2272 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2273
2274 /* If optimization is turned on, the SAVE_EXPRs that describe
2275 how to access the upper bound values are essentially bogus.
2276 They only describe (at best) how to get at these values at
2277 the points in the generated code right after they have just
2278 been computed. Worse yet, in the typical case, the upper
2279 bound values will not even *be* computed in the optimized
2280 code, so these SAVE_EXPRs are entirely bogus.
2281
2282 In order to compensate for this fact, we check here to see
2283 if optimization is enabled, and if so, we effectively create
2284 an empty location description for the (unknown and unknowable)
2285 upper bound.
2286
2287 This should not cause too much trouble for existing (stupid?)
2288 debuggers because they have to deal with empty upper bounds
2289 location descriptions anyway in order to be able to deal with
2290 incomplete array types.
2291
2292 Of course an intelligent debugger (GDB?) should be able to
2293 comprehend that a missing upper bound specification in a
2294 array type used for a storage class `auto' local array variable
2295 indicates that the upper bound is both unknown (at compile-
2296 time) and unknowable (at run-time) due to optimization. */
2297
2298 if (! optimize)
2299 {
2300 while (TREE_CODE (bound) == NOP_EXPR
2301 || TREE_CODE (bound) == CONVERT_EXPR)
2302 bound = TREE_OPERAND (bound, 0);
2303
2304 if (TREE_CODE (bound) == SAVE_EXPR)
2305 output_loc_descriptor
2306 (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
2307 }
2308
2309 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2310 }
2311 break;
2312
2313 }
2314 }
2315
2316 /* Recursive function to output a sequence of value/name pairs for
2317 enumeration constants in reversed order. This is called from
2318 enumeration_type_die. */
2319
2320 static void
2321 output_enumeral_list (link)
2322 tree link;
2323 {
2324 if (link)
2325 {
2326 output_enumeral_list (TREE_CHAIN (link));
2327
2328 if (host_integerp (TREE_VALUE (link), 0))
2329 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
2330 tree_low_cst (TREE_VALUE (link), 0));
2331
2332 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
2333 IDENTIFIER_POINTER (TREE_PURPOSE (link)));
2334 }
2335 }
2336
2337 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
2338 which is not less than the value itself. */
2339
2340 static inline HOST_WIDE_INT
2341 ceiling (value, boundary)
2342 HOST_WIDE_INT value;
2343 unsigned int boundary;
2344 {
2345 return (((value + boundary - 1) / boundary) * boundary);
2346 }
2347
2348 /* Given a pointer to what is assumed to be a FIELD_DECL node, return a
2349 pointer to the declared type for the relevant field variable, or return
2350 `integer_type_node' if the given node turns out to be an ERROR_MARK node. */
2351
2352 static inline tree
2353 field_type (decl)
2354 tree decl;
2355 {
2356 tree type;
2357
2358 if (TREE_CODE (decl) == ERROR_MARK)
2359 return integer_type_node;
2360
2361 type = DECL_BIT_FIELD_TYPE (decl);
2362 if (type == NULL)
2363 type = TREE_TYPE (decl);
2364 return type;
2365 }
2366
2367 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
2368 node, return the alignment in bits for the type, or else return
2369 BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node. */
2370
2371 static inline unsigned int
2372 simple_type_align_in_bits (type)
2373 tree type;
2374 {
2375 return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
2376 }
2377
2378 /* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
2379 node, return the size in bits for the type if it is a constant, or
2380 else return the alignment for the type if the type's size is not
2381 constant, or else return BITS_PER_WORD if the type actually turns out
2382 to be an ERROR_MARK node. */
2383
2384 static inline unsigned HOST_WIDE_INT
2385 simple_type_size_in_bits (type)
2386 tree type;
2387 {
2388 tree type_size_tree;
2389
2390 if (TREE_CODE (type) == ERROR_MARK)
2391 return BITS_PER_WORD;
2392 type_size_tree = TYPE_SIZE (type);
2393
2394 if (type_size_tree == NULL_TREE)
2395 return 0;
2396 if (! host_integerp (type_size_tree, 1))
2397 return TYPE_ALIGN (type);
2398 return tree_low_cst (type_size_tree, 1);
2399 }
2400
2401 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
2402 return the byte offset of the lowest addressed byte of the "containing
2403 object" for the given FIELD_DECL, or return 0 if we are unable to deter-
2404 mine what that offset is, either because the argument turns out to be a
2405 pointer to an ERROR_MARK node, or because the offset is actually variable.
2406 (We can't handle the latter case just yet.) */
2407
2408 static HOST_WIDE_INT
2409 field_byte_offset (decl)
2410 tree decl;
2411 {
2412 unsigned int type_align_in_bytes;
2413 unsigned int type_align_in_bits;
2414 unsigned HOST_WIDE_INT type_size_in_bits;
2415 HOST_WIDE_INT object_offset_in_align_units;
2416 HOST_WIDE_INT object_offset_in_bits;
2417 HOST_WIDE_INT object_offset_in_bytes;
2418 tree type;
2419 tree field_size_tree;
2420 HOST_WIDE_INT bitpos_int;
2421 HOST_WIDE_INT deepest_bitpos;
2422 unsigned HOST_WIDE_INT field_size_in_bits;
2423
2424 if (TREE_CODE (decl) == ERROR_MARK)
2425 return 0;
2426
2427 if (TREE_CODE (decl) != FIELD_DECL)
2428 abort ();
2429
2430 type = field_type (decl);
2431 field_size_tree = DECL_SIZE (decl);
2432
2433 /* The size could be unspecified if there was an error, or for
2434 a flexible array member. */
2435 if (! field_size_tree)
2436 field_size_tree = bitsize_zero_node;
2437
2438 /* We cannot yet cope with fields whose positions or sizes are variable,
2439 so for now, when we see such things, we simply return 0. Someday,
2440 we may be able to handle such cases, but it will be damn difficult. */
2441
2442 if (! host_integerp (bit_position (decl), 0)
2443 || ! host_integerp (field_size_tree, 1))
2444 return 0;
2445
2446 bitpos_int = int_bit_position (decl);
2447 field_size_in_bits = tree_low_cst (field_size_tree, 1);
2448
2449 type_size_in_bits = simple_type_size_in_bits (type);
2450 type_align_in_bits = simple_type_align_in_bits (type);
2451 type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
2452
2453 /* Note that the GCC front-end doesn't make any attempt to keep track
2454 of the starting bit offset (relative to the start of the containing
2455 structure type) of the hypothetical "containing object" for a bit-
2456 field. Thus, when computing the byte offset value for the start of
2457 the "containing object" of a bit-field, we must deduce this infor-
2458 mation on our own.
2459
2460 This can be rather tricky to do in some cases. For example, handling
2461 the following structure type definition when compiling for an i386/i486
2462 target (which only aligns long long's to 32-bit boundaries) can be very
2463 tricky:
2464
2465 struct S {
2466 int field1;
2467 long long field2:31;
2468 };
2469
2470 Fortunately, there is a simple rule-of-thumb which can be used in such
2471 cases. When compiling for an i386/i486, GCC will allocate 8 bytes for
2472 the structure shown above. It decides to do this based upon one simple
2473 rule for bit-field allocation. Quite simply, GCC allocates each "con-
2474 taining object" for each bit-field at the first (i.e. lowest addressed)
2475 legitimate alignment boundary (based upon the required minimum alignment
2476 for the declared type of the field) which it can possibly use, subject
2477 to the condition that there is still enough available space remaining
2478 in the containing object (when allocated at the selected point) to
2479 fully accommodate all of the bits of the bit-field itself.
2480
2481 This simple rule makes it obvious why GCC allocates 8 bytes for each
2482 object of the structure type shown above. When looking for a place to
2483 allocate the "containing object" for `field2', the compiler simply tries
2484 to allocate a 64-bit "containing object" at each successive 32-bit
2485 boundary (starting at zero) until it finds a place to allocate that 64-
2486 bit field such that at least 31 contiguous (and previously unallocated)
2487 bits remain within that selected 64 bit field. (As it turns out, for
2488 the example above, the compiler finds that it is OK to allocate the
2489 "containing object" 64-bit field at bit-offset zero within the
2490 structure type.)
2491
2492 Here we attempt to work backwards from the limited set of facts we're
2493 given, and we try to deduce from those facts, where GCC must have
2494 believed that the containing object started (within the structure type).
2495
2496 The value we deduce is then used (by the callers of this routine) to
2497 generate AT_location and AT_bit_offset attributes for fields (both
2498 bit-fields and, in the case of AT_location, regular fields as well). */
2499
2500 /* Figure out the bit-distance from the start of the structure to the
2501 "deepest" bit of the bit-field. */
2502 deepest_bitpos = bitpos_int + field_size_in_bits;
2503
2504 /* This is the tricky part. Use some fancy footwork to deduce where the
2505 lowest addressed bit of the containing object must be. */
2506 object_offset_in_bits
2507 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
2508
2509 /* Compute the offset of the containing object in "alignment units". */
2510 object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
2511
2512 /* Compute the offset of the containing object in bytes. */
2513 object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
2514
2515 /* The above code assumes that the field does not cross an alignment
2516 boundary. This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
2517 or if the structure is packed. If this happens, then we get an object
2518 which starts after the bitfield, which means that the bit offset is
2519 negative. Gdb fails when given negative bit offsets. We avoid this
2520 by recomputing using the first bit of the bitfield. This will give
2521 us an object which does not completely contain the bitfield, but it
2522 will be aligned, and it will contain the first bit of the bitfield.
2523
2524 However, only do this for a BYTES_BIG_ENDIAN target. For a
2525 ! BYTES_BIG_ENDIAN target, bitpos_int + field_size_in_bits is the first
2526 first bit of the bitfield. If we recompute using bitpos_int + 1 below,
2527 then we end up computing the object byte offset for the wrong word of the
2528 desired bitfield, which in turn causes the field offset to be negative
2529 in bit_offset_attribute. */
2530 if (BYTES_BIG_ENDIAN
2531 && object_offset_in_bits > bitpos_int)
2532 {
2533 deepest_bitpos = bitpos_int + 1;
2534 object_offset_in_bits
2535 = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
2536 object_offset_in_align_units = (object_offset_in_bits
2537 / type_align_in_bits);
2538 object_offset_in_bytes = (object_offset_in_align_units
2539 * type_align_in_bytes);
2540 }
2541
2542 return object_offset_in_bytes;
2543 }
2544
2545 /****************************** attributes *********************************/
2546
2547 /* The following routines are responsible for writing out the various types
2548 of Dwarf attributes (and any following data bytes associated with them).
2549 These routines are listed in order based on the numerical codes of their
2550 associated attributes. */
2551
2552 /* Generate an AT_sibling attribute. */
2553
2554 static inline void
2555 sibling_attribute ()
2556 {
2557 char label[MAX_ARTIFICIAL_LABEL_BYTES];
2558
2559 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sibling);
2560 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
2561 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
2562 }
2563
2564 /* Output the form of location attributes suitable for whole variables and
2565 whole parameters. Note that the location attributes for struct fields
2566 are generated by the routine `data_member_location_attribute' below. */
2567
2568 static void
2569 location_attribute (rtl)
2570 rtx rtl;
2571 {
2572 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2573 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2574
2575 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2576 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2577 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2578 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2579 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2580
2581 /* Handle a special case. If we are about to output a location descriptor
2582 for a variable or parameter which has been optimized out of existence,
2583 don't do that. Instead we output a zero-length location descriptor
2584 value as part of the location attribute.
2585
2586 A variable which has been optimized out of existence will have a
2587 DECL_RTL value which denotes a pseudo-reg.
2588
2589 Currently, in some rare cases, variables can have DECL_RTL values
2590 which look like (MEM (REG pseudo-reg#)). These cases are due to
2591 bugs elsewhere in the compiler. We treat such cases
2592 as if the variable(s) in question had been optimized out of existence.
2593
2594 Note that in all cases where we wish to express the fact that a
2595 variable has been optimized out of existence, we do not simply
2596 suppress the generation of the entire location attribute because
2597 the absence of a location attribute in certain kinds of DIEs is
2598 used to indicate something else entirely... i.e. that the DIE
2599 represents an object declaration, but not a definition. So saith
2600 the PLSIG.
2601 */
2602
2603 if (! is_pseudo_reg (rtl)
2604 && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
2605 output_loc_descriptor (rtl);
2606
2607 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2608 }
2609
2610 /* Output the specialized form of location attribute used for data members
2611 of struct and union types.
2612
2613 In the special case of a FIELD_DECL node which represents a bit-field,
2614 the "offset" part of this special location descriptor must indicate the
2615 distance in bytes from the lowest-addressed byte of the containing
2616 struct or union type to the lowest-addressed byte of the "containing
2617 object" for the bit-field. (See the `field_byte_offset' function above.)
2618
2619 For any given bit-field, the "containing object" is a hypothetical
2620 object (of some integral or enum type) within which the given bit-field
2621 lives. The type of this hypothetical "containing object" is always the
2622 same as the declared type of the individual bit-field itself (for GCC
2623 anyway... the DWARF spec doesn't actually mandate this).
2624
2625 Note that it is the size (in bytes) of the hypothetical "containing
2626 object" which will be given in the AT_byte_size attribute for this
2627 bit-field. (See the `byte_size_attribute' function below.) It is
2628 also used when calculating the value of the AT_bit_offset attribute.
2629 (See the `bit_offset_attribute' function below.) */
2630
2631 static void
2632 data_member_location_attribute (t)
2633 tree t;
2634 {
2635 unsigned object_offset_in_bytes;
2636 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2637 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2638
2639 if (TREE_CODE (t) == TREE_VEC)
2640 object_offset_in_bytes = tree_low_cst (BINFO_OFFSET (t), 0);
2641 else
2642 object_offset_in_bytes = field_byte_offset (t);
2643
2644 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
2645 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2646 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2647 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2648 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2649 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
2650 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
2651 ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
2652 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2653 }
2654
2655 /* Output an AT_const_value attribute for a variable or a parameter which
2656 does not have a "location" either in memory or in a register. These
2657 things can arise in GNU C when a constant is passed as an actual
2658 parameter to an inlined function. They can also arise in C++ where
2659 declared constants do not necessarily get memory "homes". */
2660
2661 static void
2662 const_value_attribute (rtl)
2663 rtx rtl;
2664 {
2665 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2666 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2667
2668 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_const_value_block4);
2669 sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
2670 sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
2671 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
2672 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2673
2674 switch (GET_CODE (rtl))
2675 {
2676 case CONST_INT:
2677 /* Note that a CONST_INT rtx could represent either an integer or
2678 a floating-point constant. A CONST_INT is used whenever the
2679 constant will fit into a single word. In all such cases, the
2680 original mode of the constant value is wiped out, and the
2681 CONST_INT rtx is assigned VOIDmode. Since we no longer have
2682 precise mode information for these constants, we always just
2683 output them using 4 bytes. */
2684
2685 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, (unsigned) INTVAL (rtl));
2686 break;
2687
2688 case CONST_DOUBLE:
2689 /* Note that a CONST_DOUBLE rtx could represent either an integer
2690 or a floating-point constant. A CONST_DOUBLE is used whenever
2691 the constant requires more than one word in order to be adequately
2692 represented. In all such cases, the original mode of the constant
2693 value is preserved as the mode of the CONST_DOUBLE rtx, but for
2694 simplicity we always just output CONST_DOUBLEs using 8 bytes. */
2695
2696 ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
2697 (unsigned int) CONST_DOUBLE_HIGH (rtl),
2698 (unsigned int) CONST_DOUBLE_LOW (rtl));
2699 break;
2700
2701 case CONST_STRING:
2702 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, XSTR (rtl, 0));
2703 break;
2704
2705 case SYMBOL_REF:
2706 case LABEL_REF:
2707 case CONST:
2708 ASM_OUTPUT_DWARF_ADDR_CONST (asm_out_file, rtl);
2709 break;
2710
2711 case PLUS:
2712 /* In cases where an inlined instance of an inline function is passed
2713 the address of an `auto' variable (which is local to the caller)
2714 we can get a situation where the DECL_RTL of the artificial
2715 local variable (for the inlining) which acts as a stand-in for
2716 the corresponding formal parameter (of the inline function)
2717 will look like (plus:SI (reg:SI FRAME_PTR) (const_int ...)).
2718 This is not exactly a compile-time constant expression, but it
2719 isn't the address of the (artificial) local variable either.
2720 Rather, it represents the *value* which the artificial local
2721 variable always has during its lifetime. We currently have no
2722 way to represent such quasi-constant values in Dwarf, so for now
2723 we just punt and generate an AT_const_value attribute with form
2724 FORM_BLOCK4 and a length of zero. */
2725 break;
2726
2727 default:
2728 abort (); /* No other kinds of rtx should be possible here. */
2729 }
2730
2731 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2732 }
2733
2734 /* Generate *either* an AT_location attribute or else an AT_const_value
2735 data attribute for a variable or a parameter. We generate the
2736 AT_const_value attribute only in those cases where the given
2737 variable or parameter does not have a true "location" either in
2738 memory or in a register. This can happen (for example) when a
2739 constant is passed as an actual argument in a call to an inline
2740 function. (It's possible that these things can crop up in other
2741 ways also.) Note that one type of constant value which can be
2742 passed into an inlined function is a constant pointer. This can
2743 happen for example if an actual argument in an inlined function
2744 call evaluates to a compile-time constant address. */
2745
2746 static void
2747 location_or_const_value_attribute (decl)
2748 tree decl;
2749 {
2750 rtx rtl;
2751
2752 if (TREE_CODE (decl) == ERROR_MARK)
2753 return;
2754
2755 if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
2756 {
2757 /* Should never happen. */
2758 abort ();
2759 return;
2760 }
2761
2762 /* Here we have to decide where we are going to say the parameter "lives"
2763 (as far as the debugger is concerned). We only have a couple of choices.
2764 GCC provides us with DECL_RTL and with DECL_INCOMING_RTL. DECL_RTL
2765 normally indicates where the parameter lives during most of the activa-
2766 tion of the function. If optimization is enabled however, this could
2767 be either NULL or else a pseudo-reg. Both of those cases indicate that
2768 the parameter doesn't really live anywhere (as far as the code generation
2769 parts of GCC are concerned) during most of the function's activation.
2770 That will happen (for example) if the parameter is never referenced
2771 within the function.
2772
2773 We could just generate a location descriptor here for all non-NULL
2774 non-pseudo values of DECL_RTL and ignore all of the rest, but we can
2775 be a little nicer than that if we also consider DECL_INCOMING_RTL in
2776 cases where DECL_RTL is NULL or is a pseudo-reg.
2777
2778 Note however that we can only get away with using DECL_INCOMING_RTL as
2779 a backup substitute for DECL_RTL in certain limited cases. In cases
2780 where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
2781 we can be sure that the parameter was passed using the same type as it
2782 is declared to have within the function, and that its DECL_INCOMING_RTL
2783 points us to a place where a value of that type is passed. In cases
2784 where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
2785 however, we cannot (in general) use DECL_INCOMING_RTL as a backup
2786 substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
2787 points us to a value of some type which is *different* from the type
2788 of the parameter itself. Thus, if we tried to use DECL_INCOMING_RTL
2789 to generate a location attribute in such cases, the debugger would
2790 end up (for example) trying to fetch a `float' from a place which
2791 actually contains the first part of a `double'. That would lead to
2792 really incorrect and confusing output at debug-time, and we don't
2793 want that now do we?
2794
2795 So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
2796 in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl). There are a
2797 couple of cute exceptions however. On little-endian machines we can
2798 get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
2799 not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
2800 an integral type which is smaller than TREE_TYPE(decl). These cases
2801 arise when (on a little-endian machine) a non-prototyped function has
2802 a parameter declared to be of type `short' or `char'. In such cases,
2803 TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
2804 `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
2805 passed `int' value. If the debugger then uses that address to fetch a
2806 `short' or a `char' (on a little-endian machine) the result will be the
2807 correct data, so we allow for such exceptional cases below.
2808
2809 Note that our goal here is to describe the place where the given formal
2810 parameter lives during most of the function's activation (i.e. between
2811 the end of the prologue and the start of the epilogue). We'll do that
2812 as best as we can. Note however that if the given formal parameter is
2813 modified sometime during the execution of the function, then a stack
2814 backtrace (at debug-time) will show the function as having been called
2815 with the *new* value rather than the value which was originally passed
2816 in. This happens rarely enough that it is not a major problem, but it
2817 *is* a problem, and I'd like to fix it. A future version of dwarfout.c
2818 may generate two additional attributes for any given TAG_formal_parameter
2819 DIE which will describe the "passed type" and the "passed location" for
2820 the given formal parameter in addition to the attributes we now generate
2821 to indicate the "declared type" and the "active location" for each
2822 parameter. This additional set of attributes could be used by debuggers
2823 for stack backtraces.
2824
2825 Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
2826 can be NULL also. This happens (for example) for inlined-instances of
2827 inline function formal parameters which are never referenced. This really
2828 shouldn't be happening. All PARM_DECL nodes should get valid non-NULL
2829 DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
2830 these values for inlined instances of inline function parameters, so
2831 when we see such cases, we are just out-of-luck for the time
2832 being (until integrate.c gets fixed).
2833 */
2834
2835 /* Use DECL_RTL as the "location" unless we find something better. */
2836 rtl = DECL_RTL (decl);
2837
2838 if (TREE_CODE (decl) == PARM_DECL)
2839 if (rtl == NULL_RTX || is_pseudo_reg (rtl))
2840 {
2841 /* This decl represents a formal parameter which was optimized out. */
2842 tree declared_type = type_main_variant (TREE_TYPE (decl));
2843 tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
2844
2845 /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
2846 *all* cases where (rtl == NULL_RTX) just below. */
2847
2848 if (declared_type == passed_type)
2849 rtl = DECL_INCOMING_RTL (decl);
2850 else if (! BYTES_BIG_ENDIAN)
2851 if (TREE_CODE (declared_type) == INTEGER_TYPE)
2852 /* NMS WTF? */
2853 if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
2854 rtl = DECL_INCOMING_RTL (decl);
2855 }
2856
2857 if (rtl == NULL_RTX)
2858 return;
2859
2860 rtl = eliminate_regs (rtl, 0, NULL_RTX);
2861 #ifdef LEAF_REG_REMAP
2862 if (current_function_uses_only_leaf_regs)
2863 leaf_renumber_regs_insn (rtl);
2864 #endif
2865
2866 switch (GET_CODE (rtl))
2867 {
2868 case ADDRESSOF:
2869 /* The address of a variable that was optimized away; don't emit
2870 anything. */
2871 break;
2872
2873 case CONST_INT:
2874 case CONST_DOUBLE:
2875 case CONST_STRING:
2876 case SYMBOL_REF:
2877 case LABEL_REF:
2878 case CONST:
2879 case PLUS: /* DECL_RTL could be (plus (reg ...) (const_int ...)) */
2880 const_value_attribute (rtl);
2881 break;
2882
2883 case MEM:
2884 case REG:
2885 case SUBREG:
2886 location_attribute (rtl);
2887 break;
2888
2889 case CONCAT:
2890 /* ??? CONCAT is used for complex variables, which may have the real
2891 part stored in one place and the imag part stored somewhere else.
2892 DWARF1 has no way to describe a variable that lives in two different
2893 places, so we just describe where the first part lives, and hope that
2894 the second part is stored after it. */
2895 location_attribute (XEXP (rtl, 0));
2896 break;
2897
2898 default:
2899 abort (); /* Should never happen. */
2900 }
2901 }
2902
2903 /* Generate an AT_name attribute given some string value to be included as
2904 the value of the attribute. */
2905
2906 static inline void
2907 name_attribute (name_string)
2908 const char *name_string;
2909 {
2910 if (name_string && *name_string)
2911 {
2912 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
2913 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, name_string);
2914 }
2915 }
2916
2917 static inline void
2918 fund_type_attribute (ft_code)
2919 unsigned ft_code;
2920 {
2921 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
2922 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
2923 }
2924
2925 static void
2926 mod_fund_type_attribute (type, decl_const, decl_volatile)
2927 tree type;
2928 int decl_const;
2929 int decl_volatile;
2930 {
2931 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2932 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2933
2934 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_fund_type);
2935 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2936 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2937 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2938 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2939 write_modifier_bytes (type, decl_const, decl_volatile);
2940 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
2941 fundamental_type_code (root_type (type)));
2942 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2943 }
2944
2945 static inline void
2946 user_def_type_attribute (type)
2947 tree type;
2948 {
2949 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2950
2951 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_user_def_type);
2952 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (type));
2953 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2954 }
2955
2956 static void
2957 mod_u_d_type_attribute (type, decl_const, decl_volatile)
2958 tree type;
2959 int decl_const;
2960 int decl_volatile;
2961 {
2962 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2963 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2964 char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
2965
2966 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mod_u_d_type);
2967 sprintf (begin_label, MT_BEGIN_LABEL_FMT, current_dienum);
2968 sprintf (end_label, MT_END_LABEL_FMT, current_dienum);
2969 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
2970 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
2971 write_modifier_bytes (type, decl_const, decl_volatile);
2972 sprintf (ud_type_name, TYPE_NAME_FMT, TYPE_UID (root_type (type)));
2973 ASM_OUTPUT_DWARF_REF (asm_out_file, ud_type_name);
2974 ASM_OUTPUT_LABEL (asm_out_file, end_label);
2975 }
2976
2977 #ifdef USE_ORDERING_ATTRIBUTE
2978 static inline void
2979 ordering_attribute (ordering)
2980 unsigned ordering;
2981 {
2982 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
2983 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
2984 }
2985 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
2986
2987 /* Note that the block of subscript information for an array type also
2988 includes information about the element type of type given array type. */
2989
2990 static void
2991 subscript_data_attribute (type)
2992 tree type;
2993 {
2994 unsigned dimension_number;
2995 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
2996 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
2997
2998 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_subscr_data);
2999 sprintf (begin_label, SS_BEGIN_LABEL_FMT, current_dienum);
3000 sprintf (end_label, SS_END_LABEL_FMT, current_dienum);
3001 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
3002 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3003
3004 /* The GNU compilers represent multidimensional array types as sequences
3005 of one dimensional array types whose element types are themselves array
3006 types. Here we squish that down, so that each multidimensional array
3007 type gets only one array_type DIE in the Dwarf debugging info. The
3008 draft Dwarf specification say that we are allowed to do this kind
3009 of compression in C (because there is no difference between an
3010 array or arrays and a multidimensional array in C) but for other
3011 source languages (e.g. Ada) we probably shouldn't do this. */
3012
3013 for (dimension_number = 0;
3014 TREE_CODE (type) == ARRAY_TYPE;
3015 type = TREE_TYPE (type), dimension_number++)
3016 {
3017 tree domain = TYPE_DOMAIN (type);
3018
3019 /* Arrays come in three flavors. Unspecified bounds, fixed
3020 bounds, and (in GNU C only) variable bounds. Handle all
3021 three forms here. */
3022
3023 if (domain)
3024 {
3025 /* We have an array type with specified bounds. */
3026
3027 tree lower = TYPE_MIN_VALUE (domain);
3028 tree upper = TYPE_MAX_VALUE (domain);
3029
3030 /* Handle only fundamental types as index types for now. */
3031 if (! type_is_fundamental (domain))
3032 abort ();
3033
3034 /* Output the representation format byte for this dimension. */
3035 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
3036 FMT_CODE (1, TREE_CODE (lower) == INTEGER_CST,
3037 upper && TREE_CODE (upper) == INTEGER_CST));
3038
3039 /* Output the index type for this dimension. */
3040 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
3041 fundamental_type_code (domain));
3042
3043 /* Output the representation for the lower bound. */
3044 output_bound_representation (lower, dimension_number, 'l');
3045
3046 /* Output the representation for the upper bound. */
3047 if (upper)
3048 output_bound_representation (upper, dimension_number, 'u');
3049 else
3050 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
3051 }
3052 else
3053 {
3054 /* We have an array type with an unspecified length. For C and
3055 C++ we can assume that this really means that (a) the index
3056 type is an integral type, and (b) the lower bound is zero.
3057 Note that Dwarf defines the representation of an unspecified
3058 (upper) bound as being a zero-length location description. */
3059
3060 /* Output the array-bounds format byte. */
3061
3062 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_FT_C_X);
3063
3064 /* Output the (assumed) index type. */
3065
3066 ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, FT_integer);
3067
3068 /* Output the (assumed) lower bound (constant) value. */
3069
3070 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
3071
3072 /* Output the (empty) location description for the upper bound. */
3073
3074 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
3075 }
3076 }
3077
3078 /* Output the prefix byte that says that the element type is coming up. */
3079
3080 ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
3081
3082 /* Output a representation of the type of the elements of this array type. */
3083
3084 type_attribute (type, 0, 0);
3085
3086 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3087 }
3088
3089 static void
3090 byte_size_attribute (tree_node)
3091 tree tree_node;
3092 {
3093 unsigned size;
3094
3095 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
3096 switch (TREE_CODE (tree_node))
3097 {
3098 case ERROR_MARK:
3099 size = 0;
3100 break;
3101
3102 case ENUMERAL_TYPE:
3103 case RECORD_TYPE:
3104 case UNION_TYPE:
3105 case QUAL_UNION_TYPE:
3106 case ARRAY_TYPE:
3107 size = int_size_in_bytes (tree_node);
3108 break;
3109
3110 case FIELD_DECL:
3111 /* For a data member of a struct or union, the AT_byte_size is
3112 generally given as the number of bytes normally allocated for
3113 an object of the *declared* type of the member itself. This
3114 is true even for bit-fields. */
3115 size = simple_type_size_in_bits (field_type (tree_node))
3116 / BITS_PER_UNIT;
3117 break;
3118
3119 default:
3120 abort ();
3121 }
3122
3123 /* Note that `size' might be -1 when we get to this point. If it
3124 is, that indicates that the byte size of the entity in question
3125 is variable. We have no good way of expressing this fact in Dwarf
3126 at the present time, so just let the -1 pass on through. */
3127
3128 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
3129 }
3130
3131 /* For a FIELD_DECL node which represents a bit-field, output an attribute
3132 which specifies the distance in bits from the highest order bit of the
3133 "containing object" for the bit-field to the highest order bit of the
3134 bit-field itself.
3135
3136 For any given bit-field, the "containing object" is a hypothetical
3137 object (of some integral or enum type) within which the given bit-field
3138 lives. The type of this hypothetical "containing object" is always the
3139 same as the declared type of the individual bit-field itself.
3140
3141 The determination of the exact location of the "containing object" for
3142 a bit-field is rather complicated. It's handled by the `field_byte_offset'
3143 function (above).
3144
3145 Note that it is the size (in bytes) of the hypothetical "containing
3146 object" which will be given in the AT_byte_size attribute for this
3147 bit-field. (See `byte_size_attribute' above.) */
3148
3149 static inline void
3150 bit_offset_attribute (decl)
3151 tree decl;
3152 {
3153 HOST_WIDE_INT object_offset_in_bytes = field_byte_offset (decl);
3154 tree type = DECL_BIT_FIELD_TYPE (decl);
3155 HOST_WIDE_INT bitpos_int;
3156 HOST_WIDE_INT highest_order_object_bit_offset;
3157 HOST_WIDE_INT highest_order_field_bit_offset;
3158 HOST_WIDE_INT bit_offset;
3159
3160 /* Must be a bit field. */
3161 if (!type
3162 || TREE_CODE (decl) != FIELD_DECL)
3163 abort ();
3164
3165 /* We can't yet handle bit-fields whose offsets or sizes are variable, so
3166 if we encounter such things, just return without generating any
3167 attribute whatsoever. */
3168
3169 if (! host_integerp (bit_position (decl), 0)
3170 || ! host_integerp (DECL_SIZE (decl), 1))
3171 return;
3172
3173 bitpos_int = int_bit_position (decl);
3174
3175 /* Note that the bit offset is always the distance (in bits) from the
3176 highest-order bit of the "containing object" to the highest-order
3177 bit of the bit-field itself. Since the "high-order end" of any
3178 object or field is different on big-endian and little-endian machines,
3179 the computation below must take account of these differences. */
3180
3181 highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
3182 highest_order_field_bit_offset = bitpos_int;
3183
3184 if (! BYTES_BIG_ENDIAN)
3185 {
3186 highest_order_field_bit_offset += tree_low_cst (DECL_SIZE (decl), 1);
3187 highest_order_object_bit_offset += simple_type_size_in_bits (type);
3188 }
3189
3190 bit_offset =
3191 (! BYTES_BIG_ENDIAN
3192 ? highest_order_object_bit_offset - highest_order_field_bit_offset
3193 : highest_order_field_bit_offset - highest_order_object_bit_offset);
3194
3195 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
3196 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
3197 }
3198
3199 /* For a FIELD_DECL node which represents a bit field, output an attribute
3200 which specifies the length in bits of the given field. */
3201
3202 static inline void
3203 bit_size_attribute (decl)
3204 tree decl;
3205 {
3206 /* Must be a field and a bit field. */
3207 if (TREE_CODE (decl) != FIELD_DECL
3208 || ! DECL_BIT_FIELD_TYPE (decl))
3209 abort ();
3210
3211 if (host_integerp (DECL_SIZE (decl), 1))
3212 {
3213 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
3214 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
3215 tree_low_cst (DECL_SIZE (decl), 1));
3216 }
3217 }
3218
3219 /* The following routine outputs the `element_list' attribute for enumeration
3220 type DIEs. The element_lits attribute includes the names and values of
3221 all of the enumeration constants associated with the given enumeration
3222 type. */
3223
3224 static inline void
3225 element_list_attribute (element)
3226 tree element;
3227 {
3228 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3229 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3230
3231 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_element_list);
3232 sprintf (begin_label, EE_BEGIN_LABEL_FMT, current_dienum);
3233 sprintf (end_label, EE_END_LABEL_FMT, current_dienum);
3234 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
3235 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3236
3237 /* Here we output a list of value/name pairs for each enumeration constant
3238 defined for this enumeration type (as required), but we do it in REVERSE
3239 order. The order is the one required by the draft #5 Dwarf specification
3240 published by the UI/PLSIG. */
3241
3242 output_enumeral_list (element); /* Recursively output the whole list. */
3243
3244 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3245 }
3246
3247 /* Generate an AT_stmt_list attribute. These are normally present only in
3248 DIEs with a TAG_compile_unit tag. */
3249
3250 static inline void
3251 stmt_list_attribute (label)
3252 const char *label;
3253 {
3254 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
3255 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
3256 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
3257 }
3258
3259 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
3260 for a subroutine DIE. */
3261
3262 static inline void
3263 low_pc_attribute (asm_low_label)
3264 const char *asm_low_label;
3265 {
3266 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
3267 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
3268 }
3269
3270 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
3271 subroutine DIE. */
3272
3273 static inline void
3274 high_pc_attribute (asm_high_label)
3275 const char *asm_high_label;
3276 {
3277 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
3278 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
3279 }
3280
3281 /* Generate an AT_body_begin attribute for a subroutine DIE. */
3282
3283 static inline void
3284 body_begin_attribute (asm_begin_label)
3285 const char *asm_begin_label;
3286 {
3287 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
3288 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
3289 }
3290
3291 /* Generate an AT_body_end attribute for a subroutine DIE. */
3292
3293 static inline void
3294 body_end_attribute (asm_end_label)
3295 const char *asm_end_label;
3296 {
3297 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
3298 ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
3299 }
3300
3301 /* Generate an AT_language attribute given a LANG value. These attributes
3302 are used only within TAG_compile_unit DIEs. */
3303
3304 static inline void
3305 language_attribute (language_code)
3306 unsigned language_code;
3307 {
3308 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
3309 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
3310 }
3311
3312 static inline void
3313 member_attribute (context)
3314 tree context;
3315 {
3316 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3317
3318 /* Generate this attribute only for members in C++. */
3319
3320 if (context != NULL && is_tagged_type (context))
3321 {
3322 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
3323 sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
3324 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
3325 }
3326 }
3327
3328 #if 0
3329 static inline void
3330 string_length_attribute (upper_bound)
3331 tree upper_bound;
3332 {
3333 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3334 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3335
3336 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_string_length);
3337 sprintf (begin_label, SL_BEGIN_LABEL_FMT, current_dienum);
3338 sprintf (end_label, SL_END_LABEL_FMT, current_dienum);
3339 ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
3340 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
3341 output_bound_representation (upper_bound, 0, 'u');
3342 ASM_OUTPUT_LABEL (asm_out_file, end_label);
3343 }
3344 #endif
3345
3346 static inline void
3347 comp_dir_attribute (dirname)
3348 const char *dirname;
3349 {
3350 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
3351 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
3352 }
3353
3354 static inline void
3355 sf_names_attribute (sf_names_start_label)
3356 const char *sf_names_start_label;
3357 {
3358 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
3359 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
3360 ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
3361 }
3362
3363 static inline void
3364 src_info_attribute (src_info_start_label)
3365 const char *src_info_start_label;
3366 {
3367 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
3368 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
3369 ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
3370 }
3371
3372 static inline void
3373 mac_info_attribute (mac_info_start_label)
3374 const char *mac_info_start_label;
3375 {
3376 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
3377 /* Don't use ASM_OUTPUT_DWARF_DATA4 here. */
3378 ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
3379 }
3380
3381 static inline void
3382 prototyped_attribute (func_type)
3383 tree func_type;
3384 {
3385 if ((strcmp (lang_hooks.name, "GNU C") == 0)
3386 && (TYPE_ARG_TYPES (func_type) != NULL))
3387 {
3388 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
3389 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3390 }
3391 }
3392
3393 static inline void
3394 producer_attribute (producer)
3395 const char *producer;
3396 {
3397 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
3398 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, producer);
3399 }
3400
3401 static inline void
3402 inline_attribute (decl)
3403 tree decl;
3404 {
3405 if (DECL_INLINE (decl))
3406 {
3407 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
3408 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3409 }
3410 }
3411
3412 static inline void
3413 containing_type_attribute (containing_type)
3414 tree containing_type;
3415 {
3416 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3417
3418 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_containing_type);
3419 sprintf (label, TYPE_NAME_FMT, TYPE_UID (containing_type));
3420 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
3421 }
3422
3423 static inline void
3424 abstract_origin_attribute (origin)
3425 tree origin;
3426 {
3427 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3428
3429 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
3430 switch (TREE_CODE_CLASS (TREE_CODE (origin)))
3431 {
3432 case 'd':
3433 sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
3434 break;
3435
3436 case 't':
3437 sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
3438 break;
3439
3440 default:
3441 abort (); /* Should never happen. */
3442
3443 }
3444 ASM_OUTPUT_DWARF_REF (asm_out_file, label);
3445 }
3446
3447 #ifdef DWARF_DECL_COORDINATES
3448 static inline void
3449 src_coords_attribute (src_fileno, src_lineno)
3450 unsigned src_fileno;
3451 unsigned src_lineno;
3452 {
3453 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
3454 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
3455 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
3456 }
3457 #endif /* defined(DWARF_DECL_COORDINATES) */
3458
3459 static inline void
3460 pure_or_virtual_attribute (func_decl)
3461 tree func_decl;
3462 {
3463 if (DECL_VIRTUAL_P (func_decl))
3464 {
3465 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific. */
3466 if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
3467 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
3468 else
3469 #endif
3470 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
3471 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
3472 }
3473 }
3474
3475 /************************* end of attributes *****************************/
3476
3477 /********************* utility routines for DIEs *************************/
3478
3479 /* Output an AT_name attribute and an AT_src_coords attribute for the
3480 given decl, but only if it actually has a name. */
3481
3482 static void
3483 name_and_src_coords_attributes (decl)
3484 tree decl;
3485 {
3486 tree decl_name = DECL_NAME (decl);
3487
3488 if (decl_name && IDENTIFIER_POINTER (decl_name))
3489 {
3490 name_attribute (IDENTIFIER_POINTER (decl_name));
3491 #ifdef DWARF_DECL_COORDINATES
3492 {
3493 register unsigned file_index;
3494
3495 /* This is annoying, but we have to pop out of the .debug section
3496 for a moment while we call `lookup_filename' because calling it
3497 may cause a temporary switch into the .debug_sfnames section and
3498 most svr4 assemblers are not smart enough to be able to nest
3499 section switches to any depth greater than one. Note that we
3500 also can't skirt this issue by delaying all output to the
3501 .debug_sfnames section unit the end of compilation because that
3502 would cause us to have inter-section forward references and
3503 Fred Fish sez that m68k/svr4 assemblers botch those. */
3504
3505 ASM_OUTPUT_POP_SECTION (asm_out_file);
3506 file_index = lookup_filename (DECL_SOURCE_FILE (decl));
3507 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
3508
3509 src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
3510 }
3511 #endif /* defined(DWARF_DECL_COORDINATES) */
3512 }
3513 }
3514
3515 /* Many forms of DIEs contain a "type description" part. The following
3516 routine writes out these "type descriptor" parts. */
3517
3518 static void
3519 type_attribute (type, decl_const, decl_volatile)
3520 tree type;
3521 int decl_const;
3522 int decl_volatile;
3523 {
3524 enum tree_code code = TREE_CODE (type);
3525 int root_type_modified;
3526
3527 if (code == ERROR_MARK)
3528 return;
3529
3530 /* Handle a special case. For functions whose return type is void,
3531 we generate *no* type attribute. (Note that no object may have
3532 type `void', so this only applies to function return types. */
3533
3534 if (code == VOID_TYPE)
3535 return;
3536
3537 /* If this is a subtype, find the underlying type. Eventually,
3538 this should write out the appropriate subtype info. */
3539 while ((code == INTEGER_TYPE || code == REAL_TYPE)
3540 && TREE_TYPE (type) != 0)
3541 type = TREE_TYPE (type), code = TREE_CODE (type);
3542
3543 root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
3544 || decl_const || decl_volatile
3545 || TYPE_READONLY (type) || TYPE_VOLATILE (type));
3546
3547 if (type_is_fundamental (root_type (type)))
3548 {
3549 if (root_type_modified)
3550 mod_fund_type_attribute (type, decl_const, decl_volatile);
3551 else
3552 fund_type_attribute (fundamental_type_code (type));
3553 }
3554 else
3555 {
3556 if (root_type_modified)
3557 mod_u_d_type_attribute (type, decl_const, decl_volatile);
3558 else
3559 /* We have to get the type_main_variant here (and pass that to the
3560 `user_def_type_attribute' routine) because the ..._TYPE node we
3561 have might simply be a *copy* of some original type node (where
3562 the copy was created to help us keep track of typedef names)
3563 and that copy might have a different TYPE_UID from the original
3564 ..._TYPE node. (Note that when `equate_type_number_to_die_number'
3565 is labeling a given type DIE for future reference, it always and
3566 only creates labels for DIEs representing *main variants*, and it
3567 never even knows about non-main-variants.) */
3568 user_def_type_attribute (type_main_variant (type));
3569 }
3570 }
3571
3572 /* Given a tree pointer to a struct, class, union, or enum type node, return
3573 a pointer to the (string) tag name for the given type, or zero if the
3574 type was declared without a tag. */
3575
3576 static const char *
3577 type_tag (type)
3578 tree type;
3579 {
3580 const char *name = 0;
3581
3582 if (TYPE_NAME (type) != 0)
3583 {
3584 tree t = 0;
3585
3586 /* Find the IDENTIFIER_NODE for the type name. */
3587 if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
3588 t = TYPE_NAME (type);
3589
3590 /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
3591 a TYPE_DECL node, regardless of whether or not a `typedef' was
3592 involved. */
3593 else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
3594 && ! DECL_IGNORED_P (TYPE_NAME (type)))
3595 t = DECL_NAME (TYPE_NAME (type));
3596
3597 /* Now get the name as a string, or invent one. */
3598 if (t != 0)
3599 name = IDENTIFIER_POINTER (t);
3600 }
3601
3602 return (name == 0 || *name == '\0') ? 0 : name;
3603 }
3604
3605 static inline void
3606 dienum_push ()
3607 {
3608 /* Start by checking if the pending_sibling_stack needs to be expanded.
3609 If necessary, expand it. */
3610
3611 if (pending_siblings == pending_siblings_allocated)
3612 {
3613 pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
3614 pending_sibling_stack
3615 = (unsigned *) xrealloc (pending_sibling_stack,
3616 pending_siblings_allocated * sizeof(unsigned));
3617 }
3618
3619 pending_siblings++;
3620 NEXT_DIE_NUM = next_unused_dienum++;
3621 }
3622
3623 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
3624 NEXT_DIE_NUM. */
3625
3626 static inline void
3627 dienum_pop ()
3628 {
3629 pending_siblings--;
3630 }
3631
3632 static inline tree
3633 member_declared_type (member)
3634 tree member;
3635 {
3636 return (DECL_BIT_FIELD_TYPE (member))
3637 ? DECL_BIT_FIELD_TYPE (member)
3638 : TREE_TYPE (member);
3639 }
3640
3641 /* Get the function's label, as described by its RTL.
3642 This may be different from the DECL_NAME name used
3643 in the source file. */
3644
3645 static const char *
3646 function_start_label (decl)
3647 tree decl;
3648 {
3649 rtx x;
3650 const char *fnname;
3651
3652 x = DECL_RTL (decl);
3653 if (GET_CODE (x) != MEM)
3654 abort ();
3655 x = XEXP (x, 0);
3656 if (GET_CODE (x) != SYMBOL_REF)
3657 abort ();
3658 fnname = XSTR (x, 0);
3659 return fnname;
3660 }
3661
3662
3663 /******************************* DIEs ************************************/
3664
3665 /* Output routines for individual types of DIEs. */
3666
3667 /* Note that every type of DIE (except a null DIE) gets a sibling. */
3668
3669 static void
3670 output_array_type_die (arg)
3671 void *arg;
3672 {
3673 tree type = arg;
3674
3675 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
3676 sibling_attribute ();
3677 equate_type_number_to_die_number (type);
3678 member_attribute (TYPE_CONTEXT (type));
3679
3680 /* I believe that we can default the array ordering. SDB will probably
3681 do the right things even if AT_ordering is not present. It's not
3682 even an issue until we start to get into multidimensional arrays
3683 anyway. If SDB is ever caught doing the Wrong Thing for multi-
3684 dimensional arrays, then we'll have to put the AT_ordering attribute
3685 back in. (But if and when we find out that we need to put these in,
3686 we will only do so for multidimensional arrays. After all, we don't
3687 want to waste space in the .debug section now do we?) */
3688
3689 #ifdef USE_ORDERING_ATTRIBUTE
3690 ordering_attribute (ORD_row_major);
3691 #endif /* defined(USE_ORDERING_ATTRIBUTE) */
3692
3693 subscript_data_attribute (type);
3694 }
3695
3696 static void
3697 output_set_type_die (arg)
3698 void *arg;
3699 {
3700 tree type = arg;
3701
3702 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
3703 sibling_attribute ();
3704 equate_type_number_to_die_number (type);
3705 member_attribute (TYPE_CONTEXT (type));
3706 type_attribute (TREE_TYPE (type), 0, 0);
3707 }
3708
3709 #if 0
3710 /* Implement this when there is a GNU FORTRAN or GNU Ada front end. */
3711
3712 static void
3713 output_entry_point_die (arg)
3714 void *arg;
3715 {
3716 tree decl = arg;
3717 tree origin = decl_ultimate_origin (decl);
3718
3719 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
3720 sibling_attribute ();
3721 dienum_push ();
3722 if (origin != NULL)
3723 abstract_origin_attribute (origin);
3724 else
3725 {
3726 name_and_src_coords_attributes (decl);
3727 member_attribute (DECL_CONTEXT (decl));
3728 type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
3729 }
3730 if (DECL_ABSTRACT (decl))
3731 equate_decl_number_to_die_number (decl);
3732 else
3733 low_pc_attribute (function_start_label (decl));
3734 }
3735 #endif
3736
3737 /* Output a DIE to represent an inlined instance of an enumeration type. */
3738
3739 static void
3740 output_inlined_enumeration_type_die (arg)
3741 void *arg;
3742 {
3743 tree type = arg;
3744
3745 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3746 sibling_attribute ();
3747 if (!TREE_ASM_WRITTEN (type))
3748 abort ();
3749 abstract_origin_attribute (type);
3750 }
3751
3752 /* Output a DIE to represent an inlined instance of a structure type. */
3753
3754 static void
3755 output_inlined_structure_type_die (arg)
3756 void *arg;
3757 {
3758 tree type = arg;
3759
3760 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
3761 sibling_attribute ();
3762 if (!TREE_ASM_WRITTEN (type))
3763 abort ();
3764 abstract_origin_attribute (type);
3765 }
3766
3767 /* Output a DIE to represent an inlined instance of a union type. */
3768
3769 static void
3770 output_inlined_union_type_die (arg)
3771 void *arg;
3772 {
3773 tree type = arg;
3774
3775 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
3776 sibling_attribute ();
3777 if (!TREE_ASM_WRITTEN (type))
3778 abort ();
3779 abstract_origin_attribute (type);
3780 }
3781
3782 /* Output a DIE to represent an enumeration type. Note that these DIEs
3783 include all of the information about the enumeration values also.
3784 This information is encoded into the element_list attribute. */
3785
3786 static void
3787 output_enumeration_type_die (arg)
3788 void *arg;
3789 {
3790 tree type = arg;
3791
3792 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
3793 sibling_attribute ();
3794 equate_type_number_to_die_number (type);
3795 name_attribute (type_tag (type));
3796 member_attribute (TYPE_CONTEXT (type));
3797
3798 /* Handle a GNU C/C++ extension, i.e. incomplete enum types. If the
3799 given enum type is incomplete, do not generate the AT_byte_size
3800 attribute or the AT_element_list attribute. */
3801
3802 if (COMPLETE_TYPE_P (type))
3803 {
3804 byte_size_attribute (type);
3805 element_list_attribute (TYPE_FIELDS (type));
3806 }
3807 }
3808
3809 /* Output a DIE to represent either a real live formal parameter decl or
3810 to represent just the type of some formal parameter position in some
3811 function type.
3812
3813 Note that this routine is a bit unusual because its argument may be
3814 a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
3815 represents an inlining of some PARM_DECL) or else some sort of a
3816 ..._TYPE node. If it's the former then this function is being called
3817 to output a DIE to represent a formal parameter object (or some inlining
3818 thereof). If it's the latter, then this function is only being called
3819 to output a TAG_formal_parameter DIE to stand as a placeholder for some
3820 formal argument type of some subprogram type. */
3821
3822 static void
3823 output_formal_parameter_die (arg)
3824 void *arg;
3825 {
3826 tree node = arg;
3827
3828 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
3829 sibling_attribute ();
3830
3831 switch (TREE_CODE_CLASS (TREE_CODE (node)))
3832 {
3833 case 'd': /* We were called with some kind of a ..._DECL node. */
3834 {
3835 register tree origin = decl_ultimate_origin (node);
3836
3837 if (origin != NULL)
3838 abstract_origin_attribute (origin);
3839 else
3840 {
3841 name_and_src_coords_attributes (node);
3842 type_attribute (TREE_TYPE (node),
3843 TREE_READONLY (node), TREE_THIS_VOLATILE (node));
3844 }
3845 if (DECL_ABSTRACT (node))
3846 equate_decl_number_to_die_number (node);
3847 else
3848 location_or_const_value_attribute (node);
3849 }
3850 break;
3851
3852 case 't': /* We were called with some kind of a ..._TYPE node. */
3853 type_attribute (node, 0, 0);
3854 break;
3855
3856 default:
3857 abort (); /* Should never happen. */
3858 }
3859 }
3860
3861 /* Output a DIE to represent a declared function (either file-scope
3862 or block-local) which has "external linkage" (according to ANSI-C). */
3863
3864 static void
3865 output_global_subroutine_die (arg)
3866 void *arg;
3867 {
3868 tree decl = arg;
3869 tree origin = decl_ultimate_origin (decl);
3870
3871 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
3872 sibling_attribute ();
3873 dienum_push ();
3874 if (origin != NULL)
3875 abstract_origin_attribute (origin);
3876 else
3877 {
3878 tree type = TREE_TYPE (decl);
3879
3880 name_and_src_coords_attributes (decl);
3881 inline_attribute (decl);
3882 prototyped_attribute (type);
3883 member_attribute (DECL_CONTEXT (decl));
3884 type_attribute (TREE_TYPE (type), 0, 0);
3885 pure_or_virtual_attribute (decl);
3886 }
3887 if (DECL_ABSTRACT (decl))
3888 equate_decl_number_to_die_number (decl);
3889 else
3890 {
3891 if (! DECL_EXTERNAL (decl) && ! in_class
3892 && decl == current_function_decl)
3893 {
3894 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3895
3896 low_pc_attribute (function_start_label (decl));
3897 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
3898 high_pc_attribute (label);
3899 if (use_gnu_debug_info_extensions)
3900 {
3901 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
3902 body_begin_attribute (label);
3903 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
3904 body_end_attribute (label);
3905 }
3906 }
3907 }
3908 }
3909
3910 /* Output a DIE to represent a declared data object (either file-scope
3911 or block-local) which has "external linkage" (according to ANSI-C). */
3912
3913 static void
3914 output_global_variable_die (arg)
3915 void *arg;
3916 {
3917 tree decl = arg;
3918 tree origin = decl_ultimate_origin (decl);
3919
3920 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
3921 sibling_attribute ();
3922 if (origin != NULL)
3923 abstract_origin_attribute (origin);
3924 else
3925 {
3926 name_and_src_coords_attributes (decl);
3927 member_attribute (DECL_CONTEXT (decl));
3928 type_attribute (TREE_TYPE (decl),
3929 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
3930 }
3931 if (DECL_ABSTRACT (decl))
3932 equate_decl_number_to_die_number (decl);
3933 else
3934 {
3935 if (! DECL_EXTERNAL (decl) && ! in_class
3936 && current_function_decl == decl_function_context (decl))
3937 location_or_const_value_attribute (decl);
3938 }
3939 }
3940
3941 static void
3942 output_label_die (arg)
3943 void *arg;
3944 {
3945 tree decl = arg;
3946 tree origin = decl_ultimate_origin (decl);
3947
3948 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
3949 sibling_attribute ();
3950 if (origin != NULL)
3951 abstract_origin_attribute (origin);
3952 else
3953 name_and_src_coords_attributes (decl);
3954 if (DECL_ABSTRACT (decl))
3955 equate_decl_number_to_die_number (decl);
3956 else
3957 {
3958 rtx insn = DECL_RTL (decl);
3959
3960 /* Deleted labels are programmer specified labels which have been
3961 eliminated because of various optimisations. We still emit them
3962 here so that it is possible to put breakpoints on them. */
3963 if (GET_CODE (insn) == CODE_LABEL
3964 || ((GET_CODE (insn) == NOTE
3965 && NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)))
3966 {
3967 char label[MAX_ARTIFICIAL_LABEL_BYTES];
3968
3969 /* When optimization is enabled (via -O) some parts of the compiler
3970 (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
3971 represent source-level labels which were explicitly declared by
3972 the user. This really shouldn't be happening though, so catch
3973 it if it ever does happen. */
3974
3975 if (INSN_DELETED_P (insn))
3976 abort (); /* Should never happen. */
3977
3978 ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
3979 low_pc_attribute (label);
3980 }
3981 }
3982 }
3983
3984 static void
3985 output_lexical_block_die (arg)
3986 void *arg;
3987 {
3988 tree stmt = arg;
3989
3990 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
3991 sibling_attribute ();
3992 dienum_push ();
3993 if (! BLOCK_ABSTRACT (stmt))
3994 {
3995 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
3996 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
3997
3998 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, BLOCK_NUMBER (stmt));
3999 low_pc_attribute (begin_label);
4000 sprintf (end_label, BLOCK_END_LABEL_FMT, BLOCK_NUMBER (stmt));
4001 high_pc_attribute (end_label);
4002 }
4003 }
4004
4005 static void
4006 output_inlined_subroutine_die (arg)
4007 void *arg;
4008 {
4009 tree stmt = arg;
4010
4011 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
4012 sibling_attribute ();
4013 dienum_push ();
4014 abstract_origin_attribute (block_ultimate_origin (stmt));
4015 if (! BLOCK_ABSTRACT (stmt))
4016 {
4017 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
4018 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
4019
4020 sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, BLOCK_NUMBER (stmt));
4021 low_pc_attribute (begin_label);
4022 sprintf (end_label, BLOCK_END_LABEL_FMT, BLOCK_NUMBER (stmt));
4023 high_pc_attribute (end_label);
4024 }
4025 }
4026
4027 /* Output a DIE to represent a declared data object (either file-scope
4028 or block-local) which has "internal linkage" (according to ANSI-C). */
4029
4030 static void
4031 output_local_variable_die (arg)
4032 void *arg;
4033 {
4034 tree decl = arg;
4035 tree origin = decl_ultimate_origin (decl);
4036
4037 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
4038 sibling_attribute ();
4039 if (origin != NULL)
4040 abstract_origin_attribute (origin);
4041 else
4042 {
4043 name_and_src_coords_attributes (decl);
4044 member_attribute (DECL_CONTEXT (decl));
4045 type_attribute (TREE_TYPE (decl),
4046 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
4047 }
4048 if (DECL_ABSTRACT (decl))
4049 equate_decl_number_to_die_number (decl);
4050 else
4051 location_or_const_value_attribute (decl);
4052 }
4053
4054 static void
4055 output_member_die (arg)
4056 void *arg;
4057 {
4058 tree decl = arg;
4059
4060 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
4061 sibling_attribute ();
4062 name_and_src_coords_attributes (decl);
4063 member_attribute (DECL_CONTEXT (decl));
4064 type_attribute (member_declared_type (decl),
4065 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
4066 if (DECL_BIT_FIELD_TYPE (decl)) /* If this is a bit field... */
4067 {
4068 byte_size_attribute (decl);
4069 bit_size_attribute (decl);
4070 bit_offset_attribute (decl);
4071 }
4072 data_member_location_attribute (decl);
4073 }
4074
4075 #if 0
4076 /* Don't generate either pointer_type DIEs or reference_type DIEs. Use
4077 modified types instead.
4078
4079 We keep this code here just in case these types of DIEs may be
4080 needed to represent certain things in other languages (e.g. Pascal)
4081 someday. */
4082
4083 static void
4084 output_pointer_type_die (arg)
4085 void *arg;
4086 {
4087 tree type = arg;
4088
4089 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
4090 sibling_attribute ();
4091 equate_type_number_to_die_number (type);
4092 member_attribute (TYPE_CONTEXT (type));
4093 type_attribute (TREE_TYPE (type), 0, 0);
4094 }
4095
4096 static void
4097 output_reference_type_die (arg)
4098 void *arg;
4099 {
4100 tree type = arg;
4101
4102 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
4103 sibling_attribute ();
4104 equate_type_number_to_die_number (type);
4105 member_attribute (TYPE_CONTEXT (type));
4106 type_attribute (TREE_TYPE (type), 0, 0);
4107 }
4108 #endif
4109
4110 static void
4111 output_ptr_to_mbr_type_die (arg)
4112 void *arg;
4113 {
4114 tree type = arg;
4115
4116 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
4117 sibling_attribute ();
4118 equate_type_number_to_die_number (type);
4119 member_attribute (TYPE_CONTEXT (type));
4120 containing_type_attribute (TYPE_OFFSET_BASETYPE (type));
4121 type_attribute (TREE_TYPE (type), 0, 0);
4122 }
4123
4124 static void
4125 output_compile_unit_die (arg)
4126 void *arg;
4127 {
4128 const char *main_input_filename = arg;
4129 const char *language_string = lang_hooks.name;
4130
4131 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
4132 sibling_attribute ();
4133 dienum_push ();
4134 name_attribute (main_input_filename);
4135
4136 {
4137 char producer[250];
4138
4139 sprintf (producer, "%s %s", language_string, version_string);
4140 producer_attribute (producer);
4141 }
4142
4143 if (strcmp (language_string, "GNU C++") == 0)
4144 language_attribute (LANG_C_PLUS_PLUS);
4145 else if (strcmp (language_string, "GNU Ada") == 0)
4146 language_attribute (LANG_ADA83);
4147 else if (strcmp (language_string, "GNU F77") == 0)
4148 language_attribute (LANG_FORTRAN77);
4149 else if (strcmp (language_string, "GNU Pascal") == 0)
4150 language_attribute (LANG_PASCAL83);
4151 else if (strcmp (language_string, "GNU Java") == 0)
4152 language_attribute (LANG_JAVA);
4153 else
4154 language_attribute (LANG_C89);
4155 low_pc_attribute (TEXT_BEGIN_LABEL);
4156 high_pc_attribute (TEXT_END_LABEL);
4157 if (debug_info_level >= DINFO_LEVEL_NORMAL)
4158 stmt_list_attribute (LINE_BEGIN_LABEL);
4159
4160 {
4161 const char *wd = getpwd ();
4162 if (wd)
4163 comp_dir_attribute (wd);
4164 }
4165
4166 if (debug_info_level >= DINFO_LEVEL_NORMAL && use_gnu_debug_info_extensions)
4167 {
4168 sf_names_attribute (SFNAMES_BEGIN_LABEL);
4169 src_info_attribute (SRCINFO_BEGIN_LABEL);
4170 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
4171 mac_info_attribute (MACINFO_BEGIN_LABEL);
4172 }
4173 }
4174
4175 static void
4176 output_string_type_die (arg)
4177 void *arg;
4178 {
4179 tree type = arg;
4180
4181 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
4182 sibling_attribute ();
4183 equate_type_number_to_die_number (type);
4184 member_attribute (TYPE_CONTEXT (type));
4185 /* this is a fixed length string */
4186 byte_size_attribute (type);
4187 }
4188
4189 static void
4190 output_inheritance_die (arg)
4191 void *arg;
4192 {
4193 tree binfo = arg;
4194
4195 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
4196 sibling_attribute ();
4197 type_attribute (BINFO_TYPE (binfo), 0, 0);
4198 data_member_location_attribute (binfo);
4199 if (TREE_VIA_VIRTUAL (binfo))
4200 {
4201 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
4202 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
4203 }
4204 if (TREE_VIA_PUBLIC (binfo))
4205 {
4206 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
4207 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
4208 }
4209 else if (TREE_VIA_PROTECTED (binfo))
4210 {
4211 ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
4212 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
4213 }
4214 }
4215
4216 static void
4217 output_structure_type_die (arg)
4218 void *arg;
4219 {
4220 tree type = arg;
4221
4222 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
4223 sibling_attribute ();
4224 equate_type_number_to_die_number (type);
4225 name_attribute (type_tag (type));
4226 member_attribute (TYPE_CONTEXT (type));
4227
4228 /* If this type has been completed, then give it a byte_size attribute
4229 and prepare to give a list of members. Otherwise, don't do either of
4230 these things. In the latter case, we will not be generating a list
4231 of members (since we don't have any idea what they might be for an
4232 incomplete type). */
4233
4234 if (COMPLETE_TYPE_P (type))
4235 {
4236 dienum_push ();
4237 byte_size_attribute (type);
4238 }
4239 }
4240
4241 /* Output a DIE to represent a declared function (either file-scope
4242 or block-local) which has "internal linkage" (according to ANSI-C). */
4243
4244 static void
4245 output_local_subroutine_die (arg)
4246 void *arg;
4247 {
4248 tree decl = arg;
4249 tree origin = decl_ultimate_origin (decl);
4250
4251 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
4252 sibling_attribute ();
4253 dienum_push ();
4254 if (origin != NULL)
4255 abstract_origin_attribute (origin);
4256 else
4257 {
4258 tree type = TREE_TYPE (decl);
4259
4260 name_and_src_coords_attributes (decl);
4261 inline_attribute (decl);
4262 prototyped_attribute (type);
4263 member_attribute (DECL_CONTEXT (decl));
4264 type_attribute (TREE_TYPE (type), 0, 0);
4265 pure_or_virtual_attribute (decl);
4266 }
4267 if (DECL_ABSTRACT (decl))
4268 equate_decl_number_to_die_number (decl);
4269 else
4270 {
4271 /* Avoid getting screwed up in cases where a function was declared
4272 static but where no definition was ever given for it. */
4273
4274 if (TREE_ASM_WRITTEN (decl))
4275 {
4276 char label[MAX_ARTIFICIAL_LABEL_BYTES];
4277 low_pc_attribute (function_start_label (decl));
4278 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
4279 high_pc_attribute (label);
4280 if (use_gnu_debug_info_extensions)
4281 {
4282 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
4283 body_begin_attribute (label);
4284 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
4285 body_end_attribute (label);
4286 }
4287 }
4288 }
4289 }
4290
4291 static void
4292 output_subroutine_type_die (arg)
4293 void *arg;
4294 {
4295 tree type = arg;
4296 tree return_type = TREE_TYPE (type);
4297
4298 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
4299 sibling_attribute ();
4300 dienum_push ();
4301 equate_type_number_to_die_number (type);
4302 prototyped_attribute (type);
4303 member_attribute (TYPE_CONTEXT (type));
4304 type_attribute (return_type, 0, 0);
4305 }
4306
4307 static void
4308 output_typedef_die (arg)
4309 void *arg;
4310 {
4311 tree decl = arg;
4312 tree origin = decl_ultimate_origin (decl);
4313
4314 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
4315 sibling_attribute ();
4316 if (origin != NULL)
4317 abstract_origin_attribute (origin);
4318 else
4319 {
4320 name_and_src_coords_attributes (decl);
4321 member_attribute (DECL_CONTEXT (decl));
4322 type_attribute (TREE_TYPE (decl),
4323 TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
4324 }
4325 if (DECL_ABSTRACT (decl))
4326 equate_decl_number_to_die_number (decl);
4327 }
4328
4329 static void
4330 output_union_type_die (arg)
4331 void *arg;
4332 {
4333 tree type = arg;
4334
4335 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
4336 sibling_attribute ();
4337 equate_type_number_to_die_number (type);
4338 name_attribute (type_tag (type));
4339 member_attribute (TYPE_CONTEXT (type));
4340
4341 /* If this type has been completed, then give it a byte_size attribute
4342 and prepare to give a list of members. Otherwise, don't do either of
4343 these things. In the latter case, we will not be generating a list
4344 of members (since we don't have any idea what they might be for an
4345 incomplete type). */
4346
4347 if (COMPLETE_TYPE_P (type))
4348 {
4349 dienum_push ();
4350 byte_size_attribute (type);
4351 }
4352 }
4353
4354 /* Generate a special type of DIE used as a stand-in for a trailing ellipsis
4355 at the end of an (ANSI prototyped) formal parameters list. */
4356
4357 static void
4358 output_unspecified_parameters_die (arg)
4359 void *arg;
4360 {
4361 tree decl_or_type = arg;
4362
4363 ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
4364 sibling_attribute ();
4365
4366 /* This kludge is here only for the sake of being compatible with what
4367 the USL CI5 C compiler does. The specification of Dwarf Version 1
4368 doesn't say that TAG_unspecified_parameters DIEs should contain any
4369 attributes other than the AT_sibling attribute, but they are certainly
4370 allowed to contain additional attributes, and the CI5 compiler
4371 generates AT_name, AT_fund_type, and AT_location attributes within
4372 TAG_unspecified_parameters DIEs which appear in the child lists for
4373 DIEs representing function definitions, so we do likewise here. */
4374
4375 if (TREE_CODE (decl_or_type) == FUNCTION_DECL && DECL_INITIAL (decl_or_type))
4376 {
4377 name_attribute ("...");
4378 fund_type_attribute (FT_pointer);
4379 /* location_attribute (?); */
4380 }
4381 }
4382
4383 static void
4384 output_padded_null_die (arg)
4385 void *arg ATTRIBUTE_UNUSED;
4386 {
4387 ASM_OUTPUT_ALIGN (asm_out_file, 2); /* 2**2 == 4 */
4388 }
4389
4390 /*************************** end of DIEs *********************************/
4391
4392 /* Generate some type of DIE. This routine generates the generic outer
4393 wrapper stuff which goes around all types of DIE's (regardless of their
4394 TAGs. All forms of DIEs start with a DIE-specific label, followed by a
4395 DIE-length word, followed by the guts of the DIE itself. After the guts
4396 of the DIE, there must always be a terminator label for the DIE. */
4397
4398 static void
4399 output_die (die_specific_output_function, param)
4400 void (*die_specific_output_function) PARAMS ((void *));
4401 void *param;
4402 {
4403 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
4404 char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
4405
4406 current_dienum = NEXT_DIE_NUM;
4407 NEXT_DIE_NUM = next_unused_dienum;
4408
4409 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
4410 sprintf (end_label, DIE_END_LABEL_FMT, current_dienum);
4411
4412 /* Write a label which will act as the name for the start of this DIE. */
4413
4414 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
4415
4416 /* Write the DIE-length word. */
4417
4418 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, end_label, begin_label);
4419
4420 /* Fill in the guts of the DIE. */
4421
4422 next_unused_dienum++;
4423 die_specific_output_function (param);
4424
4425 /* Write a label which will act as the name for the end of this DIE. */
4426
4427 ASM_OUTPUT_LABEL (asm_out_file, end_label);
4428 }
4429
4430 static void
4431 end_sibling_chain ()
4432 {
4433 char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
4434
4435 current_dienum = NEXT_DIE_NUM;
4436 NEXT_DIE_NUM = next_unused_dienum;
4437
4438 sprintf (begin_label, DIE_BEGIN_LABEL_FMT, current_dienum);
4439
4440 /* Write a label which will act as the name for the start of this DIE. */
4441
4442 ASM_OUTPUT_LABEL (asm_out_file, begin_label);
4443
4444 /* Write the DIE-length word. */
4445
4446 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 4);
4447
4448 dienum_pop ();
4449 }
4450 \f
4451 /* Generate a list of nameless TAG_formal_parameter DIEs (and perhaps a
4452 TAG_unspecified_parameters DIE) to represent the types of the formal
4453 parameters as specified in some function type specification (except
4454 for those which appear as part of a function *definition*).
4455
4456 Note that we must be careful here to output all of the parameter
4457 DIEs *before* we output any DIEs needed to represent the types of
4458 the formal parameters. This keeps svr4 SDB happy because it
4459 (incorrectly) thinks that the first non-parameter DIE it sees ends
4460 the formal parameter list. */
4461
4462 static void
4463 output_formal_types (function_or_method_type)
4464 tree function_or_method_type;
4465 {
4466 tree link;
4467 tree formal_type = NULL;
4468 tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
4469
4470 /* Set TREE_ASM_WRITTEN while processing the parameters, lest we
4471 get bogus recursion when outputting tagged types local to a
4472 function declaration. */
4473 int save_asm_written = TREE_ASM_WRITTEN (function_or_method_type);
4474 TREE_ASM_WRITTEN (function_or_method_type) = 1;
4475
4476 /* In the case where we are generating a formal types list for a C++
4477 non-static member function type, skip over the first thing on the
4478 TYPE_ARG_TYPES list because it only represents the type of the
4479 hidden `this pointer'. The debugger should be able to figure
4480 out (without being explicitly told) that this non-static member
4481 function type takes a `this pointer' and should be able to figure
4482 what the type of that hidden parameter is from the AT_member
4483 attribute of the parent TAG_subroutine_type DIE. */
4484
4485 if (TREE_CODE (function_or_method_type) == METHOD_TYPE)
4486 first_parm_type = TREE_CHAIN (first_parm_type);
4487
4488 /* Make our first pass over the list of formal parameter types and output
4489 a TAG_formal_parameter DIE for each one. */
4490
4491 for (link = first_parm_type; link; link = TREE_CHAIN (link))
4492 {
4493 formal_type = TREE_VALUE (link);
4494 if (formal_type == void_type_node)
4495 break;
4496
4497 /* Output a (nameless) DIE to represent the formal parameter itself. */
4498
4499 output_die (output_formal_parameter_die, formal_type);
4500 }
4501
4502 /* If this function type has an ellipsis, add a TAG_unspecified_parameters
4503 DIE to the end of the parameter list. */
4504
4505 if (formal_type != void_type_node)
4506 output_die (output_unspecified_parameters_die, function_or_method_type);
4507
4508 /* Make our second (and final) pass over the list of formal parameter types
4509 and output DIEs to represent those types (as necessary). */
4510
4511 for (link = TYPE_ARG_TYPES (function_or_method_type);
4512 link;
4513 link = TREE_CHAIN (link))
4514 {
4515 formal_type = TREE_VALUE (link);
4516 if (formal_type == void_type_node)
4517 break;
4518
4519 output_type (formal_type, function_or_method_type);
4520 }
4521
4522 TREE_ASM_WRITTEN (function_or_method_type) = save_asm_written;
4523 }
4524 \f
4525 /* Remember a type in the pending_types_list. */
4526
4527 static void
4528 pend_type (type)
4529 tree type;
4530 {
4531 if (pending_types == pending_types_allocated)
4532 {
4533 pending_types_allocated += PENDING_TYPES_INCREMENT;
4534 pending_types_list
4535 = (tree *) xrealloc (pending_types_list,
4536 sizeof (tree) * pending_types_allocated);
4537 }
4538 pending_types_list[pending_types++] = type;
4539
4540 /* Mark the pending type as having been output already (even though
4541 it hasn't been). This prevents the type from being added to the
4542 pending_types_list more than once. */
4543
4544 TREE_ASM_WRITTEN (type) = 1;
4545 }
4546
4547 /* Return non-zero if it is legitimate to output DIEs to represent a
4548 given type while we are generating the list of child DIEs for some
4549 DIE (e.g. a function or lexical block DIE) associated with a given scope.
4550
4551 See the comments within the function for a description of when it is
4552 considered legitimate to output DIEs for various kinds of types.
4553
4554 Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
4555 or it may point to a BLOCK node (for types local to a block), or to a
4556 FUNCTION_DECL node (for types local to the heading of some function
4557 definition), or to a FUNCTION_TYPE node (for types local to the
4558 prototyped parameter list of a function type specification), or to a
4559 RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
4560 (in the case of C++ nested types).
4561
4562 The `scope' parameter should likewise be NULL or should point to a
4563 BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
4564 node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
4565
4566 This function is used only for deciding when to "pend" and when to
4567 "un-pend" types to/from the pending_types_list.
4568
4569 Note that we sometimes make use of this "type pending" feature in a
4570 rather twisted way to temporarily delay the production of DIEs for the
4571 types of formal parameters. (We do this just to make svr4 SDB happy.)
4572 It order to delay the production of DIEs representing types of formal
4573 parameters, callers of this function supply `fake_containing_scope' as
4574 the `scope' parameter to this function. Given that fake_containing_scope
4575 is a tagged type which is *not* the containing scope for *any* other type,
4576 the desired effect is achieved, i.e. output of DIEs representing types
4577 is temporarily suspended, and any type DIEs which would have otherwise
4578 been output are instead placed onto the pending_types_list. Later on,
4579 we force these (temporarily pended) types to be output simply by calling
4580 `output_pending_types_for_scope' with an actual argument equal to the
4581 true scope of the types we temporarily pended. */
4582
4583 static inline int
4584 type_ok_for_scope (type, scope)
4585 tree type;
4586 tree scope;
4587 {
4588 /* Tagged types (i.e. struct, union, and enum types) must always be
4589 output only in the scopes where they actually belong (or else the
4590 scoping of their own tag names and the scoping of their member
4591 names will be incorrect). Non-tagged-types on the other hand can
4592 generally be output anywhere, except that svr4 SDB really doesn't
4593 want to see them nested within struct or union types, so here we
4594 say it is always OK to immediately output any such a (non-tagged)
4595 type, so long as we are not within such a context. Note that the
4596 only kinds of non-tagged types which we will be dealing with here
4597 (for C and C++ anyway) will be array types and function types. */
4598
4599 return is_tagged_type (type)
4600 ? (TYPE_CONTEXT (type) == scope
4601 /* Ignore namespaces for the moment. */
4602 || (scope == NULL_TREE
4603 && TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
4604 || (scope == NULL_TREE && is_tagged_type (TYPE_CONTEXT (type))
4605 && TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
4606 : (scope == NULL_TREE || ! is_tagged_type (scope));
4607 }
4608
4609 /* Output any pending types (from the pending_types list) which we can output
4610 now (taking into account the scope that we are working on now).
4611
4612 For each type output, remove the given type from the pending_types_list
4613 *before* we try to output it.
4614
4615 Note that we have to process the list in beginning-to-end order,
4616 because the call made here to output_type may cause yet more types
4617 to be added to the end of the list, and we may have to output some
4618 of them too. */
4619
4620 static void
4621 output_pending_types_for_scope (containing_scope)
4622 tree containing_scope;
4623 {
4624 unsigned i;
4625
4626 for (i = 0; i < pending_types; )
4627 {
4628 tree type = pending_types_list[i];
4629
4630 if (type_ok_for_scope (type, containing_scope))
4631 {
4632 tree *mover;
4633 tree *limit;
4634
4635 pending_types--;
4636 limit = &pending_types_list[pending_types];
4637 for (mover = &pending_types_list[i]; mover < limit; mover++)
4638 *mover = *(mover+1);
4639
4640 /* Un-mark the type as having been output already (because it
4641 hasn't been, really). Then call output_type to generate a
4642 Dwarf representation of it. */
4643
4644 TREE_ASM_WRITTEN (type) = 0;
4645 output_type (type, containing_scope);
4646
4647 /* Don't increment the loop counter in this case because we
4648 have shifted all of the subsequent pending types down one
4649 element in the pending_types_list array. */
4650 }
4651 else
4652 i++;
4653 }
4654 }
4655
4656 /* Remember a type in the incomplete_types_list. */
4657
4658 static void
4659 add_incomplete_type (type)
4660 tree type;
4661 {
4662 if (incomplete_types == incomplete_types_allocated)
4663 {
4664 incomplete_types_allocated += INCOMPLETE_TYPES_INCREMENT;
4665 incomplete_types_list
4666 = (tree *) xrealloc (incomplete_types_list,
4667 sizeof (tree) * incomplete_types_allocated);
4668 }
4669
4670 incomplete_types_list[incomplete_types++] = type;
4671 }
4672
4673 /* Walk through the list of incomplete types again, trying once more to
4674 emit full debugging info for them. */
4675
4676 static void
4677 retry_incomplete_types ()
4678 {
4679 tree type;
4680
4681 finalizing = 1;
4682 while (incomplete_types)
4683 {
4684 --incomplete_types;
4685 type = incomplete_types_list[incomplete_types];
4686 output_type (type, NULL_TREE);
4687 }
4688 }
4689
4690 static void
4691 output_type (type, containing_scope)
4692 tree type;
4693 tree containing_scope;
4694 {
4695 if (type == 0 || type == error_mark_node)
4696 return;
4697
4698 /* We are going to output a DIE to represent the unqualified version of
4699 this type (i.e. without any const or volatile qualifiers) so get
4700 the main variant (i.e. the unqualified version) of this type now. */
4701
4702 type = type_main_variant (type);
4703
4704 if (TREE_ASM_WRITTEN (type))
4705 {
4706 if (finalizing && AGGREGATE_TYPE_P (type))
4707 {
4708 tree member;
4709
4710 /* Some of our nested types might not have been defined when we
4711 were written out before; force them out now. */
4712
4713 for (member = TYPE_FIELDS (type); member;
4714 member = TREE_CHAIN (member))
4715 if (TREE_CODE (member) == TYPE_DECL
4716 && ! TREE_ASM_WRITTEN (TREE_TYPE (member)))
4717 output_type (TREE_TYPE (member), containing_scope);
4718 }
4719 return;
4720 }
4721
4722 /* If this is a nested type whose containing class hasn't been
4723 written out yet, writing it out will cover this one, too. */
4724
4725 if (TYPE_CONTEXT (type)
4726 && TYPE_P (TYPE_CONTEXT (type))
4727 && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
4728 {
4729 output_type (TYPE_CONTEXT (type), containing_scope);
4730 return;
4731 }
4732
4733 /* Don't generate any DIEs for this type now unless it is OK to do so
4734 (based upon what `type_ok_for_scope' tells us). */
4735
4736 if (! type_ok_for_scope (type, containing_scope))
4737 {
4738 pend_type (type);
4739 return;
4740 }
4741
4742 switch (TREE_CODE (type))
4743 {
4744 case ERROR_MARK:
4745 break;
4746
4747 case VECTOR_TYPE:
4748 output_type (TYPE_DEBUG_REPRESENTATION_TYPE (type), containing_scope);
4749 break;
4750
4751 case POINTER_TYPE:
4752 case REFERENCE_TYPE:
4753 /* Prevent infinite recursion in cases where this is a recursive
4754 type. Recursive types are possible in Ada. */
4755 TREE_ASM_WRITTEN (type) = 1;
4756 /* For these types, all that is required is that we output a DIE
4757 (or a set of DIEs) to represent the "basis" type. */
4758 output_type (TREE_TYPE (type), containing_scope);
4759 break;
4760
4761 case OFFSET_TYPE:
4762 /* This code is used for C++ pointer-to-data-member types. */
4763 /* Output a description of the relevant class type. */
4764 output_type (TYPE_OFFSET_BASETYPE (type), containing_scope);
4765 /* Output a description of the type of the object pointed to. */
4766 output_type (TREE_TYPE (type), containing_scope);
4767 /* Now output a DIE to represent this pointer-to-data-member type
4768 itself. */
4769 output_die (output_ptr_to_mbr_type_die, type);
4770 break;
4771
4772 case SET_TYPE:
4773 output_type (TYPE_DOMAIN (type), containing_scope);
4774 output_die (output_set_type_die, type);
4775 break;
4776
4777 case FILE_TYPE:
4778 output_type (TREE_TYPE (type), containing_scope);
4779 abort (); /* No way to represent these in Dwarf yet! */
4780 break;
4781
4782 case FUNCTION_TYPE:
4783 /* Force out return type (in case it wasn't forced out already). */
4784 output_type (TREE_TYPE (type), containing_scope);
4785 output_die (output_subroutine_type_die, type);
4786 output_formal_types (type);
4787 end_sibling_chain ();
4788 break;
4789
4790 case METHOD_TYPE:
4791 /* Force out return type (in case it wasn't forced out already). */
4792 output_type (TREE_TYPE (type), containing_scope);
4793 output_die (output_subroutine_type_die, type);
4794 output_formal_types (type);
4795 end_sibling_chain ();
4796 break;
4797
4798 case ARRAY_TYPE:
4799 if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
4800 {
4801 output_type (TREE_TYPE (type), containing_scope);
4802 output_die (output_string_type_die, type);
4803 }
4804 else
4805 {
4806 tree element_type;
4807
4808 element_type = TREE_TYPE (type);
4809 while (TREE_CODE (element_type) == ARRAY_TYPE)
4810 element_type = TREE_TYPE (element_type);
4811
4812 output_type (element_type, containing_scope);
4813 output_die (output_array_type_die, type);
4814 }
4815 break;
4816
4817 case ENUMERAL_TYPE:
4818 case RECORD_TYPE:
4819 case UNION_TYPE:
4820 case QUAL_UNION_TYPE:
4821
4822 /* For a non-file-scope tagged type, we can always go ahead and
4823 output a Dwarf description of this type right now, even if
4824 the type in question is still incomplete, because if this
4825 local type *was* ever completed anywhere within its scope,
4826 that complete definition would already have been attached to
4827 this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
4828 node by the time we reach this point. That's true because of the
4829 way the front-end does its processing of file-scope declarations (of
4830 functions and class types) within which other types might be
4831 nested. The C and C++ front-ends always gobble up such "local
4832 scope" things en-mass before they try to output *any* debugging
4833 information for any of the stuff contained inside them and thus,
4834 we get the benefit here of what is (in effect) a pre-resolution
4835 of forward references to tagged types in local scopes.
4836
4837 Note however that for file-scope tagged types we cannot assume
4838 that such pre-resolution of forward references has taken place.
4839 A given file-scope tagged type may appear to be incomplete when
4840 we reach this point, but it may yet be given a full definition
4841 (at file-scope) later on during compilation. In order to avoid
4842 generating a premature (and possibly incorrect) set of Dwarf
4843 DIEs for such (as yet incomplete) file-scope tagged types, we
4844 generate nothing at all for as-yet incomplete file-scope tagged
4845 types here unless we are making our special "finalization" pass
4846 for file-scope things at the very end of compilation. At that
4847 time, we will certainly know as much about each file-scope tagged
4848 type as we are ever going to know, so at that point in time, we
4849 can safely generate correct Dwarf descriptions for these file-
4850 scope tagged types. */
4851
4852 if (!COMPLETE_TYPE_P (type)
4853 && (TYPE_CONTEXT (type) == NULL
4854 || AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
4855 || TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
4856 && !finalizing)
4857 {
4858 /* We don't need to do this for function-local types. */
4859 if (! decl_function_context (TYPE_STUB_DECL (type)))
4860 add_incomplete_type (type);
4861 return; /* EARLY EXIT! Avoid setting TREE_ASM_WRITTEN. */
4862 }
4863
4864 /* Prevent infinite recursion in cases where the type of some
4865 member of this type is expressed in terms of this type itself. */
4866
4867 TREE_ASM_WRITTEN (type) = 1;
4868
4869 /* Output a DIE to represent the tagged type itself. */
4870
4871 switch (TREE_CODE (type))
4872 {
4873 case ENUMERAL_TYPE:
4874 output_die (output_enumeration_type_die, type);
4875 return; /* a special case -- nothing left to do so just return */
4876
4877 case RECORD_TYPE:
4878 output_die (output_structure_type_die, type);
4879 break;
4880
4881 case UNION_TYPE:
4882 case QUAL_UNION_TYPE:
4883 output_die (output_union_type_die, type);
4884 break;
4885
4886 default:
4887 abort (); /* Should never happen. */
4888 }
4889
4890 /* If this is not an incomplete type, output descriptions of
4891 each of its members.
4892
4893 Note that as we output the DIEs necessary to represent the
4894 members of this record or union type, we will also be trying
4895 to output DIEs to represent the *types* of those members.
4896 However the `output_type' function (above) will specifically
4897 avoid generating type DIEs for member types *within* the list
4898 of member DIEs for this (containing) type except for those
4899 types (of members) which are explicitly marked as also being
4900 members of this (containing) type themselves. The g++ front-
4901 end can force any given type to be treated as a member of some
4902 other (containing) type by setting the TYPE_CONTEXT of the
4903 given (member) type to point to the TREE node representing the
4904 appropriate (containing) type.
4905 */
4906
4907 if (COMPLETE_TYPE_P (type))
4908 {
4909 /* First output info about the base classes. */
4910 if (TYPE_BINFO (type) && TYPE_BINFO_BASETYPES (type))
4911 {
4912 register tree bases = TYPE_BINFO_BASETYPES (type);
4913 register int n_bases = TREE_VEC_LENGTH (bases);
4914 register int i;
4915
4916 for (i = 0; i < n_bases; i++)
4917 {
4918 tree binfo = TREE_VEC_ELT (bases, i);
4919 output_type (BINFO_TYPE (binfo), containing_scope);
4920 output_die (output_inheritance_die, binfo);
4921 }
4922 }
4923
4924 ++in_class;
4925
4926 {
4927 tree normal_member;
4928
4929 /* Now output info about the data members and type members. */
4930
4931 for (normal_member = TYPE_FIELDS (type);
4932 normal_member;
4933 normal_member = TREE_CHAIN (normal_member))
4934 output_decl (normal_member, type);
4935 }
4936
4937 {
4938 tree func_member;
4939
4940 /* Now output info about the function members (if any). */
4941
4942 for (func_member = TYPE_METHODS (type);
4943 func_member;
4944 func_member = TREE_CHAIN (func_member))
4945 {
4946 /* Don't include clones in the member list. */
4947 if (DECL_ABSTRACT_ORIGIN (func_member))
4948 continue;
4949
4950 output_decl (func_member, type);
4951 }
4952 }
4953
4954 --in_class;
4955
4956 /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
4957 scopes (at least in C++) so we must now output any nested
4958 pending types which are local just to this type. */
4959
4960 output_pending_types_for_scope (type);
4961
4962 end_sibling_chain (); /* Terminate member chain. */
4963 }
4964
4965 break;
4966
4967 case VOID_TYPE:
4968 case INTEGER_TYPE:
4969 case REAL_TYPE:
4970 case COMPLEX_TYPE:
4971 case BOOLEAN_TYPE:
4972 case CHAR_TYPE:
4973 break; /* No DIEs needed for fundamental types. */
4974
4975 case LANG_TYPE: /* No Dwarf representation currently defined. */
4976 break;
4977
4978 default:
4979 abort ();
4980 }
4981
4982 TREE_ASM_WRITTEN (type) = 1;
4983 }
4984
4985 static void
4986 output_tagged_type_instantiation (type)
4987 tree type;
4988 {
4989 if (type == 0 || type == error_mark_node)
4990 return;
4991
4992 /* We are going to output a DIE to represent the unqualified version of
4993 this type (i.e. without any const or volatile qualifiers) so make
4994 sure that we have the main variant (i.e. the unqualified version) of
4995 this type now. */
4996
4997 if (type != type_main_variant (type))
4998 abort ();
4999
5000 if (!TREE_ASM_WRITTEN (type))
5001 abort ();
5002
5003 switch (TREE_CODE (type))
5004 {
5005 case ERROR_MARK:
5006 break;
5007
5008 case ENUMERAL_TYPE:
5009 output_die (output_inlined_enumeration_type_die, type);
5010 break;
5011
5012 case RECORD_TYPE:
5013 output_die (output_inlined_structure_type_die, type);
5014 break;
5015
5016 case UNION_TYPE:
5017 case QUAL_UNION_TYPE:
5018 output_die (output_inlined_union_type_die, type);
5019 break;
5020
5021 default:
5022 abort (); /* Should never happen. */
5023 }
5024 }
5025 \f
5026 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
5027 the things which are local to the given block. */
5028
5029 static void
5030 output_block (stmt, depth)
5031 tree stmt;
5032 int depth;
5033 {
5034 int must_output_die = 0;
5035 tree origin;
5036 enum tree_code origin_code;
5037
5038 /* Ignore blocks never really used to make RTL. */
5039
5040 if (! stmt || ! TREE_USED (stmt)
5041 || (!TREE_ASM_WRITTEN (stmt) && !BLOCK_ABSTRACT (stmt)))
5042 return;
5043
5044 /* Determine the "ultimate origin" of this block. This block may be an
5045 inlined instance of an inlined instance of inline function, so we
5046 have to trace all of the way back through the origin chain to find
5047 out what sort of node actually served as the original seed for the
5048 creation of the current block. */
5049
5050 origin = block_ultimate_origin (stmt);
5051 origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
5052
5053 /* Determine if we need to output any Dwarf DIEs at all to represent this
5054 block. */
5055
5056 if (origin_code == FUNCTION_DECL)
5057 /* The outer scopes for inlinings *must* always be represented. We
5058 generate TAG_inlined_subroutine DIEs for them. (See below.) */
5059 must_output_die = 1;
5060 else
5061 {
5062 /* In the case where the current block represents an inlining of the
5063 "body block" of an inline function, we must *NOT* output any DIE
5064 for this block because we have already output a DIE to represent
5065 the whole inlined function scope and the "body block" of any
5066 function doesn't really represent a different scope according to
5067 ANSI C rules. So we check here to make sure that this block does
5068 not represent a "body block inlining" before trying to set the
5069 `must_output_die' flag. */
5070
5071 if (! is_body_block (origin ? origin : stmt))
5072 {
5073 /* Determine if this block directly contains any "significant"
5074 local declarations which we will need to output DIEs for. */
5075
5076 if (debug_info_level > DINFO_LEVEL_TERSE)
5077 /* We are not in terse mode so *any* local declaration counts
5078 as being a "significant" one. */
5079 must_output_die = (BLOCK_VARS (stmt) != NULL);
5080 else
5081 {
5082 tree decl;
5083
5084 /* We are in terse mode, so only local (nested) function
5085 definitions count as "significant" local declarations. */
5086
5087 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
5088 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
5089 {
5090 must_output_die = 1;
5091 break;
5092 }
5093 }
5094 }
5095 }
5096
5097 /* It would be a waste of space to generate a Dwarf TAG_lexical_block
5098 DIE for any block which contains no significant local declarations
5099 at all. Rather, in such cases we just call `output_decls_for_scope'
5100 so that any needed Dwarf info for any sub-blocks will get properly
5101 generated. Note that in terse mode, our definition of what constitutes
5102 a "significant" local declaration gets restricted to include only
5103 inlined function instances and local (nested) function definitions. */
5104
5105 if (origin_code == FUNCTION_DECL && BLOCK_ABSTRACT (stmt))
5106 /* We don't care about an abstract inlined subroutine. */;
5107 else if (must_output_die)
5108 {
5109 output_die ((origin_code == FUNCTION_DECL)
5110 ? output_inlined_subroutine_die
5111 : output_lexical_block_die,
5112 stmt);
5113 output_decls_for_scope (stmt, depth);
5114 end_sibling_chain ();
5115 }
5116 else
5117 output_decls_for_scope (stmt, depth);
5118 }
5119
5120 /* Output all of the decls declared within a given scope (also called
5121 a `binding contour') and (recursively) all of it's sub-blocks. */
5122
5123 static void
5124 output_decls_for_scope (stmt, depth)
5125 tree stmt;
5126 int depth;
5127 {
5128 /* Ignore blocks never really used to make RTL. */
5129
5130 if (! stmt || ! TREE_USED (stmt))
5131 return;
5132
5133 /* Output the DIEs to represent all of the data objects, functions,
5134 typedefs, and tagged types declared directly within this block
5135 but not within any nested sub-blocks. */
5136
5137 {
5138 tree decl;
5139
5140 for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
5141 output_decl (decl, stmt);
5142 }
5143
5144 output_pending_types_for_scope (stmt);
5145
5146 /* Output the DIEs to represent all sub-blocks (and the items declared
5147 therein) of this block. */
5148
5149 {
5150 tree subblocks;
5151
5152 for (subblocks = BLOCK_SUBBLOCKS (stmt);
5153 subblocks;
5154 subblocks = BLOCK_CHAIN (subblocks))
5155 output_block (subblocks, depth + 1);
5156 }
5157 }
5158
5159 /* Is this a typedef we can avoid emitting? */
5160
5161 static inline int
5162 is_redundant_typedef (decl)
5163 tree decl;
5164 {
5165 if (TYPE_DECL_IS_STUB (decl))
5166 return 1;
5167 if (DECL_ARTIFICIAL (decl)
5168 && DECL_CONTEXT (decl)
5169 && is_tagged_type (DECL_CONTEXT (decl))
5170 && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl))) == TYPE_DECL
5171 && DECL_NAME (decl) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))))
5172 /* Also ignore the artificial member typedef for the class name. */
5173 return 1;
5174 return 0;
5175 }
5176
5177 /* Output Dwarf .debug information for a decl described by DECL. */
5178
5179 static void
5180 output_decl (decl, containing_scope)
5181 tree decl;
5182 tree containing_scope;
5183 {
5184 /* Make a note of the decl node we are going to be working on. We may
5185 need to give the user the source coordinates of where it appeared in
5186 case we notice (later on) that something about it looks screwy. */
5187
5188 dwarf_last_decl = decl;
5189
5190 if (TREE_CODE (decl) == ERROR_MARK)
5191 return;
5192
5193 /* If a structure is declared within an initialization, e.g. as the
5194 operand of a sizeof, then it will not have a name. We don't want
5195 to output a DIE for it, as the tree nodes are in the temporary obstack */
5196
5197 if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
5198 || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
5199 && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
5200 || (TYPE_FIELDS (TREE_TYPE (decl))
5201 && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
5202 return;
5203
5204 /* If this ..._DECL node is marked to be ignored, then ignore it. */
5205
5206 if (DECL_IGNORED_P (decl))
5207 return;
5208
5209 switch (TREE_CODE (decl))
5210 {
5211 case CONST_DECL:
5212 /* The individual enumerators of an enum type get output when we
5213 output the Dwarf representation of the relevant enum type itself. */
5214 break;
5215
5216 case FUNCTION_DECL:
5217 /* If we are in terse mode, don't output any DIEs to represent
5218 mere function declarations. Also, if we are conforming
5219 to the DWARF version 1 specification, don't output DIEs for
5220 mere function declarations. */
5221
5222 if (DECL_INITIAL (decl) == NULL_TREE)
5223 #if (DWARF_VERSION > 1)
5224 if (debug_info_level <= DINFO_LEVEL_TERSE)
5225 #endif
5226 break;
5227
5228 /* Before we describe the FUNCTION_DECL itself, make sure that we
5229 have described its return type. */
5230
5231 output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
5232
5233 {
5234 /* And its containing type. */
5235 register tree origin = decl_class_context (decl);
5236 if (origin)
5237 output_type (origin, containing_scope);
5238 }
5239
5240 /* If we're emitting an out-of-line copy of an inline function,
5241 set up to refer to the abstract instance emitted from
5242 dwarfout_deferred_inline_function. */
5243 if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
5244 && ! (containing_scope && TYPE_P (containing_scope)))
5245 set_decl_origin_self (decl);
5246
5247 /* If the following DIE will represent a function definition for a
5248 function with "extern" linkage, output a special "pubnames" DIE
5249 label just ahead of the actual DIE. A reference to this label
5250 was already generated in the .debug_pubnames section sub-entry
5251 for this function definition. */
5252
5253 if (TREE_PUBLIC (decl))
5254 {
5255 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5256
5257 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
5258 ASM_OUTPUT_LABEL (asm_out_file, label);
5259 }
5260
5261 /* Now output a DIE to represent the function itself. */
5262
5263 output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
5264 ? output_global_subroutine_die
5265 : output_local_subroutine_die,
5266 decl);
5267
5268 /* Now output descriptions of the arguments for this function.
5269 This gets (unnecessarily?) complex because of the fact that
5270 the DECL_ARGUMENT list for a FUNCTION_DECL doesn't indicate
5271 cases where there was a trailing `...' at the end of the formal
5272 parameter list. In order to find out if there was a trailing
5273 ellipsis or not, we must instead look at the type associated
5274 with the FUNCTION_DECL. This will be a node of type FUNCTION_TYPE.
5275 If the chain of type nodes hanging off of this FUNCTION_TYPE node
5276 ends with a void_type_node then there should *not* be an ellipsis
5277 at the end. */
5278
5279 /* In the case where we are describing a mere function declaration, all
5280 we need to do here (and all we *can* do here) is to describe
5281 the *types* of its formal parameters. */
5282
5283 if (decl != current_function_decl || in_class)
5284 output_formal_types (TREE_TYPE (decl));
5285 else
5286 {
5287 /* Generate DIEs to represent all known formal parameters */
5288
5289 tree arg_decls = DECL_ARGUMENTS (decl);
5290 tree parm;
5291
5292 /* WARNING! Kludge zone ahead! Here we have a special
5293 hack for svr4 SDB compatibility. Instead of passing the
5294 current FUNCTION_DECL node as the second parameter (i.e.
5295 the `containing_scope' parameter) to `output_decl' (as
5296 we ought to) we instead pass a pointer to our own private
5297 fake_containing_scope node. That node is a RECORD_TYPE
5298 node which NO OTHER TYPE may ever actually be a member of.
5299
5300 This pointer will ultimately get passed into `output_type'
5301 as its `containing_scope' parameter. `Output_type' will
5302 then perform its part in the hack... i.e. it will pend
5303 the type of the formal parameter onto the pending_types
5304 list. Later on, when we are done generating the whole
5305 sequence of formal parameter DIEs for this function
5306 definition, we will un-pend all previously pended types
5307 of formal parameters for this function definition.
5308
5309 This whole kludge prevents any type DIEs from being
5310 mixed in with the formal parameter DIEs. That's good
5311 because svr4 SDB believes that the list of formal
5312 parameter DIEs for a function ends wherever the first
5313 non-formal-parameter DIE appears. Thus, we have to
5314 keep the formal parameter DIEs segregated. They must
5315 all appear (consecutively) at the start of the list of
5316 children for the DIE representing the function definition.
5317 Then (and only then) may we output any additional DIEs
5318 needed to represent the types of these formal parameters.
5319 */
5320
5321 /*
5322 When generating DIEs, generate the unspecified_parameters
5323 DIE instead if we come across the arg "__builtin_va_alist"
5324 */
5325
5326 for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
5327 if (TREE_CODE (parm) == PARM_DECL)
5328 {
5329 if (DECL_NAME(parm) &&
5330 !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
5331 "__builtin_va_alist") )
5332 output_die (output_unspecified_parameters_die, decl);
5333 else
5334 output_decl (parm, fake_containing_scope);
5335 }
5336
5337 /*
5338 Now that we have finished generating all of the DIEs to
5339 represent the formal parameters themselves, force out
5340 any DIEs needed to represent their types. We do this
5341 simply by un-pending all previously pended types which
5342 can legitimately go into the chain of children DIEs for
5343 the current FUNCTION_DECL.
5344 */
5345
5346 output_pending_types_for_scope (decl);
5347
5348 /*
5349 Decide whether we need an unspecified_parameters DIE at the end.
5350 There are 2 more cases to do this for:
5351 1) the ansi ... declaration - this is detectable when the end
5352 of the arg list is not a void_type_node
5353 2) an unprototyped function declaration (not a definition). This
5354 just means that we have no info about the parameters at all.
5355 */
5356
5357 {
5358 tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
5359
5360 if (fn_arg_types)
5361 {
5362 /* this is the prototyped case, check for ... */
5363 if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
5364 output_die (output_unspecified_parameters_die, decl);
5365 }
5366 else
5367 {
5368 /* this is unprototyped, check for undefined (just declaration) */
5369 if (!DECL_INITIAL (decl))
5370 output_die (output_unspecified_parameters_die, decl);
5371 }
5372 }
5373
5374 /* Output Dwarf info for all of the stuff within the body of the
5375 function (if it has one - it may be just a declaration). */
5376
5377 {
5378 tree outer_scope = DECL_INITIAL (decl);
5379
5380 if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
5381 {
5382 /* Note that here, `outer_scope' is a pointer to the outermost
5383 BLOCK node created to represent a function.
5384 This outermost BLOCK actually represents the outermost
5385 binding contour for the function, i.e. the contour in which
5386 the function's formal parameters and labels get declared.
5387
5388 Curiously, it appears that the front end doesn't actually
5389 put the PARM_DECL nodes for the current function onto the
5390 BLOCK_VARS list for this outer scope. (They are strung
5391 off of the DECL_ARGUMENTS list for the function instead.)
5392 The BLOCK_VARS list for the `outer_scope' does provide us
5393 with a list of the LABEL_DECL nodes for the function however,
5394 and we output DWARF info for those here.
5395
5396 Just within the `outer_scope' there will be a BLOCK node
5397 representing the function's outermost pair of curly braces,
5398 and any blocks used for the base and member initializers of
5399 a C++ constructor function. */
5400
5401 output_decls_for_scope (outer_scope, 0);
5402
5403 /* Finally, force out any pending types which are local to the
5404 outermost block of this function definition. These will
5405 all have a TYPE_CONTEXT which points to the FUNCTION_DECL
5406 node itself. */
5407
5408 output_pending_types_for_scope (decl);
5409 }
5410 }
5411 }
5412
5413 /* Generate a terminator for the list of stuff `owned' by this
5414 function. */
5415
5416 end_sibling_chain ();
5417
5418 break;
5419
5420 case TYPE_DECL:
5421 /* If we are in terse mode, don't generate any DIEs to represent
5422 any actual typedefs. Note that even when we are in terse mode,
5423 we must still output DIEs to represent those tagged types which
5424 are used (directly or indirectly) in the specification of either
5425 a return type or a formal parameter type of some function. */
5426
5427 if (debug_info_level <= DINFO_LEVEL_TERSE)
5428 if (! TYPE_DECL_IS_STUB (decl)
5429 || (! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)) && ! in_class))
5430 return;
5431
5432 /* In the special case of a TYPE_DECL node representing
5433 the declaration of some type tag, if the given TYPE_DECL is
5434 marked as having been instantiated from some other (original)
5435 TYPE_DECL node (e.g. one which was generated within the original
5436 definition of an inline function) we have to generate a special
5437 (abbreviated) TAG_structure_type, TAG_union_type, or
5438 TAG_enumeration-type DIE here. */
5439
5440 if (TYPE_DECL_IS_STUB (decl) && DECL_ABSTRACT_ORIGIN (decl))
5441 {
5442 output_tagged_type_instantiation (TREE_TYPE (decl));
5443 return;
5444 }
5445
5446 output_type (TREE_TYPE (decl), containing_scope);
5447
5448 if (! is_redundant_typedef (decl))
5449 /* Output a DIE to represent the typedef itself. */
5450 output_die (output_typedef_die, decl);
5451 break;
5452
5453 case LABEL_DECL:
5454 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5455 output_die (output_label_die, decl);
5456 break;
5457
5458 case VAR_DECL:
5459 /* If we are conforming to the DWARF version 1 specification, don't
5460 generated any DIEs to represent mere external object declarations. */
5461
5462 #if (DWARF_VERSION <= 1)
5463 if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
5464 break;
5465 #endif
5466
5467 /* If we are in terse mode, don't generate any DIEs to represent
5468 any variable declarations or definitions. */
5469
5470 if (debug_info_level <= DINFO_LEVEL_TERSE)
5471 break;
5472
5473 /* Output any DIEs that are needed to specify the type of this data
5474 object. */
5475
5476 output_type (TREE_TYPE (decl), containing_scope);
5477
5478 {
5479 /* And its containing type. */
5480 register tree origin = decl_class_context (decl);
5481 if (origin)
5482 output_type (origin, containing_scope);
5483 }
5484
5485 /* If the following DIE will represent a data object definition for a
5486 data object with "extern" linkage, output a special "pubnames" DIE
5487 label just ahead of the actual DIE. A reference to this label
5488 was already generated in the .debug_pubnames section sub-entry
5489 for this data object definition. */
5490
5491 if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
5492 {
5493 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5494
5495 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number++);
5496 ASM_OUTPUT_LABEL (asm_out_file, label);
5497 }
5498
5499 /* Now output the DIE to represent the data object itself. This gets
5500 complicated because of the possibility that the VAR_DECL really
5501 represents an inlined instance of a formal parameter for an inline
5502 function. */
5503
5504 {
5505 void (*func) PARAMS ((void *));
5506 register tree origin = decl_ultimate_origin (decl);
5507
5508 if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
5509 func = output_formal_parameter_die;
5510 else
5511 {
5512 if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
5513 func = output_global_variable_die;
5514 else
5515 func = output_local_variable_die;
5516 }
5517 output_die (func, decl);
5518 }
5519 break;
5520
5521 case FIELD_DECL:
5522 /* Ignore the nameless fields that are used to skip bits. */
5523 if (DECL_NAME (decl) != 0)
5524 {
5525 output_type (member_declared_type (decl), containing_scope);
5526 output_die (output_member_die, decl);
5527 }
5528 break;
5529
5530 case PARM_DECL:
5531 /* Force out the type of this formal, if it was not forced out yet.
5532 Note that here we can run afoul of a bug in "classic" svr4 SDB.
5533 It should be able to grok the presence of type DIEs within a list
5534 of TAG_formal_parameter DIEs, but it doesn't. */
5535
5536 output_type (TREE_TYPE (decl), containing_scope);
5537 output_die (output_formal_parameter_die, decl);
5538 break;
5539
5540 case NAMESPACE_DECL:
5541 /* Ignore for now. */
5542 break;
5543
5544 default:
5545 abort ();
5546 }
5547 }
5548 \f
5549 /* Output debug information for a function. */
5550 static void
5551 dwarfout_function_decl (decl)
5552 tree decl;
5553 {
5554 dwarfout_file_scope_decl (decl, 0);
5555 }
5556
5557 /* Debug information for a global DECL. Called from toplev.c after
5558 compilation proper has finished. */
5559 static void
5560 dwarfout_global_decl (decl)
5561 tree decl;
5562 {
5563 /* Output DWARF information for file-scope tentative data object
5564 declarations, file-scope (extern) function declarations (which
5565 had no corresponding body) and file-scope tagged type
5566 declarations and definitions which have not yet been forced out. */
5567
5568 if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
5569 dwarfout_file_scope_decl (decl, 1);
5570 }
5571
5572 /* DECL is an inline function, whose body is present, but which is not
5573 being output at this point. (We're putting that off until we need
5574 to do it.) */
5575 static void
5576 dwarfout_deferred_inline_function (decl)
5577 tree decl;
5578 {
5579 /* Generate the DWARF info for the "abstract" instance of a function
5580 which we may later generate inlined and/or out-of-line instances
5581 of. */
5582 if ((DECL_INLINE (decl) || DECL_ABSTRACT (decl))
5583 && ! DECL_ABSTRACT_ORIGIN (decl))
5584 {
5585 /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
5586 DWARF code expects it to be set in this case. Intuitively,
5587 DECL is the function we just finished defining, so setting
5588 CURRENT_FUNCTION_DECL is sensible. */
5589 tree saved_cfd = current_function_decl;
5590 int was_abstract = DECL_ABSTRACT (decl);
5591 current_function_decl = decl;
5592
5593 /* Let the DWARF code do its work. */
5594 set_decl_abstract_flags (decl, 1);
5595 dwarfout_file_scope_decl (decl, 0);
5596 if (! was_abstract)
5597 set_decl_abstract_flags (decl, 0);
5598
5599 /* Reset CURRENT_FUNCTION_DECL. */
5600 current_function_decl = saved_cfd;
5601 }
5602 }
5603
5604 static void
5605 dwarfout_file_scope_decl (decl, set_finalizing)
5606 tree decl;
5607 int set_finalizing;
5608 {
5609 if (TREE_CODE (decl) == ERROR_MARK)
5610 return;
5611
5612 /* If this ..._DECL node is marked to be ignored, then ignore it. */
5613
5614 if (DECL_IGNORED_P (decl))
5615 return;
5616
5617 switch (TREE_CODE (decl))
5618 {
5619 case FUNCTION_DECL:
5620
5621 /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
5622 a builtin function. Explicit programmer-supplied declarations of
5623 these same functions should NOT be ignored however. */
5624
5625 if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
5626 return;
5627
5628 /* What we would really like to do here is to filter out all mere
5629 file-scope declarations of file-scope functions which are never
5630 referenced later within this translation unit (and keep all of
5631 ones that *are* referenced later on) but we aren't clairvoyant,
5632 so we have no idea which functions will be referenced in the
5633 future (i.e. later on within the current translation unit).
5634 So here we just ignore all file-scope function declarations
5635 which are not also definitions. If and when the debugger needs
5636 to know something about these functions, it will have to hunt
5637 around and find the DWARF information associated with the
5638 *definition* of the function.
5639
5640 Note that we can't just check `DECL_EXTERNAL' to find out which
5641 FUNCTION_DECL nodes represent definitions and which ones represent
5642 mere declarations. We have to check `DECL_INITIAL' instead. That's
5643 because the C front-end supports some weird semantics for "extern
5644 inline" function definitions. These can get inlined within the
5645 current translation unit (an thus, we need to generate DWARF info
5646 for their abstract instances so that the DWARF info for the
5647 concrete inlined instances can have something to refer to) but
5648 the compiler never generates any out-of-lines instances of such
5649 things (despite the fact that they *are* definitions). The
5650 important point is that the C front-end marks these "extern inline"
5651 functions as DECL_EXTERNAL, but we need to generate DWARF for them
5652 anyway.
5653
5654 Note that the C++ front-end also plays some similar games for inline
5655 function definitions appearing within include files which also
5656 contain `#pragma interface' pragmas. */
5657
5658 if (DECL_INITIAL (decl) == NULL_TREE)
5659 return;
5660
5661 if (TREE_PUBLIC (decl)
5662 && ! DECL_EXTERNAL (decl)
5663 && ! DECL_ABSTRACT (decl))
5664 {
5665 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5666
5667 /* Output a .debug_pubnames entry for a public function
5668 defined in this compilation unit. */
5669
5670 fputc ('\n', asm_out_file);
5671 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
5672 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
5673 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
5674 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
5675 IDENTIFIER_POINTER (DECL_NAME (decl)));
5676 ASM_OUTPUT_POP_SECTION (asm_out_file);
5677 }
5678
5679 break;
5680
5681 case VAR_DECL:
5682
5683 /* Ignore this VAR_DECL if it refers to a file-scope extern data
5684 object declaration and if the declaration was never even
5685 referenced from within this entire compilation unit. We
5686 suppress these DIEs in order to save space in the .debug section
5687 (by eliminating entries which are probably useless). Note that
5688 we must not suppress block-local extern declarations (whether
5689 used or not) because that would screw-up the debugger's name
5690 lookup mechanism and cause it to miss things which really ought
5691 to be in scope at a given point. */
5692
5693 if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
5694 return;
5695
5696 if (TREE_PUBLIC (decl)
5697 && ! DECL_EXTERNAL (decl)
5698 && GET_CODE (DECL_RTL (decl)) == MEM
5699 && ! DECL_ABSTRACT (decl))
5700 {
5701 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5702
5703 if (debug_info_level >= DINFO_LEVEL_NORMAL)
5704 {
5705 /* Output a .debug_pubnames entry for a public variable
5706 defined in this compilation unit. */
5707
5708 fputc ('\n', asm_out_file);
5709 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
5710 sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
5711 ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
5712 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
5713 IDENTIFIER_POINTER (DECL_NAME (decl)));
5714 ASM_OUTPUT_POP_SECTION (asm_out_file);
5715 }
5716
5717 if (DECL_INITIAL (decl) == NULL)
5718 {
5719 /* Output a .debug_aranges entry for a public variable
5720 which is tentatively defined in this compilation unit. */
5721
5722 fputc ('\n', asm_out_file);
5723 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
5724 ASM_OUTPUT_DWARF_ADDR (asm_out_file,
5725 IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
5726 ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
5727 (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
5728 ASM_OUTPUT_POP_SECTION (asm_out_file);
5729 }
5730 }
5731
5732 /* If we are in terse mode, don't generate any DIEs to represent
5733 any variable declarations or definitions. */
5734
5735 if (debug_info_level <= DINFO_LEVEL_TERSE)
5736 return;
5737
5738 break;
5739
5740 case TYPE_DECL:
5741 /* Don't bother trying to generate any DIEs to represent any of the
5742 normal built-in types for the language we are compiling, except
5743 in cases where the types in question are *not* DWARF fundamental
5744 types. We make an exception in the case of non-fundamental types
5745 for the sake of objective C (and perhaps C++) because the GNU
5746 front-ends for these languages may in fact create certain "built-in"
5747 types which are (for example) RECORD_TYPEs. In such cases, we
5748 really need to output these (non-fundamental) types because other
5749 DIEs may contain references to them. */
5750
5751 /* Also ignore language dependent types here, because they are probably
5752 also built-in types. If we didn't ignore them, then we would get
5753 references to undefined labels because output_type doesn't support
5754 them. So, for now, we need to ignore them to avoid assembler
5755 errors. */
5756
5757 /* ??? This code is different than the equivalent code in dwarf2out.c.
5758 The dwarf2out.c code is probably more correct. */
5759
5760 if (DECL_SOURCE_LINE (decl) == 0
5761 && (type_is_fundamental (TREE_TYPE (decl))
5762 || TREE_CODE (TREE_TYPE (decl)) == LANG_TYPE))
5763 return;
5764
5765 /* If we are in terse mode, don't generate any DIEs to represent
5766 any actual typedefs. Note that even when we are in terse mode,
5767 we must still output DIEs to represent those tagged types which
5768 are used (directly or indirectly) in the specification of either
5769 a return type or a formal parameter type of some function. */
5770
5771 if (debug_info_level <= DINFO_LEVEL_TERSE)
5772 if (! TYPE_DECL_IS_STUB (decl)
5773 || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
5774 return;
5775
5776 break;
5777
5778 default:
5779 return;
5780 }
5781
5782 fputc ('\n', asm_out_file);
5783 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
5784 finalizing = set_finalizing;
5785 output_decl (decl, NULL_TREE);
5786
5787 /* NOTE: The call above to `output_decl' may have caused one or more
5788 file-scope named types (i.e. tagged types) to be placed onto the
5789 pending_types_list. We have to get those types off of that list
5790 at some point, and this is the perfect time to do it. If we didn't
5791 take them off now, they might still be on the list when cc1 finally
5792 exits. That might be OK if it weren't for the fact that when we put
5793 types onto the pending_types_list, we set the TREE_ASM_WRITTEN flag
5794 for these types, and that causes them never to be output unless
5795 `output_pending_types_for_scope' takes them off of the list and un-sets
5796 their TREE_ASM_WRITTEN flags. */
5797
5798 output_pending_types_for_scope (NULL_TREE);
5799
5800 /* The above call should have totally emptied the pending_types_list
5801 if this is not a nested function or class. If this is a nested type,
5802 then the remaining pending_types will be emitted when the containing type
5803 is handled. */
5804
5805 if (! DECL_CONTEXT (decl))
5806 {
5807 if (pending_types != 0)
5808 abort ();
5809 }
5810
5811 ASM_OUTPUT_POP_SECTION (asm_out_file);
5812
5813 if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
5814 current_funcdef_number++;
5815 }
5816 \f
5817 /* Output a marker (i.e. a label) for the beginning of the generated code
5818 for a lexical block. */
5819
5820 static void
5821 dwarfout_begin_block (line, blocknum)
5822 unsigned int line ATTRIBUTE_UNUSED;
5823 unsigned int blocknum;
5824 {
5825 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5826
5827 function_section (current_function_decl);
5828 sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
5829 ASM_OUTPUT_LABEL (asm_out_file, label);
5830 }
5831
5832 /* Output a marker (i.e. a label) for the end of the generated code
5833 for a lexical block. */
5834
5835 static void
5836 dwarfout_end_block (line, blocknum)
5837 unsigned int line ATTRIBUTE_UNUSED;
5838 unsigned int blocknum;
5839 {
5840 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5841
5842 function_section (current_function_decl);
5843 sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
5844 ASM_OUTPUT_LABEL (asm_out_file, label);
5845 }
5846
5847 /* Output a marker (i.e. a label) for the point in the generated code where
5848 the real body of the function begins (after parameters have been moved
5849 to their home locations). */
5850
5851 static void
5852 dwarfout_end_prologue (line)
5853 unsigned int line ATTRIBUTE_UNUSED;
5854 {
5855 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5856
5857 if (! use_gnu_debug_info_extensions)
5858 return;
5859
5860 function_section (current_function_decl);
5861 sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
5862 ASM_OUTPUT_LABEL (asm_out_file, label);
5863 }
5864
5865 /* Output a marker (i.e. a label) for the point in the generated code where
5866 the real body of the function ends (just before the epilogue code). */
5867
5868 static void
5869 dwarfout_end_function (line)
5870 unsigned int line ATTRIBUTE_UNUSED;
5871 {
5872 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5873
5874 if (! use_gnu_debug_info_extensions)
5875 return;
5876 function_section (current_function_decl);
5877 sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
5878 ASM_OUTPUT_LABEL (asm_out_file, label);
5879 }
5880
5881 /* Output a marker (i.e. a label) for the absolute end of the generated code
5882 for a function definition. This gets called *after* the epilogue code
5883 has been generated. */
5884
5885 static void
5886 dwarfout_end_epilogue ()
5887 {
5888 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5889
5890 /* Output a label to mark the endpoint of the code generated for this
5891 function. */
5892
5893 sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
5894 ASM_OUTPUT_LABEL (asm_out_file, label);
5895 }
5896
5897 static void
5898 shuffle_filename_entry (new_zeroth)
5899 filename_entry *new_zeroth;
5900 {
5901 filename_entry temp_entry;
5902 filename_entry *limit_p;
5903 filename_entry *move_p;
5904
5905 if (new_zeroth == &filename_table[0])
5906 return;
5907
5908 temp_entry = *new_zeroth;
5909
5910 /* Shift entries up in the table to make room at [0]. */
5911
5912 limit_p = &filename_table[0];
5913 for (move_p = new_zeroth; move_p > limit_p; move_p--)
5914 *move_p = *(move_p-1);
5915
5916 /* Install the found entry at [0]. */
5917
5918 filename_table[0] = temp_entry;
5919 }
5920
5921 /* Create a new (string) entry for the .debug_sfnames section. */
5922
5923 static void
5924 generate_new_sfname_entry ()
5925 {
5926 char label[MAX_ARTIFICIAL_LABEL_BYTES];
5927
5928 fputc ('\n', asm_out_file);
5929 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SFNAMES_SECTION);
5930 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
5931 ASM_OUTPUT_LABEL (asm_out_file, label);
5932 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
5933 filename_table[0].name
5934 ? filename_table[0].name
5935 : "");
5936 ASM_OUTPUT_POP_SECTION (asm_out_file);
5937 }
5938
5939 /* Lookup a filename (in the list of filenames that we know about here in
5940 dwarfout.c) and return its "index". The index of each (known) filename
5941 is just a unique number which is associated with only that one filename.
5942 We need such numbers for the sake of generating labels (in the
5943 .debug_sfnames section) and references to those unique labels (in the
5944 .debug_srcinfo and .debug_macinfo sections).
5945
5946 If the filename given as an argument is not found in our current list,
5947 add it to the list and assign it the next available unique index number.
5948
5949 Whatever we do (i.e. whether we find a pre-existing filename or add a new
5950 one), we shuffle the filename found (or added) up to the zeroth entry of
5951 our list of filenames (which is always searched linearly). We do this so
5952 as to optimize the most common case for these filename lookups within
5953 dwarfout.c. The most common case by far is the case where we call
5954 lookup_filename to lookup the very same filename that we did a lookup
5955 on the last time we called lookup_filename. We make sure that this
5956 common case is fast because such cases will constitute 99.9% of the
5957 lookups we ever do (in practice).
5958
5959 If we add a new filename entry to our table, we go ahead and generate
5960 the corresponding entry in the .debug_sfnames section right away.
5961 Doing so allows us to avoid tickling an assembler bug (present in some
5962 m68k assemblers) which yields assembly-time errors in cases where the
5963 difference of two label addresses is taken and where the two labels
5964 are in a section *other* than the one where the difference is being
5965 calculated, and where at least one of the two symbol references is a
5966 forward reference. (This bug could be tickled by our .debug_srcinfo
5967 entries if we don't output their corresponding .debug_sfnames entries
5968 before them.) */
5969
5970 static unsigned
5971 lookup_filename (file_name)
5972 const char *file_name;
5973 {
5974 filename_entry *search_p;
5975 filename_entry *limit_p = &filename_table[ft_entries];
5976
5977 for (search_p = filename_table; search_p < limit_p; search_p++)
5978 if (!strcmp (file_name, search_p->name))
5979 {
5980 /* When we get here, we have found the filename that we were
5981 looking for in the filename_table. Now we want to make sure
5982 that it gets moved to the zero'th entry in the table (if it
5983 is not already there) so that subsequent attempts to find the
5984 same filename will find it as quickly as possible. */
5985
5986 shuffle_filename_entry (search_p);
5987 return filename_table[0].number;
5988 }
5989
5990 /* We come here whenever we have a new filename which is not registered
5991 in the current table. Here we add it to the table. */
5992
5993 /* Prepare to add a new table entry by making sure there is enough space
5994 in the table to do so. If not, expand the current table. */
5995
5996 if (ft_entries == ft_entries_allocated)
5997 {
5998 ft_entries_allocated += FT_ENTRIES_INCREMENT;
5999 filename_table
6000 = (filename_entry *)
6001 xrealloc (filename_table,
6002 ft_entries_allocated * sizeof (filename_entry));
6003 }
6004
6005 /* Initially, add the new entry at the end of the filename table. */
6006
6007 filename_table[ft_entries].number = ft_entries;
6008 filename_table[ft_entries].name = xstrdup (file_name);
6009
6010 /* Shuffle the new entry into filename_table[0]. */
6011
6012 shuffle_filename_entry (&filename_table[ft_entries]);
6013
6014 if (debug_info_level >= DINFO_LEVEL_NORMAL)
6015 generate_new_sfname_entry ();
6016
6017 ft_entries++;
6018 return filename_table[0].number;
6019 }
6020
6021 static void
6022 generate_srcinfo_entry (line_entry_num, files_entry_num)
6023 unsigned line_entry_num;
6024 unsigned files_entry_num;
6025 {
6026 char label[MAX_ARTIFICIAL_LABEL_BYTES];
6027
6028 fputc ('\n', asm_out_file);
6029 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
6030 sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
6031 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
6032 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
6033 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, SFNAMES_BEGIN_LABEL);
6034 ASM_OUTPUT_POP_SECTION (asm_out_file);
6035 }
6036
6037 static void
6038 dwarfout_source_line (line, filename)
6039 unsigned int line;
6040 const char *filename;
6041 {
6042 if (debug_info_level >= DINFO_LEVEL_NORMAL
6043 /* We can't emit line number info for functions in separate sections,
6044 because the assembler can't subtract labels in different sections. */
6045 && DECL_SECTION_NAME (current_function_decl) == NULL_TREE)
6046 {
6047 char label[MAX_ARTIFICIAL_LABEL_BYTES];
6048 static unsigned last_line_entry_num = 0;
6049 static unsigned prev_file_entry_num = (unsigned) -1;
6050 unsigned this_file_entry_num;
6051
6052 function_section (current_function_decl);
6053 sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
6054 ASM_OUTPUT_LABEL (asm_out_file, label);
6055
6056 fputc ('\n', asm_out_file);
6057
6058 if (use_gnu_debug_info_extensions)
6059 this_file_entry_num = lookup_filename (filename);
6060 else
6061 this_file_entry_num = (unsigned) -1;
6062
6063 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
6064 if (this_file_entry_num != prev_file_entry_num)
6065 {
6066 char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
6067
6068 sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
6069 ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
6070 }
6071
6072 {
6073 const char *tail = strrchr (filename, '/');
6074
6075 if (tail != NULL)
6076 filename = tail;
6077 }
6078
6079 dw2_asm_output_data (4, line, "%s:%u", filename, line);
6080 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
6081 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
6082 ASM_OUTPUT_POP_SECTION (asm_out_file);
6083
6084 if (this_file_entry_num != prev_file_entry_num)
6085 generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
6086 prev_file_entry_num = this_file_entry_num;
6087 }
6088 }
6089
6090 /* Generate an entry in the .debug_macinfo section. */
6091
6092 static void
6093 generate_macinfo_entry (type, offset, string)
6094 unsigned int type;
6095 rtx offset;
6096 const char *string;
6097 {
6098 if (! use_gnu_debug_info_extensions)
6099 return;
6100
6101 fputc ('\n', asm_out_file);
6102 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
6103 assemble_integer (gen_rtx_PLUS (SImode, GEN_INT (type << 24), offset),
6104 4, BITS_PER_UNIT, 1);
6105 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, string);
6106 ASM_OUTPUT_POP_SECTION (asm_out_file);
6107 }
6108
6109 /* Wrapper for toplev.c callback to check debug info level. */
6110 static void
6111 dwarfout_start_source_file_check (line, filename)
6112 unsigned int line;
6113 const char *filename;
6114 {
6115 if (debug_info_level == DINFO_LEVEL_VERBOSE)
6116 dwarfout_start_source_file (line, filename);
6117 }
6118
6119 static void
6120 dwarfout_start_source_file (line, filename)
6121 unsigned int line ATTRIBUTE_UNUSED;
6122 const char *filename;
6123 {
6124 char label[MAX_ARTIFICIAL_LABEL_BYTES];
6125 const char *label1, *label2;
6126
6127 sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
6128 label1 = (*label == '*') + label;
6129 label2 = (*SFNAMES_BEGIN_LABEL == '*') + SFNAMES_BEGIN_LABEL;
6130 generate_macinfo_entry (MACINFO_start,
6131 gen_rtx_MINUS (Pmode,
6132 gen_rtx_SYMBOL_REF (Pmode, label1),
6133 gen_rtx_SYMBOL_REF (Pmode, label2)),
6134 "");
6135 }
6136
6137 /* Wrapper for toplev.c callback to check debug info level. */
6138 static void
6139 dwarfout_end_source_file_check (lineno)
6140 unsigned lineno;
6141 {
6142 if (debug_info_level == DINFO_LEVEL_VERBOSE)
6143 dwarfout_end_source_file (lineno);
6144 }
6145
6146 static void
6147 dwarfout_end_source_file (lineno)
6148 unsigned lineno;
6149 {
6150 generate_macinfo_entry (MACINFO_resume, GEN_INT (lineno), "");
6151 }
6152
6153 /* Called from check_newline in c-parse.y. The `buffer' parameter
6154 contains the tail part of the directive line, i.e. the part which
6155 is past the initial whitespace, #, whitespace, directive-name,
6156 whitespace part. */
6157
6158 static void
6159 dwarfout_define (lineno, buffer)
6160 unsigned lineno;
6161 const char *buffer;
6162 {
6163 static int initialized = 0;
6164
6165 if (!initialized)
6166 {
6167 dwarfout_start_source_file (0, primary_filename);
6168 initialized = 1;
6169 }
6170 generate_macinfo_entry (MACINFO_define, GEN_INT (lineno), buffer);
6171 }
6172
6173 /* Called from check_newline in c-parse.y. The `buffer' parameter
6174 contains the tail part of the directive line, i.e. the part which
6175 is past the initial whitespace, #, whitespace, directive-name,
6176 whitespace part. */
6177
6178 static void
6179 dwarfout_undef (lineno, buffer)
6180 unsigned lineno;
6181 const char *buffer;
6182 {
6183 generate_macinfo_entry (MACINFO_undef, GEN_INT (lineno), buffer);
6184 }
6185
6186 /* Set up for Dwarf output at the start of compilation. */
6187
6188 static void
6189 dwarfout_init (main_input_filename)
6190 const char *main_input_filename;
6191 {
6192 /* Remember the name of the primary input file. */
6193
6194 primary_filename = main_input_filename;
6195
6196 /* Allocate the initial hunk of the pending_sibling_stack. */
6197
6198 pending_sibling_stack
6199 = (unsigned *)
6200 xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
6201 pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
6202 pending_siblings = 1;
6203
6204 /* Allocate the initial hunk of the filename_table. */
6205
6206 filename_table
6207 = (filename_entry *)
6208 xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
6209 ft_entries_allocated = FT_ENTRIES_INCREMENT;
6210 ft_entries = 0;
6211
6212 /* Allocate the initial hunk of the pending_types_list. */
6213
6214 pending_types_list
6215 = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
6216 pending_types_allocated = PENDING_TYPES_INCREMENT;
6217 pending_types = 0;
6218
6219 /* Create an artificial RECORD_TYPE node which we can use in our hack
6220 to get the DIEs representing types of formal parameters to come out
6221 only *after* the DIEs for the formal parameters themselves. */
6222
6223 fake_containing_scope = make_node (RECORD_TYPE);
6224
6225 /* Output a starting label for the .text section. */
6226
6227 fputc ('\n', asm_out_file);
6228 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
6229 ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
6230 ASM_OUTPUT_POP_SECTION (asm_out_file);
6231
6232 /* Output a starting label for the .data section. */
6233
6234 fputc ('\n', asm_out_file);
6235 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
6236 ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
6237 ASM_OUTPUT_POP_SECTION (asm_out_file);
6238
6239 #if 0 /* GNU C doesn't currently use .data1. */
6240 /* Output a starting label for the .data1 section. */
6241
6242 fputc ('\n', asm_out_file);
6243 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
6244 ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
6245 ASM_OUTPUT_POP_SECTION (asm_out_file);
6246 #endif
6247
6248 /* Output a starting label for the .rodata section. */
6249
6250 fputc ('\n', asm_out_file);
6251 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
6252 ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
6253 ASM_OUTPUT_POP_SECTION (asm_out_file);
6254
6255 #if 0 /* GNU C doesn't currently use .rodata1. */
6256 /* Output a starting label for the .rodata1 section. */
6257
6258 fputc ('\n', asm_out_file);
6259 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
6260 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
6261 ASM_OUTPUT_POP_SECTION (asm_out_file);
6262 #endif
6263
6264 /* Output a starting label for the .bss section. */
6265
6266 fputc ('\n', asm_out_file);
6267 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
6268 ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
6269 ASM_OUTPUT_POP_SECTION (asm_out_file);
6270
6271 if (debug_info_level >= DINFO_LEVEL_NORMAL)
6272 {
6273 if (use_gnu_debug_info_extensions)
6274 {
6275 /* Output a starting label and an initial (compilation directory)
6276 entry for the .debug_sfnames section. The starting label will be
6277 referenced by the initial entry in the .debug_srcinfo section. */
6278
6279 fputc ('\n', asm_out_file);
6280 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SFNAMES_SECTION);
6281 ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
6282 {
6283 const char *pwd = getpwd ();
6284 char *dirname;
6285
6286 if (!pwd)
6287 fatal_io_error ("can't get current directory");
6288
6289 dirname = concat (pwd, "/", NULL);
6290 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
6291 free (dirname);
6292 }
6293 ASM_OUTPUT_POP_SECTION (asm_out_file);
6294 }
6295
6296 if (debug_info_level >= DINFO_LEVEL_VERBOSE
6297 && use_gnu_debug_info_extensions)
6298 {
6299 /* Output a starting label for the .debug_macinfo section. This
6300 label will be referenced by the AT_mac_info attribute in the
6301 TAG_compile_unit DIE. */
6302
6303 fputc ('\n', asm_out_file);
6304 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
6305 ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
6306 ASM_OUTPUT_POP_SECTION (asm_out_file);
6307 }
6308
6309 /* Generate the initial entry for the .line section. */
6310
6311 fputc ('\n', asm_out_file);
6312 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
6313 ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
6314 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
6315 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
6316 ASM_OUTPUT_POP_SECTION (asm_out_file);
6317
6318 if (use_gnu_debug_info_extensions)
6319 {
6320 /* Generate the initial entry for the .debug_srcinfo section. */
6321
6322 fputc ('\n', asm_out_file);
6323 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
6324 ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
6325 ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
6326 ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
6327 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
6328 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
6329 #ifdef DWARF_TIMESTAMPS
6330 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
6331 #else
6332 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
6333 #endif
6334 ASM_OUTPUT_POP_SECTION (asm_out_file);
6335 }
6336
6337 /* Generate the initial entry for the .debug_pubnames section. */
6338
6339 fputc ('\n', asm_out_file);
6340 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
6341 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
6342 ASM_OUTPUT_POP_SECTION (asm_out_file);
6343
6344 /* Generate the initial entry for the .debug_aranges section. */
6345
6346 fputc ('\n', asm_out_file);
6347 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
6348 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
6349 DEBUG_ARANGES_END_LABEL,
6350 DEBUG_ARANGES_BEGIN_LABEL);
6351 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_ARANGES_BEGIN_LABEL);
6352 ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 1);
6353 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
6354 ASM_OUTPUT_POP_SECTION (asm_out_file);
6355 }
6356
6357 /* Setup first DIE number == 1. */
6358 NEXT_DIE_NUM = next_unused_dienum++;
6359
6360 /* Generate the initial DIE for the .debug section. Note that the
6361 (string) value given in the AT_name attribute of the TAG_compile_unit
6362 DIE will (typically) be a relative pathname and that this pathname
6363 should be taken as being relative to the directory from which the
6364 compiler was invoked when the given (base) source file was compiled. */
6365
6366 fputc ('\n', asm_out_file);
6367 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
6368 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
6369 output_die (output_compile_unit_die, (PTR) main_input_filename);
6370 ASM_OUTPUT_POP_SECTION (asm_out_file);
6371
6372 fputc ('\n', asm_out_file);
6373 }
6374
6375 /* Output stuff that dwarf requires at the end of every file. */
6376
6377 static void
6378 dwarfout_finish (main_input_filename)
6379 const char *main_input_filename ATTRIBUTE_UNUSED;
6380 {
6381 char label[MAX_ARTIFICIAL_LABEL_BYTES];
6382
6383 fputc ('\n', asm_out_file);
6384 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
6385 retry_incomplete_types ();
6386 fputc ('\n', asm_out_file);
6387
6388 /* Mark the end of the chain of siblings which represent all file-scope
6389 declarations in this compilation unit. */
6390
6391 /* The (null) DIE which represents the terminator for the (sibling linked)
6392 list of file-scope items is *special*. Normally, we would just call
6393 end_sibling_chain at this point in order to output a word with the
6394 value `4' and that word would act as the terminator for the list of
6395 DIEs describing file-scope items. Unfortunately, if we were to simply
6396 do that, the label that would follow this DIE in the .debug section
6397 (i.e. `..D2') would *not* be properly aligned (as it must be on some
6398 machines) to a 4 byte boundary.
6399
6400 In order to force the label `..D2' to get aligned to a 4 byte boundary,
6401 the trick used is to insert extra (otherwise useless) padding bytes
6402 into the (null) DIE that we know must precede the ..D2 label in the
6403 .debug section. The amount of padding required can be anywhere between
6404 0 and 3 bytes. The length word at the start of this DIE (i.e. the one
6405 with the padding) would normally contain the value 4, but now it will
6406 also have to include the padding bytes, so it will instead have some
6407 value in the range 4..7.
6408
6409 Fortunately, the rules of Dwarf say that any DIE whose length word
6410 contains *any* value less than 8 should be treated as a null DIE, so
6411 this trick works out nicely. Clever, eh? Don't give me any credit
6412 (or blame). I didn't think of this scheme. I just conformed to it.
6413 */
6414
6415 output_die (output_padded_null_die, (void *) 0);
6416 dienum_pop ();
6417
6418 sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
6419 ASM_OUTPUT_LABEL (asm_out_file, label); /* should be ..D2 */
6420 ASM_OUTPUT_POP_SECTION (asm_out_file);
6421
6422 /* Output a terminator label for the .text section. */
6423
6424 fputc ('\n', asm_out_file);
6425 ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
6426 ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
6427 ASM_OUTPUT_POP_SECTION (asm_out_file);
6428
6429 /* Output a terminator label for the .data section. */
6430
6431 fputc ('\n', asm_out_file);
6432 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
6433 ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
6434 ASM_OUTPUT_POP_SECTION (asm_out_file);
6435
6436 #if 0 /* GNU C doesn't currently use .data1. */
6437 /* Output a terminator label for the .data1 section. */
6438
6439 fputc ('\n', asm_out_file);
6440 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
6441 ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
6442 ASM_OUTPUT_POP_SECTION (asm_out_file);
6443 #endif
6444
6445 /* Output a terminator label for the .rodata section. */
6446
6447 fputc ('\n', asm_out_file);
6448 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
6449 ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
6450 ASM_OUTPUT_POP_SECTION (asm_out_file);
6451
6452 #if 0 /* GNU C doesn't currently use .rodata1. */
6453 /* Output a terminator label for the .rodata1 section. */
6454
6455 fputc ('\n', asm_out_file);
6456 ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
6457 ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
6458 ASM_OUTPUT_POP_SECTION (asm_out_file);
6459 #endif
6460
6461 /* Output a terminator label for the .bss section. */
6462
6463 fputc ('\n', asm_out_file);
6464 ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
6465 ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
6466 ASM_OUTPUT_POP_SECTION (asm_out_file);
6467
6468 if (debug_info_level >= DINFO_LEVEL_NORMAL)
6469 {
6470 /* Output a terminating entry for the .line section. */
6471
6472 fputc ('\n', asm_out_file);
6473 ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
6474 ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
6475 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6476 ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
6477 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
6478 ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
6479 ASM_OUTPUT_POP_SECTION (asm_out_file);
6480
6481 if (use_gnu_debug_info_extensions)
6482 {
6483 /* Output a terminating entry for the .debug_srcinfo section. */
6484
6485 fputc ('\n', asm_out_file);
6486 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
6487 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
6488 LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
6489 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
6490 ASM_OUTPUT_POP_SECTION (asm_out_file);
6491 }
6492
6493 if (debug_info_level >= DINFO_LEVEL_VERBOSE)
6494 {
6495 /* Output terminating entries for the .debug_macinfo section. */
6496
6497 dwarfout_end_source_file (0);
6498
6499 fputc ('\n', asm_out_file);
6500 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
6501 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6502 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
6503 ASM_OUTPUT_POP_SECTION (asm_out_file);
6504 }
6505
6506 /* Generate the terminating entry for the .debug_pubnames section. */
6507
6508 fputc ('\n', asm_out_file);
6509 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
6510 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6511 ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
6512 ASM_OUTPUT_POP_SECTION (asm_out_file);
6513
6514 /* Generate the terminating entries for the .debug_aranges section.
6515
6516 Note that we want to do this only *after* we have output the end
6517 labels (for the various program sections) which we are going to
6518 refer to here. This allows us to work around a bug in the m68k
6519 svr4 assembler. That assembler gives bogus assembly-time errors
6520 if (within any given section) you try to take the difference of
6521 two relocatable symbols, both of which are located within some
6522 other section, and if one (or both?) of the symbols involved is
6523 being forward-referenced. By generating the .debug_aranges
6524 entries at this late point in the assembly output, we skirt the
6525 issue simply by avoiding forward-references.
6526 */
6527
6528 fputc ('\n', asm_out_file);
6529 ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
6530
6531 ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
6532 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
6533
6534 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
6535 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
6536
6537 #if 0 /* GNU C doesn't currently use .data1. */
6538 ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
6539 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
6540 DATA1_BEGIN_LABEL);
6541 #endif
6542
6543 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
6544 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
6545 RODATA_BEGIN_LABEL);
6546
6547 #if 0 /* GNU C doesn't currently use .rodata1. */
6548 ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
6549 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
6550 RODATA1_BEGIN_LABEL);
6551 #endif
6552
6553 ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
6554 ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);
6555
6556 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6557 ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
6558
6559 ASM_OUTPUT_LABEL (asm_out_file, DEBUG_ARANGES_END_LABEL);
6560 ASM_OUTPUT_POP_SECTION (asm_out_file);
6561 }
6562
6563 /* There should not be any pending types left at the end. We need
6564 this now because it may not have been checked on the last call to
6565 dwarfout_file_scope_decl. */
6566 if (pending_types != 0)
6567 abort ();
6568 }
6569
6570 #endif /* DWARF_DEBUGGING_INFO */
This page took 0.338992 seconds and 5 git commands to generate.