struct dive_table dive_table

Linus Torvalds torvalds at linux-foundation.org
Wed Apr 17 10:14:44 PDT 2013


On Wed, Apr 17, 2013 at 9:30 AM, Amit Chaudhuri
<amit.k.chaudhuri at gmail.com> wrote:
> At parse-xml.c : 31 there is this: struct dive_table dive_table
>
> I've written a very nasty piece of code which I need to debug.  So I'm
> trying to use gdb to examine dive_table.  But using 'p dive_table' generates
> an error: "Attempt to use a type name as an expression".

Wow. That's a really fundamental bug.

Not in subsurface, though. It's very much a gdb bug, and it's a
seriously screwed up one. It implies that gdb doesn't know the first
thing about the C namespace rules. The struct/union/enum namespace is
totally separate from the identifier one.

We use that C namespace differentiation all over the place ("struct
dive *dive" is a very common thing), and I've never seen gdb confused
about that. But maybe the gdb bug only happens for identifiers in
global scope, and that gdb only knows about name *scope*, but not
about name *spaces*.

I absolutely refuse to fix things like "struct dive *dive", so if you
can find out more details about exactly what triggers the gdb bug, and
can show that it's somehow *only* related to the dive_table thing
(because of some global scope issue or whatever), then I guess we
could work around that one particular case.

However, I can't reproduce this bug to begin with. For me, "p
dive_table" just does the right thing (current gdb from
f18:7.5.1-37.fc18). What gdb version are you on?

Does something like "p *&dive_table" work around it for you?

                    Linus


More information about the subsurface mailing list