Bug 23336 - [4.1 Regression] enum constants not visible to gdb because of -feliminate-unused-debug-types
Summary: [4.1 Regression] enum constants not visible to gdb because of -feliminate-unu...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: debug (show other bugs)
Version: 4.1.0
: P2 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL:
Keywords: wrong-debug
Depends on:
Blocks: 24551
  Show dependency treegraph
 
Reported: 2005-08-11 18:34 UTC by Tom Tromey
Modified: 2008-07-04 15:08 UTC (History)
2 users (show)

See Also:
Host:
Target: dwarf-2
Build:
Known to work: 3.3.3 4.2.0
Known to fail: 3.4.0 4.0.0 4.0.4 4.1.0 4.1.3
Last reconfirmed: 2006-07-05 09:58:41


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2005-08-11 18:34:44 UTC
This is with today's cvs head gcc and cvs head gdb.
I'm running on x86 FC2.

The test program:

#include <stdio.h>

enum java_tree_index
{
  JTI_PROMOTED_BYTE_TYPE_NODE,
  JTI_PROMOTED_SHORT_TYPE_NODE,
  JTI_PROMOTED_CHAR_TYPE_NODE,
  JTI_PROMOTED_BOOLEAN_TYPE_NODE,

  JTI_MAX
};

int main()
{
  printf ("%d\n", (int) JTI_MAX);
}


what happens:
opsy. gcc -g -o zz zz.c
opsy. ~/gnu/baseline-gdb/install/bin/gdb zz
GNU gdb 6.3.50.20050811-cvs
Copyright 2004 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db library
"/lib/tls/libthread_db.so.1".
                                                                                
(gdb) b main
Breakpoint 1 at 0x8048380: file zz.c, line 15.
(gdb) r
Starting program: /tmp/zz
                                                                                
Breakpoint 1, main () at zz.c:15
15        printf ("%d\n", (int) JTI_MAX);
(gdb) p JTI_MAX
No symbol "JTI_MAX" in current context.


I think it should know the value of JTI_MAX here.
I know this used to work; for instance it works fine with the
system compiler on FC2 - gcc (GCC) 3.3.3 20040412 (Red Hat Linux 3.3.3-7)
(FWIW this bug is a big impediment to debugging gcj.)
Comment 1 Andrew Pinski 2005-08-11 18:59:16 UTC
Confirmed, another -feliminate-unused-debug-types bug.

a regression from 3.3.3.
Comment 2 Mark Mitchell 2005-10-31 04:56:44 UTC
Leaving as P2; we should definitely fix this.
Comment 3 Aldy Hernandez 2005-11-16 20:54:26 UTC
What the heck...death by dwarf.  I'll take a look at this.
Comment 4 Mark Mitchell 2006-02-24 00:26:08 UTC
This issue will not be resolved in GCC 4.1.0; retargeted at GCC 4.1.1.
Comment 5 Mark Mitchell 2006-05-25 02:33:13 UTC
Will not be fixed in 4.1.1; adjust target milestone to 4.1.2.
Comment 6 Andrew Pinski 2006-06-03 22:22:04 UTC
This still fails on the mainline.
Comment 7 Aldy Hernandez 2006-06-03 22:32:07 UTC
This still fails because it hasn't been fixed ;-).  My patch for -feliminate-unused-debug-types only handled casts.  It needs further front-end work to handle enums.  At least the infrastructure is in place for the front-end work.
Comment 8 Daniel Jacobowitz 2006-07-22 18:06:35 UTC
Hmm.  What's happening here is that we set TREE_USED on the enumerator, but not on the type.  The enumerator never gets output, because the type is not output.

It would probably be a strict improvement to add the type to the used_types hash table like we now do for casts.

However, that is not a great solution either.  It won't cause the enum to be emitted for "static int x = JTI_MAX;" at the global scope even if x is emitted.  We really need a more general solution to this...
Comment 9 Daniel Jacobowitz 2006-07-22 18:34:30 UTC
Meanwhile, I'm testing a patch to treat them just as well as we treat casts.
Comment 10 Daniel Jacobowitz 2006-08-01 14:24:09 UTC
Subject: Bug 23336

Author: drow
Date: Tue Aug  1 14:23:58 2006
New Revision: 115853

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=115853
Log:
gcc/
	PR debug/23336
	* c-typeck.c (build_external_type): Mark used enum types.
	* dwarf2out.c (dwarf2out_abstract_function): Save and restore
	cfun also.
	(gen_subprogram_die): Whitespace fix.
gcc/cp/
	PR debug/23336
	* pt.c (tsubst_copy_and_build): Mark used enum types.
	* semantics.c (finish_id_expression): Likewise.
gcc/testsuite/
	PR debug/23336
	* lib/gcc-dg.exp (gcc-dg-debug-runtest): Suppress new tests
	at -g1.
	* gcc.dg/debug/enum-1.c, g++.dg/debug/enum-1.C,
	g++.dg/debug/enum-2.C: New.

Added:
    trunk/gcc/testsuite/g++.dg/debug/enum-1.C
    trunk/gcc/testsuite/g++.dg/debug/enum-2.C
    trunk/gcc/testsuite/gcc.dg/debug/enum-1.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/c-typeck.c
    trunk/gcc/cp/ChangeLog
    trunk/gcc/cp/pt.c
    trunk/gcc/cp/semantics.c
    trunk/gcc/dwarf2out.c
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/lib/gcc-dg.exp

Comment 11 Daniel Jacobowitz 2006-08-02 13:35:37 UTC
Fixed for 4.2.
Comment 12 Daniel Jacobowitz 2008-01-21 20:59:48 UTC
I don't care about 4.0/4.1 at this date.
Comment 13 Joseph S. Myers 2008-07-04 15:08:29 UTC
Closing 4.1 branch.