Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Jim Blandy <jimb@redhat.com>
To: Kevin Nomura <nomura@netapp.com>
Cc: gdb@sources.redhat.com
Subject: Re: problem printing enums as integers with dwarf2
Date: Mon, 10 Nov 2003 23:34:00 -0000	[thread overview]
Message-ID: <vt2n0b3pzos.fsf@zenia.home> (raw)
In-Reply-To: <20031107232037.GK4286@bughouse.netapp.com>


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


  reply	other threads:[~2003-11-10 23:34 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-11-07 23:20 Kevin Nomura
2003-11-10 23:34 ` Jim Blandy [this message]
2003-11-11  0:05   ` Kevin Nomura

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=vt2n0b3pzos.fsf@zenia.home \
    --to=jimb@redhat.com \
    --cc=gdb@sources.redhat.com \
    --cc=nomura@netapp.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox