OSDN Git Service

* config/i386/freebsd.h (ASM_OUTPUT_MAX_SKIP_ALIGN): Handle
[pf3gnuchains/gcc-fork.git] / gcc / dwarfout.c
index 1300afd..43ab37b 100644 (file)
-/* This file contains code written by Ron Guilmette (rfg@ncd.com) for
-   Network Computing Devices, August, September, October, November 1990.
+/* Output Dwarf format symbol table information from GCC.
+   Copyright (C) 1992, 1993, 1995, 1996, 1997, 1998, 1999, 2000, 2001,
+   2002, 2003 Free Software Foundation, Inc.
+   Contributed by Ron Guilmette (rfg@monkeys.com) of Network Computing Devices.
 
-   Output Dwarf format symbol table information from the GNU C compiler.
-   Copyright (C) 1992, 1993 Free Software Foundation, Inc.
+This file is part of GCC.
 
-This file is part of GNU CC.
+GCC is free software; you can redistribute it and/or modify it under
+the terms of the GNU General Public License as published by the Free
+Software Foundation; either version 2, or (at your option) any later
+version.
 
-GNU CC is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2, or (at your option)
-any later version.
-
-GNU CC is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+GCC is distributed in the hope that it will be useful, but WITHOUT ANY
+WARRANTY; without even the implied warranty of MERCHANTABILITY or
+FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+for more details.
 
 You should have received a copy of the GNU General Public License
-along with GNU CC; see the file COPYING.  If not, write to
-the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
+along with GCC; see the file COPYING.  If not, write to the Free
+Software Foundation, 59 Temple Place - Suite 330, Boston, MA
+02111-1307, USA.  */
+
+/*
+
+ Notes on the GNU Implementation of DWARF Debugging Information
+ --------------------------------------------------------------
+ Last Major Update: Sun Jul 17 08:17:42 PDT 1994 by rfg@segfault.us.com
+ ------------------------------------------------------------
+
+ This file describes special and unique aspects of the GNU implementation of
+ the DWARF Version 1 debugging information language, as provided in the GNU
+ version 2.x compiler(s).
+
+ For general information about the DWARF debugging information language,
+ you should obtain the DWARF version 1.1 specification document (and perhaps
+ also the DWARF version 2 draft specification document) developed by the
+ (now defunct) UNIX International Programming Languages Special Interest Group.
+
+ To obtain a copy of the DWARF Version 1 and/or DWARF Version 2
+ specification, visit the web page for the DWARF Version 2 committee, at
+
+   http://www.eagercon.com/dwarf/dwarf2std.htm
+
+ The generation of DWARF debugging information by the GNU version 2.x C
+ compiler has now been tested rather extensively for m88k, i386, i860, and
+ SPARC targets.  The DWARF output of the GNU C compiler appears to inter-
+ operate well with the standard SVR4 SDB debugger on these kinds of target
+ systems (but of course, there are no guarantees).
+
+ DWARF 1 generation for the GNU g++ compiler is implemented, but limited.
+ C++ users should definitely use DWARF 2 instead.
+
+ Future plans for the dwarfout.c module of the GNU compiler(s) includes the
+ addition of full support for GNU FORTRAN.  (This should, in theory, be a
+ lot simpler to add than adding support for g++... but we'll see.)
+
+ Many features of the DWARF version 2 specification have been adapted to
+ (and used in) the GNU implementation of DWARF (version 1).  In most of
+ these cases, a DWARF version 2 approach is used in place of (or in addition
+ to) DWARF version 1 stuff simply because it is apparent that DWARF version
+ 1 is not sufficiently expressive to provide the kinds of information which
+ may be necessary to support really robust debugging.  In all of these cases
+ however, the use of DWARF version 2 features should not interfere in any
+ way with the interoperability (of GNU compilers) with generally available
+ "classic" (pre version 1) DWARF consumer tools (e.g. SVR4 SDB).
+
+ The DWARF generation enhancement for the GNU compiler(s) was initially
+ donated to the Free Software Foundation by Network Computing Devices.
+ (Thanks NCD!) Additional development and maintenance of dwarfout.c has
+ been largely supported (i.e. funded) by Intel Corporation.  (Thanks Intel!)
+
+ If you have questions or comments about the DWARF generation feature, please
+ send mail to me <rfg@netcom.com>.  I will be happy to investigate any bugs
+ reported and I may even provide fixes (but of course, I can make no promises).
+
+ The DWARF debugging information produced by GCC may deviate in a few minor
+ (but perhaps significant) respects from the DWARF debugging information
+ currently produced by other C compilers.  A serious attempt has been made
+ however to conform to the published specifications, to existing practice,
+ and to generally accepted norms in the GNU implementation of DWARF.
+
+     ** IMPORTANT NOTE **    ** IMPORTANT NOTE **    ** IMPORTANT NOTE **
+
+ Under normal circumstances, the DWARF information generated by the GNU
+ compilers (in an assembly language file) is essentially impossible for
+ a human being to read.  This fact can make it very difficult to debug
+ certain DWARF-related problems.  In order to overcome this difficulty,
+ a feature has been added to dwarfout.c (enabled by the -dA
+ option) which causes additional comments to be placed into the assembly
+ language output file, out to the right-hand side of most bits of DWARF
+ material.  The comments indicate (far more clearly that the obscure
+ DWARF hex codes do) what is actually being encoded in DWARF.  Thus, the
+ -dA option can be highly useful for those who must study the
+ DWARF output from the GNU compilers in detail.
+
+ ---------
+
+ (Footnote: Within this file, the term `Debugging Information Entry' will
+ be abbreviated as `DIE'.)
+
+
+ Release Notes  (aka known bugs)
+ -------------------------------
+
+ In one very obscure case involving dynamically sized arrays, the DWARF
+ "location information" for such an array may make it appear that the
+ array has been totally optimized out of existence, when in fact it
+ *must* actually exist.  (This only happens when you are using *both* -g
+ *and* -O.)  This is due to aggressive dead store elimination in the
+ compiler, and to the fact that the DECL_RTL expressions associated with
+ variables are not always updated to correctly reflect the effects of
+ GCC's aggressive dead store elimination.
+
+ -------------------------------
+
+ When attempting to set a breakpoint at the "start" of a function compiled
+ with -g1, the debugger currently has no way of knowing exactly where the
+ end of the prologue code for the function is.  Thus, for most targets,
+ all the debugger can do is to set the breakpoint at the AT_low_pc address
+ for the function.  But if you stop there and then try to look at one or
+ more of the formal parameter values, they may not have been "homed" yet,
+ so you may get inaccurate answers (or perhaps even addressing errors).
+
+ Some people may consider this simply a non-feature, but I consider it a
+ bug, and I hope to provide some GNU-specific attributes (on function
+ DIEs) which will specify the address of the end of the prologue and the
+ address of the beginning of the epilogue in a future release.
+
+ -------------------------------
+
+ It is believed at this time that old bugs relating to the AT_bit_offset
+ values for bit-fields have been fixed.
+
+ There may still be some very obscure bugs relating to the DWARF description
+ of type `long long' bit-fields for target machines (e.g. 80x86 machines)
+ where the alignment of type `long long' data objects is different from
+ (and less than) the size of a type `long long' data object.
+
+ Please report any problems with the DWARF description of bit-fields as you
+ would any other GCC bug.  (Procedures for bug reporting are given in the
+ GNU C compiler manual.)
+
+ --------------------------------
+
+ At this time, GCC does not know how to handle the GNU C "nested functions"
+ extension.  (See the GCC manual for more info on this extension to ANSI C.)
+
+ --------------------------------
+
+ The GNU compilers now represent inline functions (and inlined instances
+ thereof) in exactly the manner described by the current DWARF version 2
+ (draft) specification.  The version 1 specification for handling inline
+ functions (and inlined instances) was known to be brain-damaged (by the
+ PLSIG) when the version 1 spec was finalized, but it was simply too late
+ in the cycle to get it removed before the version 1 spec was formally
+ released to the public (by UI).
+
+ --------------------------------
+
+ At this time, GCC does not generate the kind of really precise information
+ about the exact declared types of entities with signed integral types which
+ is required by the current DWARF draft specification.
+
+ Specifically, the current DWARF draft specification seems to require that
+ the type of a non-unsigned integral bit-field member of a struct or union
+ type be represented as either a "signed" type or as a "plain" type,
+ depending upon the exact set of keywords that were used in the
+ type specification for the given bit-field member.  It was felt (by the
+ UI/PLSIG) that this distinction between "plain" and "signed" integral types
+ could have some significance (in the case of bit-fields) because ANSI C
+ does not constrain the signedness of a plain bit-field, whereas it does
+ constrain the signedness of an explicitly "signed" bit-field.  For this
+ reason, the current DWARF specification calls for compilers to produce
+ type information (for *all* integral typed entities... not just bit-fields)
+ which explicitly indicates the signedness of the relevant type to be
+ "signed" or "plain" or "unsigned".
+
+ Unfortunately, the GNU DWARF implementation is currently incapable of making
+ such distinctions.
+
+ --------------------------------
+
+
+ Known Interoperability Problems
+ -------------------------------
+
+ Although the GNU implementation of DWARF conforms (for the most part) with
+ the current UI/PLSIG DWARF version 1 specification (with many compatible
+ version 2 features added in as "vendor specific extensions" just for good
+ measure) there are a few known cases where GCC's DWARF output can cause
+ some confusion for "classic" (pre version 1) DWARF consumers such as the
+ System V Release 4 SDB debugger.  These cases are described in this section.
+
+ --------------------------------
+
+ The DWARF version 1 specification includes the fundamental type codes
+ FT_ext_prec_float, FT_complex, FT_dbl_prec_complex, and FT_ext_prec_complex.
+ Since GNU C is only a C compiler (and since C doesn't provide any "complex"
+ data types) the only one of these fundamental type codes which GCC ever
+ generates is FT_ext_prec_float.  This fundamental type code is generated
+ by GCC for the `long double' data type.  Unfortunately, due to an apparent
+ bug in the SVR4 SDB debugger, SDB can become very confused wherever any
+ attempt is made to print a variable, parameter, or field whose type was
+ given in terms of FT_ext_prec_float.
+
+ (Actually, SVR4 SDB fails to understand *any* of the four fundamental type
+ codes mentioned here.  This will fact will cause additional problems when
+ there is a GNU FORTRAN front-end.)
+
+ --------------------------------
+
+ In general, it appears that SVR4 SDB is not able to effectively ignore
+ fundamental type codes in the "implementation defined" range.  This can
+ cause problems when a program being debugged uses the `long long' data
+ type (or the signed or unsigned varieties thereof) because these types
+ are not defined by ANSI C, and thus, GCC must use its own private fundamental
+ type codes (from the implementation-defined range) to represent these types.
+
+ --------------------------------
+
+
+ General GNU DWARF extensions
+ ----------------------------
+
+ In the current DWARF version 1 specification, no mechanism is specified by
+ which accurate information about executable code from include files can be
+ properly (and fully) described.  (The DWARF version 2 specification *does*
+ specify such a mechanism, but it is about 10 times more complicated than
+ it needs to be so I'm not terribly anxious to try to implement it right
+ away.)
+
+ In the GNU implementation of DWARF version 1, a fully downward-compatible
+ extension has been implemented which permits the GNU compilers to specify
+ which executable lines come from which files.  This extension places
+ additional information (about source file names) in GNU-specific sections
+ (which should be totally ignored by all non-GNU DWARF consumers) so that
+ this extended information can be provided (to GNU DWARF consumers) in a way
+ which is totally transparent (and invisible) to non-GNU DWARF consumers
+ (e.g. the SVR4 SDB debugger).  The additional information is placed *only*
+ in specialized GNU-specific sections, where it should never even be seen
+ by non-GNU DWARF consumers.
+
+ To understand this GNU DWARF extension, imagine that the sequence of entries
+ in the .lines section is broken up into several subsections.  Each contiguous
+ sequence of .line entries which relates to a sequence of lines (or statements)
+ from one particular file (either a `base' file or an `include' file) could
+ be called a `line entries chunk' (LEC).
+
+ For each LEC there is one entry in the .debug_srcinfo section.
+
+ Each normal entry in the .debug_srcinfo section consists of two 4-byte
+ words of data as follows:
+
+        (1)    The starting address (relative to the entire .line section)
+                of the first .line entry in the relevant LEC.
+
+        (2)    The starting address (relative to the entire .debug_sfnames
+                section) of a NUL terminated string representing the
+                relevant filename.  (This filename name be either a
+                relative or an absolute filename, depending upon how the
+                given source file was located during compilation.)
+
+ Obviously, each .debug_srcinfo entry allows you to find the relevant filename,
+ and it also points you to the first .line entry that was generated as a result
+ of having compiled a given source line from the given source file.
+
+ Each subsequent .line entry should also be assumed to have been produced
+ as a result of compiling yet more lines from the same file.  The end of
+ any given LEC is easily found by looking at the first 4-byte pointer in
+ the *next* .debug_srcinfo entry.  That next .debug_srcinfo entry points
+ to a new and different LEC, so the preceding LEC (implicitly) must have
+ ended with the last .line section entry which occurs at the 2 1/2 words
+ just before the address given in the first pointer of the new .debug_srcinfo
+ entry.
+
+ The following picture may help to clarify this feature.  Let's assume that
+ `LE' stands for `.line entry'.  Also, assume that `* 'stands for a pointer.
+
+
+        .line section     .debug_srcinfo section     .debug_sfnames section
+        ----------------------------------------------------------------
+
+        LE  <---------------------- *
+        LE                         * -----------------> "foobar.c" <---
+        LE                                                             |
+        LE                                                             |
+        LE  <---------------------- *                                  |
+        LE                         * -----------------> "foobar.h" <|  |
+        LE                                                          |  |
+        LE                                                          |  |
+        LE  <---------------------- *                               |  |
+        LE                         * ----------------->  "inner.h"  |  |
+        LE                                                          |  |
+        LE  <---------------------- *                               |  |
+        LE                         * -------------------------------   |
+        LE                                                             |
+        LE                                                             |
+        LE                                                             |
+        LE                                                             |
+        LE  <---------------------- *                                  |
+        LE                         * -----------------------------------
+        LE
+        LE
+        LE
+
+ In effect, each entry in the .debug_srcinfo section points to *both* a
+ filename (in the .debug_sfnames section) and to the start of a block of
+ consecutive LEs (in the .line section).
+
+ Note that just like in the .line section, there are specialized first and
+ last entries in the .debug_srcinfo section for each object file.  These
+ special first and last entries for the .debug_srcinfo section are very
+ different from the normal .debug_srcinfo section entries.  They provide
+ additional information which may be helpful to a debugger when it is
+ interpreting the data in the .debug_srcinfo, .debug_sfnames, and .line
+ sections.
+
+ The first entry in the .debug_srcinfo section for each compilation unit
+ consists of five 4-byte words of data.  The contents of these five words
+ should be interpreted (by debuggers) as follows:
+
+        (1)    The starting address (relative to the entire .line section)
+                of the .line section for this compilation unit.
+
+        (2)    The starting address (relative to the entire .debug_sfnames
+                section) of the .debug_sfnames section for this compilation
+                unit.
+
+        (3)    The starting address (in the execution virtual address space)
+                of the .text section for this compilation unit.
+
+        (4)    The ending address plus one (in the execution virtual address
+                space) of the .text section for this compilation unit.
+
+        (5)    The date/time (in seconds since midnight 1/1/70) at which the
+                compilation of this compilation unit occurred.  This value
+                should be interpreted as an unsigned quantity because gcc
+                might be configured to generate a default value of 0xffffffff
+                in this field (in cases where it is desired to have object
+                files created at different times from identical source files
+                be byte-for-byte identical).  By default, these timestamps
+                are *not* generated by dwarfout.c (so that object files
+                compiled at different times will be byte-for-byte identical).
+                If you wish to enable this "timestamp" feature however, you
+                can simply place a #define for the symbol `DWARF_TIMESTAMPS'
+                in your target configuration file and then rebuild the GNU
+                compiler(s).
+
+ Note that the first string placed into the .debug_sfnames section for each
+ compilation unit is the name of the directory in which compilation occurred.
+ This string ends with a `/' (to help indicate that it is the pathname of a
+ directory).  Thus, the second word of each specialized initial .debug_srcinfo
+ entry for each compilation unit may be used as a pointer to the (string)
+ name of the compilation directory, and that string may in turn be used to
+ "absolutize" any relative pathnames which may appear later on in the
+ .debug_sfnames section entries for the same compilation unit.
+
+ The fifth and last word of each specialized starting entry for a compilation
+ unit in the .debug_srcinfo section may (depending upon your configuration)
+ indicate the date/time of compilation, and this may be used (by a debugger)
+ to determine if any of the source files which contributed code to this
+ compilation unit are newer than the object code for the compilation unit
+ itself.  If so, the debugger may wish to print an "out-of-date" warning
+ about the compilation unit.
+
+ The .debug_srcinfo section associated with each compilation will also have
+ a specialized terminating entry.  This terminating .debug_srcinfo section
+ entry will consist of the following two 4-byte words of data:
+
+        (1)    The offset, measured from the start of the .line section to
+                the beginning of the terminating entry for the .line section.
+
+        (2)    A word containing the value 0xffffffff.
+
+ --------------------------------
+
+ In the current DWARF version 1 specification, no mechanism is specified by
+ which information about macro definitions and un-definitions may be provided
+ to the DWARF consumer.
+
+ The DWARF version 2 (draft) specification does specify such a mechanism.
+ That specification was based on the GNU ("vendor specific extension")
+ which provided some support for macro definitions and un-definitions,
+ but the "official" DWARF version 2 (draft) specification mechanism for
+ handling macros and the GNU implementation have diverged somewhat.  I
+ plan to update the GNU implementation to conform to the "official"
+ DWARF version 2 (draft) specification as soon as I get time to do that.
+
+ Note that in the GNU implementation, additional information about macro
+ definitions and un-definitions is *only* provided when the -g3 level of
+ debug-info production is selected.  (The default level is -g2 and the
+ plain old -g option is considered to be identical to -g2.)
+
+ GCC records information about macro definitions and undefinitions primarily
+ in a section called the .debug_macinfo section.  Normal entries in the
+ .debug_macinfo section consist of the following three parts:
+
+        (1)    A special "type" byte.
+
+        (2)    A 3-byte line-number/filename-offset field.
+
+        (3)    A NUL terminated string.
+
+ The interpretation of the second and third parts is dependent upon the
+ value of the leading (type) byte.
+
+ The type byte may have one of four values depending upon the type of the
+ .debug_macinfo entry which follows.  The 1-byte MACINFO type codes presently
+ used, and their meanings are as follows:
+
+        MACINFO_start          A base file or an include file starts here.
+        MACINFO_resume         The current base or include file ends here.
+        MACINFO_define          A #define directive occurs here.
+        MACINFO_undef           A #undef directive occur here.
+
+ (Note that the MACINFO_... codes mentioned here are simply symbolic names
+ for constants which are defined in the GNU dwarf.h file.)
+
+ For MACINFO_define and MACINFO_undef entries, the second (3-byte) field
+ contains the number of the source line (relative to the start of the current
+ base source file or the current include files) when the #define or #undef
+ directive appears.  For a MACINFO_define entry, the following string field
+ contains the name of the macro which is defined, followed by its definition.
+ Note that the definition is always separated from the name of the macro
+ by at least one whitespace character.  For a MACINFO_undef entry, the
+ string which follows the 3-byte line number field contains just the name
+ of the macro which is being undef'ed.
+
+ For a MACINFO_start entry, the 3-byte field following the type byte contains
+ the offset, relative to the start of the .debug_sfnames section for the
+ current compilation unit, of a string which names the new source file which
+ is beginning its inclusion at this point.  Following that 3-byte field,
+ each MACINFO_start entry always contains a zero length NUL terminated
+ string.
+
+ For a MACINFO_resume entry, the 3-byte field following the type byte contains
+ the line number WITHIN THE INCLUDING FILE at which the inclusion of the
+ current file (whose inclusion ends here) was initiated.  Following that
+ 3-byte field, each MACINFO_resume entry always contains a zero length NUL
+ terminated string.
+
+ Each set of .debug_macinfo entries for each compilation unit is terminated
+ by a special .debug_macinfo entry consisting of a 4-byte zero value followed
+ by a single NUL byte.
+
+ --------------------------------
+
+ In the current DWARF draft specification, no provision is made for providing
+ a separate level of (limited) debugging information necessary to support
+ tracebacks (only) through fully-debugged code (e.g. code in system libraries).
+
+ A proposal to define such a level was submitted (by me) to the UI/PLSIG.
+ This proposal was rejected by the UI/PLSIG for inclusion into the DWARF
+ version 1 specification for two reasons.  First, it was felt (by the PLSIG)
+ that the issues involved in supporting a "traceback only" subset of DWARF
+ were not well understood.  Second, and perhaps more importantly, the PLSIG
+ is already having enough trouble agreeing on what it means to be "conforming"
+ to the DWARF specification, and it was felt that trying to specify multiple
+ different *levels* of conformance would only complicate our discussions of
+ this already divisive issue.  Nonetheless, the GNU implementation of DWARF
+ provides an abbreviated "traceback only" level of debug-info production for
+ use with fully-debugged "system library" code.  This level should only be
+ used for fully debugged system library code, and even then, it should only
+ be used where there is a very strong need to conserve disk space.  This
+ abbreviated level of debug-info production can be used by specifying the
+ -g1 option on the compilation command line.
+
+ --------------------------------
+
+ As mentioned above, the GNU implementation of DWARF currently uses the DWARF
+ version 2 (draft) approach for inline functions (and inlined instances
+ thereof).  This is used in preference to the version 1 approach because
+ (quite simply) the version 1 approach is highly brain-damaged and probably
+ unworkable.
+
+ --------------------------------
+
+
+ GNU DWARF Representation of GNU C Extensions to ANSI C
+ ------------------------------------------------------
+
+ The file dwarfout.c has been designed and implemented so as to provide
+ some reasonable DWARF representation for each and every declarative
+ construct which is accepted by the GNU C compiler.  Since the GNU C
+ compiler accepts a superset of ANSI C, this means that there are some
+ cases in which the DWARF information produced by GCC must take some
+ liberties in improvising DWARF representations for declarations which
+ are only valid in (extended) GNU C.
+
+ In particular, GNU C provides at least three significant extensions to
+ ANSI C when it comes to declarations.  These are (1) inline functions,
+ and (2) dynamic arrays, and (3) incomplete enum types.  (See the GCC
+ manual for more information on these GNU extensions to ANSI C.)  When
+ used, these GNU C extensions are represented (in the generated DWARF
+ output of GCC) in the most natural and intuitively obvious ways.
+
+ In the case of inline functions, the DWARF representation is exactly as
+ called for in the DWARF version 2 (draft) specification for an identical
+ function written in C++; i.e. we "reuse" the representation of inline
+ functions which has been defined for C++ to support this GNU C extension.
+
+ In the case of dynamic arrays, we use the most obvious representational
+ mechanism available; i.e. an array type in which the upper bound of
+ some dimension (usually the first and only dimension) is a variable
+ rather than a constant.  (See the DWARF version 1 specification for more
+ details.)
+
+ In the case of incomplete enum types, such types are represented simply
+ as TAG_enumeration_type DIEs which DO NOT contain either AT_byte_size
+ attributes or AT_element_list attributes.
+
+ --------------------------------
+
+
+ Future Directions
+ -----------------
+
+ The codes, formats, and other paraphernalia necessary to provide proper
+ support for symbolic debugging for the C++ language are still being worked
+ on by the UI/PLSIG.  The vast majority of the additions to DWARF which will
+ be needed to completely support C++ have already been hashed out and agreed
+ upon, but a few small issues (e.g. anonymous unions, access declarations)
+ are still being discussed.  Also, we in the PLSIG are still discussing
+ whether or not we need to do anything special for C++ templates.  (At this
+ time it is not yet clear whether we even need to do anything special for
+ these.)
+
+ With regard to FORTRAN, the UI/PLSIG has defined what is believed to be a
+ complete and sufficient set of codes and rules for adequately representing
+ all of FORTRAN 77, and most of Fortran 90 in DWARF.  While some support for
+ this has been implemented in dwarfout.c, further implementation and testing
+ is needed.
+
+ GNU DWARF support for other languages (i.e. Pascal and Modula) is a moot
+ issue until there are GNU front-ends for these other languages.
+
+ As currently defined, DWARF only describes a (binary) language which can
+ be used to communicate symbolic debugging information from a compiler
+ through an assembler and a linker, to a debugger.  There is no clear
+ specification of what processing should be (or must be) done by the
+ assembler and/or the linker.  Fortunately, the role of the assembler
+ is easily inferred (by anyone knowledgeable about assemblers) just by
+ looking  at examples of assembly-level DWARF code.  Sadly though, the
+ allowable (or required) processing steps performed by a linker are
+ harder to infer and (perhaps) even harder to agree upon.  There are
+ several forms of very useful `post-processing' steps which intelligent
+ linkers *could* (in theory) perform on object files containing DWARF,
+ but any and all such link-time transformations are currently both disallowed
+ and unspecified.
+
+ In particular, possible link-time transformations of DWARF code which could
+ provide significant benefits include (but are not limited to):
+
+        Commonization of duplicate DIEs obtained from multiple input
+        (object) files.
+
+        Cross-compilation type checking based upon DWARF type information
+        for objects and functions.
+
+        Other possible `compacting' transformations designed to save disk
+        space and to reduce linker & debugger I/O activity.
+
+*/
 
 #include "config.h"
+#include "system.h"
+#include "coretypes.h"
+#include "tm.h"
 
 #ifdef DWARF_DEBUGGING_INFO
-#include <stdio.h>
 #include "dwarf.h"
 #include "tree.h"
 #include "flags.h"
+#include "function.h"
 #include "rtl.h"
 #include "hard-reg-set.h"
 #include "insn-config.h"
 #include "reload.h"
 #include "output.h"
-#include "defaults.h"
-
-#ifndef DWARF_VERSION
-#define DWARF_VERSION 1
-#endif
-
-/* #define NDEBUG 1 */
-#include "assert.h"
-
-#if defined(DWARF_TIMESTAMPS)
-#if defined(POSIX)
-#include <time.h>
-#else /* !defined(POSIX) */
-#include <sys/types.h>
-#if defined(__STDC__)
-extern time_t time (time_t *);
-#else /* !defined(__STDC__) */
-extern time_t time ();
-#endif /* !defined(__STDC__) */
-#endif /* !defined(POSIX) */
-#endif /* defined(DWARF_TIMESTAMPS) */
-
-extern char *getpwd ();
-
-extern char *index ();
-extern char *rindex ();
-
-/* IMPORTANT NOTE: Please see the file README.DWARF for important details
-   regarding the GNU implementation of Dwarf.  */
+#include "dwarf2asm.h"
+#include "toplev.h"
+#include "tm_p.h"
+#include "debug.h"
+#include "target.h"
+#include "langhooks.h"
 
 /* NOTE: In the comments in this file, many references are made to
    so called "Debugging Information Entries".  For the sake of brevity,
@@ -70,12 +592,6 @@ extern char *rindex ();
 /* Note that the implementation of C++ support herein is (as yet) unfinished.
    If you want to try to complete it, more power to you.  */
 
