OSDN Git Service

* cppfiles.c (search_from): Special case the empty string.
[pf3gnuchains/gcc-fork.git] / gcc / dbxout.c
index 1be2025..05a95a4 100644 (file)
@@ -1,6 +1,6 @@
 /* Output dbx-format symbol table information from GNU compiler.
    Copyright (C) 1987, 1988, 1992, 1993, 1994, 1995, 1996, 1997, 1998,
-   1999, 2000 Free Software Foundation, Inc.
+   1999, 2000, 2001 Free Software Foundation, Inc.
 
 This file is part of GNU CC.
 
@@ -77,7 +77,6 @@ Boston, MA 02111-1307, USA.  */
 #include "regs.h"
 #include "insn-config.h"
 #include "reload.h"
-#include "defaults.h"
 #include "output.h" /* ASM_OUTPUT_SOURCE_LINE may refer to sdb functions.  */
 #include "dbxout.h"
 #include "toplev.h"
@@ -89,11 +88,11 @@ Boston, MA 02111-1307, USA.  */
 #endif
 
 #ifndef ASM_STABS_OP
-#define ASM_STABS_OP ".stabs"
+#define ASM_STABS_OP "\t.stabs\t"
 #endif
 
 #ifndef ASM_STABN_OP
-#define ASM_STABN_OP ".stabn"
+#define ASM_STABN_OP "\t.stabn\t"
 #endif
 
 #ifndef DBX_TYPE_DECL_STABS_CODE
@@ -348,7 +347,7 @@ dbxout_function_end ()
 
   /* By convention, GCC will mark the end of a function with an N_FUN
      symbol and an empty string.  */
-  fprintf (asmfile, "%s \"\",%d,0,0,", ASM_STABS_OP, N_FUN);
+  fprintf (asmfile, "%s\"\",%d,0,0,", ASM_STABS_OP, N_FUN);
   assemble_name (asmfile, lscope_label_name);
   fputc ('-', asmfile);
   assemble_name (asmfile, XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0));
@@ -394,7 +393,7 @@ dbxout_init (asm_file, input_file_name, syms)
 #ifdef DBX_OUTPUT_MAIN_SOURCE_DIRECTORY
          DBX_OUTPUT_MAIN_SOURCE_DIRECTORY (asmfile, cwd);
 #else /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
-         fprintf (asmfile, "%s ", ASM_STABS_OP);
+         fprintf (asmfile, "%s", ASM_STABS_OP);
          output_quoted_string (asmfile, cwd);
          fprintf (asmfile, ",%d,0,0,%s\n", N_SO, &ltext_label_name[1]);
 #endif /* no DBX_OUTPUT_MAIN_SOURCE_DIRECTORY */
@@ -409,7 +408,7 @@ dbxout_init (asm_file, input_file_name, syms)
   /* We include outputting `Ltext:' here,
      because that gives you a way to override it.  */
   /* Used to put `Ltext:' before the reference, but that loses on sun 4.  */
-  fprintf (asmfile, "%s ", ASM_STABS_OP);
+  fprintf (asmfile, "%s", ASM_STABS_OP);
   output_quoted_string (asmfile, input_file_name);
   fprintf (asmfile, ",%d,0,0,%s\n", 
           N_SO, &ltext_label_name[1]);
@@ -454,8 +453,6 @@ dbxout_init (asm_file, input_file_name, syms)
      and output them all, except for those already output.  */
 
   dbxout_typedefs (syms);
