From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 30950 invoked by alias); 20 Nov 2008 13:47:10 -0000 Received: (qmail 30831 invoked by uid 22791); 20 Nov 2008 13:47:07 -0000 X-Spam-Check-By: sourceware.org Received: from rv-out-0708.google.com (HELO rv-out-0708.google.com) (209.85.198.244) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 20 Nov 2008 13:46:32 +0000 Received: by rv-out-0708.google.com with SMTP id k29so556885rvb.0 for ; Thu, 20 Nov 2008 05:46:30 -0800 (PST) Received: by 10.141.18.12 with SMTP id v12mr1233216rvi.187.1227188790670; Thu, 20 Nov 2008 05:46:30 -0800 (PST) Received: by 10.141.198.17 with HTTP; Thu, 20 Nov 2008 05:46:30 -0800 (PST) Message-ID: Date: Thu, 20 Nov 2008 13:47:00 -0000 From: "Srinath Avadhanula" To: gdb@sourceware.org Subject: Variables created with -var-create going out of scope unexpectedly? MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2008-11/txt/msg00125.txt.bz2 Hi, I am trying to play around with GDB/MI recently, in particular with the -var-create command. I see that a variable created with -var-create goes out of scope too quickly. In particular, if I later do -var-update, I see that in_scope="false"... The following is the test program and the GDB session which illustrates my question. Basically, I put a breakpoint in the function foo below. This function gets called 4 times with 2 different stacks. If I use "display a" the first time I hit the breakpoint, the variable a gets displayed on all subsequent hits. However, if I do instead "-var-create - * a" the first time the breakpoint is hit and then do "-var-update 1 *" each subsequent time the break-point is hit, I only see 'in_scope="true"' the two times when foo() is reached with exactly the same stack. Is this expected? Is there an equivalent of gdb's "display" command for GDB/MI? The program versions are: gdb: GNU gdb 6.4.90-debian g++: g++ (GCC) 4.1.2 20061115 (prerelease) (Debian 4.1.1-21) Regards, Srinath ~/code/gdbmiserver/test $ cat -n foo.cpp 1 #include 2 3 void foo(double a) 4 { 5 printf("a = %g\n", a); 6 } 7 8 void bar(double a) 9 { 10 foo(a); 11 } 12 13 int main() 14 { 15 foo(2.5); 16 bar(3.5); 17 foo(4.5); 18 bar(5.5); 19 } ~/code/gdbmiserver/test $ g++ -g -o foo foo.cpp ~/code/gdbmiserver/test $ gdb foo GNU gdb 6.4.90-debian Copyright (C) 2006 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 "x86_64-linux-gnu"...Using host libthread_db library "/lib/libthread_db.so.1". (gdb) b foo.cpp:5 Breakpoint 1 at 0x400565: file foo.cpp, line 5. (gdb) r Starting program: /mathworks/home/savadhan/code/gdbmiserver/test/foo Breakpoint 1, foo (a=2.5) at foo.cpp:5 5 printf("a = %g\n", a); (gdb) display a 1: a = 2.5 (gdb) interpreter mi '-var-create - * a' ^done,name="var1",numchild="0",type="double" (gdb) (gdb) interpreter mi '-var-update 1 *' ^done,changelist=[] (gdb) (gdb) c Continuing. a = 2.5 Breakpoint 1, foo (a=3.5) at foo.cpp:5 5 printf("a = %g\n", a); 1: a = 3.5 (gdb) interpreter mi '-var-update 1 *' ^done,changelist=[{name="var1",in_scope="false"}] (gdb) (gdb) c Continuing. a = 3.5 Breakpoint 1, foo (a=4.5) at foo.cpp:5 5 printf("a = %g\n", a); 1: a = 4.5 (gdb) interpreter mi '-var-update 1 *' ^done,changelist=[{name="var1",value="4.5",in_scope="true",type_changed="false"}] (gdb) (gdb) c Continuing. a = 4.5 Breakpoint 1, foo (a=5.5) at foo.cpp:5 5 printf("a = %g\n", a); 1: a = 5.5 (gdb) interpreter mi '-var-update 1 *' ^done,changelist=[{name="var1",in_scope="false"}] (gdb) (gdb) c Continuing. a = 5.5 Program exited normally. (gdb) q ~/code/gdbmiserver/test $