-#if defined(__GNUC__) && (NDEBUG == 1)
-#define inline static inline
-#else
-#define inline static
-#endif
-
 /* How to start an assembler comment.  */
 #ifndef ASM_COMMENT_START
 #define ASM_COMMENT_START ";#"
@@ -87,7 +603,7 @@ extern char *rindex ();
   fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
 #endif
 
-/* Define a macro which returns non-zero for any tagged type which is
+/* Define a macro which returns nonzero for any tagged type which is
    used (directly or indirectly) in the specification of either some
    function's return type or some formal parameter of some function.
    We use this macro when we are operating in "terse" mode to help us
@@ -99,74 +615,40 @@ extern char *rindex ();
    for these nodes.  For now, we have to just fake it.  It it safe for
    us to simply return zero for all complete tagged types (which will
    get forced out anyway if they were used in the specification of some
-   formal or return type) and non-zero for all incomplete tagged types.
+   formal or return type) and nonzero for all incomplete tagged types.
 */
 
 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
 
-extern int flag_traditional;
-extern char *version_string;
-extern char *language_string;
+/* Define a macro which returns nonzero for a TYPE_DECL which was
+   implicitly generated for a tagged type.
+
+   Note that unlike the gcc front end (which generates a NULL named
+   TYPE_DECL node for each complete tagged type, each array type, and
+   each function type node created) the g++ front end generates a
+   _named_ TYPE_DECL node for each tagged type node created.
+   These TYPE_DECLs have DECL_ARTIFICIAL set, so we know not to
+   generate a DW_TAG_typedef DIE for them.  */
+#define TYPE_DECL_IS_STUB(decl)                                \
+  (DECL_NAME (decl) == NULL                            \
+   || (DECL_ARTIFICIAL (decl)                          \
+       && is_tagged_type (TREE_TYPE (decl))            \
+       && decl == TYPE_STUB_DECL (TREE_TYPE (decl))))
 
 /* Maximum size (in bytes) of an artificially generated label. */
 
 #define MAX_ARTIFICIAL_LABEL_BYTES     30
 \f
-/* Make sure we know the sizes of the various types dwarf can describe.
-   These are only defaults.  If the sizes are different for your target,
-   you should override these values by defining the appropriate symbols
-   in your tm.h file.  */
-
-#ifndef CHAR_TYPE_SIZE
-#define CHAR_TYPE_SIZE BITS_PER_UNIT
-#endif
-
-#ifndef SHORT_TYPE_SIZE
-#define SHORT_TYPE_SIZE (BITS_PER_UNIT * 2)
-#endif
-
-#ifndef INT_TYPE_SIZE
-#define INT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef LONG_TYPE_SIZE
-#define LONG_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef LONG_LONG_TYPE_SIZE
-#define LONG_LONG_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef WCHAR_TYPE_SIZE
-#define WCHAR_TYPE_SIZE INT_TYPE_SIZE
-#endif
-
-#ifndef WCHAR_UNSIGNED
-#define WCHAR_UNSIGNED 0
-#endif
-
-#ifndef FLOAT_TYPE_SIZE
-#define FLOAT_TYPE_SIZE BITS_PER_WORD
-#endif
-
-#ifndef DOUBLE_TYPE_SIZE
-#define DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-
-#ifndef LONG_DOUBLE_TYPE_SIZE
-#define LONG_DOUBLE_TYPE_SIZE (BITS_PER_WORD * 2)
-#endif
-\f
 /* Structure to keep track of source filenames.  */
 
 struct filename_entry {
   unsigned     number;
-  char *       name;
+  const char * name;
 };
 
 typedef struct filename_entry filename_entry;
 
-/* Pointer to an array of elements, each one having the structure above. */
+/* Pointer to an array of elements, each one having the structure above.  */
 
 static filename_entry *filename_table;
 
@@ -189,23 +671,9 @@ static unsigned ft_entries;
 /* Local pointer to the name of the main input file.  Initialized in
    dwarfout_init.  */
 
-static char *primary_filename;
-
-/* Pointer to the most recent filename for which we produced some line info.  */
-
-static char *last_filename;
+static const char *primary_filename;
 
-/* For Dwarf output, we must assign lexical-blocks id numbers
-   in the order in which their beginnings are encountered.
-   We output Dwarf debugging info that refers to the beginnings
-   and ends of the ranges of code for each lexical block with
-   assembler labels ..Bn and ..Bn.e, where n is the block number.
-   The labels themselves are generated in final.c, which assigns
-   numbers to the blocks in the same way.  */
-
-static unsigned next_block_number = 2;
-
-/* Counter to generate unique names for DIEs. */
+/* Counter to generate unique names for DIEs.  */
 
 static unsigned next_unused_dienum = 1;
 
@@ -217,7 +685,7 @@ static unsigned current_dienum;
    represents a function or data object defined in this compilation
    unit which has "extern" linkage.  */
 
-static next_pubname_number = 0;
+static int next_pubname_number = 0;
 
 #define NEXT_DIE_NUM pending_sibling_stack[pending_siblings-1]
 
@@ -242,7 +710,7 @@ static unsigned pending_siblings_allocated;
 
 #define PENDING_SIBLINGS_INCREMENT 64
 
-/* Non-zero if we are performing our file-scope finalization pass and if
+/* Nonzero if we are performing our file-scope finalization pass and if
    we should force out Dwarf descriptions of any and all file-scope
    tagged types which are still incomplete types.  */
 
@@ -268,6 +736,22 @@ static unsigned pending_types;
 
 #define PENDING_TYPES_INCREMENT 64
 
+/* A pointer to the base of a list of incomplete types which might be
+   completed at some later time.  */
+
+static tree *incomplete_types_list;
+
+/* Number of elements currently allocated for the incomplete_types_list.  */
+static unsigned incomplete_types_allocated;
+
+/* Number of elements of incomplete_types_list currently in use.  */
+static unsigned incomplete_types;
+
+/* Size (in elements) of increments by which we may expand the incomplete
+   types list.  Actually, a single hunk of space of this size should
+   be enough for most typical programs.         */
+#define INCOMPLETE_TYPES_INCREMENT 64
+
 /* Pointer to an artificial RECORD_TYPE which we create in dwarfout_init.
    This is used in a hack to help us get the DIEs describing types of
    formal parameters to come *after* all of the DIEs describing the formal
@@ -276,14 +760,6 @@ static unsigned pending_types;
 
 static tree fake_containing_scope;
 
-/* The number of the current function definition that we are generating
-   debugging information for.  These numbers range from 1 up to the maximum
-   number of function definitions contained within the current compilation
-   unit.  These numbers are used to create unique labels for various things
-   contained within various function definitions.  */
-
-static unsigned current_funcdef_number = 1;
-
 /* A pointer to the ..._DECL node which we have most recently been working
    on.  We keep this around just in case something about it looks screwy
    and we want to tell the user what the source coordinates for the actual
@@ -291,13 +767,165 @@ static unsigned current_funcdef_number = 1;
 
 static tree dwarf_last_decl;
 
+/* A flag indicating that we are emitting the member declarations of a
+   class, so member functions and variables should not be entirely emitted.
+   This is a kludge to avoid passing a second argument to output_*_die.  */
+
+static int in_class;
+
 /* Forward declarations for functions defined in this file.  */
 
-static void output_type ();
-static void type_attribute ();
-static void output_decls_for_scope ();
-static void output_decl ();
-static unsigned lookup_filename ();
+static void dwarfout_init (const char *);
+static void dwarfout_finish (const char *);
+static void dwarfout_define (unsigned int, const char *);
+static void dwarfout_undef (unsigned int, const char *);
+static void dwarfout_start_source_file (unsigned, const char *);
+static void dwarfout_start_source_file_check (unsigned, const char *);
+static void dwarfout_end_source_file (unsigned);
+static void dwarfout_end_source_file_check (unsigned);
+static void dwarfout_begin_block (unsigned, unsigned);
+static void dwarfout_end_block (unsigned, unsigned);
+static void dwarfout_end_epilogue (unsigned int, const char *);
+static void dwarfout_source_line (unsigned int, const char *);
+static void dwarfout_end_prologue (unsigned int, const char *);
+static void dwarfout_end_function (unsigned int);
+static void dwarfout_function_decl (tree);
+static void dwarfout_global_decl (tree);
+static void dwarfout_deferred_inline_function (tree);
+static void dwarfout_file_scope_decl (tree , int);
+static const char *dwarf_tag_name (unsigned);
+static const char *dwarf_attr_name (unsigned);
+static const char *dwarf_stack_op_name (unsigned);
+static const char *dwarf_typemod_name (unsigned);
+static const char *dwarf_fmt_byte_name (unsigned);
+static const char *dwarf_fund_type_name (unsigned);
+static tree decl_ultimate_origin (tree);
+static tree block_ultimate_origin (tree);
+static tree decl_class_context (tree);
+#if 0
+static void output_unsigned_leb128 (unsigned long);
+static void output_signed_leb128 (long);
+#endif
+static int fundamental_type_code (tree);
+static tree root_type_1 (tree, int);
+static tree root_type (tree);
+static void write_modifier_bytes_1 (tree, int, int, int);
+static void write_modifier_bytes (tree, int, int);
+static inline int type_is_fundamental (tree);
+static void equate_decl_number_to_die_number (tree);
+static inline void equate_type_number_to_die_number (tree);
+static void output_reg_number (rtx);
+static void output_mem_loc_descriptor (rtx);
+static void output_loc_descriptor (rtx);
+static void output_bound_representation (tree, unsigned, char);
+static void output_enumeral_list (tree);
+static inline HOST_WIDE_INT ceiling (HOST_WIDE_INT, unsigned int);
+static inline tree field_type (tree);
+static inline unsigned int simple_type_align_in_bits (tree);
+static inline unsigned HOST_WIDE_INT simple_type_size_in_bits (tree);
+static HOST_WIDE_INT field_byte_offset (tree);
+static inline void sibling_attribute (void);
+static void location_attribute (rtx);
+static void data_member_location_attribute (tree);
+static void const_value_attribute (rtx);
+static void location_or_const_value_attribute (tree);
+static inline void name_attribute (const char *);
+static inline void fund_type_attribute (unsigned);
+static void mod_fund_type_attribute (tree, int, int);
+static inline void user_def_type_attribute (tree);
+static void mod_u_d_type_attribute (tree, int, int);
+#ifdef USE_ORDERING_ATTRIBUTE
+static inline void ordering_attribute (unsigned);
+#endif /* defined(USE_ORDERING_ATTRIBUTE) */
+static void subscript_data_attribute (tree);
+static void byte_size_attribute (tree);
+static inline void bit_offset_attribute (tree);
+static inline void bit_size_attribute (tree);
+static inline void element_list_attribute (tree);
+static inline void stmt_list_attribute (const char *);
+static inline void low_pc_attribute (const char *);
+static inline void high_pc_attribute (const char *);
+static inline void body_begin_attribute (const char *);
+static inline void body_end_attribute (const char *);
+static inline void language_attribute (unsigned);
+static inline void member_attribute (tree);
+#if 0
+static inline void string_length_attribute (tree);
+#endif
+static inline void comp_dir_attribute (const char *);
+static inline void sf_names_attribute (const char *);
+static inline void src_info_attribute (const char *);
+static inline void mac_info_attribute (const char *);
+static inline void prototyped_attribute (tree);
+static inline void producer_attribute (const char *);
+static inline void inline_attribute (tree);
+static inline void containing_type_attribute (tree);
+static inline void abstract_origin_attribute (tree);
+#ifdef DWARF_DECL_COORDINATES
+static inline void src_coords_attribute (unsigned, unsigned);
+#endif /* defined(DWARF_DECL_COORDINATES) */
+static inline void pure_or_virtual_attribute (tree);
+static void name_and_src_coords_attributes (tree);
+static void type_attribute (tree, int, int);
+static const char *type_tag (tree);
+static inline void dienum_push (void);
+static inline void dienum_pop (void);
+static inline tree member_declared_type (tree);
+static const char *function_start_label (tree);
+static void output_array_type_die (void *);
+static void output_set_type_die (void *);
+#if 0
+static void output_entry_point_die (void *);
+#endif
+static void output_inlined_enumeration_type_die (void *);
+static void output_inlined_structure_type_die (void *);
+static void output_inlined_union_type_die (void *);
+static void output_enumeration_type_die (void *);
+static void output_formal_parameter_die (void *);
+static void output_global_subroutine_die (void *);
+static void output_global_variable_die (void *);
+static void output_label_die (void *);
+static void output_lexical_block_die (void *);
+static void output_inlined_subroutine_die (void *);
+static void output_local_variable_die (void *);
+static void output_member_die (void *);
+#if 0
+static void output_pointer_type_die (void *);
+static void output_reference_type_die (void *);
+#endif
+static void output_ptr_to_mbr_type_die (void *);
+static void output_compile_unit_die (void *);
+static void output_string_type_die (void *);
+static void output_inheritance_die (void *);
+static void output_structure_type_die (void *);
+static void output_local_subroutine_die (void *);
+static void output_subroutine_type_die (void *);
+static void output_typedef_die (void *);
+static void output_union_type_die (void *);
+static void output_unspecified_parameters_die (void *);
+static void output_padded_null_die (void *);
+static void output_die (void (*)(void *), void *);
+static void end_sibling_chain (void);
+static void output_formal_types (tree);
+static void pend_type (tree);
+static int type_ok_for_scope (tree, tree);
+static void output_pending_types_for_scope (tree);
+static void output_type (tree, tree);
+static void output_tagged_type_instantiation (tree);
+static void output_block (tree, int);
+static void output_decls_for_scope (tree, int);
+static void output_decl (tree, tree);
+static void shuffle_filename_entry (filename_entry *);
+static void generate_new_sfname_entry (void);
+static unsigned lookup_filename (const char *);
+static void generate_srcinfo_entry (unsigned, unsigned);
+static void generate_macinfo_entry (unsigned int, rtx, const char *);
+static int is_pseudo_reg (rtx);
+static tree type_main_variant (tree);
+static int is_tagged_type (tree);
+static int is_redundant_typedef (tree);
+static void add_incomplete_type (tree);
+static void retry_incomplete_types (void);
 \f
 /* Definitions of defaults for assembler-dependent names of various
    pseudo-ops and section names.
@@ -307,26 +935,14 @@ static unsigned lookup_filename ();
    what is expected by "standard" AT&T System V.4 assemblers.  */
 
 #ifndef FILE_ASM_OP
-#define FILE_ASM_OP            ".file"
-#endif
-#ifndef VERSION_ASM_OP
-#define VERSION_ASM_OP         ".version"
-#endif
-#ifndef UNALIGNED_SHORT_ASM_OP
-#define UNALIGNED_SHORT_ASM_OP ".2byte"
-#endif
-#ifndef UNALIGNED_INT_ASM_OP
-#define UNALIGNED_INT_ASM_OP   ".4byte"
-#endif
-#ifndef ASM_BYTE_OP
-#define ASM_BYTE_OP            ".byte"
+#define FILE_ASM_OP            "\t.file\t"
 #endif
 #ifndef SET_ASM_OP
-#define SET_ASM_OP             ".set"
+#define SET_ASM_OP             "\t.set\t"
 #endif
 
 /* Pseudo-ops for pushing the current section onto the section stack (and
-   simultaneously changing to a new section) and for poping back to the
+   simultaneously changing to a new section) and for popping back to the
    section we were in immediately before this one.  Note that most svr4
    assemblers only maintain a one level stack... you can push all the
    sections you want, but you can only pop out one level.  (The sparc
@@ -334,10 +950,10 @@ static unsigned lookup_filename ();
    OK because we only use at most one level of the section stack herein.  */
 
 #ifndef PUSHSECTION_ASM_OP
-#define PUSHSECTION_ASM_OP     ".section"
+#define PUSHSECTION_ASM_OP     "\t.section\t"
 #endif
 #ifndef POPSECTION_ASM_OP
-#define POPSECTION_ASM_OP      ".previous"
+#define POPSECTION_ASM_OP      "\t.previous"
 #endif
 
 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
@@ -346,7 +962,7 @@ static unsigned lookup_filename ();
    section name must be enclosed in double quotes.  (See sparcv4.h.)  */
 
 #ifndef PUSHSECTION_FORMAT
-#define PUSHSECTION_FORMAT     "%s\t%s\n"
+#define PUSHSECTION_FORMAT     "%s%s\n"
 #endif
 
 #ifndef DEBUG_SECTION
@@ -355,38 +971,38 @@ static unsigned lookup_filename ();
 #ifndef LINE_SECTION
 #define LINE_SECTION           ".line"
 #endif
-#ifndef SFNAMES_SECTION
-#define SFNAMES_SECTION                ".debug_sfnames"
+#ifndef DEBUG_SFNAMES_SECTION
+#define DEBUG_SFNAMES_SECTION  ".debug_sfnames"
 #endif
-#ifndef SRCINFO_SECTION
-#define SRCINFO_SECTION                ".debug_srcinfo"
+#ifndef DEBUG_SRCINFO_SECTION
+#define DEBUG_SRCINFO_SECTION  ".debug_srcinfo"
 #endif
-#ifndef MACINFO_SECTION
-#define MACINFO_SECTION                ".debug_macinfo"
+#ifndef DEBUG_MACINFO_SECTION
+#define DEBUG_MACINFO_SECTION  ".debug_macinfo"
 #endif
-#ifndef PUBNAMES_SECTION
-#define PUBNAMES_SECTION       ".debug_pubnames"
+#ifndef DEBUG_PUBNAMES_SECTION
+#define DEBUG_PUBNAMES_SECTION ".debug_pubnames"
 #endif
-#ifndef ARANGES_SECTION
-#define ARANGES_SECTION                ".debug_aranges"
+#ifndef DEBUG_ARANGES_SECTION
+#define DEBUG_ARANGES_SECTION  ".debug_aranges"
 #endif
-#ifndef TEXT_SECTION
-#define TEXT_SECTION           ".text"
+#ifndef TEXT_SECTION_NAME
+#define TEXT_SECTION_NAME      ".text"
 #endif
-#ifndef DATA_SECTION
-#define DATA_SECTION           ".data"
+#ifndef DATA_SECTION_NAME
+#define DATA_SECTION_NAME      ".data"
 #endif
-#ifndef DATA1_SECTION
-#define DATA1_SECTION          ".data1"
+#ifndef DATA1_SECTION_NAME
+#define DATA1_SECTION_NAME     ".data1"
 #endif
-#ifndef RODATA_SECTION
-#define RODATA_SECTION         ".rodata"
+#ifndef RODATA_SECTION_NAME
+#define RODATA_SECTION_NAME    ".rodata"
 #endif
-#ifndef RODATA1_SECTION
-#define RODATA1_SECTION                ".rodata1"
+#ifndef RODATA1_SECTION_NAME
+#define RODATA1_SECTION_NAME   ".rodata1"
 #endif
-#ifndef BSS_SECTION
-#define BSS_SECTION            ".bss"
+#ifndef BSS_SECTION_NAME
+#define BSS_SECTION_NAME       ".bss"
 #endif
 \f
 /* Definitions of defaults for formats and names of various special
@@ -401,170 +1017,159 @@ static unsigned lookup_filename ();
    stock m88k/svr4 assembler, both of which need to see .L at the start of
    a label in order to prevent that label from going into the linker symbol
    table).  When I get time, I'll have to fix this the right way so that we
-   will use ASM_GENERATE_INTERNAL_LABEL and ASM_OUTPUT_INTERNAL_LABEL herein,
+   will use ASM_GENERATE_INTERNAL_LABEL and (*targetm.asm_out.internal_label) herein,
    but that will require a rather massive set of changes.  For the moment,
    the following definitions out to produce the right results for all svr4
    and svr3 assemblers. -- rfg
 */
 
 #ifndef TEXT_BEGIN_LABEL
-#define TEXT_BEGIN_LABEL       ".L_text_b"
+#define TEXT_BEGIN_LABEL       "*.L_text_b"
 #endif
 #ifndef TEXT_END_LABEL
-#define TEXT_END_LABEL         ".L_text_e"
+#define TEXT_END_LABEL         "*.L_text_e"
 #endif
 
 #ifndef DATA_BEGIN_LABEL
-#define DATA_BEGIN_LABEL       ".L_data_b"
+#define DATA_BEGIN_LABEL       "*.L_data_b"
 #endif
 #ifndef DATA_END_LABEL
-#define DATA_END_LABEL         ".L_data_e"
+#define DATA_END_LABEL         "*.L_data_e"
 #endif
 
 #ifndef DATA1_BEGIN_LABEL
-#define DATA1_BEGIN_LABEL      ".L_data1_b"
+#define DATA1_BEGIN_LABEL      "*.L_data1_b"
 #endif
 #ifndef DATA1_END_LABEL
-#define DATA1_END_LABEL                ".L_data1_e"
+#define DATA1_END_LABEL                "*.L_data1_e"
 #endif
 
 #ifndef RODATA_BEGIN_LABEL
-#define RODATA_BEGIN_LABEL     ".L_rodata_b"
+#define RODATA_BEGIN_LABEL     "*.L_rodata_b"
 #endif
 #ifndef RODATA_END_LABEL
-#define RODATA_END_LABEL       ".L_rodata_e"
+#define RODATA_END_LABEL       "*.L_rodata_e"
 #endif
 
 #ifndef RODATA1_BEGIN_LABEL
-#define RODATA1_BEGIN_LABEL    ".L_rodata1_b"
+#define RODATA1_BEGIN_LABEL    "*.L_rodata1_b"
 #endif
 #ifndef RODATA1_END_LABEL
-#define RODATA1_END_LABEL      ".L_rodata1_e"
+#define RODATA1_END_LABEL      "*.L_rodata1_e"
 #endif
 
 #ifndef BSS_BEGIN_LABEL
-#define BSS_BEGIN_LABEL                ".L_bss_b"
+#define BSS_BEGIN_LABEL                "*.L_bss_b"
 #endif
 #ifndef BSS_END_LABEL
-#define BSS_END_LABEL          ".L_bss_e"
+#define BSS_END_LABEL          "*.L_bss_e"
 #endif
 
 #ifndef LINE_BEGIN_LABEL
-#define LINE_BEGIN_LABEL       ".L_line_b"
+#define LINE_BEGIN_LABEL       "*.L_line_b"
 #endif
 #ifndef LINE_LAST_ENTRY_LABEL
-#define LINE_LAST_ENTRY_LABEL  ".L_line_last"
+#define LINE_LAST_ENTRY_LABEL  "*.L_line_last"
 #endif
 #ifndef LINE_END_LABEL
-#define LINE_END_LABEL         ".L_line_e"
+#define LINE_END_LABEL         "*.L_line_e"
 #endif
 
 #ifndef DEBUG_BEGIN_LABEL
-#define DEBUG_BEGIN_LABEL      ".L_debug_b"
+#define DEBUG_BEGIN_LABEL      "*.L_debug_b"
 #endif
 #ifndef SFNAMES_BEGIN_LABEL
-#define SFNAMES_BEGIN_LABEL    ".L_sfnames_b"
+#define SFNAMES_BEGIN_LABEL    "*.L_sfnames_b"
 #endif
 #ifndef SRCINFO_BEGIN_LABEL
-#define SRCINFO_BEGIN_LABEL    ".L_srcinfo_b"
+#define SRCINFO_BEGIN_LABEL    "*.L_srcinfo_b"
 #endif
 #ifndef MACINFO_BEGIN_LABEL
-#define MACINFO_BEGIN_LABEL    ".L_macinfo_b"
+#define MACINFO_BEGIN_LABEL    "*.L_macinfo_b"
+#endif
+
+#ifndef DEBUG_ARANGES_BEGIN_LABEL
+#define DEBUG_ARANGES_BEGIN_LABEL "*.L_debug_aranges_begin"
+#endif
+#ifndef DEBUG_ARANGES_END_LABEL
+#define DEBUG_ARANGES_END_LABEL "*.L_debug_aranges_end"
 #endif
 
 #ifndef DIE_BEGIN_LABEL_FMT
-#define DIE_BEGIN_LABEL_FMT    ".L_D%u"
+#define DIE_BEGIN_LABEL_FMT    "*.L_D%u"
 #endif
 #ifndef DIE_END_LABEL_FMT
-#define DIE_END_LABEL_FMT      ".L_D%u_e"
+#define DIE_END_LABEL_FMT      "*.L_D%u_e"
 #endif
 #ifndef PUB_DIE_LABEL_FMT
-#define PUB_DIE_LABEL_FMT      ".L_P%u"
-#endif
-#ifndef INSN_LABEL_FMT
-#define INSN_LABEL_FMT         ".L_I%u_%u"
+#define PUB_DIE_LABEL_FMT      "*.L_P%u"
 #endif
 #ifndef BLOCK_BEGIN_LABEL_FMT
-#define BLOCK_BEGIN_LABEL_FMT  ".L_B%u"
+#define BLOCK_BEGIN_LABEL_FMT  "*.L_B%u"
 #endif
 #ifndef BLOCK_END_LABEL_FMT
-#define BLOCK_END_LABEL_FMT    ".L_B%u_e"
+#define BLOCK_END_LABEL_FMT    "*.L_B%u_e"
 #endif
 #ifndef SS_BEGIN_LABEL_FMT
-#define SS_BEGIN_LABEL_FMT     ".L_s%u"
+#define SS_BEGIN_LABEL_FMT     "*.L_s%u"
 #endif
 #ifndef SS_END_LABEL_FMT
-#define SS_END_LABEL_FMT       ".L_s%u_e"
+#define SS_END_LABEL_FMT       "*.L_s%u_e"
 #endif
 #ifndef EE_BEGIN_LABEL_FMT
-#define EE_BEGIN_LABEL_FMT     ".L_e%u"
+#define EE_BEGIN_LABEL_FMT     "*.L_e%u"
 #endif
 #ifndef EE_END_LABEL_FMT
-#define EE_END_LABEL_FMT       ".L_e%u_e"
+#define EE_END_LABEL_FMT       "*.L_e%u_e"
 #endif
 #ifndef MT_BEGIN_LABEL_FMT
-#define MT_BEGIN_LABEL_FMT     ".L_t%u"
+#define MT_BEGIN_LABEL_FMT     "*.L_t%u"
 #endif
 #ifndef MT_END_LABEL_FMT
