From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 19289 invoked by alias); 22 Feb 2005 20:45:48 -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 19088 invoked from network); 22 Feb 2005 20:45:38 -0000 Received: from unknown (HELO legolas.inter.net.il) (192.114.186.24) by sourceware.org with SMTP; 22 Feb 2005 20:45:38 -0000 Received: from zaretski (tony01-5-201.inter.net.il [80.230.5.201]) by legolas.inter.net.il (MOS 3.5.6-GR) with ESMTP id DUS87402 (AUTH halo1); Tue, 22 Feb 2005 22:45:31 +0200 (IST) Date: Tue, 22 Feb 2005 20:50:00 -0000 From: "Eli Zaretskii" To: tj <999alfred@comcast.net> Message-ID: <01c5191f$Blat.v2.4$6b7c0e60@zahav.net.il> Content-Transfer-Encoding: 7BIT Content-Type: text/plain; charset=ISO-8859-1 CC: gdb@sources.redhat.com In-reply-to: <421B8556.6070905@comcast.net> (message from tj on Tue, 22 Feb 2005 14:17:42 -0500) Subject: Re: Still problems with gdb and nested functions. Reply-to: Eli Zaretskii References: <421B8556.6070905@comcast.net> X-SW-Source: 2005-02/txt/msg00140.txt.bz2 > Date: Tue, 22 Feb 2005 14:17:42 -0500 > From: tj <999alfred@comcast.net> > > Breakpoint 1, inside.0 () at test.c:12 > 12 printf("inside, k = %d, l = %d\n", k,l); > (gdb) p k > No symbol "k" in current context. > (gdb) continue > Continuing. > inside, k = 1, l = 1 I can confirm this, but it looks like this is either a GCC problem, or perhaps GCC generates DWARF-2 debug info that confuses GDB. Observe: $ gcc -O0 -ggdb3 -o test test.c $ gdb ./test ... (gdb) break 12 Breakpoint 1 at 0x16de: file test.c, line 12. (gdb) info address k No symbol "k" in current context. (gdb) disassemble Dump of assembler code for function inside.0: 0x000016c8 : push %ebp 0x000016c9 : mov %esp,%ebp 0x000016cb : sub $0x18,%esp 0x000016ce : mov %ecx,0xfffffffc(%ebp) 0x000016d1 : movl $0x1,0xfffffff8(%ebp) 0x000016d8 : mov 0xfffffff8(%ebp),%eax 0x000016db : mov %eax,0xfffffff4(%ebp) 0x000016de : sub $0x4,%esp 0x000016e1 : pushl 0xfffffff4(%ebp) 0x000016e4 : pushl 0xfffffff8(%ebp) 0x000016e7 : push $0x16b0 0x000016ec : call 0x3360 0x000016f1 : add $0x10,%esp 0x000016f4 : mov $0x0,%eax 0x000016f9 : leave 0x000016fa : ret End of assembler dump. (gdb) info locals No locals. The disassembly clearly shows that GDB is wrong: the variable k is stored at 0xfffffff8(%ebp). Now watch what happens with stabs debug info: gcc -O0 -gstabs3 -o test test.c $ gdb ./test ... (gdb) break 12 Breakpoint 1 at 0x160e: file test.c, line 12. (gdb) info address k Symbol "k" is a local variable at frame offset -8. (gdb) print k $1 = 1 (gdb) info locals k = 1 l = 1 (gdb) So with stabs debug info, GDB works correctly, but with the default DWARF-2 debug info, it gets confused. (Strangely, the code location corresponding to breakpoint at line 12 is also different in these two builds: 0x160e vs 0x16de. Why would debug info affect code locations? anyone?)