Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug
Bug#: 13956
Product:  
Component:  
Status: RESOLVED
Resolution: FIXED
Assigned To: Zack Weinberg <zackw@panix.com>
Host:
Reported against  
Priority:  
Severity:  
Target Milestone:  
 
 
Target:
Reporter: Michael Elizabeth Chastain <mec.gnu@mindspring.com>
Add CC:
CC:
Remove selected CCs
Build:
URL:
Summary:
Keywords:
Known to work:
Known to fail:

Attachment Description Type Created Size Actions
alpha.c Source code with nested scopes. text/plain 2004-02-01 07:23 153 bytes Edit
alpha.332.stabs+.s Generated assembly code, good, gcc 3.3.2 -S -gstabs+ text/plain 2004-02-01 07:24 1.10 KB Edit
alpha.HEAD.stabs+.s Generated assembly code, bad, gcc HEAD 2004-02-01 -gstabs+ -S text/plain 2004-02-01 07:24 1.14 KB Edit
Create a New Attachment (proposed patch, testcase, etc.) View All

Bug 13956 depends on: Show dependency tree
Show dependency graph
Bug 13956 blocks:

Additional Comments:






View Bug Activity   |   Format For Printing   |   Clone This Bug


Description:   Last confirmed: 2004-02-01 13:15 Opened: 2004-02-01 07:21
Here is an excerpt from a test program:

  void f1 ()
  {
    int alpha;
    int beta;

    ...
    {
      int alpha;
      int gamma;
      ...
    }
    ...
   }

My command line is "gcc -gstabs+ -S alpha.c".

With gcc 3.3.2, I get these healthy-looking stabs:

  .LBE2:
        .size   f1, .-f1
        .stabs  "alpha:(0,1)",128,0,15,-4
        .stabs  "beta:(0,1)",128,0,16,-8
        .stabn  192,0,0,.LBB2-f1
        .stabs  "alpha:(0,1)",128,0,21,-12
        .stabs  "gamma:(0,1)",128,0,22,-16
        .stabn  192,0,0,.LBB3-f1
        .stabn  224,0,0,.LBE3-f1
        .stabn  224,0,0,.LBE2-f1

stabn 192 is N_LBRAC, and stabn 224 is N_RBRAC.  Each group of local variables
is followed by its range.  All is well.

With gcc HEAD 2003-04-11 03:00:00 UTC, all is still fine:

  .LBE2:
        .size   f1, .-f1
        .stabs  "alpha:(0,1)",128,0,15,-4
        .stabs  "beta:(0,1)",128,0,16,-8
        .stabn  192,0,0,.LBB2-f1
        .stabs  "alpha:(0,1)",128,0,21,-12
        .stabs  "gamma:(0,1)",128,0,22,-16
        .stabn  192,0,0,.LBB3-f1
        .stabn  224,0,0,.LBE3-f1
        .stabn  224,0,0,.LBE2-f1

With gcc HEAD 2003-04-11 04:30:00 UTC, the stabs are wrong:

        .size   f1, .-f1
        .stabs  "alpha:(0,1)",128,0,15,-4
        .stabs  "beta:(0,1)",128,0,16,-8
        .stabs  "alpha:(0,1)",128,0,21,-12
        .stabs  "gamma:(0,1)",128,0,22,-16
        .stabn  192,0,0,.LBB2-f1
        .stabn  224,0,0,.LBE2-f1

One of the N_LBRAC/N_RBRAC pairs has disappeared.

And with current gcc, gcc HEAD 2004-02-01 01:34:15 UTC:

        .size   f1, .-f1
        .stabs  "alpha:(0,1)",128,0,15,-4
        .stabs  "beta:(0,1)",128,0,16,-8
        .stabs  "alpha:(0,1)",128,0,21,-12
        .stabs  "gamma:(0,1)",128,0,22,-16
        .stabn  192,0,0,.LBB2-f1
        .stabn  224,0,0,.LBE2-f1