-#define MT_END_LABEL_FMT       ".L_t%u_e"
+#define MT_END_LABEL_FMT       "*.L_t%u_e"
 #endif
 #ifndef LOC_BEGIN_LABEL_FMT
-#define LOC_BEGIN_LABEL_FMT    ".L_l%u"
+#define LOC_BEGIN_LABEL_FMT    "*.L_l%u"
 #endif
 #ifndef LOC_END_LABEL_FMT
-#define LOC_END_LABEL_FMT      ".L_l%u_e"
+#define LOC_END_LABEL_FMT      "*.L_l%u_e"
 #endif
 #ifndef BOUND_BEGIN_LABEL_FMT
-#define BOUND_BEGIN_LABEL_FMT  ".L_b%u_%u_%c"
+#define BOUND_BEGIN_LABEL_FMT  "*.L_b%u_%u_%c"
 #endif
 #ifndef BOUND_END_LABEL_FMT
-#define BOUND_END_LABEL_FMT    ".L_b%u_%u_%c_e"
-#endif
-#ifndef DERIV_BEGIN_LABEL_FMT
-#define DERIV_BEGIN_LABEL_FMT  ".L_d%u"
-#endif
-#ifndef DERIV_END_LABEL_FMT
-#define DERIV_END_LABEL_FMT    ".L_d%u_e"
-#endif
-#ifndef SL_BEGIN_LABEL_FMT
-#define SL_BEGIN_LABEL_FMT     ".L_sl%u"
-#endif
-#ifndef SL_END_LABEL_FMT
-#define SL_END_LABEL_FMT       ".L_sl%u_e"
+#define BOUND_END_LABEL_FMT    "*.L_b%u_%u_%c_e"
 #endif
 #ifndef BODY_BEGIN_LABEL_FMT
-#define BODY_BEGIN_LABEL_FMT   ".L_b%u"
+#define BODY_BEGIN_LABEL_FMT   "*.L_b%u"
 #endif
 #ifndef BODY_END_LABEL_FMT
-#define BODY_END_LABEL_FMT     ".L_b%u_e"
+#define BODY_END_LABEL_FMT     "*.L_b%u_e"
 #endif
 #ifndef FUNC_END_LABEL_FMT
-#define FUNC_END_LABEL_FMT     ".L_f%u_e"
+#define FUNC_END_LABEL_FMT     "*.L_f%u_e"
 #endif
 #ifndef TYPE_NAME_FMT
-#define TYPE_NAME_FMT          ".L_T%u"
+#define TYPE_NAME_FMT          "*.L_T%u"
 #endif
 #ifndef DECL_NAME_FMT
-#define DECL_NAME_FMT          ".L_E%u"
+#define DECL_NAME_FMT          "*.L_E%u"
 #endif
 #ifndef LINE_CODE_LABEL_FMT
-#define LINE_CODE_LABEL_FMT    ".L_LC%u"
+#define LINE_CODE_LABEL_FMT    "*.L_LC%u"
 #endif
 #ifndef SFNAMES_ENTRY_LABEL_FMT
-#define SFNAMES_ENTRY_LABEL_FMT        ".L_F%u"
+#define SFNAMES_ENTRY_LABEL_FMT        "*.L_F%u"
 #endif
 #ifndef LINE_ENTRY_LABEL_FMT
-#define LINE_ENTRY_LABEL_FMT   ".L_LE%u"
+#define LINE_ENTRY_LABEL_FMT   "*.L_LE%u"
 #endif
 \f
 /* Definitions of defaults for various types of primitive assembly language
    output operations.
 
    If necessary, these may be overridden from within your tm.h file,
-   but typically, you shouldn't need to override these.  One known
-   exception is ASM_OUTPUT_DEF which has to be different for stock
-   sparc/svr4 assemblers.
-*/
+   but typically, you shouldn't need to override these.  */
 
 #ifndef ASM_OUTPUT_PUSH_SECTION
 #define ASM_OUTPUT_PUSH_SECTION(FILE, SECTION) \
@@ -573,201 +1178,137 @@ static unsigned lookup_filename ();
 
 #ifndef ASM_OUTPUT_POP_SECTION
 #define ASM_OUTPUT_POP_SECTION(FILE) \
-  fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
-#endif
-
-#ifndef ASM_OUTPUT_SOURCE_FILENAME
-#define ASM_OUTPUT_SOURCE_FILENAME(FILE,NAME) \
-  do { fprintf (FILE, "\t%s\t", FILE_ASM_OP);                          \
-       output_quoted_string (FILE, NAME);                              \
-       fputc ('\n', FILE);                                             \
-  } while (0)
-#endif
-
-#ifndef ASM_OUTPUT_DEF
-#define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                             \
- do {  fprintf ((FILE), "\t%s\t", SET_ASM_OP);                         \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, ",");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-       fprintf (FILE, "\n");                                           \
-  } while (0)
+  fprintf ((FILE), "%s\n", POPSECTION_ASM_OP)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DELTA2
 #define ASM_OUTPUT_DWARF_DELTA2(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_SHORT_ASM_OP);             \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-       fprintf (FILE, "\n");                                           \
-  } while (0)
+  dw2_asm_output_delta (2, LABEL1, LABEL2, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DELTA4
 #define ASM_OUTPUT_DWARF_DELTA4(FILE,LABEL1,LABEL2)                    \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
-       assemble_name (FILE, LABEL1);                                   \
-       fprintf (FILE, "-");                                            \
-       assemble_name (FILE, LABEL2);                                   \
-       fprintf (FILE, "\n");                                           \
-  } while (0)
+  dw2_asm_output_delta (4, LABEL1, LABEL2, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_TAG
 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG)                                 \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t0x%x",                                     \
-                    UNALIGNED_SHORT_ASM_OP, (unsigned) TAG);           \
-    if (flag_verbose_asm)                                              \
-      fprintf ((FILE), "\t%s %s",                                      \
-                      ASM_COMMENT_START, dwarf_tag_name (TAG));        \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_data (2, TAG, "%s", dwarf_tag_name (TAG));
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
 #define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTR)                          \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t0x%x",                                     \
-                    UNALIGNED_SHORT_ASM_OP, (unsigned) ATTR);          \
-    if (flag_verbose_asm)                                              \
-      fprintf ((FILE), "\t%s %s",                                      \
-                      ASM_COMMENT_START, dwarf_attr_name (ATTR));      \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_data (2, ATTR, "%s", dwarf_attr_name (ATTR))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_STACK_OP
 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP)                             \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) OP);                \
-    if (flag_verbose_asm)                                              \
-      fprintf ((FILE), "\t%s %s",                                      \
-                      ASM_COMMENT_START, dwarf_stack_op_name (OP));    \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_data (1, OP, "%s", dwarf_stack_op_name (OP))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT)                            \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t0x%x",                                     \
-                    UNALIGNED_SHORT_ASM_OP, (unsigned) FT);            \
-    if (flag_verbose_asm)                                              \
-      fprintf ((FILE), "\t%s %s",                                      \
-                      ASM_COMMENT_START, dwarf_fund_type_name (FT));   \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_data (2, FT, "%s", dwarf_fund_type_name (FT))
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT)                            \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) FMT);       \
-    if (flag_verbose_asm)                                              \
-      fprintf ((FILE), "\t%s %s",                                      \
-                      ASM_COMMENT_START, dwarf_fmt_byte_name (FMT));   \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_data (1, FMT, "%s", dwarf_fmt_byte_name (FMT));
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD)                       \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) MOD);       \
-    if (flag_verbose_asm)                                              \
-      fprintf ((FILE), "\t%s %s",                                      \
-                      ASM_COMMENT_START, dwarf_typemod_name (MOD));    \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_data (1, MOD, "%s", dwarf_typemod_name (MOD));
 #endif
 \f
 #ifndef ASM_OUTPUT_DWARF_ADDR
 #define ASM_OUTPUT_DWARF_ADDR(FILE,LABEL)                              \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
