On Sun, Jul 16, 2006 at 06:05:32PM -0700, Ian Lance Taylor wrote:
> Previously, scope_labelno was referenced in dbxout_block and
> incremented in dbxout_function_end.  Both functions are called only by
> dbxout_function_decl (a debug hook).  So it was always consistent.
> 
> Now scope_labelno is used by dbxout_begin_prologue and
> dbxout_source_line.  Those are both debug hooks themselves.  So this
> patch has introduced a dependency which was not previously there,
> which has led to a bug.
> 
> There are several ways to fix this, of course.  I think the simplest
> is going to be to always preincrement scope_labelno in
> dbxout_begin_prologue, rather than postincrementing it in
> dbxout_function_end.  In cases where that fails, we are already in
> trouble.
> 
> Note that scope_labelno is now used for two different things: for the
> LFBB symbol, and for the Lscope symbol.  It does not have to be used
> for both, although as far as I can see it does no harm.

The following patch does a pre-increment of scope_labelno in
dbxout_begin_prologue.

No regressions on arm-none-eabi, and I verified the output stabs by
hand. The .Lscope and .LFBB labels start at 1, and increment for each
call to dbxout_begin_prologue.

Andrew, I built a powerpc-darwin cross compiler and manually verified
the output assembly from your testcase. It looks like it should fix your
problem. I don't see any repeated LFBB symbols, where previously I saw
repeated LFBB1 and LFBB4 due to the thunks.

OK to commit? 

Cheers,
Carlos.
-- 
Carlos O'Donell
CodeSourcery
[EMAIL PROTECTED]
(650) 331-3385 x716

2006-07-17  Carlos O'Donell  <[EMAIL PROTECTED]>

        * dbxout.c (dbxout_function_end): Do not increment scope_labelno.
        (dbxout_begin_prologue): Increment scope_labelno.

Index: gcc/dbxout.c
===================================================================
--- gcc/dbxout.c        (revision 115532)
+++ gcc/dbxout.c        (working copy)
@@ -905,7 +905,6 @@ static void
 dbxout_function_end (tree decl)
 {
   char lscope_label_name[100];
-  int lscope_labelno = scope_labelno++;
 
   /* The Lscope label must be emitted even if we aren't doing anything
      else; dbxout_block needs it.  */
@@ -914,8 +913,8 @@ dbxout_function_end (tree decl)
   /* Convert Lscope into the appropriate format for local labels in case
      the system doesn't insert underscores in front of user generated
      labels.  */
-  ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", lscope_labelno);
-  targetm.asm_out.internal_label (asm_out_file, "Lscope", lscope_labelno);
+  ASM_GENERATE_INTERNAL_LABEL (lscope_label_name, "Lscope", scope_labelno);
+  targetm.asm_out.internal_label (asm_out_file, "Lscope", scope_labelno);
 
   /* The N_FUN tag at the end of the function is a GNU extension,
      which may be undesirable, and is unnecessary if we do not have
@@ -941,7 +940,7 @@ dbxout_function_end (tree decl)
     {
       char begin_label[20];
       /* Reference current function start using LFBB.  */
-      ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", lscope_labelno);
+      ASM_GENERATE_INTERNAL_LABEL (begin_label, "LFBB", scope_labelno);
       dbxout_begin_empty_stabs (N_FUN);
       dbxout_stab_value_label_diff (lscope_label_name, begin_label);
     }
@@ -1249,6 +1248,9 @@ dbxout_begin_prologue (unsigned int line
       && !flag_debug_only_used_symbols)
     dbxout_stabd (N_BNSYM, 0);
 
+  /* pre-increment the scope counter */
+  scope_labelno++;
+
   dbxout_source_line (lineno, filename);
   /* Output function begin block at function scope, referenced 
      by dbxout_block, dbxout_source_line and dbxout_function_end.  */

Reply via email to