-
-  ggc_add_string_root ((char **) &lastfile, 1);
 }
 
 /* Output any typedef names for types described by TYPE_DECLs in SYMS,
@@ -493,7 +490,7 @@ dbxout_start_new_source_file (filename)
   n->file_number = next_file_number++;
   n->next_type_number = 1;
   current_file = n;
-  fprintf (asmfile, "%s ", ASM_STABS_OP);
+  fprintf (asmfile, "%s", ASM_STABS_OP);
   output_quoted_string (asmfile, filename);
   fprintf (asmfile, ",%d,0,0,0\n", N_BINCL);
 #endif
@@ -507,7 +504,7 @@ dbxout_resume_previous_source_file ()
 #ifdef DBX_USE_BINCL
   struct dbx_file *next;
 
-  fprintf (asmfile, "%s %d,0,0,0\n", ASM_STABN_OP, N_EINCL);
+  fprintf (asmfile, "%s%d,0,0,0\n", ASM_STABN_OP, N_EINCL);
   next = current_file->next;
   free (current_file);
   current_file = next;
@@ -530,7 +527,7 @@ dbxout_source_file (file, filename)
 #else
       ASM_GENERATE_INTERNAL_LABEL (ltext_label_name, "Ltext",
                                   source_label_number);
-      fprintf (file, "%s ", ASM_STABS_OP);
+      fprintf (file, "%s", ASM_STABS_OP);
       output_quoted_string (file, filename);
       fprintf (file, ",%d,0,0,%s\n", N_SOL, &ltext_label_name[1]);
       if (current_function_decl != NULL_TREE
@@ -559,7 +556,7 @@ dbxout_source_line (file, filename, lineno)
 #ifdef ASM_OUTPUT_SOURCE_LINE
   ASM_OUTPUT_SOURCE_LINE (file, lineno);
 #else
-  fprintf (file, "\t%s %d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
+  fprintf (file, "%s%d,0,%d\n", ASM_STABD_OP, N_SLINE, lineno);
 #endif
 }
 
@@ -609,7 +606,7 @@ dbxout_continue ()
   fprintf (asmfile, "\\\\");
 #endif
   dbxout_finish_symbol (NULL_TREE);
-  fprintf (asmfile, "%s \"", ASM_STABS_OP);
+  fprintf (asmfile, "%s\"", ASM_STABS_OP);
   current_sym_nchars = 0;
 }
 #endif /* DBX_CONTIN_LENGTH > 0 */
@@ -844,7 +841,9 @@ dbxout_type_methods (type)
 
          last = fndecl;
 
-         if (DECL_IGNORED_P (fndecl))
+         /* Also ignore abstract methods; those are only interesting to
+            the DWARF backends.  */
+         if (DECL_IGNORED_P (fndecl) || DECL_ABSTRACT (fndecl))
            continue;
 
          if (flag_minimal_debug)
@@ -1043,7 +1042,7 @@ dbxout_type (type, full, show_arg_types)
          typevec
            = (struct typeinfo *) xrealloc (typevec,
                                            typevec_len * 2 * sizeof typevec[0]);
-         bzero ((char *) (typevec + typevec_len),
+         memset ((char *) (typevec + typevec_len), 0,
                 typevec_len * sizeof typevec[0]);
          typevec_len *= 2;
        }
@@ -1754,7 +1753,7 @@ dbxout_symbol (decl, local)
        break;
       FORCE_TEXT;
 
-      fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
+      fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
               IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl)),
               TREE_PUBLIC (decl) ? 'F' : 'f');
       result = 1;
@@ -1830,14 +1829,14 @@ dbxout_symbol (decl, local)
                current_sym_addr = 0;
                current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
 
-               fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
                         IDENTIFIER_POINTER (name));
                dbxout_type (type, 1, 0);
                dbxout_finish_symbol (NULL_TREE);
              }
 
            /* Output typedef name.  */
-           fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
+           fprintf (asmfile, "%s\"%s:", ASM_STABS_OP,
                     IDENTIFIER_POINTER (DECL_NAME (decl)));
 
            /* Short cut way to output a tag also.  */
@@ -1891,7 +1890,7 @@ dbxout_symbol (decl, local)
            current_sym_addr = 0;
            current_sym_nchars = 2 + IDENTIFIER_LENGTH (name);
 
-           fprintf (asmfile, "%s \"%s:T", ASM_STABS_OP,
+           fprintf (asmfile, "%s\"%s:T", ASM_STABS_OP,
                     IDENTIFIER_POINTER (name));
            dbxout_type (type, 1, 0);
            dbxout_finish_symbol (NULL_TREE);
@@ -1910,7 +1909,7 @@ dbxout_symbol (decl, local)
 
            /* Some debuggers fail when given NULL names, so give this a
               harmless name of ` '.  */
-           fprintf (asmfile, "%s \" :T", ASM_STABS_OP);
+           fprintf (asmfile, "%s\" :T", ASM_STABS_OP);
            dbxout_type (type, 1, 0);
            dbxout_finish_symbol (NULL_TREE);
          }
@@ -1956,7 +1955,7 @@ dbxout_symbol (decl, local)
 #ifdef DBX_OUTPUT_CONSTANT_SYMBOL
                  DBX_OUTPUT_CONSTANT_SYMBOL (asmfile, name, ival);
 #else
-                 fprintf (asmfile, "%s \"%s:c=i", ASM_STABS_OP, name);
+                 fprintf (asmfile, "%s\"%s:c=i", ASM_STABS_OP, name);
 
                  fprintf (asmfile, HOST_WIDE_INT_PRINT_DEC, ival);
                  fprintf (asmfile, "\",0x%x,0,0,0\n", N_LSYM);