-       assemble_name (FILE, LABEL);                                    \
-       fprintf (FILE, "\n");                                           \
-  } while (0)
+  dw2_asm_output_addr (4, LABEL, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                          \
-  do {                                                                 \
-    fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);                  \
-    output_addr_const ((FILE), (RTX));                                 \
-    fputc ('\n', (FILE));                                              \
-  } while (0)
+  dw2_asm_output_addr_rtx (4, RTX, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_REF
 #define ASM_OUTPUT_DWARF_REF(FILE,LABEL)                               \
- do {  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);               \
-       assemble_name (FILE, LABEL);                                    \
-       fprintf (FILE, "\n");                                           \
-  } while (0)
+  dw2_asm_output_addr (4, LABEL, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA1
 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
+  dw2_asm_output_data (1, VALUE, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA2
 #define ASM_OUTPUT_DWARF_DATA2(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_SHORT_ASM_OP, (unsigned) VALUE)
+  dw2_asm_output_data (2, VALUE, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA4
 #define ASM_OUTPUT_DWARF_DATA4(FILE,VALUE) \
-  fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, (unsigned) VALUE)
+  dw2_asm_output_data (4, VALUE, NULL)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA8
 #define ASM_OUTPUT_DWARF_DATA8(FILE,HIGH_VALUE,LOW_VALUE)              \
-  do {                                                                 \
-    if (WORDS_BIG_ENDIAN)                                              \
-      {                                                                        \
-       fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
-       fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
-      }                                                                        \
-    else                                                               \
-      {                                                                        \
-       fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, LOW_VALUE);\
-       fprintf ((FILE), "\t%s\t0x%x\n", UNALIGNED_INT_ASM_OP, HIGH_VALUE); \
-      }                                                                        \
-  } while (0)
+  dw2_asm_output_data (8, VALUE, NULL)
 #endif
 
+/* ASM_OUTPUT_DWARF_STRING is defined to output an ascii string, but to
+   NOT issue a trailing newline. We define ASM_OUTPUT_DWARF_STRING_NEWLINE
+   based on whether ASM_OUTPUT_DWARF_STRING is defined or not. If it is
+   defined, we call it, then issue the line feed. If not, we supply a
+   default definition of calling ASM_OUTPUT_ASCII */
+
 #ifndef ASM_OUTPUT_DWARF_STRING
-#define ASM_OUTPUT_DWARF_STRING(FILE,P) \
+#define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
   ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
+#else
+#define ASM_OUTPUT_DWARF_STRING_NEWLINE(FILE,P) \
+  ASM_OUTPUT_DWARF_STRING (FILE,P), ASM_OUTPUT_DWARF_STRING (FILE,"\n")
 #endif
+
+\f
+/* The debug hooks structure.  */
+const struct gcc_debug_hooks dwarf_debug_hooks =
+{
+  dwarfout_init,
+  dwarfout_finish,
+  dwarfout_define,
+  dwarfout_undef,
+  dwarfout_start_source_file_check,
+  dwarfout_end_source_file_check,
+  dwarfout_begin_block,
+  dwarfout_end_block,
+  debug_true_tree,             /* ignore_block */
+  dwarfout_source_line,                /* source_line */
+  dwarfout_source_line,                /* begin_prologue */
+  dwarfout_end_prologue,
+  dwarfout_end_epilogue,
+  debug_nothing_tree,          /* begin_function */
+  dwarfout_end_function,
+  dwarfout_function_decl,
+  dwarfout_global_decl,
+  dwarfout_deferred_inline_function,
+  debug_nothing_tree,          /* outlining_inline_function */
+  debug_nothing_rtx,           /* label */
+  debug_nothing_int            /* handle_pch */
+};
 \f
 /************************ general utility functions **************************/
 
-inline char *
-xstrdup (s)
-     register char *s;
-{
-  register char *p = (char *) xmalloc (strlen (s) + 1);
-
-  strcpy (p, s);
-  return p;
-}
-
-inline int
-is_pseudo_reg (rtl)
-     register rtx rtl;
+static inline int
+is_pseudo_reg (rtx rtl)
 {
   return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
-          || ((GET_CODE (rtl) == SUBREG)
-             && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
+         || ((GET_CODE (rtl) == SUBREG)
+             && (REGNO (SUBREG_REG (rtl)) >= FIRST_PSEUDO_REGISTER)));
 }
 
-inline tree
-type_main_variant (type)
-     register tree type;
+static inline tree
+type_main_variant (tree type)
 {
   type = TYPE_MAIN_VARIANT (type);
 
@@ -779,27 +1320,25 @@ type_main_variant (type)
   if (TREE_CODE (type) == ARRAY_TYPE)
     {
       while (type != TYPE_MAIN_VARIANT (type))
-        type = TYPE_MAIN_VARIANT (type);
+       type = TYPE_MAIN_VARIANT (type);
     }
 
   return type;
 }
 
-/* Return non-zero if the given type node represents a tagged type.  */
+/* Return nonzero if the given type node represents a tagged type.  */
 
-inline int
-is_tagged_type (type)
-     register tree type;
+static inline int
+is_tagged_type (tree type)
 {
-  register enum tree_code code = TREE_CODE (type);
+  enum tree_code code = TREE_CODE (type);
 
   return (code == RECORD_TYPE || code == UNION_TYPE
          || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
 }
 
-static char *
-dwarf_tag_name (tag)
-     register unsigned tag;
+static const char *
+dwarf_tag_name (unsigned int tag)
 {
   switch (tag)
     {
@@ -847,9 +1386,8 @@ dwarf_tag_name (tag)
     }
 }
 
-static char *
-dwarf_attr_name (attr)
-     register unsigned attr;
+static const char *
+dwarf_attr_name (unsigned int attr)
 {
   switch (attr)
     {
@@ -925,9 +1463,8 @@ dwarf_attr_name (attr)
     }
 }
 
-static char *
-dwarf_stack_op_name (op)
-     register unsigned op;
+static const char *
+dwarf_stack_op_name (unsigned int op)
 {
   switch (op)
     {
@@ -942,9 +1479,8 @@ dwarf_stack_op_name (op)
     }
 }
 
-static char *
-dwarf_typemod_name (mod)
-     register unsigned mod;
+static const char *
+dwarf_typemod_name (unsigned int mod)
 {
   switch (mod)
     {
@@ -956,9 +1492,8 @@ dwarf_typemod_name (mod)
     }
 }
 
-static char *
-dwarf_fmt_byte_name (fmt)
-     register unsigned fmt;
+static const char *
+dwarf_fmt_byte_name (unsigned int fmt)
 {
   switch (fmt)
     {
@@ -974,9 +1509,9 @@ dwarf_fmt_byte_name (fmt)
     default:           return "FMT_<unknown>";
     }
 }
-static char *
-dwarf_fund_type_name (ft)
-     register unsigned ft;
+
+static const char *
+dwarf_fund_type_name (unsigned int ft)
 {
   switch (ft)
     {
@@ -1020,7 +1555,10 @@ dwarf_fund_type_name (ft)
     case FT_unsigned_int32:    return "FT_unsigned_int32";
     case FT_int64:             return "FT_int64";
     case FT_signed_int64:      return "FT_signed_int64";
-    case FT_unsigned_int64:    return "FT_signed_int64";
+    case FT_unsigned_int64:    return "FT_unsigned_int64";
+    case FT_int128:            return "FT_int128";
+    case FT_signed_int128:     return "FT_signed_int128";
+    case FT_unsigned_int128:   return "FT_unsigned_int128";
 
     case FT_real32:            return "FT_real32";
     case FT_real64:            return "FT_real64";
@@ -1038,26 +1576,16 @@ dwarf_fund_type_name (ft)
    served as the original seed for the given block.  */
 
 static tree
-decl_ultimate_origin (decl)
-     register tree decl;
+decl_ultimate_origin (tree decl)
 {
-  register tree immediate_origin = DECL_ABSTRACT_ORIGIN (decl);
-
-  if (immediate_origin == NULL)
-    return NULL;
-  else
-    {
-      register tree ret_val;
-      register tree lookahead = immediate_origin;
+#ifdef ENABLE_CHECKING
+  if (DECL_FROM_INLINE (DECL_ORIGIN (decl)))
+    /* Since the DECL_ABSTRACT_ORIGIN for a DECL is supposed to be the
+       most distant ancestor, this should never happen.  */
+    abort ();
+#endif
 
-      do
-       {
-         ret_val = lookahead;
-         lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
-       }
-      while (lookahead != NULL && lookahead != ret_val);
-      return ret_val;
-    }
+  return DECL_ABSTRACT_ORIGIN (decl);
 }
 
 /* Determine the "ultimate origin" of a block.  The block may be an
@@ -1067,17 +1595,16 @@ decl_ultimate_origin (decl)
    served as the original seed for the given block.  */
 
 static tree
-block_ultimate_origin (block)
-     register tree block;
+block_ultimate_origin (tree block)
 {
-  register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
+  tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
 
   if (immediate_origin == NULL)
     return NULL;
   else
     {
-      register tree ret_val;
-      register tree lookahead = immediate_origin;
+      tree ret_val;
+      tree lookahead = immediate_origin;
 
       do
        {
@@ -1091,93 +1618,76 @@ block_ultimate_origin (block)
     }
 }
 
+/* Get the class to which DECL belongs, if any.  In g++, the DECL_CONTEXT
+   of a virtual function may refer to a base class, so we check the 'this'
+   parameter.  */
+
+static tree
+decl_class_context (tree decl)
+{
+  tree context = NULL_TREE;
+  if (TREE_CODE (decl) != FUNCTION_DECL || ! DECL_VINDEX (decl))
+    context = DECL_CONTEXT (decl);
+  else
+    context = TYPE_MAIN_VARIANT
+      (TREE_TYPE (TREE_VALUE (TYPE_ARG_TYPES (TREE_TYPE (decl)))));
+
+  if (context && !TYPE_P (context))
+    context = NULL_TREE;
+
+  return context;
+}
+
+#if 0
 static void
-output_unsigned_leb128 (value)
-     register unsigned long value;
+output_unsigned_leb128 (unsigned long value)
 {
-  register unsigned long orig_value = value;
+  unsigned long orig_value = value;
 
   do
     {
-      register unsigned byte = (value & 0x7f);
+      unsigned byte = (value & 0x7f);
 
       value >>= 7;
       if (value != 0)  /* more bytes to follow */
        byte |= 0x80;
-      fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
-      if (flag_verbose_asm && value == 0)
-       fprintf (asm_out_file, "\t%s ULEB128 number - value = %u",
-                ASM_COMMENT_START, orig_value);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, byte, "\t%s ULEB128 number - value = %lu",
+                          orig_value);
     }
   while (value != 0);
 }
 
 static void
-output_signed_leb128 (value)
-     register long value;
+output_signed_leb128 (long value)
 {
-  register long orig_value = value;
-  register int negative = (value < 0);
-  register int more;
+  long orig_value = value;
+  int negative = (value < 0);
+  int more;
 
   do
     {
-      register unsigned byte = (value & 0x7f);
+      unsigned byte = (value & 0x7f);
 
       value >>= 7;
       if (negative)
        value |= 0xfe000000;  /* manually sign extend */
       if (((value == 0) && ((byte & 0x40) == 0))
-          || ((value == -1) && ((byte & 0x40) == 1)))
+         || ((value == -1) && ((byte & 0x40) == 1)))
        more = 0;
       else
        {
          byte |= 0x80;
          more = 1;
        }
-      fprintf (asm_out_file, "\t%s\t0x%x", ASM_BYTE_OP, (unsigned) byte);
-      if (flag_verbose_asm && more == 0)
-       fprintf (asm_out_file, "\t%s SLEB128 number - value = %d",
-                ASM_COMMENT_START, orig_value);
-      fputc ('\n', asm_out_file);
+      dw2_asm_output_data (1, byte, "\t%s SLEB128 number - value = %ld",
+                          orig_value);
     }
   while (more);
 }
+#endif
 \f
 /**************** utility functions for attribute functions ******************/
 
-/* Given a pointer to a BLOCK node return non-zero if (and only if) the
-   node in question represents the outermost pair of curly braces (i.e.
-   the "body block") of a function or method.
-
-   For any BLOCK node representing a "body block" of a function or method,
-   the BLOCK_SUPERCONTEXT of the node will point to another BLOCK node
-   which represents the outermost (function) scope for the function or
-   method (i.e. the one which includes the formal parameters).  The
-   BLOCK_SUPERCONTEXT of *that* node in turn will point to the relevant
-   FUNCTION_DECL node.
-*/
-
-inline int
-is_body_block (stmt)
-     register tree stmt;
-{
-  if (TREE_CODE (stmt) == BLOCK)
-    {
-      register tree parent = BLOCK_SUPERCONTEXT (stmt);
-
-      if (TREE_CODE (parent) == BLOCK)
-       {
-         register tree grandparent = BLOCK_SUPERCONTEXT (parent);
-
-         if (TREE_CODE (grandparent) == FUNCTION_DECL)
-           return 1;
-       }
-    }
-  return 0;
-}
-
 /* Given a pointer to a tree node for some type, return a Dwarf fundamental
    type code for the given type.
 
@@ -1195,7 +1705,7 @@ is_body_block (stmt)
 
        struct s { my_type f; };
 
-   Since we may be stuck here without enought information to do exactly
+   Since we may be stuck here without enough information to do exactly
    what is called for in the Dwarf draft specification, we do the best
    that we can under the circumstances and always use the "plain" integral
    fundamental type codes for int, short, and long types.  That's probably
@@ -1203,8 +1713,7 @@ is_body_block (stmt)
    draft specification is probably never even useful in practice.  */
 
 static int
-fundamental_type_code (type)
-     register tree type;
+fundamental_type_code (tree type)
 {
   if (TREE_CODE (type) == ERROR_MARK)
     return 0;
@@ -1227,7 +1736,8 @@ fundamental_type_code (type)
            && DECL_NAME (TYPE_NAME (type)) != 0
            && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
          {
-           char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+           const char *const name =
+             IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
 
            if (!strcmp (name, "unsigned char"))
              return FT_unsigned_char;
@@ -1268,6 +1778,13 @@ fundamental_type_code (type)
        if (TYPE_PRECISION (type) == CHAR_TYPE_SIZE)
          return (TREE_UNSIGNED (type) ? FT_unsigned_char : FT_char);
 
+       if (TYPE_MODE (type) == TImode)
+         return (TREE_UNSIGNED (type) ? FT_unsigned_int128 : FT_int128);
+
+       /* In C++, __java_boolean is an INTEGER_TYPE with precision == 1 */
+       if (TYPE_PRECISION (type) == 1)
+         return FT_boolean;
+
        abort ();
 
       case REAL_TYPE:
@@ -1278,9 +1795,10 @@ fundamental_type_code (type)
            && DECL_NAME (TYPE_NAME (type)) != 0
            && TREE_CODE (DECL_NAME (TYPE_NAME (type))) == IDENTIFIER_NODE)
          {
-           char *name = IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
+           const char *const name =
+             IDENTIFIER_POINTER (DECL_NAME (TYPE_NAME (type)));
 
-           /* Note that here we can run afowl of a serious bug in "classic"
+           /* Note that here we can run afoul of a serious bug in "classic"
               svr4 SDB debuggers.  They don't seem to understand the
               FT_ext_prec_float type (even though they should).  */
 
@@ -1289,11 +1807,20 @@ fundamental_type_code (type)
          }
 
        if (TYPE_PRECISION (type) == DOUBLE_TYPE_SIZE)
-         return FT_dbl_prec_float;
+         {
+           /* On the SH, when compiling with -m3e or -m4-single-only, both
+              float and double are 32 bits.  But since the debugger doesn't
+              know about the subtarget, it always thinks double is 64 bits.
+              So we have to tell the debugger that the type is float to
+              make the output of the 'print' command etc. readable.  */
+           if (DOUBLE_TYPE_SIZE == FLOAT_TYPE_SIZE && FLOAT_TYPE_SIZE == 32)
+             return FT_float;
+           return FT_dbl_prec_float;
+         }
        if (TYPE_PRECISION (type) == FLOAT_TYPE_SIZE)
          return FT_float;
 
-       /* Note that here we can run afowl of a serious bug in "classic"
+       /* Note that here we can run afoul of a serious bug in "classic"
           svr4 SDB debuggers.  They don't seem to understand the
           FT_ext_prec_float type (even though they should).  */
 
@@ -1327,10 +1854,12 @@ fundamental_type_code (type)
    qualifiers.  */
 
 static tree
-root_type (type)
-     register tree type;
+root_type_1 (tree type, int count)
 {
-  if (TREE_CODE (type) == ERROR_MARK)
+  /* Give up after searching 1000 levels, in case this is a recursive
+     pointer type.  Such types are possible in Ada, but it is not possible
+     to represent them in DWARF1 debug info.  */
+  if (count > 1000)
     return error_mark_node;
 
   switch (TREE_CODE (type))
@@ -1340,25 +1869,37 @@ root_type (type)
 
       case POINTER_TYPE:
       case REFERENCE_TYPE:
-       return type_main_variant (root_type (TREE_TYPE (type)));
+       return root_type_1 (TREE_TYPE (type), count+1);
 
       default:
-       return type_main_variant (type);
+       return type;
     }
 }
 
+static tree
+root_type (tree type)
+{
+  type = root_type_1 (type, 0);
+  if (type != error_mark_node)
+    type = type_main_variant (type);
+  return type;
+}
+
 /* Given a pointer to an arbitrary ..._TYPE tree node, write out a sequence
    of zero or more Dwarf "type-modifier" bytes applicable to the type. */
 
 static void
-write_modifier_bytes (type, decl_const, decl_volatile)
-     register tree type;
-     register int decl_const;
-     register int decl_volatile;
+write_modifier_bytes_1 (tree type, int decl_const, int decl_volatile, int count)
 {
   if (TREE_CODE (type) == ERROR_MARK)
     return;
 
+  /* Give up after searching 1000 levels, in case this is a recursive
+     pointer type.  Such types are possible in Ada, but it is not possible
+     to represent them in DWARF1 debug info.  */
+  if (count > 1000)
+    return;
+
   if (TYPE_READONLY (type) || decl_const)
     ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_const);
   if (TYPE_VOLATILE (type) || decl_volatile)
@@ -1367,12 +1908,12 @@ write_modifier_bytes (type, decl_const, decl_volatile)
     {
       case POINTER_TYPE:
        ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_pointer_to);
-       write_modifier_bytes (TREE_TYPE (type), 0, 0);
+       write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
        return;
 
       case REFERENCE_TYPE:
        ASM_OUTPUT_DWARF_TYPE_MODIFIER (asm_out_file, MOD_reference_to);
-       write_modifier_bytes (TREE_TYPE (type), 0, 0);
+       write_modifier_bytes_1 (TREE_TYPE (type), 0, 0, count+1);
        return;
 
       case ERROR_MARK:
@@ -1380,13 +1921,18 @@ write_modifier_bytes (type, decl_const, decl_volatile)
        return;
     }
 }
+
+static void
+write_modifier_bytes (tree type, int decl_const, int decl_volatile)
+{
+  write_modifier_bytes_1 (type, decl_const, decl_volatile, 0);
+}
 \f
-/* Given a pointer to an arbitrary ..._TYPE tree node, return non-zero if the
+/* Given a pointer to an arbitrary ..._TYPE tree node, return nonzero if the
    given input type is a Dwarf "fundamental" type.  Otherwise return zero.  */
 
-inline int
-type_is_fundamental (type)
-     register tree type;
+static inline int
+type_is_fundamental (tree type)
 {
   switch (TREE_CODE (type))
     {
@@ -1409,10 +1955,10 @@ type_is_fundamental (type)
       case METHOD_TYPE:
       case POINTER_TYPE:
       case REFERENCE_TYPE:
-      case STRING_TYPE:
       case FILE_TYPE:
       case OFFSET_TYPE:
       case LANG_TYPE:
+      case VECTOR_TYPE:
        return 0;
 
       default:
@@ -1435,8 +1981,7 @@ type_is_fundamental (type)
    UID number. */
 
 static void
-equate_decl_number_to_die_number (decl)
-     register tree decl;
+equate_decl_number_to_die_number (tree decl)
 {
   /* In the case where we are generating a DIE for some ..._DECL node
      which represents either some inline function declaration or some
@@ -1466,9 +2011,8 @@ equate_decl_number_to_die_number (decl)
    simply by re-generating the alternative name from the ..._TYPE node's
    UID number. */
 
-inline void
-equate_type_number_to_die_number (type)
-     register tree type;
+static inline void
+equate_type_number_to_die_number (tree type)
 {
   char type_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -1486,20 +2030,19 @@ equate_type_number_to_die_number (type)
 }
 
 static void
-output_reg_number (rtl)
-     register rtx rtl;
+output_reg_number (rtx rtl)
 {
-  register unsigned regno = REGNO (rtl);
+  unsigned regno = REGNO (rtl);
 
-  if (regno >= FIRST_PSEUDO_REGISTER)
+  if (regno >= DWARF_FRAME_REGISTERS)
     {
-      warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
-                        regno);
+      warning ("%Hinternal regno botch: '%D' has regno = %d\n",
+               &DECL_SOURCE_LOCATION (dwarf_last_decl), dwarf_last_decl,
+               regno);
       regno = 0;
     }
-  fprintf (asm_out_file, "\t%s\t0x%x",
-          UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
-  if (flag_verbose_asm)
+  dw2_assemble_integer (4, GEN_INT (DBX_REGISTER_NUMBER (regno)));
+  if (flag_debug_asm)
     {
       fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
       PRINT_REG (rtl, 0, asm_out_file);
@@ -1518,14 +2061,15 @@ output_reg_number (rtl)
    RTL tree, turning it into Dwarf postfix code as it goes.  */
 
 static void
-output_mem_loc_descriptor (rtl)
-      register rtx rtl;
+output_mem_loc_descriptor (rtx rtl)
 {
   /* Note that for a dynamically sized array, the location we will
      generate a description of here will be the lowest numbered location
      which is actually within the array.  That's *not* necessarily the
      same as the zeroth element of the array.  */
 
+  rtl = (*targetm.delegitimize_address) (rtl);
+
   switch (GET_CODE (rtl))
     {
       case SUBREG:
@@ -1536,7 +2080,7 @@ output_mem_loc_descriptor (rtl)
           legitimate to make the Dwarf info refer to the whole register
           which contains the given subreg.  */
 
-       rtl = XEXP (rtl, 0);
+       rtl = SUBREG_REG (rtl);
        /* Drop thru.  */
 
       case REG:
@@ -1586,6 +2130,15 @@ output_mem_loc_descriptor (rtl)
        ASM_OUTPUT_DWARF_DATA4 (asm_out_file, INTVAL (rtl));
        break;
 
+      case MULT:
+       /* If a pseudo-reg is optimized away, it is possible for it to
+          be replaced with a MEM containing a multiply.  Use a GNU extension
+          to describe it.  */
+       output_mem_loc_descriptor (XEXP (rtl, 0));
+       output_mem_loc_descriptor (XEXP (rtl, 1));
+       ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_MULT);
+       break;
+
       default:
        abort ();
     }
@@ -1598,8 +2151,7 @@ output_mem_loc_descriptor (rtl)
    generate the (dynamic) address of the object onto the address stack.  */
 
 static void
-output_loc_descriptor (rtl)
-     register rtx rtl;
+output_loc_descriptor (rtx rtl)
 {
   switch (GET_CODE (rtl))
     {
@@ -1611,7 +2163,7 @@ output_loc_descriptor (rtl)
           legitimate to make the Dwarf info refer to the whole register
           which contains the given subreg.  */
 
-       rtl = XEXP (rtl, 0);
+       rtl = SUBREG_REG (rtl);
        /* Drop thru.  */
 
     case REG:
@@ -1629,90 +2181,84 @@ output_loc_descriptor (rtl)
 }
 
 /* Given a tree node describing an array bound (either lower or upper)
-   output a representation for that bound.  */
+   output a representation for that bound.  DIM_NUM is used for
+   multi-dimensional arrays and U_OR_L designates upper or lower
+   bound.  */
 
 static void
-output_bound_representation (bound, dim_num, u_or_l)
-     register tree bound;
-     register unsigned dim_num; /* For multi-dimensional arrays.  */
-     register char u_or_l;     /* Designates upper or lower bound.  */
+output_bound_representation (tree bound, unsigned int dim_num, char u_or_l)
 {
   switch (TREE_CODE (bound))
     {
 
-      case ERROR_MARK:
-       return;
+    case ERROR_MARK:
+      return;
 
       /* All fixed-bounds are represented by INTEGER_CST nodes.         */
 
-      case INTEGER_CST:
-       ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                               (unsigned) TREE_INT_CST_LOW (bound));
-       break;
-
-      /* Dynamic bounds may be represented by NOP_EXPR nodes containing
-        SAVE_EXPR nodes.  */
-
-      case NOP_EXPR:
-       bound = TREE_OPERAND (bound, 0);
-       /* ... fall thru... */
-
-      case SAVE_EXPR:
-       {
-         char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
-         char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-         sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
-                               current_dienum, dim_num, u_or_l);
-
-         sprintf (end_label,   BOUND_END_LABEL_FMT,
-                               current_dienum, dim_num, u_or_l);
-
-         ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
-         ASM_OUTPUT_LABEL (asm_out_file, begin_label);
-
-         /* If we are working on a bound for a dynamic dimension in C,
-            the dynamic dimension in question had better have a static
-            (zero) lower bound and a dynamic *upper* bound.  */
-
-         if (u_or_l != 'u')
-           abort ();
+    case INTEGER_CST:
+      if (host_integerp (bound, 0))
+       ASM_OUTPUT_DWARF_DATA4 (asm_out_file, tree_low_cst (bound, 0));
+      break;
 
-         /* If optimization is turned on, the SAVE_EXPRs that describe
-            how to access the upper bound values are essentially bogus.
-            They only describe (at best) how to get at these values at
-            the points in the generated code right after they have just
-            been computed.  Worse yet, in the typical case, the upper
-            bound values will not even *be* computed in the optimized
-            code, so these SAVE_EXPRs are entirely bogus.
-
-            In order to compensate for this fact, we check here to see
-            if optimization is enabled, and if so, we effectively create
-            an empty location description for the (unknown and unknowable)
-            upper bound.
-
-            This should not cause too much trouble for existing (stupid?)
-            debuggers because they have to deal with empty upper bounds
-            location descriptions anyway in order to be able to deal with
-            incomplete array types.
-
-            Of course an intelligent debugger (GDB?) should be able to
-            comprehend that a missing upper bound specification in a
-            array type used for a storage class `auto' local array variable
-            indicates that the upper bound is both unknown (at compile-
-            time) and unknowable (at run-time) due to optimization.
-         */
+    default:
 
-         if (! optimize)
-           output_loc_descriptor
-             (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
+      /* Dynamic bounds may be represented by NOP_EXPR nodes containing
+        SAVE_EXPR nodes, in which case we can do something, or as
+        an expression, which we cannot represent.  */
+      {
+       char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
+       char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+       sprintf (begin_label, BOUND_BEGIN_LABEL_FMT,
+                current_dienum, dim_num, u_or_l);
+
+       sprintf (end_label, BOUND_END_LABEL_FMT,
+                current_dienum, dim_num, u_or_l);
+
+       ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
+       ASM_OUTPUT_LABEL (asm_out_file, begin_label);
+
+       /* If optimization is turned on, the SAVE_EXPRs that describe
+          how to access the upper bound values are essentially bogus.
+          They only describe (at best) how to get at these values at
+          the points in the generated code right after they have just
+          been computed.  Worse yet, in the typical case, the upper
+          bound values will not even *be* computed in the optimized
+          code, so these SAVE_EXPRs are entirely bogus.
+
+          In order to compensate for this fact, we check here to see
+          if optimization is enabled, and if so, we effectively create
+          an empty location description for the (unknown and unknowable)
+          upper bound.
+
+          This should not cause too much trouble for existing (stupid?)
+          debuggers because they have to deal with empty upper bounds
+          location descriptions anyway in order to be able to deal with
+          incomplete array types.
+
+          Of course an intelligent debugger (GDB?) should be able to
+          comprehend that a missing upper bound specification in a
+          array type used for a storage class `auto' local array variable
+          indicates that the upper bound is both unknown (at compile-
+          time) and unknowable (at run-time) due to optimization.  */
+
+       if (! optimize)
+         {
+           while (TREE_CODE (bound) == NOP_EXPR
+                  || TREE_CODE (bound) == CONVERT_EXPR)
+             bound = TREE_OPERAND (bound, 0);
+
+           if (TREE_CODE (bound) == SAVE_EXPR
+               && SAVE_EXPR_RTL (bound))
+             output_loc_descriptor
+               (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
+         }
 
-         ASM_OUTPUT_LABEL (asm_out_file, end_label);
-       }
-       break;
+       ASM_OUTPUT_LABEL (asm_out_file, end_label);
+      }
+      break;
 
-      default:
-       abort ();
     }
 }
 
@@ -1721,15 +2267,17 @@ output_bound_representation (bound, dim_num, u_or_l)
    enumeration_type_die.  */
 
 static void
-output_enumeral_list (link)
-     register tree link;
+output_enumeral_list (tree link)
 {
   if (link)
     {
       output_enumeral_list (TREE_CHAIN (link));
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                             (unsigned) TREE_INT_CST_LOW (TREE_VALUE (link)));
-      ASM_OUTPUT_DWARF_STRING (asm_out_file,
+
+      if (host_integerp (TREE_VALUE (link), 0))
+       ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
+                               tree_low_cst (TREE_VALUE (link), 0));
+
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                               IDENTIFIER_POINTER (TREE_PURPOSE (link)));
     }
 }
@@ -1737,10 +2285,8 @@ output_enumeral_list (link)
 /* Given an unsigned value, round it up to the lowest multiple of `boundary'
    which is not less than the value itself.  */
 
-inline unsigned
-ceiling (value, boundary)
-     register unsigned value;
-     register unsigned boundary;
+static inline HOST_WIDE_INT
+ceiling (HOST_WIDE_INT value, unsigned int boundary)
 {
   return (((value + boundary - 1) / boundary) * boundary);
 }
@@ -1749,11 +2295,10 @@ ceiling (value, boundary)
    pointer to the declared type for the relevant field variable, or return
    `integer_type_node' if the given node turns out to be an ERROR_MARK node.  */
 
-inline tree
-field_type (decl)
-     register tree decl;
+static inline tree
+field_type (tree decl)
 {
-  register tree type;
+  tree type;
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return integer_type_node;
@@ -1768,9 +2313,8 @@ field_type (decl)
    node, return the alignment in bits for the type, or else return
    BITS_PER_WORD if the node actually turns out to be an ERROR_MARK node.  */
 
-inline unsigned
-simple_type_align_in_bits (type)
-     register tree type;
+static inline unsigned int
+simple_type_align_in_bits (tree type)
 {
   return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
 }
@@ -1781,21 +2325,20 @@ simple_type_align_in_bits (type)
    constant, or else return BITS_PER_WORD if the type actually turns out
    to be an ERROR_MARK node.  */
 
-inline unsigned
-simple_type_size_in_bits (type)
-     register tree type;
+static inline unsigned HOST_WIDE_INT
+simple_type_size_in_bits (tree type)
 {
+  tree type_size_tree;
+
   if (TREE_CODE (type) == ERROR_MARK)
     return BITS_PER_WORD;
-  else
-    {
-      register tree type_size_tree = TYPE_SIZE (type);
+  type_size_tree = TYPE_SIZE (type);
 
-      if (TREE_CODE (type_size_tree) != INTEGER_CST)
-       return TYPE_ALIGN (type);
-
-      return (unsigned) TREE_INT_CST_LOW (type_size_tree);
-    }
+  if (type_size_tree == NULL_TREE)
+    return 0;
+  if (! host_integerp (type_size_tree, 1))
+    return TYPE_ALIGN (type);
+  return tree_low_cst (type_size_tree, 1);
 }
 
 /* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
@@ -1805,22 +2348,20 @@ simple_type_size_in_bits (type)
    pointer to an ERROR_MARK node, or because the offset is actually variable.
    (We can't handle the latter case just yet.)  */
 
-static unsigned
-field_byte_offset (decl)
-     register tree decl;
-{
-  register unsigned type_align_in_bytes;
-  register unsigned type_align_in_bits;
-  register unsigned type_size_in_bits;
-  register unsigned object_offset_in_align_units;
-  register unsigned object_offset_in_bits;
-  register unsigned object_offset_in_bytes;
-  register tree type;
-  register tree bitpos_tree;
-  register tree field_size_tree;
-  register unsigned bitpos_int;
-  register unsigned deepest_bitpos;
-  register unsigned field_size_in_bits;
+static HOST_WIDE_INT
+field_byte_offset (tree decl)
+{
+  unsigned int type_align_in_bytes;
+  unsigned int type_align_in_bits;
+  unsigned HOST_WIDE_INT type_size_in_bits;
+  HOST_WIDE_INT object_offset_in_align_units;
+  HOST_WIDE_INT object_offset_in_bits;
+  HOST_WIDE_INT object_offset_in_bytes;
+  tree type;
+  tree field_size_tree;
+  HOST_WIDE_INT bitpos_int;
+  HOST_WIDE_INT deepest_bitpos;
+  unsigned HOST_WIDE_INT field_size_in_bits;
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return 0;
@@ -1829,24 +2370,25 @@ field_byte_offset (decl)
     abort ();
 
   type = field_type (decl);
-
-  bitpos_tree = DECL_FIELD_BITPOS (decl);
   field_size_tree = DECL_SIZE (decl);
 
+  /* The size could be unspecified if there was an error, or for
+     a flexible array member.  */
+  if (! field_size_tree)
+    field_size_tree = bitsize_zero_node;
+
   /* We cannot yet cope with fields whose positions or sizes are variable,
      so for now, when we see such things, we simply return 0.  Someday,
      we may be able to handle such cases, but it will be damn difficult.  */
 
-  if (TREE_CODE (bitpos_tree) != INTEGER_CST)
+  if (! host_integerp (bit_position (decl), 0)
+      || ! host_integerp (field_size_tree, 1))
     return 0;
-  bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
 
-  if (TREE_CODE (field_size_tree) != INTEGER_CST)
-    return 0;
-  field_size_in_bits = (unsigned) TREE_INT_CST_LOW (field_size_tree);
+  bitpos_int = int_bit_position (decl);
+  field_size_in_bits = tree_low_cst (field_size_tree, 1);
 
   type_size_in_bits = simple_type_size_in_bits (type);
-
   type_align_in_bits = simple_type_align_in_bits (type);
   type_align_in_bytes = type_align_in_bits / BITS_PER_UNIT;
 
@@ -1895,8 +2437,7 @@ field_byte_offset (decl)
 
      The value we deduce is then used (by the callers of this routine) to
      generate AT_location and AT_bit_offset attributes for fields (both
-     bit-fields and, in the case of AT_location, regular fields as well).
-  */
+     bit-fields and, in the case of AT_location, regular fields as well).  */
 
   /* Figure out the bit-distance from the start of the structure to the
      "deepest" bit of the bit-field.  */
@@ -1913,6 +2454,33 @@ field_byte_offset (decl)
   /* Compute the offset of the containing object in bytes.  */
   object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
 
+  /* The above code assumes that the field does not cross an alignment
+     boundary.  This can happen if PCC_BITFIELD_TYPE_MATTERS is not defined,
+     or if the structure is packed.  If this happens, then we get an object
+     which starts after the bitfield, which means that the bit offset is
+     negative.  Gdb fails when given negative bit offsets.  We avoid this
+     by recomputing using the first bit of the bitfield.  This will give
+     us an object which does not completely contain the bitfield, but it
+     will be aligned, and it will contain the first bit of the bitfield.
+
+     However, only do this for a BYTES_BIG_ENDIAN target.  For a
+     ! BYTES_BIG_ENDIAN target, bitpos_int + field_size_in_bits is the first
+     first bit of the bitfield.  If we recompute using bitpos_int + 1 below,
+     then we end up computing the object byte offset for the wrong word of the
+     desired bitfield, which in turn causes the field offset to be negative
+     in bit_offset_attribute.  */
+  if (BYTES_BIG_ENDIAN
+      && object_offset_in_bits > bitpos_int)
+    {
+      deepest_bitpos = bitpos_int + 1;
+      object_offset_in_bits
+       = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
+      object_offset_in_align_units = (object_offset_in_bits
+                                     / type_align_in_bits);
+      object_offset_in_bytes = (object_offset_in_align_units
+                               * type_align_in_bytes);
+    }
+
   return object_offset_in_bytes;
 }
 
@@ -1925,8 +2493,8 @@ field_byte_offset (decl)
 
 /* Generate an AT_sibling attribute.  */
 
-inline void
-sibling_attribute ()
+static inline void
+sibling_attribute (void)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -1940,8 +2508,7 @@ sibling_attribute ()
    are generated by the routine `data_member_location_attribute' below.  */
 
 static void
-location_attribute (rtl)
-     register rtx rtl;
+location_attribute (rtx rtl)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -1970,13 +2537,13 @@ location_attribute (rtl)
      suppress the generation of the entire location attribute because
      the absence of a location attribute in certain kinds of DIEs is
      used to indicate something else entirely... i.e. that the DIE
-     represents an object declaration, but not a definition.  So sayeth
+     represents an object declaration, but not a definition.  So saith
      the PLSIG.
   */
 
   if (! is_pseudo_reg (rtl)
       && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
-    output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
+    output_loc_descriptor (rtl);
 
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
@@ -2000,17 +2567,20 @@ location_attribute (rtl)
    object" which will be given in the AT_byte_size attribute for this
    bit-field.  (See the `byte_size_attribute' function below.)  It is
    also used when calculating the value of the AT_bit_offset attribute.
-   (See the `bit_offset_attribute' function below.)
-*/
+   (See the `bit_offset_attribute' function below.)  */
 
 static void
-data_member_location_attribute (decl)
-     register tree decl;
+data_member_location_attribute (tree t)
 {
-  register unsigned object_offset_in_bytes = field_byte_offset (decl);
+  unsigned object_offset_in_bytes;
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
+  if (TREE_CODE (t) == TREE_VEC)
+    object_offset_in_bytes = tree_low_cst (BINFO_OFFSET (t), 0);
+  else
+    object_offset_in_bytes = field_byte_offset (t);
+
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_location);
   sprintf (begin_label, LOC_BEGIN_LABEL_FMT, current_dienum);
   sprintf (end_label, LOC_END_LABEL_FMT, current_dienum);
@@ -2029,8 +2599,7 @@ data_member_location_attribute (decl)
    declared constants do not necessarily get memory "homes".  */
 
 static void
-const_value_attribute (rtl)
-     register rtx rtl;
+const_value_attribute (rtx rtl)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -2064,12 +2633,12 @@ const_value_attribute (rtl)
           simplicity we always just output CONST_DOUBLEs using 8 bytes.  */
 
        ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
-                               (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
-                               (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
+                               (unsigned int) CONST_DOUBLE_HIGH (rtl),
+                               (unsigned int) CONST_DOUBLE_LOW (rtl));
        break;
 
       case CONST_STRING:
-       ASM_OUTPUT_DWARF_STRING (asm_out_file, XSTR (rtl, 0));
+       ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, XSTR (rtl, 0));
        break;
 
       case SYMBOL_REF:
@@ -2114,10 +2683,9 @@ const_value_attribute (rtl)
    call evaluates to a compile-time constant address.  */
 
 static void
-location_or_const_value_attribute (decl)
-     register tree decl;
+location_or_const_value_attribute (tree decl)
 {
-  register rtx rtl;
+  rtx rtl;
 
   if (TREE_CODE (decl) == ERROR_MARK)
     return;
@@ -2198,7 +2766,7 @@ location_or_const_value_attribute (decl)
      shouldn't be happening.  All PARM_DECL nodes should get valid non-NULL
      DECL_INCOMING_RTL values, but integrate.c doesn't currently generate
      these values for inlined instances of inline function parameters, so
-     when we see such cases, we are just SOL (shit-out-of-luck) for the time
+     when we see such cases, we are just out-of-luck for the time
      being (until integrate.c gets fixed).
   */
 
@@ -2209,27 +2777,37 @@ location_or_const_value_attribute (decl)
     if (rtl == NULL_RTX || is_pseudo_reg (rtl))
       {
        /* This decl represents a formal parameter which was optimized out.  */
-        register tree declared_type = type_main_variant (TREE_TYPE (decl));
-        register tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
+       tree declared_type = type_main_variant (TREE_TYPE (decl));
+       tree passed_type = type_main_variant (DECL_ARG_TYPE (decl));
 
        /* Note that DECL_INCOMING_RTL may be NULL in here, but we handle
           *all* cases where (rtl == NULL_RTX) just below.  */
 
        if (declared_type == passed_type)
          rtl = DECL_INCOMING_RTL (decl);
-#if (BYTES_BIG_ENDIAN == 0)
-       else
+       else if (! BYTES_BIG_ENDIAN)
          if (TREE_CODE (declared_type) == INTEGER_TYPE)
+           /* NMS WTF? */
            if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
              rtl = DECL_INCOMING_RTL (decl);
-#endif /* (BYTES_BIG_ENDIAN == 0) */
       }
 
   if (rtl == NULL_RTX)
     return;
 
+  rtl = eliminate_regs (rtl, 0, NULL_RTX);
+#ifdef LEAF_REG_REMAP
+  if (current_function_uses_only_leaf_regs)
+    leaf_renumber_regs_insn (rtl);
+#endif
+
   switch (GET_CODE (rtl))
     {
+    case ADDRESSOF:
+      /* The address of a variable that was optimized away; don't emit
+        anything.  */
+      break;
+
     case CONST_INT:
     case CONST_DOUBLE:
     case CONST_STRING:
@@ -2246,6 +2824,15 @@ location_or_const_value_attribute (decl)
       location_attribute (rtl);
       break;
 
+    case CONCAT:
+      /* ??? CONCAT is used for complex variables, which may have the real
+        part stored in one place and the imag part stored somewhere else.
+        DWARF1 has no way to describe a variable that lives in two different
+        places, so we just describe where the first part lives, and hope that
+        the second part is stored after it.  */
+      location_attribute (XEXP (rtl, 0));
+      break;
+
     default:
       abort ();                /* Should never happen.  */
     }
@@ -2254,30 +2841,25 @@ location_or_const_value_attribute (decl)
 /* Generate an AT_name attribute given some string value to be included as
    the value of the attribute. */
 
-inline void
-name_attribute (name_string)
-     register char *name_string;
+static inline void
+name_attribute (const char *name_string)
 {
   if (name_string && *name_string)
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_name);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, name_string);
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, name_string);
     }
 }
 
-inline void
-fund_type_attribute (ft_code)
-     register unsigned ft_code;
+static inline void
+fund_type_attribute (unsigned int ft_code)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_fund_type);
   ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file, ft_code);
 }
 
 static void
-mod_fund_type_attribute (type, decl_const, decl_volatile)
-     register tree type;
-     register int decl_const;
-     register int decl_volatile;
+mod_fund_type_attribute (tree type, int decl_const, int decl_volatile)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -2293,9 +2875,8 @@ mod_fund_type_attribute (type, decl_const, decl_volatile)
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
 
-inline void
-user_def_type_attribute (type)
-     register tree type;
+static inline void
+user_def_type_attribute (tree type)
 {
   char ud_type_name[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -2305,10 +2886,7 @@ user_def_type_attribute (type)
 }
 
 static void
-mod_u_d_type_attribute (type, decl_const, decl_volatile)
-     register tree type;
-     register int decl_const;
-     register int decl_volatile;
+mod_u_d_type_attribute (tree type, int decl_const, int decl_volatile)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -2326,9 +2904,8 @@ mod_u_d_type_attribute (type, decl_const, decl_volatile)
 }
 
 #ifdef USE_ORDERING_ATTRIBUTE
-inline void
-ordering_attribute (ordering)
-     register unsigned ordering;
+static inline void
+ordering_attribute (unsigned ordering)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
   ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
@@ -2339,10 +2916,9 @@ ordering_attribute (ordering)
    includes information about the element type of type given array type.  */
 
 static void
-subscript_data_attribute (type)
-     register tree type;
+subscript_data_attribute (tree type)
 {
-  register unsigned dimension_number;
+  unsigned dimension_number;
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -2365,7 +2941,7 @@ subscript_data_attribute (type)
        TREE_CODE (type) == ARRAY_TYPE;
        type = TREE_TYPE (type), dimension_number++)
     {
-      register tree domain = TYPE_DOMAIN (type);
+      tree domain = TYPE_DOMAIN (type);
 
       /* Arrays come in three flavors. Unspecified bounds, fixed
         bounds, and (in GNU C only) variable bounds.  Handle all
@@ -2375,33 +2951,30 @@ subscript_data_attribute (type)
        {
          /* We have an array type with specified bounds.  */
 
-         register tree lower = TYPE_MIN_VALUE (domain);
-         register tree upper = TYPE_MAX_VALUE (domain);
+         tree lower = TYPE_MIN_VALUE (domain);
+         tree upper = TYPE_MAX_VALUE (domain);
 
          /* Handle only fundamental types as index types for now.  */
-
          if (! type_is_fundamental (domain))
            abort ();
 
-         /* Output the representation format byte for this dimension. */
-
+         /* Output the representation format byte for this dimension.  */
          ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file,
-                                 FMT_CODE (1,
-                                           TREE_CODE (lower) == INTEGER_CST,
-                                           TREE_CODE (upper) == INTEGER_CST));
+                 FMT_CODE (1, TREE_CODE (lower) == INTEGER_CST,
+                           upper && TREE_CODE (upper) == INTEGER_CST));
 
          /* Output the index type for this dimension.  */
-
          ASM_OUTPUT_DWARF_FUND_TYPE (asm_out_file,
                                      fundamental_type_code (domain));
 
          /* Output the representation for the lower bound.  */
-
          output_bound_representation (lower, dimension_number, 'l');
 
          /* Output the representation for the upper bound.  */
-
-         output_bound_representation (upper, dimension_number, 'u');
+         if (upper)
+           output_bound_representation (upper, dimension_number, 'u');
+         else
+           ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0);
        }
       else
        {
@@ -2429,7 +3002,7 @@ subscript_data_attribute (type)
        }
     }
 
-  /* Output the prefix byte that says that the element type is comming up.  */
+  /* Output the prefix byte that says that the element type is coming up.  */
 
   ASM_OUTPUT_DWARF_FMT_BYTE (asm_out_file, FMT_ET);
 
@@ -2441,10 +3014,9 @@ subscript_data_attribute (type)
 }
 
 static void
-byte_size_attribute (tree_node)
-     register tree tree_node;
+byte_size_attribute (tree tree_node)
 {
-  register unsigned size;
+  unsigned size;
 
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_byte_size);
   switch (TREE_CODE (tree_node))
@@ -2457,6 +3029,7 @@ byte_size_attribute (tree_node)
       case RECORD_TYPE:
       case UNION_TYPE:
       case QUAL_UNION_TYPE:
+      case ARRAY_TYPE:
        size = int_size_in_bytes (tree_node);
        break;
 
@@ -2497,31 +3070,32 @@ byte_size_attribute (tree_node)
 
    Note that it is the size (in bytes) of the hypothetical "containing
    object" which will be given in the AT_byte_size attribute for this
-   bit-field.  (See `byte_size_attribute' above.)
-*/
+   bit-field.  (See `byte_size_attribute' above.) */
 
-inline void
-bit_offset_attribute (decl)
-    register tree decl;
+static inline void
+bit_offset_attribute (tree decl)
 {
-  register unsigned object_offset_in_bytes = field_byte_offset (decl);
-  register tree type = DECL_BIT_FIELD_TYPE (decl);
-  register tree bitpos_tree = DECL_FIELD_BITPOS (decl);
-  register unsigned bitpos_int;
-  register unsigned highest_order_object_bit_offset;
-  register unsigned highest_order_field_bit_offset;
-  register unsigned bit_offset;
+  HOST_WIDE_INT object_offset_in_bytes = field_byte_offset (decl);
+  tree type = DECL_BIT_FIELD_TYPE (decl);
+  HOST_WIDE_INT bitpos_int;
+  HOST_WIDE_INT highest_order_object_bit_offset;
+  HOST_WIDE_INT highest_order_field_bit_offset;
+  HOST_WIDE_INT bit_offset;
 
-  assert (TREE_CODE (decl) == FIELD_DECL);     /* Must be a field.  */
-  assert (type);                               /* Must be a bit field.  */
+  /* Must be a bit field.  */
+  if (!type
+      || TREE_CODE (decl) != FIELD_DECL)
+    abort ();
 
-  /* We can't yet handle bit-fields whose offsets are variable, so if we
-     encounter such things, just return without generating any attribute
-     whatsoever.  */
+  /* We can't yet handle bit-fields whose offsets or sizes are variable, so
+     if we encounter such things, just return without generating any
+     attribute whatsoever.  */
 
-  if (TREE_CODE (bitpos_tree) != INTEGER_CST)
+  if (! host_integerp (bit_position (decl), 0)
+      || ! host_integerp (DECL_SIZE (decl), 1))
     return;
-  bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
+
+  bitpos_int = int_bit_position (decl);
 
   /* Note that the bit offset is always the distance (in bits) from the
      highest-order bit of the "containing object" to the highest-order
@@ -2532,19 +3106,16 @@ bit_offset_attribute (decl)
   highest_order_object_bit_offset = object_offset_in_bytes * BITS_PER_UNIT;
   highest_order_field_bit_offset = bitpos_int;
 
-#if (BYTES_BIG_ENDIAN == 0)
-  highest_order_field_bit_offset
-    += (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl));
-
-  highest_order_object_bit_offset += simple_type_size_in_bits (type);
-#endif /* (BYTES_BIG_ENDIAN == 0) */
+  if (! BYTES_BIG_ENDIAN)
+    {
+      highest_order_field_bit_offset += tree_low_cst (DECL_SIZE (decl), 1);
+      highest_order_object_bit_offset += simple_type_size_in_bits (type);
+    }
 
   bit_offset =
-#if (BYTES_BIG_ENDIAN == 0)
-         highest_order_object_bit_offset - highest_order_field_bit_offset;
-#else /* (BYTES_BIG_ENDIAN != 0) */
-         highest_order_field_bit_offset - highest_order_object_bit_offset;
-#endif /* (BYTES_BIG_ENDIAN != 0) */
+    (! BYTES_BIG_ENDIAN
+     ? highest_order_object_bit_offset - highest_order_field_bit_offset
+     : highest_order_field_bit_offset - highest_order_object_bit_offset);
 
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
   ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
@@ -2553,16 +3124,20 @@ bit_offset_attribute (decl)
 /* For a FIELD_DECL node which represents a bit field, output an attribute
    which specifies the length in bits of the given field.  */
 
-inline void
-bit_size_attribute (decl)
-    register tree decl;
+static inline void
+bit_size_attribute (tree decl)
 {
-  assert (TREE_CODE (decl) == FIELD_DECL);     /* Must be a field.  */
-  assert (DECL_BIT_FIELD_TYPE (decl));         /* Must be a bit field.  */
+  /* Must be a field and a bit field.  */
+  if (TREE_CODE (decl) != FIELD_DECL
+      || ! DECL_BIT_FIELD_TYPE (decl))
+    abort ();
 
-  ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
-  ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                         (unsigned) TREE_INT_CST_LOW (DECL_SIZE (decl)));
+  if (host_integerp (DECL_SIZE (decl), 1))
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_size);
+      ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
+                             tree_low_cst (DECL_SIZE (decl), 1));
+    }
 }
 
 /* The following routine outputs the `element_list' attribute for enumeration
@@ -2570,9 +3145,8 @@ bit_size_attribute (decl)
    all of the enumeration constants associated with the given enumeration
    type.  */
 
-inline void
-element_list_attribute (element)
-     register tree element;
+static inline void
+element_list_attribute (tree element)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -2596,9 +3170,8 @@ element_list_attribute (element)
 /* Generate an AT_stmt_list attribute. These are normally present only in
    DIEs with a TAG_compile_unit tag.  */
 
-inline void
-stmt_list_attribute (label)
-    register char *label;
+static inline void
+stmt_list_attribute (const char *label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_stmt_list);
   /* Don't use ASM_OUTPUT_DWARF_DATA4 here.  */
@@ -2608,9 +3181,8 @@ stmt_list_attribute (label)
 /* Generate an AT_low_pc attribute for a label DIE, a lexical_block DIE or
    for a subroutine DIE.  */
 
-inline void
-low_pc_attribute (asm_low_label)
-     register char *asm_low_label;
+static inline void
+low_pc_attribute (const char *asm_low_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_low_pc);
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_low_label);
@@ -2619,9 +3191,8 @@ low_pc_attribute (asm_low_label)
 /* Generate an AT_high_pc attribute for a lexical_block DIE or for a
    subroutine DIE.  */
 
-inline void
-high_pc_attribute (asm_high_label)
-    register char *asm_high_label;
+static inline void
+high_pc_attribute (const char *asm_high_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_high_pc);
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_high_label);
@@ -2629,9 +3200,8 @@ high_pc_attribute (asm_high_label)
 
 /* Generate an AT_body_begin attribute for a subroutine DIE.  */
 
-inline void
-body_begin_attribute (asm_begin_label)
-     register char *asm_begin_label;
+static inline void
+body_begin_attribute (const char *asm_begin_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_begin_label);
@@ -2639,9 +3209,8 @@ body_begin_attribute (asm_begin_label)
 
 /* Generate an AT_body_end attribute for a subroutine DIE.  */
 
-inline void
-body_end_attribute (asm_end_label)
-     register char *asm_end_label;
+static inline void
+body_end_attribute (const char *asm_end_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
@@ -2650,17 +3219,15 @@ body_end_attribute (asm_end_label)
 /* Generate an AT_language attribute given a LANG value.  These attributes
    are used only within TAG_compile_unit DIEs.  */
 
-inline void
-language_attribute (language_code)
-     register unsigned language_code;
+static inline void
+language_attribute (unsigned int language_code)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_language);
   ASM_OUTPUT_DWARF_DATA4 (asm_out_file, language_code);
 }
 
-inline void
-member_attribute (context)
-    register tree context;
+static inline void
+member_attribute (tree context)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -2674,9 +3241,16 @@ member_attribute (context)
     }
 }
 
-inline void
-string_length_attribute (upper_bound)
-     register tree upper_bound;
+#if 0
+#ifndef SL_BEGIN_LABEL_FMT
+#define SL_BEGIN_LABEL_FMT     "*.L_sl%u"
+#endif
+#ifndef SL_END_LABEL_FMT
+#define SL_END_LABEL_FMT       "*.L_sl%u_e"
+#endif
+
+static inline void
+string_length_attribute (tree upper_bound)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -2689,76 +3263,69 @@ string_length_attribute (upper_bound)
   output_bound_representation (upper_bound, 0, 'u');
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
+#endif
 
-inline void
-comp_dir_attribute (dirname)
-     register char *dirname;
+static inline void
+comp_dir_attribute (const char *dirname)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_comp_dir);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
 }
 
-inline void
-sf_names_attribute (sf_names_start_label)
-     register char *sf_names_start_label;
+static inline void
+sf_names_attribute (const char *sf_names_start_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_sf_names);
   /* Don't use ASM_OUTPUT_DWARF_DATA4 here.  */
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, sf_names_start_label);
 }
 
