OSDN Git Service

* pa.h (OVERRIDE_OPTIONS): Define. Give a warning if -fpic or
[pf3gnuchains/gcc-fork.git] / gcc / dwarfout.c
index 5a4d6fa..49339ae 100644 (file)
@@ -2,7 +2,7 @@
    Network Computing Devices, August, September, October, November 1990.
 
    Output Dwarf format symbol table information from the GNU C compiler.
-   Copyright (C) 1992 Free Software Foundation, Inc.
+   Copyright (C) 1992, 1993 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -28,12 +28,18 @@ the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.  */
 #include "tree.h"
 #include "flags.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>
+#include "assert.h"
 
 #if defined(DWARF_TIMESTAMPS)
 #if defined(POSIX)
@@ -48,15 +54,10 @@ extern time_t time ();
 #endif /* !defined(POSIX) */
 #endif /* defined(DWARF_TIMESTAMPS) */
 
-#if defined(USG) || defined(POSIX)
-#include <string.h>
-#else
-#include <strings.h>
-#define strrchr rindex
-#endif
-
-char *getpwd ();
+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.  */
@@ -80,12 +81,11 @@ char *getpwd ();
 #define ASM_COMMENT_START ";#"
 #endif
 
-/* Define a macro which, when given a pointer to some BLOCK node, returns
-   a pointer to the FUNCTION_DECL node from which the given BLOCK node
-   was instantiated (as an inline expansion).  This macro needs to be
-   defined properly in tree.h, however for the moment, we just fake it.  */
-
-#define BLOCK_INLINE_FUNCTION(block) 0
+/* How to print out a register name.  */
+#ifndef PRINT_REG
+#define PRINT_REG(RTX, CODE, FILE) \
+  fprintf ((FILE), "%s", reg_names[REGNO (RTX)])
+#endif
 
 /* Define a macro which returns non-zero for any tagged type which is
    used (directly or indirectly) in the specification of either some
@@ -104,13 +104,6 @@ char *getpwd ();
 
 #define TYPE_USED_FOR_FUNCTION(tagged_type) (TYPE_SIZE (tagged_type) == 0)
 
-#define BITFIELD_OFFSET_BITS(DECL) \
-  ((unsigned) TREE_INT_CST_LOW (DECL_FIELD_BITPOS (DECL)))
-#define BITFIELD_OFFSET_UNITS(DECL) \
-  (BITFIELD_OFFSET_BITS(DECL) / (unsigned) BITS_PER_UNIT)
-#define BITFIELD_OFFSET_WORDS_IN_UNITS(DECL) \
-  ((BITFIELD_OFFSET_BITS(DECL) / (unsigned) BITS_PER_WORD) * UNITS_PER_WORD)
-
 extern int flag_traditional;
 extern char *version_string;
 extern char *language_string;
@@ -250,7 +243,7 @@ static unsigned pending_siblings_allocated;
 #define PENDING_SIBLINGS_INCREMENT 64
 
 /* Non-zero if we are performing our file-scope finalization pass and if
-   we should force out Dwarf decsriptions of any and all file-scope
+   we should force out Dwarf descriptions of any and all file-scope
    tagged types which are still incomplete types.  */
 
 static int finalizing = 0;
@@ -275,11 +268,11 @@ static unsigned pending_types;
 
 #define PENDING_TYPES_INCREMENT 64
 
-/* Pointer to an artifical RECORD_TYPE which we create in dwarfout_init.
+/* 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
    parameters themselves.  That's necessary in order to be compatible
-   with what the brain-dammaged svr4 SDB debugger requires.  */
+   with what the brain-damaged svr4 SDB debugger requires.  */
 
 static tree fake_containing_scope;
 
@@ -291,6 +284,13 @@ static tree fake_containing_scope;
 
 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
+   declaration are.  */
+
+static tree dwarf_last_decl;
+
 /* Forward declarations for functions defined in this file.  */
 
 static void output_type ();
@@ -318,11 +318,11 @@ static unsigned lookup_filename ();
 #ifndef UNALIGNED_INT_ASM_OP
 #define UNALIGNED_INT_ASM_OP   ".4byte"
 #endif
-#ifndef DEF_ASM_OP
-#define DEF_ASM_OP             ".set"
-#endif
 #ifndef ASM_BYTE_OP
-#define ASM_BYTE_OP            "\t.byte"
+#define ASM_BYTE_OP            ".byte"
+#endif
+#ifndef SET_ASM_OP
+#define SET_ASM_OP             ".set"
 #endif
 
 /* Pseudo-ops for pushing the current section onto the section stack (and
@@ -330,14 +330,14 @@ static unsigned lookup_filename ();
    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
-   svr4 assembler might be an exception to this general rule.)  That's
+   svr4 assembler is an exception to this general rule.)  That's
    OK because we only use at most one level of the section stack herein.  */
 
 #ifndef PUSHSECTION_ASM_OP
-#define PUSHSECTION_ASM_OP     "\t.section"
+#define PUSHSECTION_ASM_OP     ".section"
 #endif
 #ifndef POPSECTION_ASM_OP
