[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: gdb 5.0: no symbol 'foo' in current context
From: |
Daniel Berlin |
Subject: |
Re: gdb 5.0: no symbol 'foo' in current context |
Date: |
13 Feb 2001 22:23:30 -0500 |
User-agent: |
Gnus/5.090001 (Oort Gnus v0.01) XEmacs/21.2 (Thalia) |
address@hidden (Thomas Sevaldrud) writes:
I *believe* this was a known bug in the compiler, it should be fixed
in the latest compiler errata, make sure you have the latest gcc
update for redhat 7.
--Dan
> Hello,
>
> I am having a problem with debugging c++ programs with gdb 5.0. I am running
> on
> a RedHat 7.0 system, and the bug may of course be related to the non-standard
> compiler shipping with this system. However, I hope someone on this list might
> have heard about this problem, and hopefully know of a fix or workaround to
> it.
>
> The problem is that the debugger doesn't find the contents of variables that
> are inside nested scopes. For example, in the following program gdb won't
> print
> the contents of either variables 'b' or 'c'
>
> int main(int argc, char** argv)
> {
> int a = 10;
> for(int i = 0; i < 10; i++)
> {
> for(int j = 0; j < 10; j++)
> {
> int b = 20;
> int c = 30;
> }
> }
> }
>
> I compile this program with
>
> address@hidden [tse] 109> g++ -g -o foo foo.cpp
>
> Then I run the debugger:
>
> address@hidden [tse] 110> gdb foo
> GNU gdb 5.0
> Copyright 2000 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) break main
> Breakpoint 1 at 0x8048532: file foo.cpp, line 3.
> (gdb) run
> Starting program: /home/tse/foo
>
> Breakpoint 1, main (argc=1, argv=0xbffff0e4) at foo.cpp:3
> 3 int a = 10;
> (gdb) next
> 4 for(int i = 0; i < 10; i++)
> (gdb) print a
> $1 = 10
> (gdb) next 3
> 9 int c = 30;
> (gdb) print b
> No symbol "b" in current context.
> (gdb)
>
> Here is some more info on my system:
>
> address@hidden [tse] 112> uname -a
> Linux sauron.si.sintef.no 2.2.16-22smp #1 SMP Tue Aug 22 16:39:21 EDT 2000
> i686 unknown
>
> address@hidden [tse] 113> g++ --version
> 2.96
>
>
> If a variable is declared between the scopes here, such as in the following
> code, all variables are found without problems.
>
> int main(int argc, char** argv)
> {
> int a = 10;
> for(int i = 0; i < 10; i++)
> {
> int b = 20;
> for(int j = 0; j < 10; j++)
> {
> int c = 30;
> }
> }
> }
>
>
> I am not subscribed to the mailing list, so please CC the answer to my email
> address.
>
>
> Regards,
> Thomas Sevaldrud
- Re: gdb 5.0: no symbol 'foo' in current context,
Daniel Berlin <=