@@ -2215,14 +2214,22 @@ dbxout_symbol_name (decl, suffix, letter)
      const char *suffix;
      int letter;
 {
-  /* One slight hitch: if this is a VAR_DECL which is a static
-     class member, we must put out the mangled name instead of the
-     DECL_NAME.  Note also that static member (variable) names DO NOT begin
-     with underscores in .stabs directives.  */
-  const char *name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  const char *name;
+
+  if (DECL_CONTEXT (decl) && TYPE_P (DECL_CONTEXT (decl)))
+    /* One slight hitch: if this is a VAR_DECL which is a static
+       class member, we must put out the mangled name instead of the
+       DECL_NAME.  Note also that static member (variable) names DO NOT begin
+       with underscores in .stabs directives.  */
+    name = IDENTIFIER_POINTER (DECL_ASSEMBLER_NAME (decl));
+  else
+    /* ...but if we're function-local, we don't want to include the junk
+       added by ASM_FORMAT_PRIVATE_NAME.  */
+    name = IDENTIFIER_POINTER (DECL_NAME (decl));
+
   if (name == 0)
     name = "(anon)";
-  fprintf (asmfile, "%s \"%s%s:", ASM_STABS_OP, name,
+  fprintf (asmfile, "%s\"%s%s:", ASM_STABS_OP, name,
           (suffix ? suffix : ""));
 
   if (letter) putc (letter, asmfile);
@@ -2331,14 +2338,14 @@ dbxout_parms (parms)
              {
                current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
 
-               fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
                         IDENTIFIER_POINTER (DECL_NAME (parms)),
                         DBX_MEMPARM_STABS_LETTER);
              }
            else
              {
                current_sym_nchars = 8;
-               fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
                         DBX_MEMPARM_STABS_LETTER);
              }
 
@@ -2396,14 +2403,14 @@ dbxout_parms (parms)
            if (DECL_NAME (parms))
              {
                current_sym_nchars = 2 + IDENTIFIER_LENGTH (DECL_NAME (parms));
-               fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
                         IDENTIFIER_POINTER (DECL_NAME (parms)),
                         regparm_letter);
              }
            else
              {
                current_sym_nchars = 8;
-               fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
                         regparm_letter);
              }
 
@@ -2449,14 +2456,14 @@ dbxout_parms (parms)
              {
                current_sym_nchars = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
 
-               fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
                         IDENTIFIER_POINTER (DECL_NAME (parms)),
                         regparm_letter);
              }
            else
              {
                current_sym_nchars = 8;
-               fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
                         regparm_letter);
              }
 
@@ -2464,6 +2471,28 @@ dbxout_parms (parms)
            dbxout_finish_symbol (parms);
          }
        else if (GET_CODE (DECL_RTL (parms)) == MEM
+                && GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
+         {
+           /* Parm was passed via invisible reference, with the reference
+              living on the stack.  DECL_RTL looks like
+              (MEM (MEM (PLUS (REG ...) (CONST_INT ...)))) or it
+              could look like (MEM (MEM (REG))).  */
+           const char *decl_name = (DECL_NAME (parms)
+                                    ? IDENTIFIER_POINTER (DECL_NAME (parms))
+                                    : "(anon)");
+           if (GET_CODE (XEXP (XEXP (DECL_RTL (parms), 0), 0)) == REG)
+              current_sym_value = 0;
+           else
+             current_sym_value
+               = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
+           current_sym_addr = 0;
+             
+           FORCE_TEXT;
+           fprintf (asmfile, "%s\"%s:v", ASM_STABS_OP, decl_name);
+           dbxout_type (TREE_TYPE (parms), 0, 0);
+           dbxout_finish_symbol (parms);
+         }
+       else if (GET_CODE (DECL_RTL (parms)) == MEM
                 && XEXP (DECL_RTL (parms), 0) != const0_rtx
                 /* ??? A constant address for a parm can happen
                    when the reg it lives in is equiv to a constant in memory.
@@ -2471,22 +2500,14 @@ dbxout_parms (parms)
                 && ! CONSTANT_P (XEXP (DECL_RTL (parms), 0)))
          {
            /* Parm was passed in registers but lives on the stack.  */
-           int aux_sym_value = 0;
 
            current_sym_code = N_PSYM;
            /* DECL_RTL looks like (MEM (PLUS (REG...) (CONST_INT...))),
               in which case we want the value of that CONST_INT,
-              or (MEM (REG ...)) or (MEM (MEM ...)),
+              or (MEM (REG ...)),
               in which case we use a value of zero.  */
            if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == REG)
              current_sym_value = 0;
-           else if (GET_CODE (XEXP (DECL_RTL (parms), 0)) == MEM)
-             {
-               /* Remember the location on the stack the parm is moved to */
-               aux_sym_value
-                 = INTVAL (XEXP (XEXP (XEXP (DECL_RTL (parms), 0), 0), 1));
-               current_sym_value = 0;
-             }
            else
                current_sym_value
                  = INTVAL (XEXP (XEXP (DECL_RTL (parms), 0), 1));
@@ -2510,14 +2531,14 @@ dbxout_parms (parms)
                current_sym_nchars
                  = 2 + strlen (IDENTIFIER_POINTER (DECL_NAME (parms)));
 
-               fprintf (asmfile, "%s \"%s:%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"%s:%c", ASM_STABS_OP,
                         IDENTIFIER_POINTER (DECL_NAME (parms)),
                         DBX_MEMPARM_STABS_LETTER);
              }
            else
              {
                current_sym_nchars = 8;
-               fprintf (asmfile, "%s \"(anon):%c", ASM_STABS_OP,
+               fprintf (asmfile, "%s\"(anon):%c", ASM_STABS_OP,
                DBX_MEMPARM_STABS_LETTER);
              }
 
@@ -2526,17 +2547,6 @@ dbxout_parms (parms)
                                     XEXP (DECL_RTL (parms), 0));
            dbxout_type (TREE_TYPE (parms), 0, 0);
            dbxout_finish_symbol (parms);
