OSDN Git Service

PR 13596
[pf3gnuchains/gcc-fork.git] / gcc / dbxout.c
index 6630702..8171757 100644 (file)
@@ -3089,6 +3089,46 @@ dbxout_args (tree args)
     }
 }
 \f
+/* Subroutine of dbxout_block.  Emit an N_LBRAC stab referencing LABEL.
+   BEGIN_LABEL is the name of the beginning of the function, which may
+   be required.  */
+static void
+dbx_output_lbrac (const char *label,
+                 const char *begin_label ATTRIBUTE_UNUSED)
+{
+#ifdef DBX_OUTPUT_LBRAC
+  DBX_OUTPUT_LBRAC (asmfile, label);
+#else
+  fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
+  assemble_name (asmfile, label);
+#if DBX_BLOCKS_FUNCTION_RELATIVE
+  putc ('-', asmfile);
+  assemble_name (asmfile, begin_label);
+#endif
+  fprintf (asmfile, "\n");
+#endif
+}
+
+/* Subroutine of dbxout_block.  Emit an N_RBRAC stab referencing LABEL.
+   BEGIN_LABEL is the name of the beginning of the function, which may
+   be required.  */
+static void
+dbx_output_rbrac (const char *label,
+                 const char *begin_label ATTRIBUTE_UNUSED)
+{
+#ifdef DBX_OUTPUT_RBRAC
+  DBX_OUTPUT_RBRAC (asmfile, label);
+#else
+  fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_RBRAC);
+  assemble_name (asmfile, label);
+#if DBX_BLOCKS_FUNCTION_RELATIVE
+  putc ('-', asmfile);
+  assemble_name (asmfile, begin_label);
+#endif
+  fprintf (asmfile, "\n");
+#endif
+}
+
 /* Output everything about a symbol block (a BLOCK node
    that represents a scope level),
    including recursive output of contained blocks.
@@ -3109,15 +3149,11 @@ dbxout_args (tree args)
 static void
 dbxout_block (tree block, int depth, tree args)
 {
-  int blocknum = -1;
-
-#if DBX_BLOCKS_FUNCTION_RELATIVE
   const char *begin_label;
   if (current_function_func_begin_label != NULL_TREE)
     begin_label = IDENTIFIER_POINTER (current_function_func_begin_label);
   else
     begin_label = XSTR (XEXP (DECL_RTL (current_function_decl), 0), 0);
-#endif
 
   while (block)
     {
@@ -3125,6 +3161,7 @@ dbxout_block (tree block, int depth, tree args)
       if (TREE_USED (block) && TREE_ASM_WRITTEN (block))
        {
          int did_output;
+         int blocknum = BLOCK_NUMBER (block);
 
          /* 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.  */
@@ -3138,11 +3175,20 @@ dbxout_block (tree block, int depth, tree 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 && did_output)
+         if (did_output)
            {
              char buf[20];
-             blocknum = BLOCK_NUMBER (block);
-             ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
+             const char *scope_start;
+
+             if (depth == 0)
+               /* The outermost block doesn't get LBB labels; use
+                  the function symbol.  */
+               scope_start = begin_label;
+             else
+               {
+                 ASM_GENERATE_INTERNAL_LABEL (buf, "LBB", blocknum);
+                 scope_start = buf;
+               }
 
              if (BLOCK_HANDLER_BLOCK (block))
                {
@@ -3152,44 +3198,30 @@ dbxout_block (tree block, int depth, tree args)
                    {
                      fprintf (asmfile, "%s\"%s:C1\",%d,0,0,", ASM_STABS_OP,
                               IDENTIFIER_POINTER (DECL_NAME (decl)), N_CATCH);
-                     assemble_name (asmfile, buf);
+                     assemble_name (asmfile, scope_start);
                      fprintf (asmfile, "\n");
                      decl = TREE_CHAIN (decl);
                    }
                }
-
-#ifdef DBX_OUTPUT_LBRAC
-             DBX_OUTPUT_LBRAC (asmfile, buf);
-#else
-             fprintf (asmfile, "%s%d,0,0,", ASM_STABN_OP, N_LBRAC);
-             assemble_name (asmfile, buf);
-#if DBX_BLOCKS_FUNCTION_RELATIVE
-             putc ('-', asmfile);
-             assemble_name (asmfile, begin_label);
-#endif
-             fprintf (asmfile, "\n");
-#endif
+             dbx_output_lbrac (scope_start, begin_label);
            }
 
          /* Output the subblocks.  */
          dbxout_block (BLOCK_SUBBLOCKS (block), depth + 1, NULL_TREE);
 
          /* Refer to the marker for the end of the block.  */
-         if (depth > 0 && did_output)
+         if (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);
-             assemble_name (asmfile, buf);
-#if DBX_BLOCKS_FUNCTION_RELATIVE
-             putc ('-', asmfile);
-             assemble_name (asmfile, begin_label);
-#endif
-             fprintf (asmfile, "\n");
-#endif
+             char buf[100];
+             if (depth == 0)
+               /* The outermost block doesn't get LBE labels;
+                  use the "scope" label which will be emitted
+                  by dbxout_function_end.  */
+               ASM_GENERATE_INTERNAL_LABEL (buf, "Lscope", scope_labelno);
+             else
+               ASM_GENERATE_INTERNAL_LABEL (buf, "LBE", blocknum);
+
+             dbx_output_rbrac (buf, begin_label);
            }
        }
       block = BLOCK_CHAIN (block);