-inline void
-src_info_attribute (src_info_start_label)
-     register char *src_info_start_label;
+static inline void
+src_info_attribute (const char *src_info_start_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_info);
   /* Don't use ASM_OUTPUT_DWARF_DATA4 here.  */
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, src_info_start_label);
 }
 
-inline void
-mac_info_attribute (mac_info_start_label)
-     register char *mac_info_start_label;
+static inline void
+mac_info_attribute (const char *mac_info_start_label)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_mac_info);
   /* Don't use ASM_OUTPUT_DWARF_DATA4 here.  */
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, mac_info_start_label);
 }
 
-inline void
-prototyped_attribute (func_type)
-     register tree func_type;
+static inline void
+prototyped_attribute (tree func_type)
 {
-  if ((strcmp (language_string, "GNU C") == 0)
+  if ((strcmp (lang_hooks.name, "GNU C") == 0)
       && (TYPE_ARG_TYPES (func_type) != NULL))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_prototyped);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }
 
-inline void
-producer_attribute (producer)
-     register char *producer;
+static inline void
+producer_attribute (const char *producer)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_producer);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file, producer);
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, producer);
 }
 
-inline void
-inline_attribute (decl)
-     register tree decl;
+static inline void
+inline_attribute (tree decl)
 {
   if (DECL_INLINE (decl))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }
 
-inline void
-containing_type_attribute (containing_type)
-     register tree containing_type;
+static inline void
+containing_type_attribute (tree containing_type)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -2767,9 +3334,8 @@ containing_type_attribute (containing_type)
   ASM_OUTPUT_DWARF_REF (asm_out_file, label);
 }
 
-inline void
-abstract_origin_attribute (origin)
-     register tree origin;
+static inline void
+abstract_origin_attribute (tree origin)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -2792,10 +3358,8 @@ abstract_origin_attribute (origin)
 }
 
 #ifdef DWARF_DECL_COORDINATES
-inline void
-src_coords_attribute (src_fileno, src_lineno)
-     register unsigned src_fileno;
-     register unsigned src_lineno;
+static inline void
+src_coords_attribute (unsigned src_fileno, unsigned src_lineno)
 {
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
   ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
@@ -2803,19 +3367,18 @@ src_coords_attribute (src_fileno, src_lineno)
 }
 #endif /* defined(DWARF_DECL_COORDINATES) */
 
-inline void
-pure_or_virtual_attribute (func_decl)
-     register tree func_decl;
+static inline void
+pure_or_virtual_attribute (tree func_decl)
 {
   if (DECL_VIRTUAL_P (func_decl))
     {
 #if 0 /* DECL_ABSTRACT_VIRTUAL_P is C++-specific.  */
       if (DECL_ABSTRACT_VIRTUAL_P (func_decl))
-        ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
+       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_pure_virtual);
       else
 #endif
-        ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
     }
 }
 
@@ -2827,10 +3390,9 @@ pure_or_virtual_attribute (func_decl)
    given decl, but only if it actually has a name.  */
 
 static void
-name_and_src_coords_attributes (decl)
-    register tree decl;
+name_and_src_coords_attributes (tree decl)
 {
-  register tree decl_name = DECL_NAME (decl);
+  tree decl_name = DECL_NAME (decl);
 
   if (decl_name && IDENTIFIER_POINTER (decl_name))
     {
@@ -2842,7 +3404,7 @@ name_and_src_coords_attributes (decl)
        /* This is annoying, but we have to pop out of the .debug section
           for a moment while we call `lookup_filename' because calling it
           may cause a temporary switch into the .debug_sfnames section and
-          most svr4 assemblers are not smart enough be be able to nest
+          most svr4 assemblers are not smart enough to be able to nest
           section switches to any depth greater than one.  Note that we
           also can't skirt this issue by delaying all output to the
           .debug_sfnames section unit the end of compilation because that
@@ -2853,7 +3415,7 @@ name_and_src_coords_attributes (decl)
        file_index = lookup_filename (DECL_SOURCE_FILE (decl));
        ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
 
-        src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
+       src_coords_attribute (file_index, DECL_SOURCE_LINE (decl));
       }
 #endif /* defined(DWARF_DECL_COORDINATES) */
     }
@@ -2863,37 +3425,43 @@ name_and_src_coords_attributes (decl)
    routine writes out these "type descriptor" parts.  */
 
 static void
-type_attribute (type, decl_const, decl_volatile)
-     register tree type;
-     register int decl_const;
-     register int decl_volatile;
+type_attribute (tree type, int decl_const, int decl_volatile)
 {
-  register enum tree_code code = TREE_CODE (type);
-  register int root_type_modified;
+  enum tree_code code = TREE_CODE (type);
+  int root_type_modified;
 
-  if (TREE_CODE (type) == ERROR_MARK)
+  if (code == ERROR_MARK)
     return;
 
   /* Handle a special case.  For functions whose return type is void,
      we generate *no* type attribute.  (Note that no object may have
      type `void', so this only applies to function return types.  */
 
-  if (TREE_CODE (type) == VOID_TYPE)
+  if (code == VOID_TYPE)
     return;
 
+  /* If this is a subtype, find the underlying type.  Eventually,
+     this should write out the appropriate subtype info.  */
+  while ((code == INTEGER_TYPE || code == REAL_TYPE)
+        && TREE_TYPE (type) != 0)
+    type = TREE_TYPE (type), code = TREE_CODE (type);
+
   root_type_modified = (code == POINTER_TYPE || code == REFERENCE_TYPE
                        || decl_const || decl_volatile
                        || TYPE_READONLY (type) || TYPE_VOLATILE (type));
 
   if (type_is_fundamental (root_type (type)))
-    if (root_type_modified)
+    {
+      if (root_type_modified)
        mod_fund_type_attribute (type, decl_const, decl_volatile);
-    else
+      else
        fund_type_attribute (fundamental_type_code (type));
+    }
   else
-    if (root_type_modified)
+    {
+      if (root_type_modified)
        mod_u_d_type_attribute (type, decl_const, decl_volatile);
-    else
+      else
        /* We have to get the type_main_variant here (and pass that to the
           `user_def_type_attribute' routine) because the ..._TYPE node we
           have might simply be a *copy* of some original type node (where
@@ -2904,44 +3472,33 @@ type_attribute (type, decl_const, decl_volatile)
           only creates labels for DIEs representing *main variants*, and it
           never even knows about non-main-variants.)  */
        user_def_type_attribute (type_main_variant (type));
+    }
 }
 
 /* Given a tree pointer to a struct, class, union, or enum type node, return
    a pointer to the (string) tag name for the given type, or zero if the
    type was declared without a tag.  */
 
-static char *
-type_tag (type)
-     register tree type;
+static const char *
+type_tag (tree type)
 {
-  register char *name = 0;
+  const char *name = 0;
 
   if (TYPE_NAME (type) != 0)
     {
-      register tree t = 0;
+      tree t = 0;
 
       /* Find the IDENTIFIER_NODE for the type name.  */
       if (TREE_CODE (TYPE_NAME (type)) == IDENTIFIER_NODE)
        t = TYPE_NAME (type);
-#if 0
-      /* The g++ front end makes the TYPE_NAME of *each* tagged type point
-        to a TYPE_DECL node, regardless of whether or not a `typedef' was
-        involved.  This is distinctly different from what the gcc front-end
-        does.  It always makes the TYPE_NAME for each tagged type be either
-        NULL (signifying an anonymous tagged type) or else a pointer to an
-        IDENTIFIER_NODE.  Obviously, we would like to generate correct Dwarf
-        for both C and C++, but given this inconsistency in the TREE
-        representation of tagged types for C and C++ in the GNU front-ends,
-        we cannot support both languages correctly unless we introduce some
-        front-end specific code here, and rms objects to that, so we can
-        only generate correct Dwarf for one of these two languages.  C is
-        more important, so for now we'll do the right thing for C and let
-        g++ go fish.  */
 
-      else
-       if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL)
+      /* The g++ front end makes the TYPE_NAME of *each* tagged type point to
+         a TYPE_DECL node, regardless of whether or not a `typedef' was
+         involved.  */
+      else if (TREE_CODE (TYPE_NAME (type)) == TYPE_DECL
+              && ! DECL_IGNORED_P (TYPE_NAME (type)))
          t = DECL_NAME (TYPE_NAME (type));
-#endif
+
       /* Now get the name as a string, or invent one.  */
       if (t != 0)
        name = IDENTIFIER_POINTER (t);
@@ -2950,8 +3507,8 @@ type_tag (type)
   return (name == 0 || *name == '\0') ? 0 : name;
 }
 
-inline void
-dienum_push ()
+static inline void
+dienum_push (void)
 {
   /* Start by checking if the pending_sibling_stack needs to be expanded.
      If necessary, expand it.  */
@@ -2960,8 +3517,8 @@ dienum_push ()
     {
       pending_siblings_allocated += PENDING_SIBLINGS_INCREMENT;
       pending_sibling_stack
-       = (unsigned *) xrealloc (pending_sibling_stack,
-                                pending_siblings_allocated * sizeof(unsigned));
+       = xrealloc (pending_sibling_stack,
+                   pending_siblings_allocated * sizeof(unsigned));
     }
 
   pending_siblings++;
@@ -2971,21 +3528,41 @@ dienum_push ()
 /* Pop the sibling stack so that the most recently pushed DIEnum becomes the
    NEXT_DIE_NUM.  */
 
-inline void
-dienum_pop ()
+static inline void
+dienum_pop (void)
 {
   pending_siblings--;
 }
 
-inline tree
-member_declared_type (member)
-     register tree member;
+static inline tree
+member_declared_type (tree member)
 {
   return (DECL_BIT_FIELD_TYPE (member))
           ? DECL_BIT_FIELD_TYPE (member)
           : TREE_TYPE (member);
 }
 
+/* Get the function's label, as described by its RTL.
+   This may be different from the DECL_NAME name used
+   in the source file.  */
+
+static const char *
+function_start_label (tree decl)
+{
+  rtx x;
+  const char *fnname;
+
+  x = DECL_RTL (decl);
+  if (GET_CODE (x) != MEM)
+    abort ();
+  x = XEXP (x, 0);
+  if (GET_CODE (x) != SYMBOL_REF)
+              abort ();
+  fnname = XSTR (x, 0);
+  return fnname;
+}
+
+
 /******************************* DIEs ************************************/
 
 /* Output routines for individual types of DIEs.  */
@@ -2993,10 +3570,9 @@ member_declared_type (member)
 /* Note that every type of DIE (except a null DIE) gets a sibling.  */
 
 static void
-output_array_type_die (arg)
-     register void *arg;
+output_array_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_array_type);
   sibling_attribute ();
@@ -3020,10 +3596,9 @@ output_array_type_die (arg)
 }
 
 static void
-output_set_type_die (arg)
-     register void *arg;
+output_set_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
   sibling_attribute ();
@@ -3034,12 +3609,12 @@ output_set_type_die (arg)
 
 #if 0
 /* Implement this when there is a GNU FORTRAN or GNU Ada front end.  */
+
 static void
-output_entry_point_die (arg)
-     register void *arg;
+output_entry_point_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
   sibling_attribute ();
@@ -3055,49 +3630,49 @@ output_entry_point_die (arg)
   if (DECL_ABSTRACT (decl))
     equate_decl_number_to_die_number (decl);
   else
-    low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+    low_pc_attribute (function_start_label (decl));
 }
 #endif
 
 /* Output a DIE to represent an inlined instance of an enumeration type.  */
 
 static void
-output_inlined_enumeration_type_die (arg)
-     register void *arg;
+output_inlined_enumeration_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
   sibling_attribute ();
-  assert (TREE_ASM_WRITTEN (type));
+  if (!TREE_ASM_WRITTEN (type))
+    abort ();
   abstract_origin_attribute (type);
 }
 
 /* Output a DIE to represent an inlined instance of a structure type.  */
 
 static void
-output_inlined_structure_type_die (arg)
-     register void *arg;
+output_inlined_structure_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
   sibling_attribute ();
-  assert (TREE_ASM_WRITTEN (type));
+  if (!TREE_ASM_WRITTEN (type))
+    abort ();
   abstract_origin_attribute (type);
 }
 
 /* Output a DIE to represent an inlined instance of a union type.  */
 
 static void
-output_inlined_union_type_die (arg)
-     register void *arg;
+output_inlined_union_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
   sibling_attribute ();
-  assert (TREE_ASM_WRITTEN (type));
+  if (!TREE_ASM_WRITTEN (type))
+    abort ();
   abstract_origin_attribute (type);
 }
 
@@ -3106,10 +3681,9 @@ output_inlined_union_type_die (arg)
    This information is encoded into the element_list attribute.         */
 
 static void
-output_enumeration_type_die (arg)
-     register void *arg;
+output_enumeration_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
   sibling_attribute ();
@@ -3121,7 +3695,7 @@ output_enumeration_type_die (arg)
      given enum type is incomplete, do not generate the AT_byte_size
      attribute or the AT_element_list attribute.  */
 
-  if (TYPE_SIZE (type))
+  if (COMPLETE_TYPE_P (type))
     {
       byte_size_attribute (type);
       element_list_attribute (TYPE_FIELDS (type));
@@ -3142,10 +3716,9 @@ output_enumeration_type_die (arg)
    formal argument type of some subprogram type.  */
 
 static void
-output_formal_parameter_die (arg)
-     register void *arg;
+output_formal_parameter_die (void *arg)
 {
-  register tree node = arg;
+  tree node = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
   sibling_attribute ();
@@ -3184,11 +3757,10 @@ output_formal_parameter_die (arg)
    or block-local) which has "external linkage" (according to ANSI-C).  */
 
 static void
-output_global_subroutine_die (arg)
-     register void *arg;
+output_global_subroutine_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
   sibling_attribute ();
@@ -3197,7 +3769,7 @@ output_global_subroutine_die (arg)
     abstract_origin_attribute (origin);
   else
     {
-      register tree type = TREE_TYPE (decl);
+      tree type = TREE_TYPE (decl);
 
       name_and_src_coords_attributes (decl);
       inline_attribute (decl);
@@ -3210,18 +3782,23 @@ output_global_subroutine_die (arg)
     equate_decl_number_to_die_number (decl);
   else
     {
-      if (! DECL_EXTERNAL (decl))
+      if (! DECL_EXTERNAL (decl) && ! in_class
+         && decl == current_function_decl)
        {
          char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-         low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
-         sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
+         low_pc_attribute (function_start_label (decl));
+         sprintf (label, FUNC_END_LABEL_FMT, current_function_funcdef_no);
          high_pc_attribute (label);
-         sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
-         body_begin_attribute (label);
-         sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
-         body_end_attribute (label);
-       }
+         if (use_gnu_debug_info_extensions)
+           {
+             sprintf (label, BODY_BEGIN_LABEL_FMT,
+                      current_function_funcdef_no);
+             body_begin_attribute (label);
+             sprintf (label, BODY_END_LABEL_FMT, current_function_funcdef_no);
+             body_end_attribute (label);
+           }
+       }
     }
 }
 
@@ -3229,11 +3806,10 @@ output_global_subroutine_die (arg)
    or block-local) which has "external linkage" (according to ANSI-C).  */
 
 static void
-output_global_variable_die (arg)
-     register void *arg;
+output_global_variable_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
   sibling_attribute ();
@@ -3250,17 +3826,17 @@ output_global_variable_die (arg)
     equate_decl_number_to_die_number (decl);
   else
     {
-      if (!DECL_EXTERNAL (decl))
+      if (! DECL_EXTERNAL (decl) && ! in_class
+         && current_function_decl == decl_function_context (decl))
        location_or_const_value_attribute (decl);
     }
 }
 
 static void
-output_label_die (arg)
-     register void *arg;
+output_label_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
   sibling_attribute ();
@@ -3272,9 +3848,14 @@ output_label_die (arg)
     equate_decl_number_to_die_number (decl);
   else
     {
-      register rtx insn = DECL_RTL (decl);
-
-      if (GET_CODE (insn) == CODE_LABEL)
+      rtx insn = DECL_RTL (decl);
+
+      /* Deleted labels are programmer specified labels which have been
+        eliminated because of various optimizations.  We still emit them
+        here so that it is possible to put breakpoints on them.  */
+      if (GET_CODE (insn) == CODE_LABEL
+         || ((GET_CODE (insn) == NOTE
+              && NOTE_LINE_NUMBER (insn) == NOTE_INSN_DELETED_LABEL)))
        {
          char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -3287,18 +3868,16 @@ output_label_die (arg)
          if (INSN_DELETED_P (insn))
            abort ();   /* Should never happen.  */
 
-         sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
-                                         (unsigned) INSN_UID (insn));
+         ASM_GENERATE_INTERNAL_LABEL (label, "L", CODE_LABEL_NUMBER (insn));
          low_pc_attribute (label);
        }
     }
 }
 
 static void