This problem came in with this patch:

  2003-04-10  Zack Weinberg  <zack@codesourcery.com>

        * c-decl.c (struct binding_level): Add shadowed_tags and
        function_body; remove this_block, tag_transparent, and
        subblocks_tag_transparent; update comments.
        ...

  2003-04-10  Zack Weinberg  <zack@codesourcery.com>

        * c-tree.h (struct lang_identifier): Replace global_value,
        local_value members with symbol_value, tag_value.  Kill
        implicit_decl and limbo_value.
        ...

There are two ChangeLog entries here, but only one patch.

This is the same patch that caused PR debug/12267.  Per the comments in 12267,
I'm assigning it to Zack (or trying to).

Attachments to follow.

------- Comment #1 From Michael Elizabeth Chastain 2004-02-01 07:23 -------
Created an attachment (id=5633) [edit]
Source code with nested scopes.

Compile with gcc -S -gstabs+.

------- Comment #2 From Michael Elizabeth Chastain 2004-02-01 07:24 -------
Created an attachment (id=5634) [edit]
Generated assembly code, good, gcc 3.3.2 -S -gstabs+ 

------- Comment #3 From Michael Elizabeth Chastain 2004-02-01 07:24 -------
Created an attachment (id=5635) [edit]
Generated assembly code, bad, gcc HEAD 2004-02-01 -gstabs+ -S

------- Comment #4 From Andrew Pinski 2004-02-01 13:15 -------
Confirmed.

------- Comment #5 From Zack Weinberg 2004-03-15 21:05 -------
fixed the mime types of all the attachments.  sorry for the noise.

------- Comment #6 From Michael Elizabeth Chastain 2004-03-16 02:20 -------
Subject: Re:  [3.4/3.5 regression] incorrect stabs for nested local variables

> fixed the mime types of all the attachments.  sorry for the noise.

Woops, sorry for the un-useful mime types.  I was letting
them be set automatically.  In the future I will set them explicitly
to text/plain.

Michael C

------- Comment #7 From Mark Mitchell 2004-03-21 17:56 -------
Given that stabs are only used on a few platforms by deafult, and that Zack
doesn't think this easy to fix for 3.4.0, I've retargeted this at 3.4.1.

Zack, does the c-decl rewrite fix this one too?

------- Comment #8 From Mark Mitchell 2004-03-21 17:56 -------
Regarted at 3.4.1.

------- Comment #9 From Eric Botcazou 2004-03-21 18:07 -------
One of the primary platforms (sparc-sun-solaris2.8) use stabs by default.

------- Comment #10 From Zack Weinberg 2004-03-21 18:20 -------
Subject: Re:  [3.4/3.5 regression] incorrect stabs for
 nested local variables


This one, unfortunately, is not fixed by the c-decl rewrite; I mean to
look at it as soon as I get the rewrite laid down, but my time is very
limited for the next two weeks.

zw

------- Comment #11 From Mark Mitchell 2004-03-23 21:32 -------
Subject: Re:  [3.4/3.5 regression] incorrect stabs for nested
 local variables

ebotcazou at gcc dot gnu dot org wrote:

>------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-03-21 18:07 -------
>One of the primary platforms (sparc-sun-solaris2.8) use stabs by default.
>  
>
How unfortunate.

As a SPARC user, do you think this is a showstopper problem?


------- Comment #12 From Eric Botcazou 2004-03-23 23:30 -------
Probably no, since GCC can generate DWARF-2 debug info on Solaris 7 and later,
that both DBX and GDB can grok (DWARF-2 is not available on Solaris 2.6 and
earlier).  But it would be nice to fix it on the 3.4 branch at some point.

------- Comment #13 From Daniel Jacobowitz 2004-03-29 15:28 -------
Subject: Re:  [3.4/3.5 regression] incorrect stabs for nested local variables

Should DWARF-2 be the default for Solaris 7 and later, then?  I'm in
favor of anything that decreases use of stabs!