-#define POPSECTION_ASM_OP      "\t.previous"
+#define POPSECTION_ASM_OP      ".previous"
 #endif
 
 /* The default format used by the ASM_OUTPUT_PUSH_SECTION macro (see below)
@@ -394,156 +394,176 @@ static unsigned lookup_filename ();
    the -g options is used and DWARF_DEBUGGING_INFO is in effect.
 
    If necessary, these may be overridden from within your tm.h file,
-   but typically, you should never need to override these.  */
+   but typically, you should never need to override these.
+
+   These labels have been hacked (temporarily) so that they all begin with
+   a `.L' sequence so as to appease the stock sparc/svr4 assembler and the
+   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,
+   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       "._text_b"
+#define TEXT_BEGIN_LABEL       ".L_text_b"
 #endif
 #ifndef TEXT_END_LABEL
-#define TEXT_END_LABEL         "._text_e"
+#define TEXT_END_LABEL         ".L_text_e"
 #endif
 
 #ifndef DATA_BEGIN_LABEL
-#define DATA_BEGIN_LABEL       "._data_b"
+#define DATA_BEGIN_LABEL       ".L_data_b"
 #endif
 #ifndef DATA_END_LABEL
-#define DATA_END_LABEL         "._data_e"
+#define DATA_END_LABEL         ".L_data_e"
 #endif
 
 #ifndef DATA1_BEGIN_LABEL
-#define DATA1_BEGIN_LABEL      "._data1_b"
+#define DATA1_BEGIN_LABEL      ".L_data1_b"
 #endif
 #ifndef DATA1_END_LABEL
-#define DATA1_END_LABEL                "._data1_e"
+#define DATA1_END_LABEL                ".L_data1_e"
 #endif
 
 #ifndef RODATA_BEGIN_LABEL
-#define RODATA_BEGIN_LABEL     "._rodata_b"
+#define RODATA_BEGIN_LABEL     ".L_rodata_b"
 #endif
 #ifndef RODATA_END_LABEL
-#define RODATA_END_LABEL       "._rodata_e"
+#define RODATA_END_LABEL       ".L_rodata_e"
 #endif
 
 #ifndef RODATA1_BEGIN_LABEL
-#define RODATA1_BEGIN_LABEL    "._rodata1_b"
+#define RODATA1_BEGIN_LABEL    ".L_rodata1_b"
 #endif
 #ifndef RODATA1_END_LABEL
-#define RODATA1_END_LABEL      "._rodata1_e"
+#define RODATA1_END_LABEL      ".L_rodata1_e"
 #endif
 
 #ifndef BSS_BEGIN_LABEL
-#define BSS_BEGIN_LABEL                "._bss_b"
+#define BSS_BEGIN_LABEL                ".L_bss_b"
 #endif
 #ifndef BSS_END_LABEL
-#define BSS_END_LABEL          "._bss_e"
+#define BSS_END_LABEL          ".L_bss_e"
 #endif
 
 #ifndef LINE_BEGIN_LABEL
-#define LINE_BEGIN_LABEL       "._line_b"
+#define LINE_BEGIN_LABEL       ".L_line_b"
 #endif
 #ifndef LINE_LAST_ENTRY_LABEL
-#define LINE_LAST_ENTRY_LABEL  "._line_last"
+#define LINE_LAST_ENTRY_LABEL  ".L_line_last"
 #endif
 #ifndef LINE_END_LABEL
-#define LINE_END_LABEL         "._line_e"
+#define LINE_END_LABEL         ".L_line_e"
 #endif
 
 #ifndef DEBUG_BEGIN_LABEL
-#define DEBUG_BEGIN_LABEL      "._debug_b"
+#define DEBUG_BEGIN_LABEL      ".L_debug_b"
 #endif
 #ifndef SFNAMES_BEGIN_LABEL
-#define SFNAMES_BEGIN_LABEL    "._sfnames_b"
+#define SFNAMES_BEGIN_LABEL    ".L_sfnames_b"
 #endif
 #ifndef SRCINFO_BEGIN_LABEL
-#define SRCINFO_BEGIN_LABEL    "._srcinfo_b"
+#define SRCINFO_BEGIN_LABEL    ".L_srcinfo_b"
 #endif
 #ifndef MACINFO_BEGIN_LABEL
-#define MACINFO_BEGIN_LABEL    "._macinfo_b"
+#define MACINFO_BEGIN_LABEL    ".L_macinfo_b"
 #endif
 
 #ifndef DIE_BEGIN_LABEL_FMT
-#define DIE_BEGIN_LABEL_FMT    "._D%u"
+#define DIE_BEGIN_LABEL_FMT    ".L_D%u"
 #endif
 #ifndef DIE_END_LABEL_FMT
-#define DIE_END_LABEL_FMT      "._D%u_e"
+#define DIE_END_LABEL_FMT      ".L_D%u_e"
 #endif
 #ifndef PUB_DIE_LABEL_FMT
-#define PUB_DIE_LABEL_FMT      "._P%u"
+#define PUB_DIE_LABEL_FMT      ".L_P%u"
 #endif
 #ifndef INSN_LABEL_FMT
-#define INSN_LABEL_FMT         "._I%u_%u"
+#define INSN_LABEL_FMT         ".L_I%u_%u"
 #endif
 #ifndef BLOCK_BEGIN_LABEL_FMT
-#define BLOCK_BEGIN_LABEL_FMT  "._B%u"
+#define BLOCK_BEGIN_LABEL_FMT  ".L_B%u"
 #endif
 #ifndef BLOCK_END_LABEL_FMT
-#define BLOCK_END_LABEL_FMT    "._B%u_e"
+#define BLOCK_END_LABEL_FMT    ".L_B%u_e"
 #endif
 #ifndef SS_BEGIN_LABEL_FMT
-#define SS_BEGIN_LABEL_FMT     "._s%u"
+#define SS_BEGIN_LABEL_FMT     ".L_s%u"
 #endif
 #ifndef SS_END_LABEL_FMT
-#define SS_END_LABEL_FMT       "._s%u_e"
+#define SS_END_LABEL_FMT       ".L_s%u_e"
 #endif
 #ifndef EE_BEGIN_LABEL_FMT
-#define EE_BEGIN_LABEL_FMT     "._e%u"
+#define EE_BEGIN_LABEL_FMT     ".L_e%u"
 #endif
 #ifndef EE_END_LABEL_FMT
-#define EE_END_LABEL_FMT       "._e%u_e"
+#define EE_END_LABEL_FMT       ".L_e%u_e"
 #endif
 #ifndef MT_BEGIN_LABEL_FMT
-#define MT_BEGIN_LABEL_FMT     "._t%u"
+#define MT_BEGIN_LABEL_FMT     ".L_t%u"
 #endif
 #ifndef MT_END_LABEL_FMT
-#define MT_END_LABEL_FMT       "._t%u_e"
+#define MT_END_LABEL_FMT       ".L_t%u_e"
 #endif
 #ifndef LOC_BEGIN_LABEL_FMT
-#define LOC_BEGIN_LABEL_FMT    "._l%u"
+#define LOC_BEGIN_LABEL_FMT    ".L_l%u"
 #endif
 #ifndef LOC_END_LABEL_FMT
-#define LOC_END_LABEL_FMT      "._l%u_e"
+#define LOC_END_LABEL_FMT      ".L_l%u_e"
 #endif
 #ifndef BOUND_BEGIN_LABEL_FMT
-#define BOUND_BEGIN_LABEL_FMT  "._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    "._b%u_%u_%c_e"
+#define BOUND_END_LABEL_FMT    ".L_b%u_%u_%c_e"
 #endif
 #ifndef DERIV_BEGIN_LABEL_FMT
-#define DERIV_BEGIN_LABEL_FMT  "._d%u"
+#define DERIV_BEGIN_LABEL_FMT  ".L_d%u"
 #endif
 #ifndef DERIV_END_LABEL_FMT
-#define DERIV_END_LABEL_FMT    "._d%u_e"
+#define DERIV_END_LABEL_FMT    ".L_d%u_e"
 #endif
 #ifndef SL_BEGIN_LABEL_FMT
-#define SL_BEGIN_LABEL_FMT     "._sl%u"
+#define SL_BEGIN_LABEL_FMT     ".L_sl%u"
 #endif
 #ifndef SL_END_LABEL_FMT
-#define SL_END_LABEL_FMT       "._sl%u_e"
+#define SL_END_LABEL_FMT       ".L_sl%u_e"
+#endif
+#ifndef BODY_BEGIN_LABEL_FMT
+#define BODY_BEGIN_LABEL_FMT   ".L_b%u"
+#endif
+#ifndef BODY_END_LABEL_FMT
+#define BODY_END_LABEL_FMT     ".L_b%u_e"
 #endif
 #ifndef FUNC_END_LABEL_FMT
-#define FUNC_END_LABEL_FMT     "._f%u_e"
+#define FUNC_END_LABEL_FMT     ".L_f%u_e"
 #endif
 #ifndef TYPE_NAME_FMT
-#define TYPE_NAME_FMT          "._T%u"
+#define TYPE_NAME_FMT          ".L_T%u"
+#endif
+#ifndef DECL_NAME_FMT
+#define DECL_NAME_FMT          ".L_E%u"
 #endif
 #ifndef LINE_CODE_LABEL_FMT
-#define LINE_CODE_LABEL_FMT    "._LC%u"
+#define LINE_CODE_LABEL_FMT    ".L_LC%u"
 #endif
 #ifndef SFNAMES_ENTRY_LABEL_FMT
-#define SFNAMES_ENTRY_LABEL_FMT        "._F%u"
+#define SFNAMES_ENTRY_LABEL_FMT        ".L_F%u"
 #endif
 #ifndef LINE_ENTRY_LABEL_FMT
-#define LINE_ENTRY_LABEL_FMT   "._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.  Two known
-   exceptions are the ASM_OUTPUT_PUSH_SECTION and ASM_OUTPUT_POP_SECTION
-   definitions, which need to be somewhat special for a sparc running svr4.
+   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.
 */
 
 #ifndef ASM_OUTPUT_PUSH_SECTION
@@ -553,7 +573,7 @@ static unsigned lookup_filename ();
 
 #ifndef ASM_OUTPUT_POP_SECTION
 #define ASM_OUTPUT_POP_SECTION(FILE) \
-  fprintf ((FILE), "%s\n", POPSECTION_ASM_OP)
+  fprintf ((FILE), "\t%s\n", POPSECTION_ASM_OP)
 #endif
 
 #ifndef ASM_OUTPUT_SOURCE_FILENAME
@@ -563,7 +583,7 @@ static unsigned lookup_filename ();
 
 #ifndef ASM_OUTPUT_DEF
 #define ASM_OUTPUT_DEF(FILE,LABEL1,LABEL2)                             \
- do {  fprintf ((FILE), "\t%s\t", DEF_ASM_OP);                         \
+ do {  fprintf ((FILE), "\t%s\t", SET_ASM_OP);                         \
        assemble_name (FILE, LABEL1);                                   \
        fprintf (FILE, ",");                                            \
        assemble_name (FILE, LABEL2);                                   \
@@ -593,38 +613,71 @@ static unsigned lookup_filename ();
 
 #ifndef ASM_OUTPUT_DWARF_TAG
 #define ASM_OUTPUT_DWARF_TAG(FILE,TAG)                                 \
-  fprintf ((FILE), "\t%s\t0x%x\t%s %s\n", UNALIGNED_SHORT_ASM_OP,      \
-       (unsigned) TAG, ASM_COMMENT_START, tag_name (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)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_ATTRIBUTE
-#define ASM_OUTPUT_DWARF_ATTRIBUTE(FILE,ATTRIBUTE)                     \
-  fprintf ((FILE), "\t%s\t0x%x\t%s %s\n", UNALIGNED_SHORT_ASM_OP,      \
-       (unsigned) ATTRIBUTE, ASM_COMMENT_START, attribute_name (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)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_STACK_OP
 #define ASM_OUTPUT_DWARF_STACK_OP(FILE,OP)                             \
-  fprintf ((FILE), "%s\t0x%x\t%s %s\n", ASM_BYTE_OP,                   \
-       (unsigned) OP, ASM_COMMENT_START, stack_op_name (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)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_FUND_TYPE
 #define ASM_OUTPUT_DWARF_FUND_TYPE(FILE,FT)                            \
-  fprintf ((FILE), "\t%s\t0x%x\t%s %s\n", UNALIGNED_SHORT_ASM_OP,      \
-       (unsigned) FT, ASM_COMMENT_START, fundamental_type_name (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)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_FMT_BYTE
 #define ASM_OUTPUT_DWARF_FMT_BYTE(FILE,FMT)                            \
-  fprintf ((FILE), "%s\t0x%x\t%s %s\n", ASM_BYTE_OP,                   \
-       (unsigned) FMT, ASM_COMMENT_START, format_byte_name (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)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_TYPE_MODIFIER
 #define ASM_OUTPUT_DWARF_TYPE_MODIFIER(FILE,MOD)                       \
-  fprintf ((FILE), "%s\t0x%x\t%s %s\n", ASM_BYTE_OP,                   \
-       (unsigned) MOD, ASM_COMMENT_START, modifier_name (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)
 #endif
 \f
 #ifndef ASM_OUTPUT_DWARF_ADDR
@@ -637,9 +690,11 @@ static unsigned lookup_filename ();
 
 #ifndef ASM_OUTPUT_DWARF_ADDR_CONST
 #define ASM_OUTPUT_DWARF_ADDR_CONST(FILE,RTX)                          \
-  fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);                    \
-  output_addr_const ((FILE), (RTX));                                   \
-  fputc ('\n', (FILE))
+  do {                                                                 \
+    fprintf ((FILE), "\t%s\t", UNALIGNED_INT_ASM_OP);                  \
+    output_addr_const ((FILE), (RTX));                                 \
+    fputc ('\n', (FILE));                                              \
+  } while (0)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_REF
@@ -652,7 +707,7 @@ static unsigned lookup_filename ();
 
 #ifndef ASM_OUTPUT_DWARF_DATA1
 #define ASM_OUTPUT_DWARF_DATA1(FILE,VALUE) \
-  fprintf ((FILE), "%s\t0x%x\n", ASM_BYTE_OP, VALUE)
+  fprintf ((FILE), "\t%s\t0x%x\n", ASM_BYTE_OP, VALUE)
 #endif
 
 #ifndef ASM_OUTPUT_DWARF_DATA2
@@ -681,49 +736,6 @@ static unsigned lookup_filename ();
   } while (0)
 #endif
 
-/* choose a reasonable default for ASM_OUTPUT_ASCII, as that is what
-   varasm.c does.  If the below is changed, please also change
-   definition in varasm.c Both of these should be factored out, into a
-   higher layer.  */
-#ifndef ASM_OUTPUT_ASCII
-#define ASM_OUTPUT_ASCII(MYFILE, MYSTRING, MYLENGTH) \
-  do {                                                                       \
-    FILE *_hide_asm_out_file = MYFILE;                                       \
-    char *_hide_p = MYSTRING;                                                \
-    int _hide_thissize = MYLENGTH;                                           \
-    {                                                                        \
-      FILE *asm_out_file = _hide_asm_out_file;                               \
-      char *p = _hide_p;                                                     \
-      int thissize = _hide_thissize;                                         \
-      int i;                                                                 \
-      fprintf (asm_out_file, "\t.ascii \"");                                 \
-                                                                             \
-      for (i = 0; i < thissize; i++)                                         \
-       {                                                                     \
-         register int c = p[i];                                              \
-         if (c == '\"' || c == '\\')                                         \
-           putc ('\\', asm_out_file);                                        \
-         if (c >= ' ' && c < 0177)                                           \
-           putc (c, asm_out_file);                                           \
-         else                                                                \
-           {                                                                 \
-             fprintf (asm_out_file, "\\%o", c);                              \
-             /* After an octal-escape, if a digit follows,                   \
-                terminate one string constant and start another.             \
-                The Vax assembler fails to stop reading the escape           \
-                after three digits, so this is the only way we               \
-                can get it to parse the data properly.  */                   \
-             if (i < thissize - 1                                            \
-                 && p[i + 1] >= '0' && p[i + 1] <= '9')                      \
-               fprintf (asm_out_file, "\"\n\t.ascii \"");                    \
-         }                                                                   \
-       }                                                                     \
-      fprintf (asm_out_file, "\"\n");                                        \
-    }                                                                        \
-  }                                                                          \
-  while (0)
-#endif
-
 #ifndef ASM_OUTPUT_DWARF_STRING
 #define ASM_OUTPUT_DWARF_STRING(FILE,P) \
   ASM_OUTPUT_ASCII ((FILE), P, strlen (P)+1)
@@ -741,88 +753,177 @@ xstrdup (s)
   return p;
 }
 
+inline int
+is_pseudo_reg (rtl)
+     register rtx rtl;
+{
+  return (((GET_CODE (rtl) == REG) && (REGNO (rtl) >= FIRST_PSEUDO_REGISTER))
+          || ((GET_CODE (rtl) == SUBREG)
+             && (REGNO (XEXP (rtl, 0)) >= FIRST_PSEUDO_REGISTER)));
+}
+
+inline tree
+type_main_variant (type)
+     register tree type;
+{
+  type = TYPE_MAIN_VARIANT (type);
+
+  /* There really should be only one main variant among any group of variants
+     of a given type (and all of the MAIN_VARIANT values for all members of
+     the group should point to that one type) but sometimes the C front-end
+     messes this up for array types, so we work around that bug here.  */
+
+  if (TREE_CODE (type) == ARRAY_TYPE)
+    {
+      while (type != TYPE_MAIN_VARIANT (type))
+        type = TYPE_MAIN_VARIANT (type);
+    }
+
+  return type;
+}
+
+/* Return non-zero if the given type node represents a tagged type.  */
+
+inline int
+is_tagged_type (type)
+     register tree type;
+{
+  register enum tree_code code = TREE_CODE (type);
+
+  return (code == RECORD_TYPE || code == UNION_TYPE
+         || code == QUAL_UNION_TYPE || code == ENUMERAL_TYPE);
+}
+
 static char *
-tag_name (tag)
+dwarf_tag_name (tag)
      register unsigned tag;
 {
   switch (tag)
     {
-    case TAG_padding:          return "TAG_padding";
-    case TAG_array_type:       return "TAG_array_type";
-    case TAG_class_type:       return "TAG_class_type";
-    case TAG_entry_point:      return "TAG_entry_point";
-    case TAG_enumeration_type: return "TAG_enumeration_type";
-    case TAG_formal_parameter: return "TAG_formal_parameter";
-    case TAG_global_subroutine:        return "TAG_global_subroutine";
-    case TAG_global_variable:  return "TAG_global_variable";
-    case TAG_imported_declaration:     return "TAG_imported_declaration";
-    case TAG_label:            return "TAG_label";
-    case TAG_lexical_block:    return "TAG_lexical_block";
-    case TAG_local_variable:   return "TAG_local_variable";
-    case TAG_member:           return "TAG_member";
-    case TAG_pointer_type:     return "TAG_pointer_type";
-    case TAG_reference_type:   return "TAG_reference_type";
-    case TAG_compile_unit:     return "TAG_compile_unit";
-    case TAG_string_type:      return "TAG_string_type";
-    case TAG_structure_type:   return "TAG_structure_type";
-    case TAG_subroutine:       return "TAG_subroutine";
-    case TAG_subroutine_type:  return "TAG_subroutine_type";
-    case TAG_typedef:          return "TAG_typedef";
-    case TAG_union_type:       return "TAG_union_type";
+    case TAG_padding:                  return "TAG_padding";
+    case TAG_array_type:               return "TAG_array_type";
+    case TAG_class_type:               return "TAG_class_type";
+    case TAG_entry_point:              return "TAG_entry_point";
+    case TAG_enumeration_type:         return "TAG_enumeration_type";
+    case TAG_formal_parameter:         return "TAG_formal_parameter";
+    case TAG_global_subroutine:                return "TAG_global_subroutine";
+    case TAG_global_variable:          return "TAG_global_variable";
+    case TAG_label:                    return "TAG_label";
+    case TAG_lexical_block:            return "TAG_lexical_block";
+    case TAG_local_variable:           return "TAG_local_variable";
+    case TAG_member:                   return "TAG_member";
+    case TAG_pointer_type:             return "TAG_pointer_type";
+    case TAG_reference_type:           return "TAG_reference_type";
+    case TAG_compile_unit:             return "TAG_compile_unit";
+    case TAG_string_type:              return "TAG_string_type";
+    case TAG_structure_type:           return "TAG_structure_type";
+    case TAG_subroutine:               return "TAG_subroutine";
+    case TAG_subroutine_type:          return "TAG_subroutine_type";
+    case TAG_typedef:                  return "TAG_typedef";
+    case TAG_union_type:               return "TAG_union_type";
     case TAG_unspecified_parameters:   return "TAG_unspecified_parameters";
-    case TAG_variant:          return "TAG_variant";
-    case TAG_format:           return "TAG_format";
-    case TAG_with_stmt:                return "TAG_with_stmt";
-    case TAG_set_type:         return "TAG_set_type";
-    default:                   return "<unknown tag>";
+    case TAG_variant:                  return "TAG_variant";
+    case TAG_common_block:             return "TAG_common_block";
+    case TAG_common_inclusion:         return "TAG_common_inclusion";
+    case TAG_inheritance:              return "TAG_inheritance";
+    case TAG_inlined_subroutine:       return "TAG_inlined_subroutine";
+    case TAG_module:                   return "TAG_module";
+    case TAG_ptr_to_member_type:       return "TAG_ptr_to_member_type";
+    case TAG_set_type:                 return "TAG_set_type";
+    case TAG_subrange_type:            return "TAG_subrange_type";
+    case TAG_with_stmt:                        return "TAG_with_stmt";
+
+    /* GNU extensions.  */
+
+    case TAG_format_label:             return "TAG_format_label";
+    case TAG_namelist:                 return "TAG_namelist";
+    case TAG_function_template:                return "TAG_function_template";
+    case TAG_class_template:           return "TAG_class_template";
+
+    default:                           return "TAG_<unknown>";
     }
 }
 
 static char *
-attribute_name (attr)
+dwarf_attr_name (attr)
      register unsigned attr;
 {
   switch (attr)
     {
-    case AT_sibling:           return "AT_sibling";
-    case AT_location:          return "AT_location";
-    case AT_name:              return "AT_name";
-    case AT_fund_type:         return "AT_fund_type";
-    case AT_mod_fund_type:     return "AT_mod_fund_type";
-    case AT_user_def_type:     return "AT_user_def_type";
-    case AT_mod_u_d_type:      return "AT_mod_u_d_type";
-    case AT_ordering:          return "AT_ordering";
-    case AT_subscr_data:       return "AT_subscr_data";
-    case AT_byte_size:         return "AT_byte_size";
-    case AT_bit_offset:                return "AT_bit_offset";
-    case AT_bit_size:          return "AT_bit_size";
-    case AT_element_list:      return "AT_element_list";
-    case AT_stmt_list:         return "AT_stmt_list";
-    case AT_low_pc:            return "AT_low_pc";
-    case AT_high_pc:           return "AT_high_pc";
-    case AT_language:          return "AT_language";
-    case AT_member:            return "AT_member";
-    case AT_discr:             return "AT_discr";
-    case AT_discr_value:       return "AT_discr_value";
-    case AT_visibility:                return "AT_visibility";
-    case AT_import:            return "AT_import";
-    case AT_string_length:     return "AT_string_length";
-    case AT_comp_dir:          return "AT_comp_dir";
-    case AT_producer:          return "AT_producer";
-    case AT_frame_base:                return "AT_frame_base";
-    case AT_start_scope:       return "AT_start_scope";
-    case AT_stride_size:       return "AT_stride_size";
-    case AT_src_info:          return "AT_src_info";
-    case AT_prototyped:                return "AT_prototyped";
+    case AT_sibling:                   return "AT_sibling";
+    case AT_location:                  return "AT_location";
+    case AT_name:                      return "AT_name";
+    case AT_fund_type:                 return "AT_fund_type";
+    case AT_mod_fund_type:             return "AT_mod_fund_type";
+    case AT_user_def_type:             return "AT_user_def_type";
+    case AT_mod_u_d_type:              return "AT_mod_u_d_type";
+    case AT_ordering:                  return "AT_ordering";
+    case AT_subscr_data:               return "AT_subscr_data";
+    case AT_byte_size:                 return "AT_byte_size";
+    case AT_bit_offset:                        return "AT_bit_offset";
+    case AT_bit_size:                  return "AT_bit_size";
+    case AT_element_list:              return "AT_element_list";
+    case AT_stmt_list:                 return "AT_stmt_list";
+    case AT_low_pc:                    return "AT_low_pc";
+    case AT_high_pc:                   return "AT_high_pc";
+    case AT_language:                  return "AT_language";
+    case AT_member:                    return "AT_member";
+    case AT_discr:                     return "AT_discr";
+    case AT_discr_value:               return "AT_discr_value";
+    case AT_string_length:             return "AT_string_length";
+    case AT_common_reference:          return "AT_common_reference";
+    case AT_comp_dir:                  return "AT_comp_dir";
+    case AT_const_value_string:                return "AT_const_value_string";
+    case AT_const_value_data2:         return "AT_const_value_data2";
+    case AT_const_value_data4:         return "AT_const_value_data4";
+    case AT_const_value_data8:         return "AT_const_value_data8";
+    case AT_const_value_block2:                return "AT_const_value_block2";
     case AT_const_value_block4:                return "AT_const_value_block4";
-    case AT_sf_names:          return "AT_sf_names";
-    case AT_mac_info:          return "AT_mac_info";
-    default:                   return "<unknown attribute>";
+    case AT_containing_type:           return "AT_containing_type";
+    case AT_default_value_addr:                return "AT_default_value_addr";
+    case AT_default_value_data2:       return "AT_default_value_data2";
+    case AT_default_value_data4:       return "AT_default_value_data4";
+    case AT_default_value_data8:       return "AT_default_value_data8";
+    case AT_default_value_string:      return "AT_default_value_string";
+    case AT_friends:                   return "AT_friends";
+    case AT_inline:                    return "AT_inline";
+    case AT_is_optional:               return "AT_is_optional";
+    case AT_lower_bound_ref:           return "AT_lower_bound_ref";
+    case AT_lower_bound_data2:         return "AT_lower_bound_data2";
+    case AT_lower_bound_data4:         return "AT_lower_bound_data4";
+    case AT_lower_bound_data8:         return "AT_lower_bound_data8";
+    case AT_private:                   return "AT_private";
+    case AT_producer:                  return "AT_producer";
+    case AT_program:                   return "AT_program";
+    case AT_protected:                 return "AT_protected";
+    case AT_prototyped:                        return "AT_prototyped";
+    case AT_public:                    return "AT_public";
+    case AT_pure_virtual:              return "AT_pure_virtual";
+    case AT_return_addr:               return "AT_return_addr";
+    case AT_abstract_origin:           return "AT_abstract_origin";
+    case AT_start_scope:               return "AT_start_scope";
+    case AT_stride_size:               return "AT_stride_size";
+    case AT_upper_bound_ref:           return "AT_upper_bound_ref";
+    case AT_upper_bound_data2:         return "AT_upper_bound_data2";
+    case AT_upper_bound_data4:         return "AT_upper_bound_data4";
+    case AT_upper_bound_data8:         return "AT_upper_bound_data8";
+    case AT_virtual:                   return "AT_virtual";
+
+    /* GNU extensions */
+
+    case AT_sf_names:                  return "AT_sf_names";
+    case AT_src_info:                  return "AT_src_info";
+    case AT_mac_info:                  return "AT_mac_info";
+    case AT_src_coords:                        return "AT_src_coords";
+    case AT_body_begin:                        return "AT_body_begin";
+    case AT_body_end:                  return "AT_body_end";
+
+    default:                           return "AT_<unknown>";
     }
 }
 
 static char *
-stack_op_name (op)
+dwarf_stack_op_name (op)
      register unsigned op;
 {
   switch (op)
@@ -834,12 +935,12 @@ stack_op_name (op)
     case OP_DEREF2:            return "OP_DEREF2";
     case OP_DEREF4:            return "OP_DEREF4";
     case OP_ADD:               return "OP_ADD";
-    default:                   return "<unknown stack operator>";
+    default:                   return "OP_<unknown>";
     }
 }
 
 static char *
-modifier_name (mod)
+dwarf_typemod_name (mod)
      register unsigned mod;
 {
   switch (mod)
@@ -848,12 +949,12 @@ modifier_name (mod)
     case MOD_reference_to:     return "MOD_reference_to";
     case MOD_const:            return "MOD_const";
     case MOD_volatile:         return "MOD_volatile";
-    default:                   return "<unknown modifier>";
+    default:                   return "MOD_<unknown>";
     }
 }
 
 static char *
-format_byte_name (fmt)
+dwarf_fmt_byte_name (fmt)
      register unsigned fmt;
 {
   switch (fmt)
@@ -867,11 +968,11 @@ format_byte_name (fmt)
     case FMT_UT_X_C:   return "FMT_UT_X_C";
     case FMT_UT_X_X:   return "FMT_UT_X_X";
     case FMT_ET:       return "FMT_ET";
-    default:           return "<unknown array bound format byte>";
+    default:           return "FMT_<unknown>";
     }
 }
 static char *
-fundamental_type_name (ft)
+dwarf_fund_type_name (ft)
      register unsigned ft;
 {
   switch (ft)
@@ -896,15 +997,184 @@ fundamental_type_name (ft)
     case FT_dbl_prec_complex:  return "FT_dbl_prec_complex";
     case FT_void:              return "FT_void";
     case FT_boolean:           return "FT_boolean";
+    case FT_ext_prec_complex:  return "FT_ext_prec_complex";
+    case FT_label:             return "FT_label";
+
+    /* GNU extensions.  */
+
     case FT_long_long:         return "FT_long_long";
     case FT_signed_long_long:  return "FT_signed_long_long";
     case FT_unsigned_long_long: return "FT_unsigned_long_long";
-    default:                   return "<unknown fundamental type>";
+
+    case FT_int8:              return "FT_int8";
+    case FT_signed_int8:       return "FT_signed_int8";
+    case FT_unsigned_int8:     return "FT_unsigned_int8";
+    case FT_int16:             return "FT_int16";
+    case FT_signed_int16:      return "FT_signed_int16";
+    case FT_unsigned_int16:    return "FT_unsigned_int16";
+    case FT_int32:             return "FT_int32";
+    case FT_signed_int32:      return "FT_signed_int32";
+    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_real32:            return "FT_real32";
+    case FT_real64:            return "FT_real64";
+    case FT_real96:            return "FT_real96";
+    case FT_real128:           return "FT_real128";
+
+    default:                   return "FT_<unknown>";
+    }
+}
+
+/* Determine the "ultimate origin" of a decl.  The decl may be an
+   inlined instance of an inlined instance of a decl which is local
+   to an inline function, so we have to trace all of the way back
+   through the origin chain to find out what sort of node actually
+   served as the original seed for the given block.  */
+
+static tree
+decl_ultimate_origin (decl)
+     register 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;
+
+      do
+       {
+         ret_val = lookahead;
+         lookahead = DECL_ABSTRACT_ORIGIN (ret_val);
+       }
+      while (lookahead != NULL && lookahead != ret_val);
+      return ret_val;
+    }
+}
+
+/* Determine the "ultimate origin" of a block.  The block may be an
+   inlined instance of an inlined instance of a block which is local
+   to an inline function, so we have to trace all of the way back
+   through the origin chain to find out what sort of node actually
+   served as the original seed for the given block.  */
+
+static tree
+block_ultimate_origin (block)
+     register tree block;
+{
+  register tree immediate_origin = BLOCK_ABSTRACT_ORIGIN (block);
+
+  if (immediate_origin == NULL)
+    return NULL;
+  else
+    {
+      register tree ret_val;
+      register tree lookahead = immediate_origin;
+
+      do
+       {
+         ret_val = lookahead;
+         lookahead = (TREE_CODE (ret_val) == BLOCK)
+                      ? BLOCK_ABSTRACT_ORIGIN (ret_val)
+                      : NULL;
+       }
+      while (lookahead != NULL && lookahead != ret_val);
+      return ret_val;
+    }
+}
+
+static void
+output_unsigned_leb128 (value)
+     register unsigned long value;
+{
+  register unsigned long orig_value = value;
+
+  do
+    {
+      register 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);
+    }
+  while (value != 0);
+}
+
+static void
+output_signed_leb128 (value)
+     register long value;
+{
+  register long orig_value = value;
+  register int negative = (value < 0);
+  register int more;
+
+  do
+    {
+      register unsigned byte = (value & 0x7f);
+
+      value >>= 7;
+      if (negative)
+       value |= 0xfe000000;  /* manually sign extend */
+      if (((value == 0) && ((byte & 0x40) == 0))
+          || ((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);
     }
+  while (more);
 }
 \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.
 
@@ -913,14 +1183,14 @@ fundamental_type_name (ft)
 
    The current Dwarf draft specification calls for Dwarf fundamental types
    to accurately reflect the fact that a given type was either a "plain"
-   integral type or an explicitly "signed" integral type.  Unfortuantely,
+   integral type or an explicitly "signed" integral type.  Unfortunately,
    we can't always do this, because GCC may already have thrown away the
    information about the precise way in which the type was originally
    specified, as in:
 
-       typedef signed int field_type;
+       typedef signed int my_type;
 
-       struct s { field_type f; };
+       struct s { my_type f; };
 
    Since we may be stuck here without enought information to do exactly
    what is called for in the Dwarf draft specification, we do the best
@@ -1067,10 +1337,10 @@ root_type (type)
 
       case POINTER_TYPE:
       case REFERENCE_TYPE:
-       return TYPE_MAIN_VARIANT (root_type (TREE_TYPE (type)));
+       return type_main_variant (root_type (TREE_TYPE (type)));
 
       default:
-       return TYPE_MAIN_VARIANT (type);
+       return type_main_variant (type);
     }
 }
 
@@ -1130,6 +1400,7 @@ type_is_fundamental (type)
       case ARRAY_TYPE:
       case RECORD_TYPE:
       case UNION_TYPE:
+      case QUAL_UNION_TYPE:
       case ENUMERAL_TYPE:
       case FUNCTION_TYPE:
       case METHOD_TYPE:
@@ -1147,9 +1418,40 @@ type_is_fundamental (type)
   return 0;
 }
 
+/* Given a pointer to some ..._DECL tree node, generate an assembly language
+   equate directive which will associate a symbolic name with the current DIE.
+
+   The name used is an artificial label generated from the DECL_UID number
+   associated with the given decl node.  The name it gets equated to is the
+   symbolic label that we (previously) output at the start of the DIE that
+   we are currently generating.
+
+   Calling this function while generating some "decl related" form of DIE
+   makes it possible to later refer to the DIE which represents the given
+   decl simply by re-generating the symbolic name from the ..._DECL node's
+   UID number. */
+
+static void
+equate_decl_number_to_die_number (decl)
+     register tree decl;
+{
+  /* In the case where we are generating a DIE for some ..._DECL node
+     which represents either some inline function declaration or some
+     entity declared within an inline function declaration/definition,
+     setup a symbolic name for the current DIE so that we have a name
+     for this DIE that we can easily refer to later on within
+     AT_abstract_origin attributes.  */
+
+  char decl_label[MAX_ARTIFICIAL_LABEL_BYTES];
+  char die_label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+  sprintf (decl_label, DECL_NAME_FMT, DECL_UID (decl));
+  sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
+  ASM_OUTPUT_DEF (asm_out_file, decl_label, die_label);
+}
+
 /* Given a pointer to some ..._TYPE tree node, generate an assembly language
-   equate directive which will associate an easily remembered symbolic name
-   with the current DIE.
+   equate directive which will associate a symbolic name with the current DIE.
 
    The name used is an artificial label generated from the TYPE_UID number
    associated with the given type node.  The name it gets equated to is the
@@ -1173,13 +1475,35 @@ equate_type_number_to_die_number (type)
      to get the equate to come out right, we need to get the main variant
      itself here.  */
 
-  type = TYPE_MAIN_VARIANT (type);
+  type = type_main_variant (type);
 
   sprintf (type_label, TYPE_NAME_FMT, TYPE_UID (type));
   sprintf (die_label, DIE_BEGIN_LABEL_FMT, current_dienum);
   ASM_OUTPUT_DEF (asm_out_file, type_label, die_label);
 }
 
+static void
+output_reg_number (rtl)
+     register rtx rtl;
+{
+  register unsigned regno = REGNO (rtl);
+
+  if (regno >= FIRST_PSEUDO_REGISTER)
+    {
+      warning_with_decl (dwarf_last_decl, "internal regno botch: regno = %d\n",
+                        regno);
+      regno = 0;
+    }
+  fprintf (asm_out_file, "\t%s\t0x%x",
+          UNALIGNED_INT_ASM_OP, DBX_REGISTER_NUMBER (regno));
+  if (flag_verbose_asm)
+    {
+      fprintf (asm_out_file, "\t%s ", ASM_COMMENT_START);
+      PRINT_REG (rtl, 0, asm_out_file);
+    }
+  fputc ('\n', asm_out_file);
+}
+
 /* The following routine is a nice and simple transducer.  It converts the
    RTL for a variable or parameter (resident in memory) into an equivalent
    Dwarf representation of a mechanism for getting the address of that same
@@ -1216,15 +1540,25 @@ output_mem_loc_descriptor (rtl)
 
        /* Whenever a register number forms a part of the description of
           the method for calculating the (dynamic) address of a memory
-          resident object, Dwarf rules require the register number to
+          resident object, DWARF rules require the register number to
           be referred to as a "base register".  This distinction is not
           based in any way upon what category of register the hardware
           believes the given register belongs to.  This is strictly
-          Dwarf terminology we're dealing with here.  */
+          DWARF terminology we're dealing with here.
+
+          Note that in cases where the location of a memory-resident data
+          object could be expressed as:
+
+                   OP_ADD (OP_BASEREG (basereg), OP_CONST (0))
+
+          the actual DWARF location descriptor that we generate may just
+          be OP_BASEREG (basereg).  This may look deceptively like the
+          object in question was allocated to a register (rather than
+          in memory) so DWARF consumers need to be aware of the subtle
+          distinction between OP_REG and OP_BASEREG.  */
 
        ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_BASEREG);
-        ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                               DBX_REGISTER_NUMBER (REGNO (rtl)));
+       output_reg_number (rtl);
        break;
 
       case MEM:
@@ -1279,8 +1613,7 @@ output_loc_descriptor (rtl)
 
     case REG:
        ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_REG);
-        ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                               DBX_REGISTER_NUMBER (REGNO (rtl)));
+       output_reg_number (rtl);
        break;
 
     case MEM:
@@ -1369,7 +1702,7 @@ output_bound_representation (bound, dim_num, u_or_l)
 
          if (! optimize)
            output_loc_descriptor
-             (eliminate_regs (SAVE_EXPR_RTL (bound), 0, 0));
+             (eliminate_regs (SAVE_EXPR_RTL (bound), 0, NULL_RTX));
 
          ASM_OUTPUT_LABEL (asm_out_file, end_label);
        }
@@ -1398,6 +1731,188 @@ 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;
+{
+  return (((value + boundary - 1) / boundary) * boundary);
+}
+
+/* Given a pointer to what is assumed to be a FIELD_DECL node, return a
+   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;
+{
+  register tree type;
+
+  if (TREE_CODE (decl) == ERROR_MARK)
+    return integer_type_node;
+
+  type = DECL_BIT_FIELD_TYPE (decl);
+  if (type == NULL)
+    type = TREE_TYPE (decl);
+  return type;
+}
+
+/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
+   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;
+{
+  return (TREE_CODE (type) != ERROR_MARK) ? TYPE_ALIGN (type) : BITS_PER_WORD;
+}
+
+/* Given a pointer to a tree node, assumed to be some kind of a ..._TYPE
+   node, return the size in bits for the type if it is a constant, or
+   else return the alignment for the type if the type's size is not
+   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;
+{
+  if (TREE_CODE (type) == ERROR_MARK)
+    return BITS_PER_WORD;
+  else
+    {
+      register tree 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);
+    }
+}
+
+/* Given a pointer to what is assumed to be a FIELD_DECL node, compute and
+   return the byte offset of the lowest addressed byte of the "containing
+   object" for the given FIELD_DECL, or return 0 if we are unable to deter-
+   mine what that offset is, either because the argument turns out to be a
+   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;
+
+  if (TREE_CODE (decl) == ERROR_MARK)
+    return 0;
+
+  if (TREE_CODE (decl) != FIELD_DECL)
+    abort ();
+
+  type = field_type (decl);
+
+  bitpos_tree = DECL_FIELD_BITPOS (decl);
+  field_size_tree = DECL_SIZE (decl);
+
+  /* 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)
+    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);
+
+  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;
+
+  /* Note that the GCC front-end doesn't make any attempt to keep track
+     of the starting bit offset (relative to the start of the containing
+     structure type) of the hypothetical "containing object" for a bit-
+     field.  Thus, when computing the byte offset value for the start of
+     the "containing object" of a bit-field, we must deduce this infor-
+     mation on our own.
+
+     This can be rather tricky to do in some cases.  For example, handling
+     the following structure type definition when compiling for an i386/i486
+     target (which only aligns long long's to 32-bit boundaries) can be very
+     tricky:
+
+               struct S {
+                       int             field1;
+                       long long       field2:31;
+               };
+
+     Fortunately, there is a simple rule-of-thumb which can be used in such
+     cases.  When compiling for an i386/i486, GCC will allocate 8 bytes for
+     the structure shown above.  It decides to do this based upon one simple
+     rule for bit-field allocation.  Quite simply, GCC allocates each "con-
+     taining object" for each bit-field at the first (i.e. lowest addressed)
+     legitimate alignment boundary (based upon the required minimum alignment
+     for the declared type of the field) which it can possibly use, subject
+     to the condition that there is still enough available space remaining
+     in the containing object (when allocated at the selected point) to
+     fully accommodate all of the bits of the bit-field itself.
+
+     This simple rule makes it obvious why GCC allocates 8 bytes for each
+     object of the structure type shown above.  When looking for a place to
+     allocate the "containing object" for `field2', the compiler simply tries
+     to allocate a 64-bit "containing object" at each successive 32-bit
+     boundary (starting at zero) until it finds a place to allocate that 64-
+     bit field such that at least 31 contiguous (and previously unallocated)
+     bits remain within that selected 64 bit field.  (As it turns out, for
+     the example above, the compiler finds that it is OK to allocate the
+     "containing object" 64-bit field at bit-offset zero within the
+     structure type.)
+
+     Here we attempt to work backwards from the limited set of facts we're
+     given, and we try to deduce from those facts, where GCC must have
+     believed that the containing object started (within the structure type).
+
+     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).
+  */
+
+  /* Figure out the bit-distance from the start of the structure to the
+     "deepest" bit of the bit-field.  */
+  deepest_bitpos = bitpos_int + field_size_in_bits;
+
+  /* This is the tricky part.  Use some fancy footwork to deduce where the
+     lowest addressed bit of the containing object must be.  */
+  object_offset_in_bits
+    = ceiling (deepest_bitpos, type_align_in_bits) - type_size_in_bits;
+
+  /* Compute the offset of the containing object in "alignment units".  */
+  object_offset_in_align_units = object_offset_in_bits / type_align_in_bits;
+
+  /* Compute the offset of the containing object in bytes.  */
+  object_offset_in_bytes = object_offset_in_align_units * type_align_in_bytes;
+
+  return object_offset_in_bytes;
+}
+
 /****************************** attributes *********************************/
 
 /* The following routines are responsible for writing out the various types
@@ -1437,56 +1952,69 @@ location_attribute (rtl)
   /* Handle a special case.  If we are about to output a location descriptor
      for a variable or parameter which has been optimized out of existence,
      don't do that.  Instead we output a zero-length location descriptor
-     value as part of the location attribute.  Note that we cannot simply
-     suppress the entire location attribute, because the absence of a
-     location attribute in certain kinds of DIEs is used to indicate some-
-     thing entirely different... i.e. that the DIE represents an object
-     declaration, but not a definition.  So sayeth the PLSIG.  */
+     value as part of the location attribute.
+
+     A variable which has been optimized out of existence will have a
+     DECL_RTL value which denotes a pseudo-reg.
+
+     Currently, in some rare cases, variables can have DECL_RTL values
+     which look like (MEM (REG pseudo-reg#)).  These cases are due to
+     bugs elsewhere in the compiler.  We treat such cases
+     as if the variable(s) in question had been optimized out of existence.
+
+     Note that in all cases where we wish to express the fact that a
+     variable has been optimized out of existence, we do not simply
+     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
+     the PLSIG.
+  */
 
-  if (((GET_CODE (rtl) != REG) || (REGNO (rtl) < FIRST_PSEUDO_REGISTER))
-      && ((GET_CODE (rtl) != SUBREG)
-         || (REGNO (XEXP (rtl, 0)) < FIRST_PSEUDO_REGISTER)))
-    output_loc_descriptor (eliminate_regs (rtl, 0, 0));
+  if (! is_pseudo_reg (rtl)
+      && (GET_CODE (rtl) != MEM || ! is_pseudo_reg (XEXP (rtl, 0))))
+    output_loc_descriptor (eliminate_regs (rtl, 0, NULL_RTX));
 
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
 
 /* Output the specialized form of location attribute used for data members
-   of struct types.  */
+   of struct and union types.
+
+   In the special case of a FIELD_DECL node which represents a bit-field,
+   the "offset" part of this special location descriptor must indicate the
+   distance in bytes from the lowest-addressed byte of the containing
+   struct or union type to the lowest-addressed byte of the "containing
+   object" for the bit-field.  (See the `field_byte_offset' function above.)
+
+   For any given bit-field, the "containing object" is a hypothetical
+   object (of some integral or enum type) within which the given bit-field
+   lives.  The type of this hypothetical "containing object" is always the
+   same as the declared type of the individual bit-field itself (for GCC
+   anyway... the DWARF spec doesn't actually mandate this).
+
+   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 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.)
+*/
 
 static void
 data_member_location_attribute (decl)
      register tree decl;
 {
+  register unsigned object_offset_in_bytes = field_byte_offset (decl);
   char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
   char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  if (TREE_CODE (decl) == ERROR_MARK)
-    return;
-
-  if (TREE_CODE (decl) != FIELD_DECL)
-    abort ();
-
   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);
   ASM_OUTPUT_DWARF_DELTA2 (asm_out_file, end_label, begin_label);
   ASM_OUTPUT_LABEL (asm_out_file, begin_label);
   ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_CONST);
-
-  /* This is pretty strange, but existing compilers producing DWARF
-     apparently calculate the byte offset of a field differently
-     depending upon whether or not it is a bit-field.  If the given
-     field is *not* a bit-field, then the offset is simply the
-     the byte offset of the given field from the beginning of the
-     struct.  For bit-fields however, the offset is the offset (in
-     bytes) of the beginning of the *containing word* from the
-     beginning of the whole struct.  */
-
-  ASM_OUTPUT_DWARF_DATA4 (asm_out_file,
-                         (DECL_BIT_FIELD_TYPE (decl))
-                               ? BITFIELD_OFFSET_WORDS_IN_UNITS (decl)
-                               : BITFIELD_OFFSET_UNITS (decl));
+  ASM_OUTPUT_DWARF_DATA4 (asm_out_file, object_offset_in_bytes);
   ASM_OUTPUT_DWARF_STACK_OP (asm_out_file, OP_ADD);
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
@@ -1533,8 +2061,8 @@ const_value_attribute (rtl)
           simplicity we always just output CONST_DOUBLEs using 8 bytes.  */
 
        ASM_OUTPUT_DWARF_DATA8 (asm_out_file,
-                               (unsigned) CONST_DOUBLE_HIGH (rtl),
-                               (unsigned) CONST_DOUBLE_LOW (rtl));
+                               (unsigned HOST_WIDE_INT) CONST_DOUBLE_HIGH (rtl),
+                               (unsigned HOST_WIDE_INT) CONST_DOUBLE_LOW (rtl));
        break;
 
       case CONST_STRING:
@@ -1562,6 +2090,9 @@ const_value_attribute (rtl)
           we just punt and generate an AT_const_value attribute with form
           FORM_BLOCK4 and a length of zero.  */
        break;
+
+      default:
+       abort ();  /* No other kinds of rtx should be possible here.  */
     }
 
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
@@ -1589,31 +2120,109 @@ location_or_const_value_attribute (decl)
     return;
 
   if ((TREE_CODE (decl) != VAR_DECL) && (TREE_CODE (decl) != PARM_DECL))
-    abort ();
+    {
+      /* Should never happen.  */
+      abort ();
+      return;
+    }
 
-  /* It's not really clear what existing Dwarf debuggers need or expect
-     as regards to location information for formal parameters.  A later
-     version of the Dwarf specification should resolve such issues, but
-     for the time being, we assume here that debuggers want information
-     about the location where the parameter was passed into the function.
-     That seems to be what USL's CI5 compiler generates.  Note that this
-     will probably be different from the place where the parameter actual
-     resides during function execution.  Dwarf Version 2 will provide us
-     with a means to describe that location also, but for now we can only
-     describe the "passing" location.  */
-
-#if 1 /* This is probably right, but it leads to a lot of trouble.
-        Fixing one problem has been exposing another,
-        all of which seemed to have no ill effects before.
-        Let's try it again for now.  */
-  rtl = (TREE_CODE (decl) == PARM_DECL)
-        ? DECL_INCOMING_RTL (decl)
-        : DECL_RTL (decl);
-#else
+  /* Here we have to decide where we are going to say the parameter "lives"
+     (as far as the debugger is concerned).  We only have a couple of choices.
+     GCC provides us with DECL_RTL and with DECL_INCOMING_RTL.  DECL_RTL
+     normally indicates where the parameter lives during most of the activa-
+     tion of the function.  If optimization is enabled however, this could
+     be either NULL or else a pseudo-reg.  Both of those cases indicate that
+     the parameter doesn't really live anywhere (as far as the code generation
+     parts of GCC are concerned) during most of the function's activation.
+     That will happen (for example) if the parameter is never referenced
+     within the function.
+
+     We could just generate a location descriptor here for all non-NULL
+     non-pseudo values of DECL_RTL and ignore all of the rest, but we can
+     be a little nicer than that if we also consider DECL_INCOMING_RTL in
+     cases where DECL_RTL is NULL or is a pseudo-reg.
+
+     Note however that we can only get away with using DECL_INCOMING_RTL as
+     a backup substitute for DECL_RTL in certain limited cases.  In cases
+     where DECL_ARG_TYPE(decl) indicates the same type as TREE_TYPE(decl)
+     we can be sure that the parameter was passed using the same type as it
+     is declared to have within the function, and that its DECL_INCOMING_RTL
+     points us to a place where a value of that type is passed.  In cases
+     where DECL_ARG_TYPE(decl) and TREE_TYPE(decl) are different types
+     however, we cannot (in general) use DECL_INCOMING_RTL as a backup
+     substitute for DECL_RTL because in these cases, DECL_INCOMING_RTL
+     points us to a value of some type which is *different* from the type
+     of the parameter itself.  Thus, if we tried to use DECL_INCOMING_RTL
+     to generate a location attribute in such cases, the debugger would
+     end up (for example) trying to fetch a `float' from a place which
+     actually contains the first part of a `double'.  That would lead to
+     really incorrect and confusing output at debug-time, and we don't
+     want that now do we?
+
+     So in general, we DO NOT use DECL_INCOMING_RTL as a backup for DECL_RTL
+     in cases where DECL_ARG_TYPE(decl) != TREE_TYPE(decl).  There are a
+     couple of cute exceptions however.  On little-endian machines we can
+     get away with using DECL_INCOMING_RTL even when DECL_ARG_TYPE(decl) is
+     not the same as TREE_TYPE(decl) but only when DECL_ARG_TYPE(decl) is
+     an integral type which is smaller than TREE_TYPE(decl).  These cases
+     arise when (on a little-endian machine) a non-prototyped function has
+     a parameter declared to be of type `short' or `char'.  In such cases,
+     TREE_TYPE(decl) will be `short' or `char', DECL_ARG_TYPE(decl) will be
+     `int', and DECL_INCOMING_RTL will point to the lowest-order byte of the
+     passed `int' value.  If the debugger then uses that address to fetch a
+     `short' or a `char' (on a little-endian machine) the result will be the
+     correct data, so we allow for such exceptional cases below.
+
+     Note that our goal here is to describe the place where the given formal
+     parameter lives during most of the function's activation (i.e. between
+     the end of the prologue and the start of the epilogue).  We'll do that
+     as best as we can.  Note however that if the given formal parameter is
+     modified sometime during the execution of the function, then a stack
+     backtrace (at debug-time) will show the function as having been called
+     with the *new* value rather than the value which was originally passed
+     in.  This happens rarely enough that it is not a major problem, but it
+     *is* a problem, and I'd like to fix it.  A future version of dwarfout.c
+     may generate two additional attributes for any given TAG_formal_parameter
+     DIE which will describe the "passed type" and the "passed location" for
+     the given formal parameter in addition to the attributes we now generate
+     to indicate the "declared type" and the "active location" for each
+     parameter.  This additional set of attributes could be used by debuggers
+     for stack backtraces.
+
+     Separately, note that sometimes DECL_RTL can be NULL and DECL_INCOMING_RTL
+     can be NULL also.  This happens (for example) for inlined-instances of
+     inline function formal parameters which are never referenced.  This really
+     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
+     being (until integrate.c gets fixed).
+  */
+
+  /* Use DECL_RTL as the "location" unless we find something better.  */
   rtl = DECL_RTL (decl);
