This is the mail archive of the
gdb-prs@sources.redhat.com
mailing list for the GDB project.
gdb/782: GDB can't find local variables in function with switch
- From: dks at antrim dot com
- To: gdb-gnats at sources dot redhat dot com
- Date: 2 Oct 2002 18:56:45 -0000
- Subject: gdb/782: GDB can't find local variables in function with switch
- Reply-to: dks at antrim dot com
>Number: 782
>Category: gdb
>Synopsis: GDB can't find local variables in function with switch
>Confidential: no
>Severity: serious
>Priority: medium
>Responsible: unassigned
>State: open
>Class: sw-bug
>Submitter-Id: net
>Arrival-Date: Wed Oct 02 11:58:01 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator: dks@antrim.com
>Release: gdb 5.2.90_2002-09-27-cv
>Organization:
>Environment:
Linux eng-1.antrim.com 2.4.17-ext3-2 #12 SMP Thu Jun 13 08:10:56 PDT 2002 i686 unknown
GCC version 2.96
This GDB was configured as "i686-pc-linux-gnu"...
>Description:
For the following testcase, if I break anywhere before the "stringstream liness(input);" line, I cannot print the values of any local variables. Once I reach the "liness" declaration, I can:
--------------------------------------------------------
(gdb) break gdbbug.C:16
Breakpoint 1 at 0x804aa09: file gdbbug.C, line 16.
(gdb) run
Starting program: /home/dks/gdb_test/gdbbug
Breakpoint 1, getDataSetInfo () at gdbbug.C:16
16 input = inputBuf;
(gdb) print done
No symbol "done" in current context.
(gdb) print inputBuf
No symbol "inputBuf" in current context.
(gdb) next
20 done = true;
(gdb) print done
No symbol "done" in current context.
(gdb) print inputBuf
No symbol "inputBuf" in current context.
(gdb) next
24 stringstream liness(input);
(gdb) print done
$1 = true
(gdb) print inputBuf
$2 = '\0' <repeats 376 times>, ...
--------------------------------------------------------
The testcase follows. I compile this with:
g++ -O0 -g -o gdbbug gdbbug.C
Notes:
+ If I replace the liness declaration with the "int x;"
declaration, the problem goes away.
+ If I get rid of the switch statement surrounding the
"done = true;" line, the problem goes away.
+ Replacing the "-g" with "-gstabs", "-gdwarf" or
"-gdwarf-2" makes no difference.
+ I've also tried GCC 3.2, but it makes no difference
+ I've also tried GDB 5.2.1, but it makes no difference
---------------------------------------------------------
#include <sstream>
int countNumbers(char *input)
{
return 1;
}
void getDataSetInfo(void)
{
bool done;
char *input;
char inputBuf[4096];
done = false;
input = inputBuf;
switch(input[0])
{
default:
done = true;
break;
}
// int x;
std::stringstream liness(input);
unsigned numElts = countNumbers(input);
unsigned numLines = 0;
unsigned totalElts = 0;
}
int main(int argc,char *argv[])
{
getDataSetInfo();
}
>How-To-Repeat:
>Fix:
>Release-Note:
>Audit-Trail:
>Unformatted: