This is the mail archive of the
mailing list for the GDB project.
Re: static variables: "no symbol X in current context"
- From: Michael Snyder <msnyder at redhat dot com>
- To: Michael Hamilton <michaeljohnhamilton at cox dot net>, gdb at sources dot redhat dot com
- Date: Thu, 11 Apr 2002 17:08:13 -0700
- Subject: Re: static variables: "no symbol X in current context"
- Organization: Red Hat, Inc.
- References: <email@example.com>
Michael Hamilton wrote:
> System: Linux 2.2.16-22 (Redhat 7.?)
> GDB 5.0 (run inside of xemacs)
> I don't know if this is a bug or just my problem, but, I haven't been
> able to figure out how to fix it despite looking at FAQs and docs and
> I have a local variable declared static in a subroutine my code. In
> gdb, when inside the subroutine, I use
> > p x
> No symbol "x" in current context.
> This only seems to happen when running GDB on Linux. When I run it on
> a solaris/sun machine, it gives me the value. Non-static vars seem to
> work fine.
> What am I missing?
This problem keeps resurfacing. I'm not sure how many times it has
been fixed and come back again. Actually, I don't even remember for
if the bug is in gcc or in gdb, and I certainly can't remember which
releases it is broken in.
There's a workaround:
You will find that there exists a symbol whose name is close to,
but not identical to your missing static variable. If your variable's
name is "foo", the broken name will be something like "foo.3".
You can find it either by using "info var" or "info scope"
(I forget which).
Then you can examine or modify the variable by using this munged name,
which must be quoted because it contains a period:
(gdb) print 'foo.3'