-#endif
 
-  if (rtl == NULL)
+  if (TREE_CODE (decl) == PARM_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));
+
+       /* 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
+         if (TREE_CODE (declared_type) == INTEGER_TYPE)
+           if (TYPE_SIZE (declared_type) <= TYPE_SIZE (passed_type))
+             rtl = DECL_INCOMING_RTL (decl);
+#endif /* (BYTES_BIG_ENDIAN == 0) */
+      }
+
+  if (rtl == NULL_RTX)
     return;
 
   switch (GET_CODE (rtl))
@@ -1640,7 +2249,7 @@ location_or_const_value_attribute (decl)
 }
 
 /* Generate an AT_name attribute given some string value to be included as
-   the value of the attribute. If the name is null, don't do anything.  */
+   the value of the attribute. */
 
 inline void
 name_attribute (name_string)
@@ -1713,6 +2322,7 @@ mod_u_d_type_attribute (type, decl_const, decl_volatile)
   ASM_OUTPUT_LABEL (asm_out_file, end_label);
 }
 
+#ifdef USE_ORDERING_ATTRIBUTE
 inline void
 ordering_attribute (ordering)
      register unsigned ordering;
@@ -1720,6 +2330,7 @@ ordering_attribute (ordering)
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_ordering);
   ASM_OUTPUT_DWARF_DATA2 (asm_out_file, ordering);
 }
+#endif /* defined(USE_ORDERING_ATTRIBUTE) */
 
 /* Note that the block of subscript information for an array type also
    includes information about the element type of type given array type.  */
@@ -1842,40 +2453,98 @@ byte_size_attribute (tree_node)
       case ENUMERAL_TYPE:
       case RECORD_TYPE:
       case UNION_TYPE:
+      case QUAL_UNION_TYPE:
        size = int_size_in_bytes (tree_node);
        break;
 
       case FIELD_DECL:
-       {
-         register unsigned words;
-         register unsigned bits;
-
-         bits = TREE_INT_CST_LOW (DECL_SIZE (tree_node));
-         words = (bits + (BITS_PER_WORD-1)) / BITS_PER_WORD;
-         size = words * (BITS_PER_WORD / BITS_PER_UNIT);
-       }
+       /* For a data member of a struct or union, the AT_byte_size is
+          generally given as the number of bytes normally allocated for
+          an object of the *declared* type of the member itself.  This
+          is true even for bit-fields.  */
+       size = simple_type_size_in_bits (field_type (tree_node))
+              / BITS_PER_UNIT;
        break;
 
       default:
        abort ();
     }
+
+  /* Note that `size' might be -1 when we get to this point.  If it
+     is, that indicates that the byte size of the entity in question
+     is variable.  We have no good way of expressing this fact in Dwarf
+     at the present time, so just let the -1 pass on through.  */
+
   ASM_OUTPUT_DWARF_DATA4 (asm_out_file, size);
 }
 
-/* For a FIELD_DECL node which represents a bit field, output an attribute
-   which specifies the distance in bits from the start of the *word*
-   containing the given field to the first bit of the field.  */
+/* For a FIELD_DECL node which represents a bit-field, output an attribute
+   which specifies the distance in bits from the highest order bit of the
+   "containing object" for the bit-field to the highest order bit of the
+   bit-field itself.
+
+   For any given bit-field, the "containing object" is a hypothetical
+   object (of some integral or enum type) within which the given bit-field
+   lives.  The type of this hypothetical "containing object" is always the
+   same as the declared type of the individual bit-field itself.
+
+   The determination of the exact location of the "containing object" for
+   a bit-field is rather complicated.  It's handled by the `field_byte_offset'
+   function (above).
+
+   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.)
+*/
 
 inline void
 bit_offset_attribute (decl)
     register 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;
+
   assert (TREE_CODE (decl) == FIELD_DECL);     /* Must be a field.  */
-  assert (DECL_BIT_FIELD_TYPE (decl));         /* Must be a bit field.  */
+  assert (type);                               /* Must be a bit field.  */
+
+  /* We can't yet handle bit-fields whose offsets are variable, so if we
+     encounter such things, just return without generating any attribute
+     whatsoever.  */
+
+  if (TREE_CODE (bitpos_tree) != INTEGER_CST)
+    return;
+  bitpos_int = (unsigned) TREE_INT_CST_LOW (bitpos_tree);
+
+  /* Note that the bit offset is always the distance (in bits) from the
+     highest-order bit of the "containing object" to the highest-order
+     bit of the bit-field itself.  Since the "high-order end" of any
+     object or field is different on big-endian and little-endian machines,
+     the computation below must take account of these differences.  */
+
+  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) */
+
+  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) */
 
   ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_bit_offset);
-  ASM_OUTPUT_DWARF_DATA2 (asm_out_file,
-       BITFIELD_OFFSET_BITS (decl) % (unsigned) BITS_PER_WORD);
+  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, bit_offset);
 }
 
 /* For a FIELD_DECL node which represents a bit field, output an attribute
@@ -1955,6 +2624,26 @@ high_pc_attribute (asm_high_label)
   ASM_OUTPUT_DWARF_ADDR (asm_out_file, 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;
+{
+  ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_begin);
+  ASM_OUTPUT_DWARF_ADDR (asm_out_file, 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;
+{
+  ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_body_end);
+  ASM_OUTPUT_DWARF_ADDR (asm_out_file, asm_end_label);
+}
+
 /* Generate an AT_language attribute given a LANG value.  These attributes
    are used only within TAG_compile_unit DIEs.  */
 
@@ -1974,9 +2663,7 @@ member_attribute (context)
 
   /* Generate this attribute only for members in C++.  */
 
-  if (context != NULL
-      && (TREE_CODE (context) == RECORD_TYPE
-         || TREE_CODE (context) == UNION_TYPE))
+  if (context != NULL && is_tagged_type (context))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_member);
       sprintf (label, TYPE_NAME_FMT, TYPE_UID (context));
@@ -2059,7 +2746,7 @@ inline void
 inline_attribute (decl)
      register tree decl;
 {
-  if (TREE_INLINE (decl))
+  if (DECL_INLINE (decl))
     {
       ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_inline);
       ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
@@ -2077,10 +2764,98 @@ containing_type_attribute (containing_type)
   ASM_OUTPUT_DWARF_REF (asm_out_file, label);
 }
 
+inline void
+abstract_origin_attribute (origin)
+     register tree origin;
+{
+  char label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+  ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_abstract_origin);
+  switch (TREE_CODE_CLASS (TREE_CODE (origin)))
+    {
+    case 'd':
+      sprintf (label, DECL_NAME_FMT, DECL_UID (origin));
+      break;
+
+    case 't':
+      sprintf (label, TYPE_NAME_FMT, TYPE_UID (origin));
+      break;
+
+    default:
+      abort ();                /* Should never happen.  */
+
+    }
+  ASM_OUTPUT_DWARF_REF (asm_out_file, label);
+}
+
+#ifdef DWARF_DECL_COORDINATES
+inline void
+src_coords_attribute (src_fileno, src_lineno)
+     register unsigned src_fileno;
+     register unsigned src_lineno;
+{
+  ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_src_coords);
+  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_fileno);
+  ASM_OUTPUT_DWARF_DATA2 (asm_out_file, src_lineno);
+}
+#endif /* defined(DWARF_DECL_COORDINATES) */
+
+inline void
+pure_or_virtual_attribute (func_decl)
+     register 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);
+      else
+#endif
+        ASM_OUTPUT_DWARF_ATTRIBUTE (asm_out_file, AT_virtual);
+      ASM_OUTPUT_DWARF_STRING (asm_out_file, "");
+    }
+}
+
 /************************* end of attributes *****************************/
 
 /********************* utility routines for DIEs *************************/
 
+/* Output an AT_name attribute and an AT_src_coords attribute for the
+   given decl, but only if it actually has a name.  */
+
+static void
+name_and_src_coords_attributes (decl)
+    register tree decl;
+{
+  register tree decl_name = DECL_NAME (decl);
+
+  if (decl_name && IDENTIFIER_POINTER (decl_name))
+    {
+      name_attribute (IDENTIFIER_POINTER (decl_name));
+#ifdef DWARF_DECL_COORDINATES
+      {
+       register unsigned file_index;
+
+       /* 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
+          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
+          would cause us to have inter-section forward references and
+          Fred Fish sez that m68k/svr4 assemblers botch those.  */
+
+       ASM_OUTPUT_POP_SECTION (asm_out_file);
+       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));
+      }
+#endif /* defined(DWARF_DECL_COORDINATES) */
+    }
+}
+
 /* Many forms of DIEs contain a "type description" part.  The following
    routine writes out these "type descriptor" parts.  */
 
@@ -2116,7 +2891,16 @@ type_attribute (type, decl_const, decl_volatile)
     if (root_type_modified)
        mod_u_d_type_attribute (type, decl_const, decl_volatile);
     else
-       user_def_type_attribute (type);
+       /* 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
+          the copy was created to help us keep track of typedef names)
+          and that copy might have a different TYPE_UID from the original
+          ..._TYPE node.  (Note that when `equate_type_number_to_die_number'
+          is labeling a given type DIE for future reference, it always and
+          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
@@ -2143,7 +2927,7 @@ type_tag (type)
         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 inconsistancy in the TREE
+        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
@@ -2219,50 +3003,100 @@ output_array_type_die (arg)
   /* I believe that we can default the array ordering.  SDB will probably
      do the right things even if AT_ordering is not present.  It's not
      even an issue until we start to get into multidimensional arrays
-     anyway.  If SDB is shown to do the wrong thing in those cases, then
-     we'll have to put the AT_ordering attribute back in, but only for
-     multidimensional array.  (After all, we don't want to waste space
-     in the .debug section now do we?)  */
+     anyway.  If SDB is ever caught doing the Wrong Thing for multi-
+     dimensional arrays, then we'll have to put the AT_ordering attribute
+     back in.  (But if and when we find out that we need to put these in,
+     we will only do so for multidimensional arrays.  After all, we don't
+     want to waste space in the .debug section now do we?)  */
 
-#if 0
+#ifdef USE_ORDERING_ATTRIBUTE
   ordering_attribute (ORD_row_major);
-#endif
+#endif /* defined(USE_ORDERING_ATTRIBUTE) */
 
   subscript_data_attribute (type);
 }
 
 static void
-output_set_type_die (arg)
+output_set_type_die (arg)
+     register void *arg;
+{
+  register tree type = arg;
+
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
+  sibling_attribute ();
+  equate_type_number_to_die_number (type);
+  member_attribute (TYPE_CONTEXT (type));
+  type_attribute (TREE_TYPE (type), 0, 0);
+}
+
+#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;
+{
+  register tree decl = arg;
+  register tree origin = decl_ultimate_origin (decl);
+
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
+  sibling_attribute ();
+  dienum_push ();
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
+    {
+      name_and_src_coords_attributes (decl);
+      member_attribute (DECL_CONTEXT (decl));
+      type_attribute (TREE_TYPE (TREE_TYPE (decl)), 0, 0);
+    }
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
+  else
+    low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (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;
+{
+  register tree type = arg;
+
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_enumeration_type);
+  sibling_attribute ();
+  assert (TREE_ASM_WRITTEN (type));
+  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;
 {
   register tree type = arg;
 
-  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_set_type);
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_structure_type);
   sibling_attribute ();
-  equate_type_number_to_die_number (type);
-  member_attribute (TYPE_CONTEXT (type));
-  type_attribute (TREE_TYPE (type), 0, 0);
+  assert (TREE_ASM_WRITTEN (type));
+  abstract_origin_attribute (type);
 }
 
-#if 0
-/* Implement this when there is a GNU FORTRAN or GNU Ada front end.  */
+/* Output a DIE to represent an inlined instance of a union type.  */
+
 static void
-output_entry_point_die (arg)
+output_inlined_union_type_die (arg)
      register void *arg;
 {
-  register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
-  register tree return_type = TREE_TYPE (type);
+  register tree type = arg;
 
-  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_entry_point);
+  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_union_type);
   sibling_attribute ();
-  dienum_push ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (return_type, 0, 0);
+  assert (TREE_ASM_WRITTEN (type));
+  abstract_origin_attribute (type);
 }
-#endif
 
 /* Output a DIE to represent an enumeration type.  Note that these DIEs
    include all of the information about the enumeration values also.
@@ -2296,38 +3130,51 @@ output_enumeration_type_die (arg)
    function type.
 
    Note that this routine is a bit unusual because its argument may be
-   either a PARM_DECL node or else some sort of a ..._TYPE node.  If it's
-   the formar then this function is being called to output a real live
-   formal parameter declaration.  If it's the latter, then this function
-   is only being called to output a TAG_formal_parameter DIE to stand as
-   a placeholder for some formal argument type of some subprogram type.  */
+   a ..._DECL node (i.e. either a PARM_DECL or perhaps a VAR_DECL which
+   represents an inlining of some PARM_DECL) or else some sort of a
+   ..._TYPE node.  If it's the former then this function is being called
+   to output a DIE to represent a formal parameter object (or some inlining
+   thereof).  If it's the latter, then this function is only being called
+   to output a TAG_formal_parameter DIE to stand as a placeholder for some
+   formal argument type of some subprogram type.  */
 
 static void
 output_formal_parameter_die (arg)
      register void *arg;
 {
-  register tree decl = arg;
-  register tree type;
-
-  if (TREE_CODE (decl) == PARM_DECL)
-    type = TREE_TYPE (decl);
-  else
-    {
-      type = decl;     /* we were called with a type, not a decl */
-      decl = NULL;
-    }
+  register tree node = arg;
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_formal_parameter);
   sibling_attribute ();
-  if (decl)
+
+  switch (TREE_CODE_CLASS (TREE_CODE (node)))
     {
-      if (DECL_NAME (decl))
-        name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-      type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
-      location_or_const_value_attribute (decl);
+    case 'd':  /* We were called with some kind of a ..._DECL node.  */
+      {
+       register tree origin = decl_ultimate_origin (node);
+
+       if (origin != NULL)
+         abstract_origin_attribute (origin);
+       else
+         {
+           name_and_src_coords_attributes (node);
+           type_attribute (TREE_TYPE (node),
+                           TREE_READONLY (node), TREE_THIS_VOLATILE (node));
+         }
+       if (DECL_ABSTRACT (node))
+         equate_decl_number_to_die_number (node);
+       else
+         location_or_const_value_attribute (node);
+      }
+      break;
+
+    case 't':  /* We were called with some kind of a ..._TYPE node.  */
+      type_attribute (node, 0, 0);
+      break;
+
+    default:
+      abort ();        /* Should never happen.  */
     }
-  else
-    type_attribute (type, 0, 0);
 }
 
 /* Output a DIE to represent a declared function (either file-scope
@@ -2338,25 +3185,40 @@ output_global_subroutine_die (arg)
      register void *arg;
 {
   register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
-  register tree return_type = TREE_TYPE (type);
+  register tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_subroutine);
   sibling_attribute ();
   dienum_push ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  inline_attribute (decl);
-  prototyped_attribute (type);
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (return_type, 0, 0);
-  if (!TREE_EXTERNAL (decl))
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
+    {
+      register tree type = TREE_TYPE (decl);
+
+      name_and_src_coords_attributes (decl);
+      inline_attribute (decl);
+      prototyped_attribute (type);
+      member_attribute (DECL_CONTEXT (decl));
+      type_attribute (TREE_TYPE (type), 0, 0);
+      pure_or_virtual_attribute (decl);
+    }
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
+  else
     {
-      char func_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
+      if (! DECL_EXTERNAL (decl))
+       {
+         char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-      low_pc_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-      sprintf (func_end_label, FUNC_END_LABEL_FMT, current_funcdef_number);
-      high_pc_attribute (func_end_label);
+         low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+         sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
+         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);
+       }
     }
 }
 
@@ -2368,105 +3230,64 @@ output_global_variable_die (arg)
      register void *arg;
 {
   register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
+  register tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_global_variable);
   sibling_attribute ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
-  if (!TREE_EXTERNAL (decl))
-    location_or_const_value_attribute (decl);
-}
-
-#if 0
-/* TAG_inline_subroutine has been retired by the UI/PLSIG.  We're
-   now supposed to use either TAG_subroutine or TAG_global_subroutine
-   (depending on whether or not the function in question has internal
-   or external linkage) and we're supposed to just put in an AT_inline
-   attribute.  */
-static void
-output_inline_subroutine_die (arg)
-     register void *arg;
-{
-  register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
-  register tree return_type = TREE_TYPE (type);
-
-  ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inline_subroutine);
-  sibling_attribute ();
-  dienum_push ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  prototyped_attribute (type);
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (return_type, 0, 0);
-
-  /* Note:  For each inline function which gets an out-of-line body
-     generated for it, we want to generate AT_low_pc and AT_high_pc
-     attributes here for the function's out-of-line body.
-
-     Unfortunately, the decision as to whether or not to generate an
-     out-of-line body for any given inline function may not be made
-     until we reach the end of the containing scope for the given
-     inline function (because only then will it be known if the
-     function was ever even called).
-
-     For this reason, the output of DIEs representing file-scope inline
-     functions gets delayed until a special post-pass which happens only
-     after we have reached the end of the compilation unit.  Because of
-     this mechanism, we can always be sure (by the time we reach here)
-     that TREE_ASM_WRITTEN(decl) will correctly indicate whether or not
-     there was an out-of-line body generated for this inline function.
-  */
-
-  if (!TREE_EXTERNAL (decl))
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
     {
-      if (TREE_ASM_WRITTEN (decl))
-        {
-          char func_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
-
-          low_pc_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-          sprintf (func_end_label, FUNC_END_LABEL_FMT, current_funcdef_number);
-          high_pc_attribute (func_end_label);
-        }
+      name_and_src_coords_attributes (decl);
+      member_attribute (DECL_CONTEXT (decl));
+      type_attribute (TREE_TYPE (decl),
+                     TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
+    }
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
+  else
+    {
+      if (!DECL_EXTERNAL (decl))
+       location_or_const_value_attribute (decl);
     }
 }
-#endif
 
 static void
 output_label_die (arg)
      register void *arg;
 {
   register tree decl = arg;
-  register rtx insn = DECL_RTL (decl);
+  register tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_label);
   sibling_attribute ();
-  name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-
-  /* When optimization is enabled (with -O) the code in jump.c and in flow.c
-     may cause insns representing one of more of the user's own labels to
-     be deleted.  This happens whenever it is determined that a given label
-     is unreachable.
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
+    name_and_src_coords_attributes (decl);
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
+  else
+    {
+      register rtx insn = DECL_RTL (decl);
 
-     In such cases, we here generate an abbreviated form of a label DIE.
-     This abbreviated version does *not* have a low_pc attribute.  This
-     should signify to the debugger that the label has been optimized away.
+      if (GET_CODE (insn) == CODE_LABEL)
+       {
+         char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-     Note that a CODE_LABEL can get deleted either by begin converted into
-     a NOTE_INSN_DELETED note, or by simply having its INSN_DELETED_P flag
-     set to true.  We handle both cases here.
-  */
+         /* When optimization is enabled (via -O) some parts of the compiler
+            (e.g. jump.c and cse.c) may try to delete CODE_LABEL insns which
+            represent source-level labels which were explicitly declared by
+            the user.  This really shouldn't be happening though, so catch
+            it if it ever does happen.  */
 
-  if (GET_CODE (insn) == CODE_LABEL && ! INSN_DELETED_P (insn))
-    {
-      char label[MAX_ARTIFICIAL_LABEL_BYTES];
+         if (INSN_DELETED_P (insn))
+           abort ();   /* Should never happen.  */
 
-      sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
-                                     (unsigned) INSN_UID (insn));
-      low_pc_attribute (label);
+         sprintf (label, INSN_LABEL_FMT, current_funcdef_number,
+                                         (unsigned) INSN_UID (insn));
+         low_pc_attribute (label);
+       }
     }
 }
 
@@ -2475,16 +3296,20 @@ output_lexical_block_die (arg)
      register void *arg;
 {
   register tree stmt = arg;
-  char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
-  char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_lexical_block);
   sibling_attribute ();
   dienum_push ();
-  sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
-  low_pc_attribute (begin_label);
-  sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
-  high_pc_attribute (end_label);
+  if (! BLOCK_ABSTRACT (stmt))
+    {
+      char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
+      char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+      sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
+      low_pc_attribute (begin_label);
+      sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
+      high_pc_attribute (end_label);
+    }
 }
 
 static void
@@ -2492,16 +3317,21 @@ output_inlined_subroutine_die (arg)
      register void *arg;
 {
   register tree stmt = arg;
-  char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
-  char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_inlined_subroutine);
   sibling_attribute ();
   dienum_push ();
-  sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
-  low_pc_attribute (begin_label);
-  sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
-  high_pc_attribute (end_label);
+  abstract_origin_attribute (block_ultimate_origin (stmt));
+  if (! BLOCK_ABSTRACT (stmt))
+    {
+      char begin_label[MAX_ARTIFICIAL_LABEL_BYTES];
+      char end_label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+      sprintf (begin_label, BLOCK_BEGIN_LABEL_FMT, next_block_number);
+      low_pc_attribute (begin_label);
+      sprintf (end_label, BLOCK_END_LABEL_FMT, next_block_number);
+      high_pc_attribute (end_label);
+    }
 }
 
 /* Output a DIE to represent a declared data object (either file-scope
@@ -2512,15 +3342,23 @@ output_local_variable_die (arg)
      register void *arg;
 {
   register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
+  register tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_local_variable);
   sibling_attribute ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
-  location_or_const_value_attribute (decl);
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
+    {
+      name_and_src_coords_attributes (decl);
+      member_attribute (DECL_CONTEXT (decl));
+      type_attribute (TREE_TYPE (decl),
+                     TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
+    }
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
+  else
+    location_or_const_value_attribute (decl);
 }
 
 static void
@@ -2531,8 +3369,7 @@ output_member_die (arg)
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_member);
   sibling_attribute ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
+  name_and_src_coords_attributes (decl);
   member_attribute (DECL_CONTEXT (decl));
   type_attribute (member_declared_type (decl),
                  TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
@@ -2546,13 +3383,8 @@ output_member_die (arg)
 }
 
 #if 0
-/* Don't generate either pointer_type DIEs or reference_type DIEs.  According
-   to the 4-4-90 Dwarf draft spec (just after requirement #47):
-
-       These two type entries are not currently generated by any compiler.
-       Since the only way to name a pointer (or reference) type is C or C++
-       is via a "typedef", an entry with the "typedef" tag is generated
-       instead.
+/* 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.
@@ -2585,6 +3417,7 @@ output_reference_type_die (arg)
 }
 #endif
 
+static void
 output_ptr_to_mbr_type_die (arg)
      register void *arg;
 {
@@ -2618,6 +3451,8 @@ output_compile_unit_die (arg)
 
   if (strcmp (language_string, "GNU C++") == 0)
     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
@@ -2655,8 +3490,7 @@ output_string_type_die (arg)
 
   /* Fudge the string length attribute for now.  */
 
-  string_length_attribute (
-       TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
+  string_length_attribute (TYPE_MAX_VALUE (TYPE_DOMAIN (type)));
 }
 
 static void
@@ -2692,28 +3526,43 @@ output_local_subroutine_die (arg)
      register void *arg;
 {
   register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
-  register tree return_type = TREE_TYPE (type);
-  char func_end_label[MAX_ARTIFICIAL_LABEL_BYTES];
+  register tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_subroutine);
   sibling_attribute ();
   dienum_push ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  inline_attribute (decl);
-  prototyped_attribute (type);
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (return_type, 0, 0);
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
+    {
+      register tree type = TREE_TYPE (decl);
+
+      name_and_src_coords_attributes (decl);
+      inline_attribute (decl);
+      prototyped_attribute (type);
+      member_attribute (DECL_CONTEXT (decl));
+      type_attribute (TREE_TYPE (type), 0, 0);
+      pure_or_virtual_attribute (decl);
+    }
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
+  else
+    {
+      /* Avoid getting screwed up in cases where a function was declared
+        static but where no definition was ever given for it.  */
 
-  /* Avoid getting screwed up in cases where a function was declared static
-     but where no definition was ever given for it.  */
+      if (TREE_ASM_WRITTEN (decl))
+       {
+         char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
-  if (TREE_ASM_WRITTEN (decl))
-    {
-      low_pc_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-      sprintf (func_end_label, FUNC_END_LABEL_FMT, current_funcdef_number);
-      high_pc_attribute (func_end_label);
+         low_pc_attribute (IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
+         sprintf (label, FUNC_END_LABEL_FMT, current_funcdef_number);
+         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);
+       }
     }
 }
 