-           if (aux_sym_value != 0)
-             {
-               /* Generate an entry for the stack location */
-
-               fprintf (asmfile, "%s \"%s:", ASM_STABS_OP,
-                        IDENTIFIER_POINTER (DECL_NAME (parms)));
-               current_sym_value = aux_sym_value;
-               current_sym_code = N_LSYM;
-               dbxout_type (build_reference_type (TREE_TYPE (parms)), 0, 0);
-               dbxout_finish_symbol (parms);
-             }
          }
       }
 }
@@ -2636,7 +2646,6 @@ dbxout_block (block, depth, args)
      tree args;
 {
   int blocknum = -1;
-  int ignored;
 
 #if DBX_BLOCKS_FUNCTION_RELATIVE
   const char *begin_label; 
@@ -2651,12 +2660,16 @@ dbxout_block (block, depth, args)
       /* Ignore blocks never expanded or otherwise marked as real.  */
       if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
        {
-#ifndef DBX_LBRAC_FIRST
+         int did_output;
+
+#ifdef DBX_LBRAC_FIRST
+         did_output = 1;
+#else
          /* In dbx format, the syms of a block come before the N_LBRAC.
             If nothing is output, we don't need the N_LBRAC, either. */
-         ignored = 1;
+         did_output = 0;
          if (debug_info_level != DINFO_LEVEL_TERSE || depth == 0)
-           ignored = dbxout_syms (BLOCK_VARS (block));
+           did_output = dbxout_syms (BLOCK_VARS (block));
          if (args)
            dbxout_reg_parms (args);
 #endif
@@ -2665,7 +2678,7 @@ dbxout_block (block, depth, args)
             the block.  Use the block's tree-walk order to generate
             the assembler symbols LBBn and LBEn
             that final will define around the code in this block.  */
-         if (depth > 0 && !ignored)
+         if (depth > 0 && did_output)
            {
              char buf[20];
              blocknum = BLOCK_NUMBER (block);
@@ -2680,7 +2693,7 @@ dbxout_block (block, depth, args)
 #ifdef DBX_OUTPUT_CATCH
                      DBX_OUTPUT_CATCH (asmfile, decl, buf);
 #else
-                     fprintf (asmfile, "%s \"%s:C1\",%d,0,0,", ASM_STABS_OP,
+                     fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
                               IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
                      assemble_name (asmfile, buf);
                      fprintf (asmfile, "\n");
@@ -2692,7 +2705,7 @@ dbxout_block (block, depth, args)
 #ifdef DBX_OUTPUT_LBRAC
              DBX_OUTPUT_LBRAC (asmfile, buf);
 #else
-             fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_LBRAC);
+             fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
              assemble_name (asmfile, buf);
 #if DBX_BLOCKS_FUNCTION_RELATIVE
              fputc ('-', asmfile);
@@ -2715,14 +2728,14 @@ dbxout_block (block, depth, args)
          dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
 
          /* Refer to the marker for the end of the block.  */
-         if (depth > 0 && !ignored)
+         if (depth > 0 && did_output)
            {
              char buf[20];
              ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
 #ifdef DBX_OUTPUT_RBRAC
              DBX_OUTPUT_RBRAC (asmfile, buf);
 #else
-             fprintf (asmfile, "%s %d,0,0,", ASM_STABN_OP, N_RBRAC);
+             fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
              assemble_name (asmfile, buf);
 #if DBX_BLOCKS_FUNCTION_RELATIVE
              fputc ('-', asmfile);