-output_lexical_block_die (arg)
-     register void *arg;
+output_lexical_block_die (void *arg)
 {
-  register tree stmt = arg;
+  tree stmt = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
   sibling_attribute ();
@@ -3308,18 +3887,17 @@ output_lexical_block_die (arg)
       char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
       char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-      sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
+      sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, BLOCK_NUMBER (stmt));
       low_pc_attribute (begin_label);
-      sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
+      sprintf (end_label, BLOCK_END_LABEL_FMT, BLOCK_NUMBER (stmt));
       high_pc_attribute (end_label);
     }
 }
 
 static void
-output_inlined_subroutine_die (arg)
-     register void *arg;
+output_inlined_subroutine_die (void *arg)
 {
-  register tree stmt = arg;
+  tree stmt = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
   sibling_attribute ();
@@ -3330,9 +3908,9 @@ output_inlined_subroutine_die (arg)
       char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
       char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-      sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
+      sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, BLOCK_NUMBER (stmt));
       low_pc_attribute (begin_label);
-      sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
+      sprintf (end_label, BLOCK_END_LABEL_FMT, BLOCK_NUMBER (stmt));
       high_pc_attribute (end_label);
     }
 }
@@ -3341,11 +3919,10 @@ output_inlined_subroutine_die (arg)
    or block-local) which has "internal linkage" (according to ANSI-C).  */
 
 static void
-output_local_variable_die (arg)
-     register void *arg;
+output_local_variable_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
   sibling_attribute ();
@@ -3365,10 +3942,9 @@ output_local_variable_die (arg)
 }
 
 static void
-output_member_die (arg)
-     register void *arg;
+output_member_die (void *arg)
 {
-  register tree decl = arg;
+  tree decl = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
   sibling_attribute ();
@@ -3376,7 +3952,7 @@ output_member_die (arg)
   member_attribute (DECL_CONTEXT (decl));
   type_attribute (member_declared_type (decl),
                  TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
-  if (DECL_BIT_FIELD_TYPE (decl))      /* If this is a bit field... */
+  if (DECL_BIT_FIELD_TYPE (decl))      /* If this is a bit field...  */
     {
       byte_size_attribute (decl);
       bit_size_attribute (decl);
@@ -3389,15 +3965,14 @@ output_member_die (arg)
 /* Don't generate either pointer_type DIEs or reference_type DIEs.  Use
    modified types instead.
 
-   We keep this code here just in case these types of DIEs may be needed
-   to represent certain things in other languages (e.g. Pascal) someday.
-*/
+   We keep this code here just in case these types of DIEs may be
+   needed to represent certain things in other languages (e.g. Pascal)
+   someday.  */
 
 static void
-output_pointer_type_die (arg)
-     register void *arg;
+output_pointer_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_pointer_type);
   sibling_attribute ();
@@ -3407,10 +3982,9 @@ output_pointer_type_die (arg)
 }
 
 static void
-output_reference_type_die (arg)
-     register void *arg;
+output_reference_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_reference_type);
   sibling_attribute ();
@@ -3421,10 +3995,9 @@ output_reference_type_die (arg)
 #endif
 
 static void
-output_ptr_to_mbr_type_die (arg)
-     register void *arg;
+output_ptr_to_mbr_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_ptr_to_member_type);
   sibling_attribute ();
@@ -3435,10 +4008,10 @@ output_ptr_to_mbr_type_die (arg)
 }
 
 static void
-output_compile_unit_die (arg)
-     register void *arg;
+output_compile_unit_die (void *arg)
 {
-  register char *main_input_filename = arg;
+  const char *main_input_filename = arg;
+  const char *language_string = lang_hooks.name;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_compile_unit);
   sibling_attribute ();
@@ -3456,51 +4029,78 @@ output_compile_unit_die (arg)
     language_attribute (LANG_C_PLUS_PLUS);
   else if (strcmp (language_string, "GNU Ada") == 0)
     language_attribute (LANG_ADA83);
-  else if (flag_traditional)
-    language_attribute (LANG_C);
+  else if (strcmp (language_string, "GNU F77") == 0)
+    language_attribute (LANG_FORTRAN77);
+  else if (strcmp (language_string, "GNU Pascal") == 0)
+    language_attribute (LANG_PASCAL83);
+  else if (strcmp (language_string, "GNU Java") == 0)
+    language_attribute (LANG_JAVA);
   else
     language_attribute (LANG_C89);
   low_pc_attribute (TEXT_BEGIN_LABEL);
   high_pc_attribute (TEXT_END_LABEL);
   if (debug_info_level >= DINFO_LEVEL_NORMAL)
     stmt_list_attribute (LINE_BEGIN_LABEL);
-  last_filename = xstrdup (main_input_filename);
 
   {
-    char *wd = getpwd ();
+    const char *wd = get_src_pwd ();
     if (wd)
       comp_dir_attribute (wd);
   }
 
-  if (debug_info_level >= DINFO_LEVEL_NORMAL)
+  if (debug_info_level >= DINFO_LEVEL_NORMAL && use_gnu_debug_info_extensions)
     {
       sf_names_attribute (SFNAMES_BEGIN_LABEL);
       src_info_attribute (SRCINFO_BEGIN_LABEL);
       if (debug_info_level >= DINFO_LEVEL_VERBOSE)
-        mac_info_attribute (MACINFO_BEGIN_LABEL);
+       mac_info_attribute (MACINFO_BEGIN_LABEL);
     }
 }
 
 static void
-output_string_type_die (arg)
-     register void *arg;
+output_string_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_string_type);
   sibling_attribute ();
+  equate_type_number_to_die_number (type);
   member_attribute (TYPE_CONTEXT (type));
+  /* this is a fixed length string */
+  byte_size_attribute (type);
+}
 
-  /* Fudge the string length attribute for now.  */
+static void
+output_inheritance_die (void *arg)
+{
+  tree binfo = ((tree *)arg)[0];
+  tree access = ((tree *)arg)[1];
 
-  string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inheritance);
+  sibling_attribute ();
+  type_attribute (BINFO_TYPE (binfo), 0, 0);
+  data_member_location_attribute (binfo);
+  if (TREE_VIA_VIRTUAL (binfo))
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
+    }
+  if (access == access_public_node)
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_public);
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
+    }
+  else if (access == access_protected_node)
+    {
+      ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_protected);
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
+    }
 }
 
 static void
-output_structure_type_die (arg)
-     register void *arg;
+output_structure_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
   sibling_attribute ();
@@ -3514,7 +4114,7 @@ output_structure_type_die (arg)
      of members (since we don't have any idea what they might be for an
      incomplete type). */
 
-  if (TYPE_SIZE (type))
+  if (COMPLETE_TYPE_P (type))
     {
       dienum_push ();
       byte_size_attribute (type);
@@ -3525,11 +4125,10 @@ output_structure_type_die (arg)
    or block-local) which has "internal linkage" (according to ANSI-C).  */
 
 static void
-output_local_subroutine_die (arg)
-     register void *arg;
+output_local_subroutine_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
   sibling_attribute ();
@@ -3538,7 +4137,7 @@ output_local_subroutine_die (arg)
     abstract_origin_attribute (origin);
   else
     {
-      register tree type = TREE_TYPE (decl);
+      tree type = TREE_TYPE (decl);
 
       name_and_src_coords_attributes (decl);
       inline_attribute (decl);
@@ -3557,24 +4156,26 @@ output_local_subroutine_die (arg)
       if (TREE_ASM_WRITTEN (decl))
        {
          char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-         low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
-         sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
+         low_pc_attribute (function_start_label (decl));
+         sprintf (label, FUNC_END_LABEL_FMT, current_function_funcdef_no);
          high_pc_attribute (label);
-         sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
-         body_begin_attribute (label);
-         sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
-         body_end_attribute (label);
+         if (use_gnu_debug_info_extensions)
+           {
+             sprintf (label, BODY_BEGIN_LABEL_FMT,
+                      current_function_funcdef_no);
+             body_begin_attribute (label);
+             sprintf (label, BODY_END_LABEL_FMT, current_function_funcdef_no);
+             body_end_attribute (label);
+           }
        }
     }
 }
 
 static void
-output_subroutine_type_die (arg)
-     register void *arg;
+output_subroutine_type_die (void *arg)
 {
-  register tree type = arg;
-  register tree return_type = TREE_TYPE (type);
+  tree type = arg;
+  tree return_type = TREE_TYPE (type);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine_type);
   sibling_attribute ();
@@ -3586,11 +4187,10 @@ output_subroutine_type_die (arg)
 }
 
 static void
-output_typedef_die (arg)
-     register void *arg;
+output_typedef_die (void *arg)
 {
-  register tree decl = arg;
-  register tree origin = decl_ultimate_origin (decl);
+  tree decl = arg;
+  tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
   sibling_attribute ();
@@ -3608,10 +4208,9 @@ output_typedef_die (arg)
 }
 
 static void
-output_union_type_die (arg)
-     register void *arg;
+output_union_type_die (void *arg)
 {
-  register tree type = arg;
+  tree type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
   sibling_attribute ();
@@ -3625,7 +4224,7 @@ output_union_type_die (arg)
      of members (since we don't have any idea what they might be for an
      incomplete type). */
 
-  if (TYPE_SIZE (type))
+  if (COMPLETE_TYPE_P (type))
     {
       dienum_push ();
       byte_size_attribute (type);
@@ -3636,10 +4235,9 @@ output_union_type_die (arg)
    at the end of an (ANSI prototyped) formal parameters list.  */
 
 static void
-output_unspecified_parameters_die (arg)
-     register void *arg;
+output_unspecified_parameters_die (void *arg)
 {
-  register tree decl_or_type = arg;
+  tree decl_or_type = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_unspecified_parameters);
   sibling_attribute ();
@@ -3662,8 +4260,7 @@ output_unspecified_parameters_die (arg)
 }
 
 static void
-output_padded_null_die (arg)
-     register void *arg;
+output_padded_null_die (void *arg ATTRIBUTE_UNUSED)
 {
   ASM_OUTPUT_ALIGN (asm_out_file, 2);  /* 2**2 == 4 */
 }
@@ -3677,9 +4274,7 @@ output_padded_null_die (arg)
    of the DIE, there must always be a terminator label for the DIE.  */
 
 static void
-output_die (die_specific_output_function, param)
-     register void (*die_specific_output_function)();
-     register void *param;
+output_die (void (*die_specific_output_function) (void *), void *param)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
@@ -3709,7 +4304,7 @@ output_die (die_specific_output_function, param)
 }
 
 static void