@@ -2738,14 +3587,21 @@ output_typedef_die (arg)
      register void *arg;
 {
   register tree decl = arg;
-  register tree type = TREE_TYPE (decl);
+  register tree origin = decl_ultimate_origin (decl);
 
   ASM_OUTPUT_DWARF_TAG (asm_out_file, TAG_typedef);
   sibling_attribute ();
-  if (DECL_NAME (decl))
-    name_attribute (IDENTIFIER_POINTER (DECL_NAME (decl)));
-  member_attribute (DECL_CONTEXT (decl));
-  type_attribute (type, TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
+  if (origin != NULL)
+    abstract_origin_attribute (origin);
+  else
+    {
+      name_and_src_coords_attributes (decl);
+      member_attribute (DECL_CONTEXT (decl));
+      type_attribute (TREE_TYPE (decl),
+                     TREE_READONLY (decl), TREE_THIS_VOLATILE (decl));
+    }
+  if (DECL_ABSTRACT (decl))
+    equate_decl_number_to_die_number (decl);
 }
 
 static void
@@ -2886,7 +3742,7 @@ output_formal_types (function_or_method_type)
      register tree function_or_method_type;
 {
   register tree link;
-  register tree formal_type;
+  register tree formal_type = NULL;
   register tree first_parm_type = TYPE_ARG_TYPES (function_or_method_type);
 
   /* In the case where we are generating a formal types list for a C++
@@ -2960,32 +3816,22 @@ pend_type (type)
 
 /* Return non-zero if it is legitimate to output DIEs to represent a
    given type while we are generating the list of child DIEs for some
-   DIE associated with a given scope.
+   DIE (e.g. a function or lexical block DIE) associated with a given scope.
 
-   This function returns non-zero if *either* of the following two conditions
-   is satisfied:
-
-        o      the type actually belongs to the given scope (as evidenced
-               by its TYPE_CONTEXT value), or
-
-        o      the type is anonymous, and the `scope' in question is *not*
-               a RECORD_TYPE or UNION_TYPE.
-
-   In theory, we should be able to generate DIEs for anonymous types
-   *anywhere* (since the scope of an anonymous type is irrelevant)
-   however svr4 SDB doesn't want to see other type DIEs within the
-   lists of child DIEs for a TAG_structure_type or TAG_union_type DIE.
+   See the comments within the function for a description of when it is
+   considered legitimate to output DIEs for various kinds of types.
 
    Note that TYPE_CONTEXT(type) may be NULL (to indicate global scope)
    or it may point to a BLOCK node (for types local to a block), or to a
    FUNCTION_DECL node (for types local to the heading of some function
    definition), or to a FUNCTION_TYPE node (for types local to the
    prototyped parameter list of a function type specification), or to a
-   RECORD_TYPE or UNION_TYPE node (in the case of C++ nested types).
+   RECORD_TYPE, UNION_TYPE, or QUAL_UNION_TYPE node
+   (in the case of C++ nested types).
 
    The `scope' parameter should likewise be NULL or should point to a
    BLOCK node, a FUNCTION_DECL node, a FUNCTION_TYPE node, a RECORD_TYPE
-   node, or a UNION_TYPE node.
+   node, a UNION_TYPE node, or a QUAL_UNION_TYPE node.
 
    This function is used only for deciding when to "pend" and when to
    "un-pend" types to/from the pending_types_list.
@@ -2996,28 +3842,38 @@ pend_type (type)
    It order to delay the production of DIEs representing types of formal
    parameters, callers of this function supply `fake_containing_scope' as
    the `scope' parameter to this function.  Given that fake_containing_scope
-   is *not* the containing scope for *any* other type, the desired effect
-   is achieved, i.e. output of DIEs representing types is temporarily
-   suspended, and any type DIEs which would have been output otherwise
-   are instead placed onto the pending_types_list.  Later on, we can force
-   these (temporarily pended) types to be output simply by calling
+   is a tagged type which is *not* the containing scope for *any* other type,
+   the desired effect is achieved, i.e. output of DIEs representing types
+   is temporarily suspended, and any type DIEs which would have otherwise
+   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.
 */
 
-static int
+inline int
 type_ok_for_scope (type, scope)
     register tree type;
     register tree scope;
 {
-  return (TYPE_CONTEXT (type) == scope
-         || (TYPE_NAME (type) == NULL
-             && TREE_CODE (scope) != RECORD_TYPE
-             && TREE_CODE (scope) != UNION_TYPE));
+  /* Tagged types (i.e. struct, union, and enum types) must always be
+     output only in the scopes where they actually belong (or else the
+     scoping of their own tag names and the scoping of their member
+     names will be incorrect).  Non-tagged-types on the other hand can
+     generally be output anywhere, except that svr4 SDB really doesn't
+     want to see them nested within struct or union types, so here we
+     say it is always OK to immediately output any such a (non-tagged)
+     type, so long as we are not within such a context.  Note that the
+     only kinds of non-tagged types which we will be dealing with here
+     (for C and C++ anyway) will be array types and function types.  */
+
+  return is_tagged_type (type)
+        ? (TYPE_CONTEXT (type) == scope)
+        : (scope == NULL_TREE || ! is_tagged_type (scope));
 }
 
 /* Output any pending types (from the pending_types list) which we can output
-   now (given the limitations of the scope that we are working on now).
+   now (taking into account the scope that we are working on now).
 
    For each type output, remove the given type from the pending_types_list
    *before* we try to output it.
@@ -3076,7 +3932,7 @@ output_type (type, containing_scope)
      of 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);
+  type = type_main_variant (type);
 
   if (TREE_ASM_WRITTEN (type))
     return;
@@ -3098,7 +3954,7 @@ output_type (type, containing_scope)
       case POINTER_TYPE:
       case REFERENCE_TYPE:
        /* For these types, all that is required is that we output a DIE
-          (or a set of DIEs) to represent that "basis" type.  */
+          (or a set of DIEs) to represent the "basis" type.  */
        output_type (TREE_TYPE (type), containing_scope);
        break;
 
@@ -3120,7 +3976,7 @@ output_type (type, containing_scope)
 
       case FILE_TYPE:
        output_type (TREE_TYPE (type), containing_scope);
-       abort ();       /* No way to reprsent these in Dwarf yet!  */
+       abort ();       /* No way to represent these in Dwarf yet!  */
        break;
 
       case STRING_TYPE:
@@ -3160,15 +4016,16 @@ output_type (type, containing_scope)
       case ENUMERAL_TYPE:
       case RECORD_TYPE:
       case UNION_TYPE:
+      case QUAL_UNION_TYPE:
 
        /* For a non-file-scope tagged type, we can always go ahead and
           output a Dwarf description of this type right now, even if
           the type in question is still incomplete, because if this
           local type *was* ever completed anywhere within its scope,
           that complete definition would already have been attached to
-          this RECORD_TYPE, UNION_TYPE or ENUMERAL_TYPE node by the
-          time we reach this point.  That's true because of the way the
-          front-end does its processing of file-scope declarations (of
+          this RECORD_TYPE, UNION_TYPE, QUAL_UNION_TYPE or ENUMERAL_TYPE
+          node by the time we reach this point.  That's true because of the
+          way the front-end does its processing of file-scope declarations (of
           functions and class types) within which other types might be
           nested.  The C and C++ front-ends always gobble up such "local
           scope" things en-mass before they try to output *any* debugging
@@ -3213,8 +4070,12 @@ output_type (type, containing_scope)
            break;
 
          case UNION_TYPE:
+         case QUAL_UNION_TYPE:
            output_die (output_union_type_die, type);
            break;
+
+         default:
+           abort ();   /* Should never happen.  */
          }
 
        /* If this is not an incomplete type, output descriptions of
@@ -3236,22 +4097,49 @@ output_type (type, containing_scope)
 
        if (TYPE_SIZE (type))
          {
-           register tree member;
+           {
+             register tree normal_member;
 
-           /* First output info about the data members and type members.  */
+             /* First output info about the data members and type members.  */
 
-           for (member = TYPE_FIELDS (type);
-                member;
-                member = TREE_CHAIN (member))
-             output_decl (member, type);
+             for (normal_member = TYPE_FIELDS (type);
+                  normal_member;
+                  normal_member = TREE_CHAIN (normal_member))
+               output_decl (normal_member, type);
+           }
+
+           {
+             register tree vec_base;
+
+             /* Now output info about the function members (if any).  */
+
+             vec_base = TYPE_METHODS (type);
+             if (vec_base)
+               {
+                 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);
+               }
+           }
 
-           /* Now output info about the function members (if any).  */
+           /* 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.  */
 
-           if (TYPE_METHODS (type))
-             for (member = TREE_VEC_ELT (TYPE_METHODS (type), 0);
-                  member;
-                  member = TREE_CHAIN (member))
-               output_decl (member, type);
+           output_pending_types_for_scope (type);
 
            end_sibling_chain ();       /* Terminate member chain.  */
          }
@@ -3275,6 +4163,45 @@ output_type (type, containing_scope)
 
   TREE_ASM_WRITTEN (type) = 1;
 }
+
+static void
+output_tagged_type_instantiation (type)
+     register 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
+     sure that we have the main variant (i.e. the unqualified version) of
+     this type now.  */
+
+  assert (type == type_main_variant (type));
+
+  assert (TREE_ASM_WRITTEN (type));
+
+  switch (TREE_CODE (type))
+    {
+      case ERROR_MARK:
+       break;
+
+      case ENUMERAL_TYPE:
+       output_die (output_inlined_enumeration_type_die, type);
+       break;
+
+      case RECORD_TYPE:
+       output_die (output_inlined_structure_type_die, type);
+       break;
+
+      case UNION_TYPE:
+      case QUAL_UNION_TYPE:
+       output_die (output_inlined_union_type_die, type);
+       break;
+
+      default:
+       abort ();       /* Should never happen.  */
+    }
+}
 \f
 /* Output a TAG_lexical_block DIE followed by DIEs to represent all of
    the things which are local to the given block.  */
@@ -3283,33 +4210,67 @@ static void
 output_block (stmt)
     register tree stmt;
 {
-  register int have_significant_locals = 0;
+  register int must_output_die = 0;
+  register tree origin;
+  register enum tree_code origin_code;
 
   /* Ignore blocks never really used to make RTL.  */
 
   if (! stmt || ! TREE_USED (stmt))
     return;
 
-  /* Determine if this block contains any "significant" local declarations
-     which we need to output DIEs for.  */
+  /* Determine the "ultimate origin" of this block.  This block may be an
+     inlined instance of an inlined instance of inline function, so we
+     have to trace all of the way back through the origin chain to find
+     out what sort of node actually served as the original seed for the
+     creation of the current block.  */
 
-  if (BLOCK_INLINE_FUNCTION (stmt))
-    /* The outer scopes for inlinings *must* always be represented.  */
-    have_significant_locals = 1;
-  else
-    if (debug_info_level > DINFO_LEVEL_TERSE)
-      have_significant_locals = (BLOCK_VARS (stmt) != NULL);
-    else
-      {
-        register tree decl;
+  origin = block_ultimate_origin (stmt);
+  origin_code = (origin != NULL) ? TREE_CODE (origin) : ERROR_MARK;
+
+  /* Determine if we need to output any Dwarf DIEs at all to represent this
+     block.  */
 
-       for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
-         if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
+  if (origin_code == FUNCTION_DECL)
+    /* The outer scopes for inlinings *must* always be represented.  We
+       generate TAG_inlined_subroutine DIEs for them.  (See below.)  */
+    must_output_die = 1;
+  else
+    {
+      /* In the case where the current block represents an inlining of the
+        "body block" of an inline function, we must *NOT* output any DIE
+        for this block because we have already output a DIE to represent
+        the whole inlined function scope and the "body block" of any
+        function doesn't really represent a different scope according to
+        ANSI C rules.  So we check here to make sure that this block does
+        not represent a "body block inlining" before trying to set the
+        `must_output_die' flag.  */
+
+      if (origin == NULL || ! is_body_block (origin))
+       {
+         /* Determine if this block directly contains any "significant"
+            local declarations which we will need to output DIEs for.  */
+
+         if (debug_info_level > DINFO_LEVEL_TERSE)
+           /* We are not in terse mode so *any* local declaration counts
+              as being a "significant" one.  */
+           must_output_die = (BLOCK_VARS (stmt) != NULL);
+         else
            {
-             have_significant_locals = 1;
-             break;
+             register tree decl;
+
+             /* We are in terse mode, so only local (nested) function
+                definitions count as "significant" local declarations.  */
+
+             for (decl = BLOCK_VARS (stmt); decl; decl = TREE_CHAIN (decl))
+               if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl))
+                 {
+                   must_output_die = 1;
+                   break;
+                 }
            }
-      }
+       }
+    }
 
   /* It would be a waste of space to generate a Dwarf TAG_lexical_block
      DIE for any block which contains no significant local declarations
@@ -3319,11 +4280,11 @@ output_block (stmt)
      a "significant" local declaration gets restricted to include only
      inlined function instances and local (nested) function definitions.  */
 
