Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* problem printing enums as integers with dwarf2
@ 2003-11-07 23:20 Kevin Nomura
  2003-11-10 23:34 ` Jim Blandy
  0 siblings, 1 reply; 3+ messages in thread
From: Kevin Nomura @ 2003-11-07 23:20 UTC (permalink / raw)
  To: gdb

Before filing a bug I'd like to check if I'm missing
something obvious.  A C enum is defined with elements
x0, x1, ..., x999 starting at 0 and incrementing naturally
with no "=" reassignments.  It is compiled on Linux redhat 8
(for example) which uses dwarf2 by default: gcc -g enum.c

x129 is printed as an integer:

(gdb) p/d x129
$2 = -127

I expected 129.

Compile with stabs explicitly and get the expected behaviour:

[siml4]$ gcc -gstabs enum.c
[siml4]$ gdb a.out
GNU gdb Red Hat Linux (5.2.1-4)
Copyright 2002 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 "i386-redhat-linux"...
(gdb) p x129
$1 = x129
(gdb) p/d x129
$2 = 129
(gdb) 

Here is a testcase generator in perl to declare the 1000 element enum.



#!/usr/bin/perl -w
use strict

print "enum e {\n";

for ($i=0; $i<1000; $i++) { printf "\tx%d,\n", $i }
print <<EOF;
};

main()
{
        printf ("%d\\n", x129);
}
EOF


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem printing enums as integers with dwarf2
  2003-11-07 23:20 problem printing enums as integers with dwarf2 Kevin Nomura
@ 2003-11-10 23:34 ` Jim Blandy
  2003-11-11  0:05   ` Kevin Nomura
  0 siblings, 1 reply; 3+ messages in thread
From: Jim Blandy @ 2003-11-10 23:34 UTC (permalink / raw)
  To: Kevin Nomura; +Cc: gdb


Not known to me, at least.  Please go ahead and file a bug for this,
and I'll take it.

Kevin Nomura <nomura@netapp.com> writes:
> Before filing a bug I'd like to check if I'm missing
> something obvious.  A C enum is defined with elements
> x0, x1, ..., x999 starting at 0 and incrementing naturally
> with no "=" reassignments.  It is compiled on Linux redhat 8
> (for example) which uses dwarf2 by default: gcc -g enum.c
> 
> x129 is printed as an integer:
> 
> (gdb) p/d x129
> $2 = -127
> 
> I expected 129.
> 
> Compile with stabs explicitly and get the expected behaviour:
> 
> [siml4]$ gcc -gstabs enum.c
> [siml4]$ gdb a.out
> GNU gdb Red Hat Linux (5.2.1-4)
> Copyright 2002 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 "i386-redhat-linux"...
> (gdb) p x129
> $1 = x129
> (gdb) p/d x129
> $2 = 129
> (gdb) 
> 
> Here is a testcase generator in perl to declare the 1000 element enum.
> 
> 
> 
> #!/usr/bin/perl -w
> use strict
> 
> print "enum e {\n";
> 
> for ($i=0; $i<1000; $i++) { printf "\tx%d,\n", $i }
> print <<EOF;
> };
> 
> main()
> {
>         printf ("%d\\n", x129);
> }
> EOF


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: problem printing enums as integers with dwarf2
  2003-11-10 23:34 ` Jim Blandy
@ 2003-11-11  0:05   ` Kevin Nomura
  0 siblings, 0 replies; 3+ messages in thread
From: Kevin Nomura @ 2003-11-11  0:05 UTC (permalink / raw)
  To: Jim Blandy; +Cc: Kevin Nomura, gdb

Thanks for looking at it!

Kevin


Date: 10 Nov 2003 23:58:00 -0000
To: nomura@netapp.com
From: gdb-gnats@sources.redhat.com
Subject: Re: exp/1445: C enum prints 129 as -127 with dwarf-2
Reply-To: gdb-gnats@sources.redhat.com, nobody@sources.redhat.com
In-Reply-To: Your message of 10 Nov 2003 23:48:04 -0000
        <20031110234804.11729.qmail@sources.redhat.com>
X-pstn-levels:     (C:80.0762 M:99.4056 P:95.9108 R:95.9108 S:34.1559 )
X-pstn-settings: 3 (1.0000:1.0000) pmCr
X-pstn-addresses: from <gdb-gnats@sources.redhat.com>
 
Thank you very much for your problem report.
It has the internal identification `exp/1445'.
The individual assigned to look at your
report is: unassigned.
 
>Category:       exp                                                            
>Responsible:    unassigned                                                     
>Synopsis:       C enum prints 129 as -127 with dwarf-2                         
>Arrival-Date:   Mon Nov 10 23:58:00 UTC 2003                                   
 
 



On Mon, Nov 10, 2003 at 06:32:35PM -0500, Jim Blandy wrote:
> 
> Not known to me, at least.  Please go ahead and file a bug for this,
> and I'll take it.
> 
> Kevin Nomura <nomura@netapp.com> writes:
> > Before filing a bug I'd like to check if I'm missing
> > something obvious.  A C enum is defined with elements
> > x0, x1, ..., x999 starting at 0 and incrementing naturally
> > with no "=" reassignments.  It is compiled on Linux redhat 8
> > (for example) which uses dwarf2 by default: gcc -g enum.c
> > 
> > x129 is printed as an integer:
> > 
> > (gdb) p/d x129
> > $2 = -127
> > 
> > I expected 129.
> > 
> > Compile with stabs explicitly and get the expected behaviour:
> > 
> > [siml4]$ gcc -gstabs enum.c
> > [siml4]$ gdb a.out
> > GNU gdb Red Hat Linux (5.2.1-4)
> > Copyright 2002 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 "i386-redhat-linux"...
> > (gdb) p x129
> > $1 = x129
> > (gdb) p/d x129
> > $2 = 129
> > (gdb) 
> > 
> > Here is a testcase generator in perl to declare the 1000 element enum.
> > 
> > 
> > 
> > #!/usr/bin/perl -w
> > use strict
> > 
> > print "enum e {\n";
> > 
> > for ($i=0; $i<1000; $i++) { printf "\tx%d,\n", $i }
> > print <<EOF;
> > };
> > 
> > main()
> > {
> >         printf ("%d\\n", x129);
> > }
> > EOF


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2003-11-11  0:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-11-07 23:20 problem printing enums as integers with dwarf2 Kevin Nomura
2003-11-10 23:34 ` Jim Blandy
2003-11-11  0:05   ` Kevin Nomura

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox