From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19190 invoked by alias); 19 Feb 2005 16:25:39 -0000 Mailing-List: contact gdb-help@sources.redhat.com; run by ezmlm Precedence: bulk List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sources.redhat.com Received: (qmail 19114 invoked from network); 19 Feb 2005 16:25:34 -0000 Received: from unknown (HELO rwcrmhc12.comcast.net) (216.148.227.85) by sourceware.org with SMTP; 19 Feb 2005 16:25:34 -0000 Received: from comcast.net (pcp08729402pcs.grey01.tn.comcast.net[69.139.105.250]) by comcast.net (rwcrmhc12) with SMTP id <2005021916253301400hohfme>; Sat, 19 Feb 2005 16:25:33 +0000 Message-ID: <42176883.2020508@comcast.net> Date: Sat, 19 Feb 2005 19:03:00 -0000 From: tj <999alfred@comcast.net> User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.4) Gecko/20030915 MIME-Version: 1.0 To: Eli Zaretskii CC: gdb@sources.redhat.com Subject: Re: Cann't print local vars when nesting functions References: <42167219.8070507@comcast.net> <01c51674$Blat.v2.4$be4a87a0@zahav.net.il> In-Reply-To: <01c51674$Blat.v2.4$be4a87a0@zahav.net.il> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-SW-Source: 2005-02/txt/msg00124.txt.bz2 Eli Zaretskii wrote: >>Date: Fri, 18 Feb 2005 17:54:17 -0500 >>From: Jeff >> >>int main(int argc, char *argv[]){ >> int i,j; >> >> int inside(void){ >> int k,l; >> k = 3; >> l = 4; >> } >> >> i = 0; >> j = 1; >>} >> >>Now set the break point to the same line, j =1, and this happens: >>Breakpoint 1, main () at test.c:25 >>25 j = 1; >>(gdb) p i >>No symbol "i" in current context. >>(gdb) >> >>What gives? Is there something you need to special when nesting functions? >> >> > >Please tell the details: what platform is this, what versions of GCC >and GDB you use, and how (with what command-line options) you compiled >and linked the program. Also, since the line "j = 1;" is not line 25 >in the source you posted, could it be that the program you actually >compiled was different? > >FWIW, I tried this with GCC 3.3.3, naive compiler command line, and >GDB 6.3, and couldn't reproduce the problem with the source you >posted. > > > I am on linux, 2.4.26 kernel gcc 3.2.3 gdb 5.3 Source file test.c: #include int main(int argc, char *argv[]){ int i,j; int inside(void){ int k,l; k = 1; l = k; return 0; } i = 0; j = 1; } test$ cc -g -O0 test.c $ gdb ./a.out GNU gdb 5.3 Copyright 2002 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-slackware-linux"... (gdb) b test.c:16 Breakpoint 1 at 0x8048340: file test.c, line 16. (gdb) run Starting program: test/a.out Breakpoint 1, main () at test.c:16 16 j = 1; (gdb) p i No symbol "i" in current context. (gdb) As stated, removing the inside() function, breaking on the same source line and printing causes i's value to be printed. No error message. tj