-end_sibling_chain ()
+end_sibling_chain (void)
 {
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -3734,19 +4329,24 @@ end_sibling_chain ()
    parameters as specified in some function type specification (except
    for those which appear as part of a function *definition*).
 
-   Note that we must be careful here to output all of the parameter DIEs
-   *before* we output any DIEs needed to represent the types of the formal
-   parameters.  This keeps svr4 SDB happy because it (incorrectly) thinks
-   that the first non-parameter DIE it sees ends the formal parameter list.
-*/
+   Note that we must be careful here to output all of the parameter
+   DIEs *before* we output any DIEs needed to represent the types of
+   the formal parameters.  This keeps svr4 SDB happy because it
+   (incorrectly) thinks that the first non-parameter DIE it sees ends
+   the formal parameter list.  */
 
 static void
-output_formal_types (function_or_method_type)
-     register tree function_or_method_type;
+output_formal_types (tree function_or_method_type)
 {
-  register tree link;
-  register tree formal_type = NULL;
-  register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
+  tree link;
+  tree formal_type = NULL;
+  tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
+
+  /* Set TREE_ASM_WRITTEN while processing the parameters, lest we
+     get bogus recursion when outputting tagged types local to a
+     function declaration.  */
+  int save_asm_written = TREE_ASM_WRITTEN (function_or_method_type);
+  TREE_ASM_WRITTEN (function_or_method_type) = 1;
 
   /* In the case where we are generating a formal types list for a C++
      non-static member function type, skip over the first thing on the
@@ -3793,20 +4393,21 @@ output_formal_types (function_or_method_type)
 
       output_type (formal_type, function_or_method_type);
     }
+
+  TREE_ASM_WRITTEN (function_or_method_type) = save_asm_written;
 }
 \f
 /* Remember a type in the pending_types_list.  */
 
 static void
-pend_type (type)
-     register tree type;
+pend_type (tree type)
 {
   if (pending_types == pending_types_allocated)
     {
       pending_types_allocated += PENDING_TYPES_INCREMENT;
       pending_types_list
-       = (tree *) xrealloc (pending_types_list,
-                            sizeof (tree) * pending_types_allocated);
+       = xrealloc (pending_types_list,
+                   sizeof (tree) * pending_types_allocated);
     }
   pending_types_list[pending_types++] = type;
 
@@ -3817,7 +4418,7 @@ pend_type (type)
   TREE_ASM_WRITTEN (type) = 1;
 }
 
-/* Return non-zero if it is legitimate to output DIEs to represent a
+/* Return nonzero if it is legitimate to output DIEs to represent a
    given type while we are generating the list of child DIEs for some
    DIE (e.g. a function or lexical block DIE) associated with a given scope.
 
@@ -3851,13 +4452,10 @@ pend_type (type)
    been output are instead placed onto the pending_types_list.  Later on,
    we force these (temporarily pended) types to be output simply by calling
    `output_pending_types_for_scope' with an actual argument equal to the
-   true scope of the types we temporarily pended.
-*/
+   true scope of the types we temporarily pended.  */
 
-inline int
-type_ok_for_scope (type, scope)
-    register tree type;
-    register tree scope;
+static inline int
+type_ok_for_scope (tree type, tree scope)
 {
   /* Tagged types (i.e. struct, union, and enum types) must always be
      output only in the scopes where they actually belong (or else the
@@ -3871,7 +4469,12 @@ type_ok_for_scope (type, scope)
      (for C and C++ anyway) will be array types and function types.  */
 
   return is_tagged_type (type)
-        ? (TYPE_CONTEXT (type) == scope)
+        ? (TYPE_CONTEXT (type) == scope
+           /* Ignore namespaces for the moment.  */
+           || (scope == NULL_TREE
+               && TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
+           || (scope == NULL_TREE && is_tagged_type (TYPE_CONTEXT (type))
+               && TREE_ASM_WRITTEN (TYPE_CONTEXT (type))))
         : (scope == NULL_TREE || ! is_tagged_type (scope));
 }
 
@@ -3884,23 +4487,21 @@ type_ok_for_scope (type, scope)
    Note that we have to process the list in beginning-to-end order,
    because the call made here to output_type may cause yet more types
    to be added to the end of the list, and we may have to output some
-   of them too.
-*/
+   of them too.  */
 
 static void
-output_pending_types_for_scope (containing_scope)
-     register tree containing_scope;
+output_pending_types_for_scope (tree containing_scope)
 {
-  register unsigned i;
+  unsigned i;
 
   for (i = 0; i < pending_types; )
     {
-      register tree type = pending_types_list[i];
+      tree type = pending_types_list[i];
 
       if (type_ok_for_scope (type, containing_scope))
        {
-         register tree *mover;
-         register tree *limit;
+         tree *mover;
+         tree *limit;
 
          pending_types--;
          limit = &pending_types_list[pending_types];
@@ -3923,22 +4524,79 @@ output_pending_types_for_scope (containing_scope)
     }
 }
 
+/* Remember a type in the incomplete_types_list.  */
+
+static void
+add_incomplete_type (tree type)
+{
+  if (incomplete_types == incomplete_types_allocated)
+    {
+      incomplete_types_allocated += INCOMPLETE_TYPES_INCREMENT;
+      incomplete_types_list
+       = xrealloc (incomplete_types_list,
+                   sizeof (tree) * incomplete_types_allocated);
+    }
+
+  incomplete_types_list[incomplete_types++] = type;
+}
+
+/* Walk through the list of incomplete types again, trying once more to
+   emit full debugging info for them.  */
+
 static void
-output_type (type, containing_scope)
-     register tree type;
-     register tree containing_scope;
+retry_incomplete_types (void)
+{
+  tree type;
+
+  finalizing = 1;
+  while (incomplete_types)
+    {
+      --incomplete_types;
+      type = incomplete_types_list[incomplete_types];
+      output_type (type, NULL_TREE);
+    }
+}
+
+static void
+output_type (tree type, tree containing_scope)
 {
   if (type == 0 || type == error_mark_node)
     return;
 
   /* We are going to output a DIE to represent the unqualified version of
-     of this type (i.e. without any const or volatile qualifiers) so get
+     this type (i.e. without any const or volatile qualifiers) so get
      the main variant (i.e. the unqualified version) of this type now.  */
 
   type = type_main_variant (type);
 
   if (TREE_ASM_WRITTEN (type))
-    return;
+    {
+      if (finalizing && AGGREGATE_TYPE_P (type))
+       {
+         tree member;
+
+         /* Some of our nested types might not have been defined when we
+            were written out before; force them out now.  */
+
+         for (member = TYPE_FIELDS (type); member;
+              member = TREE_CHAIN (member))
+           if (TREE_CODE (member) == TYPE_DECL
+               && ! TREE_ASM_WRITTEN (TREE_TYPE (member)))
+             output_type (TREE_TYPE (member), containing_scope);
+       }
+      return;
+    }
+
+  /* If this is a nested type whose containing class hasn't been
+     written out yet, writing it out will cover this one, too.  */
+
+  if (TYPE_CONTEXT (type)
+      && TYPE_P (TYPE_CONTEXT (type))
+      && ! TREE_ASM_WRITTEN (TYPE_CONTEXT (type)))
+    {
+      output_type (TYPE_CONTEXT (type), containing_scope);
+      return;
+    }
 
   /* Don't generate any DIEs for this type now unless it is OK to do so
      (based upon what `type_ok_for_scope' tells us).  */
@@ -3954,8 +4612,15 @@ output_type (type, containing_scope)
       case ERROR_MARK:
        break;
 
+      case VECTOR_TYPE:
+       output_type (TYPE_DEBUG_REPRESENTATION_TYPE (type), containing_scope);
+       break;
+
       case POINTER_TYPE:
       case REFERENCE_TYPE:
+       /* Prevent infinite recursion in cases where this is a recursive
+          type.  Recursive types are possible in Ada.  */
+       TREE_ASM_WRITTEN (type) = 1;
        /* For these types, all that is required is that we output a DIE
           (or a set of DIEs) to represent the "basis" type.  */
        output_type (TREE_TYPE (type), containing_scope);
@@ -3973,7 +4638,7 @@ output_type (type, containing_scope)
        break;
 
       case SET_TYPE:
-       output_type (TREE_TYPE (type), containing_scope);
+       output_type (TYPE_DOMAIN (type), containing_scope);
        output_die (output_set_type_die, type);
        break;
 
@@ -3982,11 +4647,6 @@ output_type (type, containing_scope)
        abort ();       /* No way to represent these in Dwarf yet!  */
        break;
 
-      case STRING_TYPE:
-       output_type (TREE_TYPE (type), containing_scope);
-       output_die (output_string_type_die, type);
-       break;
-
       case FUNCTION_TYPE:
        /* Force out return type (in case it wasn't forced out already).  */
        output_type (TREE_TYPE (type), containing_scope);
@@ -4004,16 +4664,22 @@ output_type (type, containing_scope)
        break;
 
       case ARRAY_TYPE:
-       {
-         register tree element_type;
+       if (TYPE_STRING_FLAG (type) && TREE_CODE(TREE_TYPE(type)) == CHAR_TYPE)
+         {
+           output_type (TREE_TYPE (type), containing_scope);
+           output_die (output_string_type_die, type);
+         }
+       else
+         {
+           tree element_type;
 
-         element_type = TREE_TYPE (type);
-         while (TREE_CODE (element_type) == ARRAY_TYPE)
-           element_type = TREE_TYPE (element_type);
+           element_type = TREE_TYPE (type);
+           while (TREE_CODE (element_type) == ARRAY_TYPE)
+             element_type = TREE_TYPE (element_type);
 
-         output_type (element_type, containing_scope);
-         output_die (output_array_type_die, type);
-       }
+           output_type (element_type, containing_scope);
+           output_die (output_array_type_die, type);
+         }
        break;
 
       case ENUMERAL_TYPE:
@@ -4049,11 +4715,19 @@ output_type (type, containing_scope)
           time, we will certainly know as much about each file-scope tagged
           type as we are ever going to know, so at that point in time, we
           can safely generate correct Dwarf descriptions for these file-
-          scope tagged types.
-       */
+          scope tagged types.  */
 
-       if (TYPE_SIZE (type) == 0 && TYPE_CONTEXT (type) == NULL && !finalizing)
-         return;       /* EARLY EXIT!  Avoid setting TREE_ASM_WRITTEN.  */
+       if (!COMPLETE_TYPE_P (type)
+           && (TYPE_CONTEXT (type) == NULL
+               || AGGREGATE_TYPE_P (TYPE_CONTEXT (type))
+               || TREE_CODE (TYPE_CONTEXT (type)) == NAMESPACE_DECL)
+           && !finalizing)
+         {
+           /* We don't need to do this for function-local types.  */
+           if (! decl_function_context (TYPE_STUB_DECL (type)))
+             add_incomplete_type (type);
+           return;     /* EARLY EXIT!  Avoid setting TREE_ASM_WRITTEN.  */
+         }
 
        /* Prevent infinite recursion in cases where the type of some
           member of this type is expressed in terms of this type itself.  */
@@ -4089,7 +4763,7 @@ output_type (type, containing_scope)
           to output DIEs to represent the *types* of those members.
           However the `output_type' function (above) will specifically
           avoid generating type DIEs for member types *within* the list
-          of member DIEs for this (containing) type execpt for those
+          of member DIEs for this (containing) type except for those
           types (of members) which are explicitly marked as also being
           members of this (containing) type themselves.  The g++ front-
           end can force any given type to be treated as a member of some
@@ -4098,12 +4772,36 @@ output_type (type, containing_scope)
           appropriate (containing) type.
        */
 
-       if (TYPE_SIZE (type))
+       if (COMPLETE_TYPE_P (type))
          {
+           tree binfo = TYPE_BINFO (type);
+
+           /* First output info about the base classes.  */
+           if (binfo)
+             {
+               tree bases = BINFO_BASETYPES (binfo);
+               tree accesses = BINFO_BASEACCESSES (binfo);
+               register int n_bases = BINFO_N_BASETYPES (binfo);
+               register int i;
+
+               for (i = 0; i < n_bases; i++)
+                 {
+                   tree arg[2];
+
+                   arg[0] = TREE_VEC_ELT (bases, i);
+                   arg[1] = (accesses ? TREE_VEC_ELT (accesses, i)
+                             : access_public_node);
+                   output_type (BINFO_TYPE (binfo), containing_scope);
+                   output_die (output_inheritance_die, arg);
+                 }
+             }
+
+           ++in_class;
+
            {
-             register tree normal_member;
+             tree normal_member;
 
-             /* First output info about the data members and type members.  */
+             /* Now output info about the data members and type members.  */
 
              for (normal_member = TYPE_FIELDS (type);
                   normal_member;
@@ -4112,32 +4810,24 @@ output_type (type, containing_scope)
            }
 
            {
-             register tree vec_base;
+             tree func_member;
 
              /* Now output info about the function members (if any).  */
 
-             vec_base = TYPE_METHODS (type);
-             if (vec_base)
+             for (func_member = TYPE_METHODS (type);
+                  func_member;
+                  func_member = TREE_CHAIN (func_member))
                {
-                 register tree first_func_member = TREE_VEC_ELT (vec_base, 0);
-                 register tree func_member;
-
-                 /* This isn't documented, but the first element of the
-                    vector of member functions can be NULL in cases where
-                    the class type in question didn't have either a
-                    constructor or a destructor declared for it.  We have
-                    to make allowances for that here.  */
-
-                 if (first_func_member == NULL)
-                   first_func_member = TREE_VEC_ELT (vec_base, 1);
-
-                 for (func_member = first_func_member;
-                      func_member;
-                      func_member = TREE_CHAIN (func_member))
-                   output_decl (func_member, type);
+                 /* Don't include clones in the member list.  */
+                 if (DECL_ABSTRACT_ORIGIN (func_member))
+                   continue;
+
+                 output_decl (func_member, type);
                }
            }
 
+           --in_class;
+
            /* RECORD_TYPEs, UNION_TYPEs, and QUAL_UNION_TYPEs are themselves
               scopes (at least in C++) so we must now output any nested
               pending types which are local just to this type.  */
@@ -4168,20 +4858,21 @@ output_type (type, containing_scope)
 }
 
 static void
-output_tagged_type_instantiation (type)
-     register tree type;
+output_tagged_type_instantiation (tree type)
 {
   if (type == 0 || type == error_mark_node)
     return;
 
   /* We are going to output a DIE to represent the unqualified version of
-     of this type (i.e. without any const or volatile qualifiers) so make
+     this type (i.e. without any const or volatile qualifiers) so make
      sure that we have the main variant (i.e. the unqualified version) of
      this type now.  */
 
-  assert (type == type_main_variant (type));
+  if (type != type_main_variant (type))
+    abort ();
 
-  assert (TREE_ASM_WRITTEN (type));
+  if (!TREE_ASM_WRITTEN (type))
+    abort ();
 
   switch (TREE_CODE (type))
     {
@@ -4210,16 +4901,16 @@ output_tagged_type_instantiation (type)
    the things which are local to the given block.  */
 
 static void
-output_block (stmt)
-    register tree stmt;
+output_block (tree stmt, int depth)
 {
-  register int must_output_die = 0;
-  register tree origin;
-  register enum tree_code origin_code;
+  int must_output_die = 0;
+  tree origin;
+  enum tree_code origin_code;
 
   /* Ignore blocks never really used to make RTL.  */
 
-  if (! stmt || ! TREE_USED (stmt))
+  if (! stmt || ! TREE_USED (stmt)
+      || (!TREE_ASM_WRITTEN (stmt) && !BLOCK_ABSTRACT (stmt)))
     return;
 
   /* Determine the "ultimate origin" of this block.  This block may be an
@@ -4249,7 +4940,7 @@ output_block (stmt)
         not represent a "body block inlining" before trying to set the
         `must_output_die' flag.  */
 
-      if (origin == NULL || ! is_body_block (origin))
+      if (! is_body_block (origin ? origin : stmt))
        {
          /* Determine if this block directly contains any "significant"
             local declarations which we will need to output DIEs for.  */
@@ -4260,7 +4951,7 @@ output_block (stmt)
            must_output_die = (BLOCK_VARS (stmt) != NULL);
          else
            {
-             register tree decl;
+             tree decl;
 
              /* We are in terse mode, so only local (nested) function
                 definitions count as "significant" local declarations.  */
@@ -4283,40 +4974,38 @@ output_block (stmt)
      a "significant" local declaration gets restricted to include only
      inlined function instances and local (nested) function definitions.  */
 
-  if (must_output_die)
+  if (origin_code == FUNCTION_DECL && BLOCK_ABSTRACT (stmt))
+    /* We don't care about an abstract inlined subroutine.  */;
+  else if (must_output_die)
     {
       output_die ((origin_code == FUNCTION_DECL)
                    ? output_inlined_subroutine_die
                    : output_lexical_block_die,
                  stmt);
-      output_decls_for_scope (stmt);
+      output_decls_for_scope (stmt, depth);
       end_sibling_chain ();
     }
   else
-    output_decls_for_scope (stmt);
+    output_decls_for_scope (stmt, depth);
 }
 
 /* Output all of the decls declared within a given scope (also called
    a `binding contour') and (recursively) all of it's sub-blocks.  */
 
 static void
-output_decls_for_scope (stmt)
-     register tree stmt;
+output_decls_for_scope (tree stmt, int depth)
 {
   /* Ignore blocks never really used to make RTL.  */
 
   if (! stmt || ! TREE_USED (stmt))
     return;
 
-  if (! BLOCK_ABSTRACT (stmt))
-    next_block_number++;
-
   /* Output the DIEs to represent all of the data objects, functions,
      typedefs, and tagged types declared directly within this block
      but not within any nested sub-blocks.  */
 
   {
-    register tree decl;
+    tree decl;
 
     for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
       output_decl (decl, stmt);
@@ -4328,21 +5017,36 @@ output_decls_for_scope (stmt)
      therein) of this block.    */
 
   {
-    register tree subblocks;
+    tree subblocks;
 
     for (subblocks = BLOCK_SUBBLOCKS (stmt);
-         subblocks;
-         subblocks = BLOCK_CHAIN (subblocks))
-      output_block (subblocks);
+        subblocks;
+        subblocks = BLOCK_CHAIN (subblocks))
+      output_block (subblocks, depth + 1);
   }
 }
 
+/* Is this a typedef we can avoid emitting?  */
+
+static inline int
+is_redundant_typedef (tree decl)
+{
+  if (TYPE_DECL_IS_STUB (decl))
+    return 1;
+  if (DECL_ARTIFICIAL (decl)
+      && DECL_CONTEXT (decl)
+      && is_tagged_type (DECL_CONTEXT (decl))
+      && TREE_CODE (TYPE_NAME (DECL_CONTEXT (decl))) == TYPE_DECL
+      && DECL_NAME (decl) == DECL_NAME (TYPE_NAME (DECL_CONTEXT (decl))))
+    /* Also ignore the artificial member typedef for the class name.  */
+    return 1;
+  return 0;
+}
+
 /* Output Dwarf .debug information for a decl described by DECL.  */
 
 static void
-output_decl (decl, containing_scope)
-     register tree decl;
-     register tree containing_scope;
+output_decl (tree decl, tree containing_scope)
 {
   /* Make a note of the decl node we are going to be working on.  We may
      need to give the user the source coordinates of where it appeared in
@@ -4353,13 +5057,20 @@ output_decl (decl, containing_scope)
   if (TREE_CODE (decl) == ERROR_MARK)
     return;
 
-  /* If this ..._DECL node is marked to be ignored, then ignore it.
-     But don't ignore a function definition, since that would screw
-     up our count of blocks, and that it turn will completely screw up the
-     the labels we will reference in subsequent AT_low_pc and AT_high_pc
-     attributes (for subsequent blocks).  */
+  /* If a structure is declared within an initialization, e.g. as the
+     operand of a sizeof, then it will not have a name.  We don't want
+     to output a DIE for it, as the tree nodes are in the temporary obstack */
 
-  if (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
+  if ((TREE_CODE (TREE_TYPE (decl)) == RECORD_TYPE
+       || TREE_CODE (TREE_TYPE (decl)) == UNION_TYPE)
+      && ((DECL_NAME (decl) == 0 && TYPE_NAME (TREE_TYPE (decl)) == 0)
+         || (TYPE_FIELDS (TREE_TYPE (decl))
+             && (TREE_CODE (TYPE_FIELDS (TREE_TYPE (decl))) == ERROR_MARK))))
+    return;
+
+  /* If this ..._DECL node is marked to be ignored, then ignore it.  */
+
+  if (DECL_IGNORED_P (decl))
     return;
 
   switch (TREE_CODE (decl))
@@ -4386,6 +5097,20 @@ output_decl (decl, containing_scope)
 
       output_type (TREE_TYPE (TREE_TYPE (decl)), containing_scope);
 
+      {
+       /* And its containing type.  */
+       register tree origin = decl_class_context (decl);
+       if (origin)
+         output_type (origin, containing_scope);
+      }
+
+      /* If we're emitting an out-of-line copy of an inline function,
+        set up to refer to the abstract instance emitted from
+        dwarfout_deferred_inline_function.  */
+      if (DECL_INLINE (decl) && ! DECL_ABSTRACT (decl)
+         && ! (containing_scope && TYPE_P (containing_scope)))
+       set_decl_origin_self (decl);
+
       /* If the following DIE will represent a function definition for a
         function with "extern" linkage, output a special "pubnames" DIE
         label just ahead of the actual DIE.  A reference to this label
@@ -4422,178 +5147,135 @@ output_decl (decl, containing_scope)
         we need to do here (and all we *can* do here) is to describe
         the *types* of its formal parameters.  */
 
-      if (DECL_INITIAL (decl) == NULL_TREE)
+      if (decl != current_function_decl || in_class)
        output_formal_types (TREE_TYPE (decl));
       else
        {
-         register tree arg_decls = DECL_ARGUMENTS (decl);
-
-         {
-           register tree last_arg;
-
-           last_arg = (arg_decls && TREE_CODE (arg_decls) != ERROR_MARK)
-                       ? tree_last (arg_decls)
-                       : NULL;
+         /* Generate DIEs to represent all known formal parameters.  */
+
+         tree arg_decls = DECL_ARGUMENTS (decl);
+         tree parm;
+
+         /* WARNING!  Kludge zone ahead!  Here we have a special
+            hack for svr4 SDB compatibility.  Instead of passing the
+            current FUNCTION_DECL node as the second parameter (i.e.
+            the `containing_scope' parameter) to `output_decl' (as
+            we ought to) we instead pass a pointer to our own private
+            fake_containing_scope node.  That node is a RECORD_TYPE
+            node which NO OTHER TYPE may ever actually be a member of.
+
+            This pointer will ultimately get passed into `output_type'
+            as its `containing_scope' parameter.  `Output_type' will
+            then perform its part in the hack... i.e. it will pend
+            the type of the formal parameter onto the pending_types
+            list.  Later on, when we are done generating the whole
+            sequence of formal parameter DIEs for this function
+            definition, we will un-pend all previously pended types
+            of formal parameters for this function definition.
+
+            This whole kludge prevents any type DIEs from being
+            mixed in with the formal parameter DIEs.  That's good
+            because svr4 SDB believes that the list of formal
+            parameter DIEs for a function ends wherever the first
+            non-formal-parameter DIE appears.  Thus, we have to
+            keep the formal parameter DIEs segregated.  They must
+            all appear (consecutively) at the start of the list of
+            children for the DIE representing the function definition.
+            Then (and only then) may we output any additional DIEs
+            needed to represent the types of these formal parameters.
+         */
 
-           /* Generate DIEs to represent all known formal parameters, but
-              don't do it if this looks like a varargs function.  A given
-              function is considered to be a varargs function if (and only
-              if) its last named argument is named `__builtin_va_alist'.  */
+         /*
+            When generating DIEs, generate the unspecified_parameters
+            DIE instead if we come across the arg "__builtin_va_alist"
+         */
 
-           if (! last_arg
-               || ! DECL_NAME (last_arg)
-               || strcmp (IDENTIFIER_POINTER (DECL_NAME (last_arg)),
-                          "__builtin_va_alist"))
+         for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
+           if (TREE_CODE (parm) == PARM_DECL)
              {
-               register tree parm;
-
-               /* WARNING!  Kludge zone ahead!  Here we have a special
-                  hack for svr4 SDB compatibility.  Instead of passing the
-                  current FUNCTION_DECL node as the second parameter (i.e.
-                  the `containing_scope' parameter) to `output_decl' (as
-                  we ought to) we instead pass a pointer to our own private
-                  fake_containing_scope node.  That node is a RECORD_TYPE
-                  node which NO OTHER TYPE may ever actually be a member of.
-
-                  This pointer will ultimately get passed into `output_type'
-                  as its `containing_scope' parameter.  `Output_type' will
-                  then perform its part in the hack... i.e. it will pend
-                  the type of the formal parameter onto the pending_types
-                  list.  Later on, when we are done generating the whole
-                  sequence of formal parameter DIEs for this function
-                  definition, we will un-pend all previously pended types
-                  of formal parameters for this function definition.
-
-                  This whole kludge prevents any type DIEs from being
-                  mixed in with the formal parameter DIEs.  That's good
-                  because svr4 SDB believes that the list of formal
-                  parameter DIEs for a function ends wherever the first
-                  non-formal-parameter DIE appears.  Thus, we have to
-                  keep the formal parameter DIEs segregated.  They must
-                  all appear (consecutively) at the start of the list of
-                  children for the DIE representing the function definition.
-                  Then (and only then) may we output any additional DIEs
-                  needed to represent the types of these formal parameters.
-               */
-
-               for (parm = arg_decls; parm; parm = TREE_CHAIN (parm))
-                 if (TREE_CODE (parm) == PARM_DECL)
-                   output_decl (parm, fake_containing_scope);
-
-               /* Now that we have finished generating all of the DIEs to
-                  represent the formal parameters themselves, force out
-                  any DIEs needed to represent their types.  We do this
-                  simply by un-pending all previously pended types which
-                  can legitimately go into the chain of children DIEs for
-                  the current FUNCTION_DECL.  */
-
-               output_pending_types_for_scope (decl);
+               if (DECL_NAME(parm) &&
+                   !strcmp(IDENTIFIER_POINTER(DECL_NAME(parm)),
+                           "__builtin_va_alist") )
+                 output_die (output_unspecified_parameters_die, decl);
+               else
+                 output_decl (parm, fake_containing_scope);
              }
-         }
 
-         /* Now try to decide if we should put an ellipsis at the end. */
+         /*
+            Now that we have finished generating all of the DIEs to
+            represent the formal parameters themselves, force out
+            any DIEs needed to represent their types.  We do this
+            simply by un-pending all previously pended types which
+            can legitimately go into the chain of children DIEs for
+            the current FUNCTION_DECL.
+         */
+
+         output_pending_types_for_scope (decl);
+
+         /*
+           Decide whether we need an unspecified_parameters DIE at the end.
+           There are 2 more cases to do this for:
+           1) the ansi ... declaration - this is detectable when the end
+               of the arg list is not a void_type_node
+           2) an unprototyped function declaration (not a definition).  This
+               just means that we have no info about the parameters at all.
+         */
 
          {
-           register int has_ellipsis = TRUE;   /* default assumption */
-           register tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
+           tree fn_arg_types = TYPE_ARG_TYPES (TREE_TYPE (decl));
 
            if (fn_arg_types)
              {
-               /* This function declaration/definition was prototyped.  */
-
-               /* If the list of formal argument types ends with a
-                  void_type_node, then the formals list did *not* end
-                  with an ellipsis.  */
-
-               if (TREE_VALUE (tree_last (fn_arg_types)) == void_type_node)
-                 has_ellipsis = FALSE;
+             /* this is the prototyped case, check for ...  */
+             if (TREE_VALUE (tree_last (fn_arg_types)) != void_type_node)
+               output_die (output_unspecified_parameters_die, decl);
              }
            else
              {
-               /* This function declaration/definition was not prototyped.  */
-
-               /* Note that all non-prototyped function *declarations* are
-                  assumed to represent varargs functions (until proven
-                  otherwise).  */
-
-               if (DECL_INITIAL (decl)) /* if this is a func definition */
-                 {
-                   if (!arg_decls)
-                     has_ellipsis = FALSE; /* no args == (void) */
-                   else
-                     {
-                       /* For a non-prototyped function definition which
-                          declares one or more formal parameters, if the name
-                          of the first formal parameter is *not*
-                          __builtin_va_alist then we must assume that this
-                          is *not* a varargs function.  */
-
-                       if (DECL_NAME (arg_decls)
-                         && strcmp (IDENTIFIER_POINTER (DECL_NAME (arg_decls)),
-                                    "__builtin_va_alist"))
-                         has_ellipsis = FALSE;
-                     }
-                 }
+               /* this is unprototyped, check for undefined (just declaration) */
+               if (!DECL_INITIAL (decl))
+                 output_die (output_unspecified_parameters_die, decl);
              }
-
-           if (has_ellipsis)
-             output_die (output_unspecified_parameters_die, decl);
          }
-       }
-
-      /* Output Dwarf info for all of the stuff within the body of the
-        function (if it has one - it may be just a declaration).  */
 
-      {
-       register tree outer_scope = DECL_INITIAL (decl);
+         /* Output Dwarf info for all of the stuff within the body of the
+            function (if it has one - it may be just a declaration).  */
 
-       if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
          {
-           /* Note that here, `outer_scope' is a pointer to the outermost
-              BLOCK node created to represent a function.
-              This outermost BLOCK actually represents the outermost
-              binding contour for the function, i.e. the contour in which
-              the function's formal parameters and labels get declared.
-
-              Curiously, it appears that the front end doesn't actually
-              put the PARM_DECL nodes for the current function onto the
-              BLOCK_VARS list for this outer scope.  (They are strung
-              off of the DECL_ARGUMENTS list for the function instead.)
-              The BLOCK_VARS list for the `outer_scope' does provide us
-              with a list of the LABEL_DECL nodes for the function however,
-              and we output DWARF info for those here.
-
-              Just within the `outer_scope' there will be another BLOCK
-              node representing the function's outermost pair of curly
-              braces.  We musn't generate a lexical_block DIE for this
-              outermost pair of curly braces because that is not really an
-              independent scope according to ANSI C rules.  Rather, it is
-              the same scope in which the parameters were declared.  */
-
-           {
-             register tree label;
-
-             for (label = BLOCK_VARS (outer_scope);
-                  label;
-                  label = TREE_CHAIN (label))
-               output_decl (label, outer_scope);
-           }
-
-           /* Note here that `BLOCK_SUBBLOCKS (outer_scope)' points to a
-              list of BLOCK nodes which is always only one element long.
-              That one element represents the outermost pair of curley
-              braces for the function body.  */
+           tree outer_scope = DECL_INITIAL (decl);
 
-           output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope));
-
-           /* Finally, force out any pending types which are local to the
-              outermost block of this function definition.  These will
-              all have a TYPE_CONTEXT which points to the FUNCTION_DECL
-              node itself.  */
+           if (outer_scope && TREE_CODE (outer_scope) != ERROR_MARK)
+             {
+               /* Note that here, `outer_scope' is a pointer to the outermost
+                  BLOCK node created to represent a function.
+                  This outermost BLOCK actually represents the outermost
+                  binding contour for the function, i.e. the contour in which
+                  the function's formal parameters and labels get declared.
+
+                  Curiously, it appears that the front end doesn't actually
+                  put the PARM_DECL nodes for the current function onto the
+                  BLOCK_VARS list for this outer scope.  (They are strung
+                  off of the DECL_ARGUMENTS list for the function instead.)
+                  The BLOCK_VARS list for the `outer_scope' does provide us
+                  with a list of the LABEL_DECL nodes for the function however,
+                  and we output DWARF info for those here.
+
+                  Just within the `outer_scope' there will be a BLOCK node
+                  representing the function's outermost pair of curly braces,
+                  and any blocks used for the base and member initializers of
+                  a C++ constructor function.  */
+
+               output_decls_for_scope (outer_scope, 0);
+
+               /* Finally, force out any pending types which are local to the
+                  outermost block of this function definition.  These will
+                  all have a TYPE_CONTEXT which points to the FUNCTION_DECL
+                  node itself.  */
 
-           output_pending_types_for_scope (decl);
+               output_pending_types_for_scope (decl);
+             }
          }
-      }
+       }
 
       /* Generate a terminator for the list of stuff `owned' by this
         function.  */
@@ -4610,19 +5292,19 @@ output_decl (decl, containing_scope)
         a return type or a formal parameter type of some function.  */
 
       if (debug_info_level <= DINFO_LEVEL_TERSE)
-       if (DECL_NAME (decl) != NULL
-           || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
-          return;
+       if (! TYPE_DECL_IS_STUB (decl)
+           || (! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)) && ! in_class))
+         return;
 
-      /* In the special case of a null-named TYPE_DECL node (representing
-        the declaration of some type tag), if the given TYPE_DECL is
+      /* In the special case of a TYPE_DECL node representing
+        the declaration of some type tag, if the given TYPE_DECL is
         marked as having been instantiated from some other (original)
         TYPE_DECL node (e.g. one which was generated within the original
         definition of an inline function) we have to generate a special
         (abbreviated) TAG_structure_type, TAG_union_type, or
         TAG_enumeration-type DIE here.  */
 
-      if (! DECL_NAME (decl) && DECL_ABSTRACT_ORIGIN (decl))
+      if (TYPE_DECL_IS_STUB (decl) && DECL_ABSTRACT_ORIGIN (decl))
        {
          output_tagged_type_instantiation (TREE_TYPE (decl));
          return;
@@ -4630,16 +5312,7 @@ output_decl (decl, containing_scope)
 
       output_type (TREE_TYPE (decl), containing_scope);
 
-      /* Note that unlike the gcc front end (which generates a NULL named
-        TYPE_DECL node for each complete tagged type, each array type,
-        and each function type node created) the g++ front end generates
-        a *named* TYPE_DECL node for each tagged type node created.
-        Unfortunately, these g++ TYPE_DECL nodes cause us to output many
-        superfluous and unnecessary TAG_typedef DIEs here.  When g++ is
-        fixed to stop generating these superfluous named TYPE_DECL nodes,
-        the superfluous TAG_typedef DIEs will likewise cease.  */
-
-      if (DECL_NAME (decl))
+      if (! is_redundant_typedef (decl))
        /* Output a DIE to represent the typedef itself.  */
        output_die (output_typedef_die, decl);
       break;
@@ -4662,13 +5335,20 @@ output_decl (decl, containing_scope)
         any variable declarations or definitions.  */
 
       if (debug_info_level <= DINFO_LEVEL_TERSE)
-        break;
+       break;
 
       /* Output any DIEs that are needed to specify the type of this data
         object.  */
 
       output_type (TREE_TYPE (decl), containing_scope);
 
+      {
+       /* And its containing type.  */
+       register tree origin = decl_class_context (decl);
+       if (origin)
+         output_type (origin, containing_scope);
+      }
+
       /* If the following DIE will represent a data object definition for a
         data object with "extern" linkage, output a special "pubnames" DIE
         label just ahead of the actual DIE.  A reference to this label
@@ -4689,7 +5369,7 @@ output_decl (decl, containing_scope)
         function.  */
 
       {
-        register void (*func) ();
+       void (*func) (void *);
        register tree origin = decl_ultimate_origin (decl);
 
        if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
@@ -4710,13 +5390,13 @@ output_decl (decl, containing_scope)
       if (DECL_NAME (decl) != 0)
        {
          output_type (member_declared_type (decl), containing_scope);
-          output_die (output_member_die, decl);
+         output_die (output_member_die, decl);
        }
       break;
 
     case PARM_DECL:
      /* Force out the type of this formal, if it was not forced out yet.
-       Note that here we can run afowl of a bug in "classic" svr4 SDB.
+       Note that here we can run afoul of a bug in "classic" svr4 SDB.
        It should be able to grok the presence of type DIEs within a list
        of TAG_formal_parameter DIEs, but it doesn't.  */
 
@@ -4724,33 +5404,77 @@ output_decl (decl, containing_scope)
       output_die (output_formal_parameter_die, decl);
       break;
 
+    case NAMESPACE_DECL:
+      /* Ignore for now.  */
+      break;
+
     default:
       abort ();
     }
 }
 \f
-void
-dwarfout_file_scope_decl (decl, set_finalizing)
-     register tree decl;
-     register int set_finalizing;
+/* Output debug information for a function.  */
+static void
+dwarfout_function_decl (tree decl)
+{
+  dwarfout_file_scope_decl (decl, 0);
+}
+
+/* Debug information for a global DECL.  Called from toplev.c after
+   compilation proper has finished.  */
+static void
+dwarfout_global_decl (tree decl)
+{
+  /* Output DWARF information for file-scope tentative data object
+     declarations, file-scope (extern) function declarations (which
+     had no corresponding body) and file-scope tagged type
+     declarations and definitions which have not yet been forced out.  */
+
+  if (TREE_CODE (decl) != FUNCTION_DECL || !DECL_INITIAL (decl))
+    dwarfout_file_scope_decl (decl, 1);
+}
+
+/* DECL is an inline function, whose body is present, but which is not
+   being output at this point.  (We're putting that off until we need
+   to do it.)  */
+static void
+dwarfout_deferred_inline_function (tree decl)
+{
+  /* Generate the DWARF info for the "abstract" instance of a function
+     which we may later generate inlined and/or out-of-line instances
+     of.  */
+  if ((DECL_INLINE (decl) || DECL_ABSTRACT (decl))
+      && ! DECL_ABSTRACT_ORIGIN (decl))
+    {
+      /* The front-end may not have set CURRENT_FUNCTION_DECL, but the
+        DWARF code expects it to be set in this case.  Intuitively,
+        DECL is the function we just finished defining, so setting
+        CURRENT_FUNCTION_DECL is sensible.  */
+      tree saved_cfd = current_function_decl;
+      int was_abstract = DECL_ABSTRACT (decl);
+      current_function_decl = decl;
+
+      /* Let the DWARF code do its work.  */
+      set_decl_abstract_flags (decl, 1);
+      dwarfout_file_scope_decl (decl, 0);
+      if (! was_abstract)
+       set_decl_abstract_flags (decl, 0);
+
+      /* Reset CURRENT_FUNCTION_DECL.  */
+      current_function_decl = saved_cfd;
+    }
+}
+
+static void
+dwarfout_file_scope_decl (tree decl, int set_finalizing)
 {
   if (TREE_CODE (decl) == ERROR_MARK)
     return;
 
-  /* If this ..._DECL node is marked to be ignored, then ignore it.  We
-     gotta hope that the node in question doesn't represent a function
-     definition.  If it does, then totally ignoring it is bound to screw
-     up our count of blocks, and that it turn will completely screw up the
-     the labels we will reference in subsequent AT_low_pc and AT_high_pc
-     attributes (for subsequent blocks).  (It's too bad that BLOCK nodes
-     don't carry their own sequence numbers with them!)  */
+  /* If this ..._DECL node is marked to be ignored, then ignore it.  */
 
   if (DECL_IGNORED_P (decl))
-    {
-      if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
-       abort ();
-      return;
-    }
+    return;
 
   switch (TREE_CODE (decl))
     {
@@ -4761,17 +5485,17 @@ dwarfout_file_scope_decl (decl, set_finalizing)
         these same functions should NOT be ignored however.  */
 
       if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
-        return;
+       return;
 
       /* What we would really like to do here is to filter out all mere
         file-scope declarations of file-scope functions which are never
         referenced later within this translation unit (and keep all of
-        ones that *are* referenced later on) but we aren't clarvoiant,
+        ones that *are* referenced later on) but we aren't clairvoyant,
         so we have no idea which functions will be referenced in the
         future (i.e. later on within the current translation unit).
         So here we just ignore all file-scope function declarations
         which are not also definitions.  If and when the debugger needs
-        to know something about these funcstion, it wil have to hunt
+        to know something about these functions, it will have to hunt
         around and find the DWARF information associated with the
         *definition* of the function.
 
@@ -4786,7 +5510,7 @@ dwarfout_file_scope_decl (decl, set_finalizing)
         the compiler never generates any out-of-lines instances of such
         things (despite the fact that they *are* definitions).  The
         important point is that the C front-end marks these "extern inline"
-        functions as DECL_EXTERNAL, but we need to generate DWARf for them
+        functions as DECL_EXTERNAL, but we need to generate DWARF for them
         anyway.
 
         Note that the C++ front-end also plays some similar games for inline
@@ -4806,10 +5530,10 @@ dwarfout_file_scope_decl (decl, set_finalizing)
             defined in this compilation unit.  */
 
          fputc ('\n', asm_out_file);
-         ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
+         ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
          sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
          ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
-         ASM_OUTPUT_DWARF_STRING (asm_out_file,
+         ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                                   IDENTIFIER_POINTER (DECL_NAME (decl)));
          ASM_OUTPUT_POP_SECTION (asm_out_file);
        }
@@ -4844,10 +5568,10 @@ dwarfout_file_scope_decl (decl, set_finalizing)
                 defined in this compilation unit.  */
 
              fputc ('\n', asm_out_file);
-             ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
+             ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
              sprintf (label, PUB_DIE_LABEL_FMT, next_pubname_number);
              ASM_OUTPUT_DWARF_ADDR (asm_out_file, label);
-             ASM_OUTPUT_DWARF_STRING (asm_out_file,
+             ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
                                       IDENTIFIER_POINTER (DECL_NAME (decl)));
              ASM_OUTPUT_POP_SECTION (asm_out_file);
            }
@@ -4858,10 +5582,10 @@ dwarfout_file_scope_decl (decl, set_finalizing)
                 which is tentatively defined in this compilation unit.  */
 
              fputc ('\n', asm_out_file);
-             ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
+             ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
              ASM_OUTPUT_DWARF_ADDR (asm_out_file,
                              IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
-             ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 
+             ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
                        (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
              ASM_OUTPUT_POP_SECTION (asm_out_file);
            }
@@ -4871,7 +5595,7 @@ dwarfout_file_scope_decl (decl, set_finalizing)
         any variable declarations or definitions.  */
 
       if (debug_info_level <= DINFO_LEVEL_TERSE)
-        return;
+       return;
 
       break;
 
@@ -4880,14 +5604,24 @@ dwarfout_file_scope_decl (decl, set_finalizing)
         normal built-in types for the language we are compiling, except
         in cases where the types in question are *not* DWARF fundamental
         types.  We make an exception in the case of non-fundamental types
-        for the sake of objective C (and perhaps C++) because the GNU
+        for the sake of Objective-C (and perhaps C++) because the GNU
         front-ends for these languages may in fact create certain "built-in"
         types which are (for example) RECORD_TYPEs.  In such cases, we
         really need to output these (non-fundamental) types because other
         DIEs may contain references to them.  */
 
+      /* Also ignore language dependent types here, because they are probably
+        also built-in types.  If we didn't ignore them, then we would get
+        references to undefined labels because output_type doesn't support
+        them.   So, for now, we need to ignore them to avoid assembler
+        errors.  */
+
+      /* ??? This code is different than the equivalent code in dwarf2out.c.
+        The dwarf2out.c code is probably more correct.  */
+
       if (DECL_SOURCE_LINE (decl) == 0
-         && type_is_fundamental (TREE_TYPE (decl)))
+         && (type_is_fundamental (TREE_TYPE (decl))
+             || TREE_CODE (TREE_TYPE (decl)) == LANG_TYPE))
        return;
 
       /* If we are in terse mode, don't generate any DIEs to represent
@@ -4897,9 +5631,9 @@ dwarfout_file_scope_decl (decl, set_finalizing)
         a return type or a formal parameter type of some function.  */
 
       if (debug_info_level <= DINFO_LEVEL_TERSE)
-       if (DECL_NAME (decl) != NULL
+       if (! TYPE_DECL_IS_STUB (decl)
            || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
-          return;
+         return;
 
       break;
 
@@ -4925,26 +5659,30 @@ dwarfout_file_scope_decl (decl, set_finalizing)
 
   output_pending_types_for_scope (NULL_TREE);
 
-  /* The above call should have totally emptied the pending_types_list.  */
+  /* The above call should have totally emptied the pending_types_list
+     if this is not a nested function or class.  If this is a nested type,
+     then the remaining pending_types will be emitted when the containing type
+     is handled.  */
 
-  assert (pending_types == 0);
+  if (! DECL_CONTEXT (decl))
+    {
+      if (pending_types != 0)
+       abort ();
+    }
 
   ASM_OUTPUT_POP_SECTION (asm_out_file);
-
-  if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
-    current_funcdef_number++;
 }
 \f
 /* Output a marker (i.e. a label) for the beginning of the generated code
    for a lexical block.         */
 
-void
-dwarfout_begin_block (blocknum)
-     register unsigned blocknum;
+static void
+dwarfout_begin_block (unsigned int line ATTRIBUTE_UNUSED,
+                     unsigned int blocknum)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  text_section ();
+  function_section (current_function_decl);
   sprintf (label, BLOCK_BEGIN_LABEL_FMT, blocknum);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 }
@@ -4952,59 +5690,46 @@ dwarfout_begin_block (blocknum)
 /* Output a marker (i.e. a label) for the end of the generated code
    for a lexical block.         */
 
-void
-dwarfout_end_block (blocknum)
-     register unsigned blocknum;
+static void
+dwarfout_end_block (unsigned int line ATTRIBUTE_UNUSED, unsigned int blocknum)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  text_section ();
+  function_section (current_function_decl);
   sprintf (label, BLOCK_END_LABEL_FMT, blocknum);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 }
 
-/* Output a marker (i.e. a label) at a point in the assembly code which
-   corresponds to a given source level label.  */
-
-void
-dwarfout_label (insn)
-     register rtx insn;
-{
-  if (debug_info_level >= DINFO_LEVEL_NORMAL)
-    {
-      char label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-      text_section ();
-      sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
-                                     (unsigned) INSN_UID (insn));
-      ASM_OUTPUT_LABEL (asm_out_file, label);
-    }
-}
-
 /* Output a marker (i.e. a label) for the point in the generated code where
    the real body of the function begins (after parameters have been moved
    to their home locations).  */
 
-void
-dwarfout_begin_function ()
+static void
+dwarfout_end_prologue (unsigned int line ATTRIBUTE_UNUSED,
+                      const char *file ATTRIBUTE_UNUSED)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  text_section ();
-  sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
+  if (! use_gnu_debug_info_extensions)
+    return;
+
+  function_section (current_function_decl);
+  sprintf (label, BODY_BEGIN_LABEL_FMT, current_function_funcdef_no);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 }
 
 /* Output a marker (i.e. a label) for the point in the generated code where
    the real body of the function ends (just before the epilogue code).  */
 
