Mirror of the gdb mailing list
 help / color / mirror / Atom feed
* printing enumerated values
@ 2000-10-06 10:52 Shaun Jackman
  2000-10-06 11:04 ` J.T. Conklin
  0 siblings, 1 reply; 2+ messages in thread
From: Shaun Jackman @ 2000-10-06 10:52 UTC (permalink / raw)
  To: gdb

I have an enum that looks something like...

enum {
  A = 512,
  B = 513
};

It's not really an enumerated list, more like constant integers. I don't want
to use defines though because I can't work with them in GDB. And, 'const int's
have performance issues in -O0 (where I'll be staying until we leave the
touchy development phase).

In GDB I get this...
(gdb) p A
$1 = 0
(gdb) p B
$2 = 1
(gdb)

This should be 512, and 513 respectively (clearly).

Cheers,
Shaun
From dberlin@redhat.com Fri Oct 06 11:02:00 2000
From: Daniel Berlin <dberlin@redhat.com>
To: shaunj@gray-interfaces.com
Cc: gdb@sources.redhat.com
Subject: Re: printing enumerated values
Date: Fri, 06 Oct 2000 11:02:00 -0000
Message-id: <m366n5g861.fsf@dan2.cygnus.com>
References: <00100611524000.07740@ed>
X-SW-Source: 2000-10/msg00022.html
Content-length: 738

Shaun Jackman <shaunj@gray-interfaces.com> writes:

> I have an enum that looks something like...
> 
> enum {
>   A = 512,
>   B = 513
> };
> 
> It's not really an enumerated list, more like constant integers. I don't want
> to use defines though because I can't work with them in GDB. And, 'const int's
> have performance issues in -O0 (where I'll be staying until we leave the
> touchy development phase).
> 
> In GDB I get this...
> (gdb) p A
> $1 = 0
> (gdb) p B
> $2 = 1
> (gdb)
> 
> This should be 512, and 513 respectively (clearly).
> 

Clearly, this is a GCC problem.
At least with all the versions of GCC on my computer, unless the enum
has a real name (ie isn't anonymous), it doesn't generate the debug
info properly for it.


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

* Re: printing enumerated values
  2000-10-06 10:52 printing enumerated values Shaun Jackman
@ 2000-10-06 11:04 ` J.T. Conklin
  0 siblings, 0 replies; 2+ messages in thread
From: J.T. Conklin @ 2000-10-06 11:04 UTC (permalink / raw)
  To: shaunj; +Cc: gdb

>>>>> "Shaun" == Shaun Jackman <shaunj@gray-interfaces.com> writes:
Shaun> In GDB I get this...
Shaun> (gdb) p A
Shaun> $1 = 0
Shaun> (gdb) p B
Shaun> $2 = 1
Shaun> (gdb)

You need to let us know more about your environment.  From current
sources, on a NetBSD/i386 1.3 machine (ie i386 aout stabs) I get:

        (gdb) p A
        $1 = A
        (gdb) p B
        $2 = B
        (gdb) p (int) A
        $3 = 512
        (gdb) p (int) B
        $4 = 513

        --jtc

-- 
J.T. Conklin
RedBack Networks
From bje@redhat.com Sat Oct 07 08:02:00 2000
From: Ben Elliston <bje@redhat.com>
To: gdb@sources.redhat.com
Subject: Displaying structs
Date: Sat, 07 Oct 2000 08:02:00 -0000
Message-id: <Pine.LNX.4.21.0010080200430.19316-100000@moshpit.cygnus.com>
X-SW-Source: 2000-10/msg00024.html
Content-length: 523

Often, when debugging, I like to examine pointers to structures.  When
examining the struct instance that the pointer is addressing, I might use:

(gdb) print/x *ptr
 
If the struct has fields which are further pointers to structs, I have to
manually follow these pointers:
 
(gdb) print/x *ptr->next
or
(gdb) print/x *ptr->prev
 
Is there a way that GDB can recursively follow these (to some level)?  I am
guessing that there is enough debugging information for it to know that the
pointers are to meaningful types.

Ben


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

end of thread, other threads:[~2000-10-06 11:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-10-06 10:52 printing enumerated values Shaun Jackman
2000-10-06 11:04 ` J.T. Conklin

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