-  if (have_significant_locals)
+  if (must_output_die)
     {
-      output_die (BLOCK_INLINE_FUNCTION (stmt)
-                       ? output_inlined_subroutine_die
-                       : output_lexical_block_die,
+      output_die ((origin_code == FUNCTION_DECL)
+                   ? output_inlined_subroutine_die
+                   : output_lexical_block_die,
                  stmt);
       output_decls_for_scope (stmt);
       end_sibling_chain ();
@@ -3344,7 +4305,8 @@ output_decls_for_scope (stmt)
   if (! stmt || ! TREE_USED (stmt))
     return;
 
-  next_block_number++;
+  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
@@ -3379,11 +4341,26 @@ output_decl (decl, containing_scope)
      register tree decl;
      register 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
+     case we notice (later on) that something about it looks screwy.  */
+
+  dwarf_last_decl = decl;
+
+  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 (DECL_IGNORED_P (decl) && TREE_CODE (decl) != FUNCTION_DECL)
+    return;
+
   switch (TREE_CODE (decl))
     {
-    case ERROR_MARK:
-      break;
-
     case CONST_DECL:
       /* The individual enumerators of an enum type get output when we
         output the Dwarf representation of the relevant enum type itself.  */
@@ -3391,10 +4368,15 @@ output_decl (decl, containing_scope)
 
     case FUNCTION_DECL:
       /* If we are in terse mode, don't output any DIEs to represent
-        mere external function declarations.  */
+        mere function declarations.  Also, if we are conforming
+        to the DWARF version 1 specification, don't output DIEs for
+        mere function declarations.  */
 
-      if (TREE_EXTERNAL (decl) && debug_info_level <= DINFO_LEVEL_TERSE)
-       break;
+      if (DECL_INITIAL (decl) == NULL_TREE)
+#if (DWARF_VERSION > 1)
+       if (debug_info_level <= DINFO_LEVEL_TERSE)
+#endif
+         break;
 
       /* Before we describe the FUNCTION_DECL itself, make sure that we
         have described its return type.  */
@@ -3417,7 +4399,7 @@ output_decl (decl, containing_scope)
 
       /* Now output a DIE to represent the function itself.  */
 
-      output_die (TREE_PUBLIC (decl) || TREE_EXTERNAL (decl)
+      output_die (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl)
                                ? output_global_subroutine_die
                                : output_local_subroutine_die,
                  decl);
@@ -3433,28 +4415,16 @@ output_decl (decl, containing_scope)
         ends with a void_type_node then there should *not* be an ellipsis
         at the end.  */
 
-      /* In the case where we are describing an external function, all
+      /* In the case where we are describing a mere function declaration, all
         we need to do here (and all we *can* do here) is to describe
         the *types* of its formal parameters.  */
 
-      if (TREE_EXTERNAL (decl))
+      if (DECL_INITIAL (decl) == NULL_TREE)
        output_formal_types (TREE_TYPE (decl));
       else
        {
          register tree arg_decls = DECL_ARGUMENTS (decl);
 
-         /* In the case where the FUNCTION_DECL represents a C++ non-static
-            member function, skip over the first thing on the DECL_ARGUMENTS
-            chain.  It only represents the hidden `this pointer' parameter
-            and the debugger should know implicitly that non-static member
-            functions have such a thing, and should be able to figure out
-            exactly what the type of each `this pointer' is (from the
-            AT_member attribute of the parent TAG_subroutine DIE)  without
-            being explicitly told.  */
-
-         if (TREE_CODE (TREE_TYPE (decl)) == METHOD_TYPE)
-           arg_decls = TREE_CHAIN (arg_decls);
-
          {
            register tree last_arg;
 
@@ -3577,19 +4547,25 @@ output_decl (decl, containing_scope)
        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 the body of a function.
+              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 get declared.  Just within
-              this contour, there will be another (nested) BLOCK which
-              represents the function's outermost block.  We don't want
-              to generate a lexical_block DIE to represent the outermost
-              block of a function body, because that is not really an
+              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 and
-              for Dwarf, we do not generate a TAG_lexical_block DIE for
-              that scope.  We must however see to it that the LABEL_DECLs
-              associated with `outer_scope' get DIEs generated for them.  */
+              the same scope in which the parameters were declared.  */
 
            {
              register tree label;
@@ -3600,6 +4576,11 @@ output_decl (decl, containing_scope)
                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.  */
+
            output_decls_for_scope (BLOCK_SUBBLOCKS (outer_scope));
 
            /* Finally, force out any pending types which are local to the
@@ -3630,6 +4611,20 @@ output_decl (decl, containing_scope)
            || ! TYPE_USED_FOR_FUNCTION (TREE_TYPE (decl)))
           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
+        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))
+       {
+         output_tagged_type_instantiation (TREE_TYPE (decl));
+         return;
+       }
+
       output_type (TREE_TYPE (decl), containing_scope);
 
       /* Note that unlike the gcc front end (which generates a NULL named
@@ -3652,6 +4647,14 @@ output_decl (decl, containing_scope)
       break;
 
     case VAR_DECL:
+      /* If we are conforming to the DWARF version 1 specification, don't
+        generated any DIEs to represent mere external object declarations.  */
+
+#if (DWARF_VERSION <= 1)
+      if (DECL_EXTERNAL (decl) && ! TREE_PUBLIC (decl))
+       break;
+#endif
+
       /* If we are in terse mode, don't generate any DIEs to represent
         any variable declarations or definitions.  */
 
@@ -3669,7 +4672,7 @@ output_decl (decl, containing_scope)
         was already generated in the .debug_pubnames section sub-entry
         for this data object definition.  */
 
-      if (TREE_PUBLIC (decl))
+      if (TREE_PUBLIC (decl) && ! DECL_ABSTRACT (decl))
        {
          char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -3677,11 +4680,26 @@ output_decl (decl, containing_scope)
          ASM_OUTPUT_LABEL (asm_out_file, label);
        }
 
-      /* Now output the DIE to represent the data object itself.  */
+      /* Now output the DIE to represent the data object itself.  This gets
+        complicated because of the possibility that the VAR_DECL really
+        represents an inlined instance of a formal parameter for an inline
+        function.  */
 
-      output_die (TREE_PUBLIC (decl) || TREE_EXTERNAL (decl)
-                  ? output_global_variable_die : output_local_variable_die,
-                 decl);
+      {
+        register void (*func) ();
+       register tree origin = decl_ultimate_origin (decl);
+
+       if (origin != NULL && TREE_CODE (origin) == PARM_DECL)
+         func = output_formal_parameter_die;
+       else
+         {
+           if (TREE_PUBLIC (decl) || DECL_EXTERNAL (decl))
+             func = output_global_variable_die;
+           else
+             func = output_local_variable_die;
+         }
+       output_die (func, decl);
+      }
       break;
 
     case FIELD_DECL:
@@ -3713,29 +4731,71 @@ dwarfout_file_scope_decl (decl, set_finalizing)
      register tree decl;
      register 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 (DECL_IGNORED_P (decl))
+    {
+      if (TREE_CODE (decl) == FUNCTION_DECL && DECL_INITIAL (decl) != NULL)
+       abort ();
+      return;
+    }
+
   switch (TREE_CODE (decl))
     {
     case FUNCTION_DECL:
 
-      /* Ignore this FUNCTION_DECL if it refers to a builtin function.  */
+      /* Ignore this FUNCTION_DECL if it refers to a builtin declaration of
+        a builtin function.  Explicit programmer-supplied declarations of
+        these same functions should NOT be ignored however.  */
 
-      if (TREE_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
+      if (DECL_EXTERNAL (decl) && DECL_FUNCTION_CODE (decl))
         return;
 
-      /* Ignore this FUNCTION_DECL if it refers to a file-scope extern
-        function declaration and if the declaration was never even
-        referenced from within this entire compilation unit.  We
-        suppress these DIEs in order to save space in the .debug section
-        (by eliminating entries which are probably useless).  Note that
-        we must not suppress block-local extern declarations (whether
-        used or not) because that would screw-up the debugger's name
-        lookup mechanism and cause it to miss things which really ought
-        to be in scope at a given point.  */
-
-      if (TREE_EXTERNAL (decl) && !TREE_USED (decl))
+      /* 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,
+        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
+        around and find the DWARF information associated with the
+        *definition* of the function.
+
+        Note that we can't just check `DECL_EXTERNAL' to find out which
+        FUNCTION_DECL nodes represent definitions and which ones represent
+        mere declarations.  We have to check `DECL_INITIAL' instead.  That's
+        because the C front-end supports some weird semantics for "extern
+        inline" function definitions.  These can get inlined within the
+        current translation unit (an thus, we need to generate DWARF info
+        for their abstract instances so that the DWARF info for the
+        concrete inlined instances can have something to refer to) but
+        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
+        anyway.
+
+        Note that the C++ front-end also plays some similar games for inline
+        function definitions appearing within include files which also
+        contain `#pragma interface' pragmas.  */
+
+      if (DECL_INITIAL (decl) == NULL_TREE)
        return;
 
-      if (TREE_PUBLIC (decl) && ! TREE_EXTERNAL (decl))
+      if (TREE_PUBLIC (decl)
+         && ! DECL_EXTERNAL (decl)
+         && ! DECL_ABSTRACT (decl))
        {
          char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -3765,10 +4825,13 @@ dwarfout_file_scope_decl (decl, set_finalizing)
         lookup mechanism and cause it to miss things which really ought
         to be in scope at a given point.  */
 
-      if (TREE_EXTERNAL (decl) && !TREE_USED (decl))
+      if (DECL_EXTERNAL (decl) && !TREE_USED (decl))
        return;
 
-      if (TREE_PUBLIC (decl) && ! TREE_EXTERNAL (decl))
+      if (TREE_PUBLIC (decl)
+         && ! DECL_EXTERNAL (decl)
+         && GET_CODE (DECL_RTL (decl)) == MEM
+         && ! DECL_ABSTRACT (decl))
        {
          char label[MAX_ARTIFICIAL_LABEL_BYTES];
 
@@ -3789,12 +4852,12 @@ dwarfout_file_scope_decl (decl, set_finalizing)
          if (DECL_INITIAL (decl) == NULL)
            {
              /* Output a .debug_aranges entry for a public variable
-                which is tenatively defined in this compilation unit.  */
+                which is tentatively defined in this compilation unit.  */
 
              fputc ('\n', asm_out_file);
              ASM_OUTPUT_PUSH_SECTION (asm_out_file, ARANGES_SECTION);
              ASM_OUTPUT_DWARF_ADDR (asm_out_file,
-                                    IDENTIFIER_POINTER (DECL_NAME (decl)));
+                             IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)));
              ASM_OUTPUT_DWARF_DATA4 (asm_out_file, 
                        (unsigned) int_size_in_bytes (TREE_TYPE (decl)));
              ASM_OUTPUT_POP_SECTION (asm_out_file);
@@ -3810,9 +4873,18 @@ dwarfout_file_scope_decl (decl, set_finalizing)
       break;
 
     case TYPE_DECL:
-      /* Don't generate any DIEs to represent the standard built-in types.  */
-
-      if (DECL_SOURCE_LINE (decl) == 0)
+      /* Don't bother trying to generate any DIEs to represent any of the
+        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
+        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.  */
+
+      if (DECL_SOURCE_LINE (decl) == 0
+         && type_is_fundamental (TREE_TYPE (decl)))
        return;
 
       /* If we are in terse mode, don't generate any DIEs to represent
@@ -3835,7 +4907,7 @@ dwarfout_file_scope_decl (decl, set_finalizing)
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, DEBUG_SECTION);
   finalizing = set_finalizing;
-  output_decl (decl, NULL);
+  output_decl (decl, NULL_TREE);
 
   /* NOTE:  The call above to `output_decl' may have caused one or more
      file-scope named types (i.e. tagged types) to be placed onto the
@@ -3848,7 +4920,7 @@ dwarfout_file_scope_decl (decl, set_finalizing)
      `output_pending_types_for_scope' takes them off of the list and un-sets
      their TREE_ASM_WRITTEN flags.  */
 
-  output_pending_types_for_scope (NULL);
+  output_pending_types_for_scope (NULL_TREE);
 
   /* The above call should have totally emptied the pending_types_list.  */
 
@@ -3906,6 +4978,33 @@ dwarfout_label (insn)
     }
 }
 
+/* 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 ()
+{
+  char label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+  text_section ();
+  sprintf (label, BODY_BEGIN_LABEL_FMT, current_funcdef_number);
+  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 ()
+{
+  char label[MAX_ARTIFICIAL_LABEL_BYTES];
+
+  text_section ();
+  sprintf (label, BODY_END_LABEL_FMT, current_funcdef_number);
+  ASM_OUTPUT_LABEL (asm_out_file, label);
+}
+
 /* Output a marker (i.e. a label) for the absolute end of the generated code
    for a function definition.  This gets called *after* the epilogue code
    has been generated. */
@@ -4091,7 +5190,7 @@ dwarfout_line (filename, line)
         }
 
       {
-        register char *tail = strrchr (filename, '/');
+        register char *tail = rindex (filename, '/');
 
         if (tail != NULL)
           filename = tail;
@@ -4242,12 +5341,14 @@ dwarfout_init (asm_out_file, main_input_filename)
   ASM_OUTPUT_LABEL (asm_out_file, DATA_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
+#if 0 /* GNU C doesn't currently use .data1.  */
   /* Output a starting label for the .data1 section.  */
 
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
   ASM_OUTPUT_LABEL (asm_out_file, DATA1_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
+#endif
 
   /* Output a starting label for the .rodata section.  */
 
@@ -4256,12 +5357,14 @@ dwarfout_init (asm_out_file, main_input_filename)
   ASM_OUTPUT_LABEL (asm_out_file, RODATA_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
+#if 0 /* GNU C doesn't currently use .rodata1.  */
   /* Output a starting label for the .rodata1 section.  */
 
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA1_BEGIN_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
+#endif
 
   /* Output a starting label for the .bss section.  */
 
@@ -4385,7 +5488,7 @@ dwarfout_finish ()
 
      In order to force the label `..D2' to get aligned to a 4 byte boundary,
      the trick used is to insert extra (otherwise useless) padding bytes
-     into the (null) DIE that we know must preceed the ..D2 label in the
+     into the (null) DIE that we know must precede the ..D2 label in the
      .debug section.  The amount of padding required can be anywhere between
      0 and 3 bytes.  The length word at the start of this DIE (i.e. the one
      with the padding) would normally contain the value 4, but now it will
@@ -4419,12 +5522,14 @@ dwarfout_finish ()
   ASM_OUTPUT_LABEL (asm_out_file, DATA_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
+#if 0 /* GNU C doesn't currently use .data1.  */
   /* Output a terminator label for the .data1 section.  */
 
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, DATA1_SECTION);
   ASM_OUTPUT_LABEL (asm_out_file, DATA1_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
+#endif
 
   /* Output a terminator label for the .rodata section.  */
 
@@ -4433,12 +5538,14 @@ dwarfout_finish ()
   ASM_OUTPUT_LABEL (asm_out_file, RODATA_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
 
+#if 0 /* GNU C doesn't currently use .rodata1.  */
   /* Output a terminator label for the .rodata1 section.  */
 
   fputc ('\n', asm_out_file);
   ASM_OUTPUT_PUSH_SECTION (asm_out_file, RODATA1_SECTION);
   ASM_OUTPUT_LABEL (asm_out_file, RODATA1_END_LABEL);
   ASM_OUTPUT_POP_SECTION (asm_out_file);
+#endif
 
   /* Output a terminator label for the .bss section.  */
 
@@ -4513,17 +5620,21 @@ dwarfout_finish ()
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA_END_LABEL, DATA_BEGIN_LABEL);
 
+#if 0 /* GNU C doesn't currently use .data1.  */
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, DATA1_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, DATA1_END_LABEL,
                                             DATA1_BEGIN_LABEL);
+#endif
 
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA_END_LABEL,
                                             RODATA_BEGIN_LABEL);
 
+#if 0 /* GNU C doesn't currently use .rodata1.  */
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, RODATA1_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, RODATA1_END_LABEL,
                                             RODATA1_BEGIN_LABEL);
+#endif
 
       ASM_OUTPUT_DWARF_ADDR (asm_out_file, BSS_BEGIN_LABEL);
       ASM_OUTPUT_DWARF_DELTA4 (asm_out_file, BSS_END_LABEL, BSS_BEGIN_LABEL);