-void
-dwarfout_end_function ()
+static void
+dwarfout_end_function (unsigned int line ATTRIBUTE_UNUSED)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  text_section ();
-  sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
+  if (! use_gnu_debug_info_extensions)
+    return;
+  function_section (current_function_decl);
+  sprintf (label, BODY_END_LABEL_FMT, current_function_funcdef_no);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 }
 
@@ -5012,25 +5737,25 @@ dwarfout_end_function ()
    for a function definition.  This gets called *after* the epilogue code
    has been generated. */
 
-void
-dwarfout_end_epilogue ()
+static void
+dwarfout_end_epilogue (unsigned int line ATTRIBUTE_UNUSED,
+                      const char *file ATTRIBUTE_UNUSED)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   /* Output a label to mark the endpoint of the code generated for this
      function. */
 
-  sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
+  sprintf (label, FUNC_END_LABEL_FMT, current_function_funcdef_no);
   ASM_OUTPUT_LABEL (asm_out_file, label);
 }
 
 static void
-shuffle_filename_entry (new_zeroth)
-     register filename_entry *new_zeroth;
+shuffle_filename_entry (filename_entry *new_zeroth)
 {
   filename_entry temp_entry;
-  register filename_entry *limit_p;
-  register filename_entry *move_p;
+  filename_entry *limit_p;
+  filename_entry *move_p;
 
   if (new_zeroth == &filename_table[0])
     return;
@@ -5051,18 +5776,18 @@ shuffle_filename_entry (new_zeroth)
 /* Create a new (string) entry for the .debug_sfnames section.  */
 
 static void
-generate_new_sfname_entry ()
+generate_new_sfname_entry (void)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SFNAMES_SECTION);
   sprintf (label, SFNAMES_ENTRY_LABEL_FMT, filename_table[0].number);
   ASM_OUTPUT_LABEL (asm_out_file, label);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file,
-                          filename_table[0].name
-                            ? filename_table[0].name
-                            : "");
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file,
+                                  filename_table[0].name
+                                  ? filename_table[0].name
+                                  : "");
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 }
 
@@ -5095,15 +5820,13 @@ generate_new_sfname_entry ()
    calculated, and where at least one of the two symbol references is a
    forward reference.  (This bug could be tickled by our .debug_srcinfo
    entries if we don't output their corresponding .debug_sfnames entries
-   before them.)
-*/
+   before them.) */
 
 static unsigned
-lookup_filename (file_name)
-     char *file_name;
+lookup_filename (const char *file_name)
 {
-  register filename_entry *search_p;
-  register filename_entry *limit_p = &filename_table[ft_entries];
+  filename_entry *search_p;
+  filename_entry *limit_p = &filename_table[ft_entries];
 
   for (search_p = filename_table; search_p < limit_p; search_p++)
     if (!strcmp (file_name, search_p->name))
@@ -5115,7 +5838,7 @@ lookup_filename (file_name)
           same filename will find it as quickly as possible.  */
 
        shuffle_filename_entry (search_p);
-        return filename_table[0].number;
+       return filename_table[0].number;
       }
 
   /* We come here whenever we have a new filename which is not registered
@@ -5128,8 +5851,7 @@ lookup_filename (file_name)
     {
       ft_entries_allocated += FT_ENTRIES_INCREMENT;
       filename_table
-       = (filename_entry *)
-         xrealloc (filename_table,
+       = xrealloc (filename_table,
                    ft_entries_allocated * sizeof (filename_entry));
     }
 
@@ -5150,14 +5872,12 @@ lookup_filename (file_name)
 }
 
 static void
-generate_srcinfo_entry (line_entry_num, files_entry_num)
-     unsigned line_entry_num;
-     unsigned files_entry_num;
+generate_srcinfo_entry (unsigned int line_entry_num, unsigned int files_entry_num)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
   sprintf (label, LINE_ENTRY_LABEL_FMT, line_entry_num);
   ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, LINE_BEGIN_LABEL);
   sprintf (label, SFNAMES_ENTRY_LABEL_FMT, files_entry_num);
@@ -5165,49 +5885,53 @@ generate_srcinfo_entry (line_entry_num, files_entry_num)
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 }
 
-void
-dwarfout_line (filename, line)
-     register char *filename;
-     register unsigned line;
+static void
+dwarfout_source_line (unsigned int line, const char *filename)
 {
-  if (debug_info_level >= DINFO_LEVEL_NORMAL)
+  if (debug_info_level >= DINFO_LEVEL_NORMAL
+      /* We can't emit line number info for functions in separate sections,
+        because the assembler can't subtract labels in different sections.  */
+      && DECL_SECTION_NAME (current_function_decl) == NULL_TREE)
     {
       char label[MAX_ARTIFICIAL_LABEL_BYTES];
       static unsigned last_line_entry_num = 0;
       static unsigned prev_file_entry_num = (unsigned) -1;
-      register unsigned this_file_entry_num = lookup_filename (filename);
+      unsigned this_file_entry_num;
 
-      text_section ();
+      function_section (current_function_decl);
       sprintf (label, LINE_CODE_LABEL_FMT, ++last_line_entry_num);
       ASM_OUTPUT_LABEL (asm_out_file, label);
 
       fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
 
+      if (use_gnu_debug_info_extensions)
+       this_file_entry_num = lookup_filename (filename);
+      else
+       this_file_entry_num = (unsigned) -1;
+
+      ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
       if (this_file_entry_num != prev_file_entry_num)
-        {
-          char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
+       {
+         char line_entry_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-          sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
-          ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
-        }
+         sprintf (line_entry_label, LINE_ENTRY_LABEL_FMT, last_line_entry_num);
+         ASM_OUTPUT_LABEL (asm_out_file, line_entry_label);
+       }
 
       {
-        register char *tail = rindex (filename, '/');
+       const char *tail = strrchr (filename, '/');
 
-        if (tail != NULL)
-          filename = tail;
+       if (tail != NULL)
+         filename = tail;
       }
 
-      fprintf (asm_out_file, "\t%s\t%u\t%s %s:%u\n",
-              UNALIGNED_INT_ASM_OP, line, ASM_COMMENT_START,
-              filename, line);
+      dw2_asm_output_data (4, line, "%s:%u", filename, line);
       ASM_OUTPUT_DWARF_DATA2 (asm_out_file, 0xffff);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, label, TEXT_BEGIN_LABEL);
       ASM_OUTPUT_POP_SECTION (asm_out_file);
 
       if (this_file_entry_num != prev_file_entry_num)
-        generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
+       generate_srcinfo_entry (last_line_entry_num, this_file_entry_num);
       prev_file_entry_num = this_file_entry_num;
     }
 }
@@ -5215,39 +5939,56 @@ dwarfout_line (filename, line)
 /* Generate an entry in the .debug_macinfo section.  */
 
 static void
-generate_macinfo_entry (type_and_offset, string)
-     register char *type_and_offset;
-     register char *string;
+generate_macinfo_entry (unsigned int type, rtx offset, const char *string)
 {
+  if (! use_gnu_debug_info_extensions)
+    return;
+
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
-  fprintf (asm_out_file, "\t%s\t%s\n", UNALIGNED_INT_ASM_OP, type_and_offset);
-  ASM_OUTPUT_DWARF_STRING (asm_out_file, string);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+  assemble_integer (gen_rtx_PLUS (SImode, GEN_INT (type << 24), offset),
+                   4, BITS_PER_UNIT, 1);
+  ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, string);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 }
 
-void
-dwarfout_start_new_source_file (filename)
-     register char *filename;
+/* Wrapper for toplev.c callback to check debug info level.  */
+static void
+dwarfout_start_source_file_check (unsigned int line, const char *filename)
+{
+  if (debug_info_level == DINFO_LEVEL_VERBOSE)
+    dwarfout_start_source_file (line, filename);
+}
+
+static void
+dwarfout_start_source_file (unsigned int line ATTRIBUTE_UNUSED,
+                           const char *filename)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
-  char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*3];
+  const char *label1, *label2;
 
   sprintf (label, SFNAMES_ENTRY_LABEL_FMT, lookup_filename (filename));
-  sprintf (type_and_offset, "0x%08x+%s-%s",
-          ((unsigned) MACINFO_start << 24), label, SFNAMES_BEGIN_LABEL);
-  generate_macinfo_entry (type_and_offset, "");
+  label1 = (*label == '*') + label;
+  label2 = (*SFNAMES_BEGIN_LABEL == '*') + SFNAMES_BEGIN_LABEL;
+  generate_macinfo_entry (MACINFO_start,
+                         gen_rtx_MINUS (Pmode,
+                                        gen_rtx_SYMBOL_REF (Pmode, label1),
+                                        gen_rtx_SYMBOL_REF (Pmode, label2)),
+                         "");
 }
 
-void
-dwarfout_resume_previous_source_file (lineno)
-     register unsigned lineno;
+/* Wrapper for toplev.c callback to check debug info level.  */
+static void
+dwarfout_end_source_file_check (unsigned int lineno)
 {
-  char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
+  if (debug_info_level == DINFO_LEVEL_VERBOSE)
+    dwarfout_end_source_file (lineno);
+}
 
-  sprintf (type_and_offset, "0x%08x+%u",
-          ((unsigned) MACINFO_resume << 24), lineno);
-  generate_macinfo_entry (type_and_offset, "");
+static void
+dwarfout_end_source_file (unsigned int lineno)
+{
+  generate_macinfo_entry (MACINFO_resume, GEN_INT (lineno), "");
 }
 
 /* Called from check_newline in c-parse.y.  The `buffer' parameter
@@ -5255,22 +5996,17 @@ dwarfout_resume_previous_source_file (lineno)
    is past the initial whitespace, #, whitespace, directive-name,
    whitespace part.  */
 
-void
-dwarfout_define (lineno, buffer)
-     register unsigned lineno;
-     register char *buffer;
+static void
+dwarfout_define (unsigned int lineno, const char *buffer)
 {
   static int initialized = 0;
-  char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
 
   if (!initialized)
     {
-      dwarfout_start_new_source_file (primary_filename);
+      dwarfout_start_source_file (0, primary_filename);
       initialized = 1;
     }
-  sprintf (type_and_offset, "0x%08x+%u",
-          ((unsigned) MACINFO_define << 24), lineno);
-  generate_macinfo_entry (type_and_offset, buffer);
+  generate_macinfo_entry (MACINFO_define, GEN_INT (lineno), buffer);
 }
 
 /* Called from check_newline in c-parse.y.  The `buffer' parameter
@@ -5278,25 +6014,19 @@ dwarfout_define (lineno, buffer)
    is past the initial whitespace, #, whitespace, directive-name,
    whitespace part.  */
 
-void
-dwarfout_undef (lineno, buffer)
-     register unsigned lineno;
-     register char *buffer;
+static void
+dwarfout_undef (unsigned int lineno, const char *buffer)
 {
-  char type_and_offset[MAX_ARTIFICIAL_LABEL_BYTES*2];
-
-  sprintf (type_and_offset, "0x%08x+%u",
-          ((unsigned) MACINFO_undef << 24), lineno);
-  generate_macinfo_entry (type_and_offset, buffer);
+  generate_macinfo_entry (MACINFO_undef, GEN_INT (lineno), buffer);
 }
 
 /* Set up for Dwarf output at the start of compilation.         */
 
-void
-dwarfout_init (asm_out_file, main_input_filename)
-     register FILE *asm_out_file;
-     register char *main_input_filename;
+static void
+dwarfout_init (const char *main_input_filename)
 {
+  warning ("support for the DWARF1 debugging format is deprecated");
+
   /* Remember the name of the primary input file.  */
 
   primary_filename = main_input_filename;
@@ -5304,23 +6034,19 @@ dwarfout_init (asm_out_file, main_input_filename)
   /* Allocate the initial hunk of the pending_sibling_stack.  */
 
   pending_sibling_stack
-    = (unsigned *)
-       xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
+    = xmalloc (PENDING_SIBLINGS_INCREMENT * sizeof (unsigned));
   pending_siblings_allocated = PENDING_SIBLINGS_INCREMENT;
   pending_siblings = 1;
 
   /* Allocate the initial hunk of the filename_table.  */
 
-  filename_table
-    = (filename_entry *)
-       xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
+  filename_table = xmalloc (FT_ENTRIES_INCREMENT * sizeof (filename_entry));
   ft_entries_allocated = FT_ENTRIES_INCREMENT;
   ft_entries = 0;
 
   /* Allocate the initial hunk of the pending_types_list.  */
 
-  pending_types_list
-    = (tree *) xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
+  pending_types_list = xmalloc (PENDING_TYPES_INCREMENT * sizeof (tree));
   pending_types_allocated = PENDING_TYPES_INCREMENT;
   pending_types = 0;
 
@@ -5333,14 +6059,14 @@ dwarfout_init (asm_out_file, main_input_filename)
   /* Output a starting label for the .text section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, TEXT_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   /* Output a starting label for the .data section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -5348,7 +6074,7 @@ dwarfout_init (asm_out_file, main_input_filename)
   /* Output a starting label for the .data1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -5356,7 +6082,7 @@ dwarfout_init (asm_out_file, main_input_filename)
   /* Output a starting label for the .rodata section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -5364,7 +6090,7 @@ dwarfout_init (asm_out_file, main_input_filename)
   /* Output a starting label for the .rodata1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -5372,85 +6098,92 @@ dwarfout_init (asm_out_file, main_input_filename)
   /* Output a starting label for the .bss section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, BSS_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   if (debug_info_level >= DINFO_LEVEL_NORMAL)
     {
-      /* Output a starting label and an initial (compilation directory)
-        entry for the .debug_sfnames section.  The starting label will be
-        referenced by the initial entry in the .debug_srcinfo section.  */
-    
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, SFNAMES_SECTION);
-      ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
-      {
-       register char *pwd;
-       register unsigned len;
-       register char *dirname;
-
-       pwd = getpwd ();
-       if (!pwd)
-         pfatal_with_name ("getpwd");
-       len = strlen (pwd);
-       dirname = (char *) xmalloc (len + 2);
-    
-       strcpy (dirname, pwd);
-       strcpy (dirname + len, "/");
-        ASM_OUTPUT_DWARF_STRING (asm_out_file, dirname);
-        free (dirname);
-      }
-      ASM_OUTPUT_POP_SECTION (asm_out_file);
-    
-      if (debug_info_level >= DINFO_LEVEL_VERBOSE)
+      if (use_gnu_debug_info_extensions)
        {
-          /* Output a starting label for the .debug_macinfo section.  This
+         /* Output a starting label and an initial (compilation directory)
+            entry for the .debug_sfnames section.  The starting label will be
+            referenced by the initial entry in the .debug_srcinfo section.  */
+
+         fputc ('\n', asm_out_file);
+         ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SFNAMES_SECTION);
+         ASM_OUTPUT_LABEL (asm_out_file, SFNAMES_BEGIN_LABEL);
+         {
+           const char *pwd = get_src_pwd ();
+           char *dirname;
+
+           if (!pwd)
+             fatal_error ("can't get current directory: %m");
+
+           dirname = concat (pwd, "/", NULL);
+           ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, dirname);
+           free (dirname);
+         }
+         ASM_OUTPUT_POP_SECTION (asm_out_file);
+       }
+
+      if (debug_info_level >= DINFO_LEVEL_VERBOSE
+         && use_gnu_debug_info_extensions)
+       {
+         /* Output a starting label for the .debug_macinfo section.  This
             label will be referenced by the AT_mac_info attribute in the
             TAG_compile_unit DIE.  */
-        
-          fputc ('\n', asm_out_file);
-          ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
-          ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
-          ASM_OUTPUT_POP_SECTION (asm_out_file);
+
+         fputc ('\n', asm_out_file);
+         ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
+         ASM_OUTPUT_LABEL (asm_out_file, MACINFO_BEGIN_LABEL);
+         ASM_OUTPUT_POP_SECTION (asm_out_file);
        }
 
       /* Generate the initial entry for the .line section.  */
-    
+
       fputc ('\n', asm_out_file);
       ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
       ASM_OUTPUT_LABEL (asm_out_file, LINE_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, LINE_END_LABEL, LINE_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
       ASM_OUTPUT_POP_SECTION (asm_out_file);
-    
-      /* Generate the initial entry for the .debug_srcinfo section.  */
-    
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
-      ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
-      ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
+
+      if (use_gnu_debug_info_extensions)
+       {
+         /* Generate the initial entry for the .debug_srcinfo section.  */
+
+         fputc ('\n', asm_out_file);
+         ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
+         ASM_OUTPUT_LABEL (asm_out_file, SRCINFO_BEGIN_LABEL);
+         ASM_OUTPUT_DWARF_ADDR (asm_out_file, LINE_BEGIN_LABEL);
+         ASM_OUTPUT_DWARF_ADDR (asm_out_file, SFNAMES_BEGIN_LABEL);
+         ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
+         ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_END_LABEL);
 #ifdef DWARF_TIMESTAMPS
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
+         ASM_OUTPUT_DWARF_DATA4 (asm_out_file, time (NULL));
 #else
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
+         ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
 #endif
-      ASM_OUTPUT_POP_SECTION (asm_out_file);
-    
+         ASM_OUTPUT_POP_SECTION (asm_out_file);
+       }
+
       /* Generate the initial entry for the .debug_pubnames section.  */
-    
+
       fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
+      ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
       ASM_OUTPUT_POP_SECTION (asm_out_file);
-    
+
       /* Generate the initial entry for the .debug_aranges section.  */
-    
+
       fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
+      ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
+      ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
+                              DEBUG_ARANGES_END_LABEL,
+                              DEBUG_ARANGES_BEGIN_LABEL);
+      ASM_OUTPUT_LABEL (asm_out_file, DEBUG_ARANGES_BEGIN_LABEL);
+      ASM_OUTPUT_DWARF_DATA1 (asm_out_file, 1);
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, DEBUG_BEGIN_LABEL);
       ASM_OUTPUT_POP_SECTION (asm_out_file);
     }
@@ -5467,7 +6200,7 @@ dwarfout_init (asm_out_file, main_input_filename)
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
   ASM_OUTPUT_LABEL (asm_out_file, DEBUG_BEGIN_LABEL);
-  output_die (output_compile_unit_die, main_input_filename);
+  output_die (output_compile_unit_die, (void *) main_input_filename);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   fputc ('\n', asm_out_file);
@@ -5475,13 +6208,15 @@ dwarfout_init (asm_out_file, main_input_filename)
 
 /* Output stuff that dwarf requires at the end of every file.  */
 
-void
-dwarfout_finish ()
+static void
+dwarfout_finish (const char *main_input_filename ATTRIBUTE_UNUSED)
 {
   char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
+  retry_incomplete_types ();
+  fputc ('\n', asm_out_file);
 
   /* Mark the end of the chain of siblings which represent all file-scope
      declarations in this compilation unit.  */
@@ -5510,7 +6245,7 @@ dwarfout_finish ()
      (or blame).  I didn't think of this scheme.  I just conformed to it.
   */
 
-  output_die (output_padded_null_die, (void *)0);
+  output_die (output_padded_null_die, (void *) 0);
   dienum_pop ();
 
   sprintf (label, DIE_BEGIN_LABEL_FMT, NEXT_DIE_NUM);
@@ -5520,14 +6255,14 @@ dwarfout_finish ()
   /* Output a terminator label for the .text section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, TEXT_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, TEXT_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   /* Output a terminator label for the .data section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -5535,7 +6270,7 @@ dwarfout_finish ()
   /* Output a terminator label for the .data1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -5543,7 +6278,7 @@ dwarfout_finish ()
   /* Output a terminator label for the .rodata section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
@@ -5551,7 +6286,7 @@ dwarfout_finish ()
   /* Output a terminator label for the .rodata1 section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 #endif
@@ -5559,14 +6294,14 @@ dwarfout_finish ()
   /* Output a terminator label for the .bss section.  */
 
   fputc ('\n', asm_out_file);
-  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION);
+  ASM_OUTPUT_PUSH_SECTION (asm_out_file, BSS_SECTION_NAME);
   ASM_OUTPUT_LABEL (asm_out_file, BSS_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
   if (debug_info_level >= DINFO_LEVEL_NORMAL)
     {
       /* Output a terminating entry for the .line section.  */
-    
+
       fputc ('\n', asm_out_file);
       ASM_OUTPUT_PUSH_SECTION (asm_out_file, LINE_SECTION);
       ASM_OUTPUT_LABEL (asm_out_file, LINE_LAST_ENTRY_LABEL);
@@ -5575,37 +6310,40 @@ dwarfout_finish ()
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
       ASM_OUTPUT_LABEL (asm_out_file, LINE_END_LABEL);
       ASM_OUTPUT_POP_SECTION (asm_out_file);
-    
-      /* Output a terminating entry for the .debug_srcinfo section.  */
-    
-      fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, SRCINFO_SECTION);
-      ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
-                              LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
-      ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
-      ASM_OUTPUT_POP_SECTION (asm_out_file);
+
+      if (use_gnu_debug_info_extensions)
+       {
+         /* Output a terminating entry for the .debug_srcinfo section.  */
+
+         fputc ('\n', asm_out_file);
+         ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SRCINFO_SECTION);
+         ASM_OUTPUT_DWARF_DELTA4 (asm_out_file,
+                                  LINE_LAST_ENTRY_LABEL, LINE_BEGIN_LABEL);
+         ASM_OUTPUT_DWARF_DATA4 (asm_out_file, -1);
+         ASM_OUTPUT_POP_SECTION (asm_out_file);
+       }
 
       if (debug_info_level >= DINFO_LEVEL_VERBOSE)
        {
          /* Output terminating entries for the .debug_macinfo section.  */
-       
-         dwarfout_resume_previous_source_file (0);
+
+         dwarfout_end_source_file (0);
 
          fputc ('\n', asm_out_file);
-         ASM_OUTPUT_PUSH_SECTION (asm_out_file, MACINFO_SECTION);
+         ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_MACINFO_SECTION);
          ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-         ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+         ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
          ASM_OUTPUT_POP_SECTION (asm_out_file);
        }
-    
+
       /* Generate the terminating entry for the .debug_pubnames section.  */
-    
+
       fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, PUBNAMES_SECTION);
+      ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_PUBNAMES_SECTION);
       ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
-      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+      ASM_OUTPUT_DWARF_STRING_NEWLINE (asm_out_file, "");
       ASM_OUTPUT_POP_SECTION (asm_out_file);
-    
+
       /* Generate the terminating entries for the .debug_aranges section.
 
         Note that we want to do this only *after* we have output the end
@@ -5619,9 +6357,9 @@ dwarfout_finish ()
         entries at this late point in the assembly output, we skirt the
         issue simply by avoiding forward-references.
       */
-    
+
       fputc ('\n', asm_out_file);
-      ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
+      ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_ARANGES_SECTION);
 
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, TEXT_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, TEXT_END_LABEL, TEXT_BEGIN_LABEL);
@@ -5651,8 +6389,15 @@ dwarfout_finish ()
       ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
       ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 0);
 
+      ASM_OUTPUT_LABEL (asm_out_file, DEBUG_ARANGES_END_LABEL);
       ASM_OUTPUT_POP_SECTION (asm_out_file);
     }
+
+  /* There should not be any pending types left at the end.  We need
+     this now because it may not have been checked on the last call to
+     dwarfout_file_scope_decl.  */
+  if (pending_types != 0)
+    abort ();
 }
 
 #endif /* DWARF_DEBUGGING_INFO */