------- Comment #14 From Eric Botcazou 2004-03-29 16:52 -------
I guess so, since DWARF-2 is already the default for 64-bit code.

Mark, do you think we can switch the default debug format for 32-bit code too?

------- Comment #15 From Mark Mitchell 2004-03-30 17:01 -------
Subject: Re:  [3.4/3.5 regression] incorrect stabs for nested
 local variables

ebotcazou at gcc dot gnu dot org wrote:

>------- Additional Comments From ebotcazou at gcc dot gnu dot org  2004-03-29 16:52 -------
>I guess so, since DWARF-2 is already the default for 64-bit code.
>
>Mark, do you think we can switch the default debug format for 32-bit code too?
>  
>
Yes, I do, actually.  It would be good to do a little testing there to 
make sure that GDB basically works, but it's hard for me to see how 
DWARF-2, which we use on so many systems, including other SPARC 
configurations, could be worse than STABS.


------- Comment #16 From Mark Mitchell 2004-06-18 23:49 -------
Eric -- didn't we end up switching to DWARF for Solaris?  If so, would you
please close this as WONTFIX?

Postponed until GCC 3.4.2 in the meanwhile.

------- Comment #17 From Eric Botcazou 2004-06-19 05:54 -------
> Eric -- didn't we end up switching to DWARF for Solaris?

Yes, we did.  This uncovered a couple of issues, one in each of the 2 supported
assemblers, but nothing that would justify the backwards move I'd say.

> If so, would you please close this as WONTFIX?

Done.

------- Comment #18 From Daniel Jacobowitz 2004-06-21 03:05 -------
Subject: Re:  [3.4/3.5 regression] incorrect stabs for nested local variables

Doesn't this bug still affect HEAD stabs generation?  Surely
SPARC/Solaris was not the only platform left which used stabs.

------- Comment #19 From Andrew Pinski 2004-06-21 03:58 -------
Yes, Mac OS X (darwin) is effect also (even though dwarf-2 support was just
added, it is still not the 
default).

------- Comment #20 From CVS Commits 2004-08-04 07:32 -------
Subject: Bug 13956

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	zack@gcc.gnu.org	2004-08-04 07:32:20

Modified files:
	gcc            : ChangeLog dbxout.c 

Log message:
	PR 13956
	* dbxout.c (dbx_output_lbrac, dbx_output_rbrac): New
	functions, broken out of dbxout_block.
	(dbxout_block): The block at depth 0 should get LBRAC/RBRAC
	stabs too, if it contains symbols.  Use the begin_label and
	the Lscope label (emitted by dbxout_function_end) for the
	range of this block.
	(dbxout_function_decl): Always call dbxout_function_end.
	(dbxout_function_end): Return after emitting the "Lscope" symbol
	under the same conditions that this function formerly wasn't called.
	Add explanatory comments.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.573&r2=2.2326.2.574
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/dbxout.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.172.2.1&r2=1.172.2.2


------- Comment #21 From Zack Weinberg 2004-08-04 07:36 -------
there.

------- Comment #22 From Wolfgang Bangerth 2004-08-04 14:53 -------
The cvs commit message for mainline erroneously got attached to 
PR 13596. It is fixed on mainline, though. 
 
W. 

------- Comment #23 From Michael Elizabeth Chastain 2004-08-05 16:29 -------
gcc HEAD works great for me.

I tested it on three examples that I had and it worked on all of them.

Also I ran the gdb test suite on native i686-pc-linux-gnu with this test matrix:

  gdb 6.1.1, gdb HEAD
  gdb test suite HEAD, with local modifications
  gcc 3.4.1, gcc HEAD 20040731, gcc HEAD 20040804
  debug formats dwarf2, stabs+

The bugs got fixed (gdb.base/scope.exp in particular) and no new regressions
appeared.  Cheers for Zack!

Bug List: (This bug is not in your last search results)   Show last search results      Search page      Enter new bug