From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 2370 invoked by alias); 8 Dec 2006 19:38:53 -0000 Received: (qmail 2321 invoked by uid 22791); 8 Dec 2006 19:38:51 -0000 X-Spam-Check-By: sourceware.org Received: from viper.snap.net.nz (HELO viper.snap.net.nz) (202.37.101.8) by sourceware.org (qpsmtpd/0.31) with ESMTP; Fri, 08 Dec 2006 19:38:39 +0000 Received: from kahikatea.snap.net.nz (p202-124-125-148.snap.net.nz [202.124.125.148]) by viper.snap.net.nz (Postfix) with ESMTP id ECB2F2F4C44 for ; Sat, 9 Dec 2006 08:39:43 +1300 (NZDT) Received: by kahikatea.snap.net.nz (Postfix, from userid 500) id 2F21ABE3CF; Sat, 9 Dec 2006 08:34:10 +1300 (NZDT) From: Nick Roberts MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Message-ID: <17785.48689.501272.349814@kahikatea.snap.net.nz> Date: Fri, 08 Dec 2006 19:38:00 -0000 To: gdb-patches@sources.redhat.com Subject: [PATCH] MI: -var-update bug X-Mailer: VM 7.19 under Emacs 22.0.91.14 Mailing-List: contact gdb-patches-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-patches-owner@sourceware.org X-SW-Source: 2006-12/txt/msg00127.txt.bz2 This patch fixes a bug where -var-update doesn't restore the selected frame when there is an out of scope variable object. Here is one way see this bug (it might need an OS that randomizes the virtual address space of a process but there are other ways to make it work in this case): gdb -i=mi yourprog ... (gdb) start ... (gdb) -var-create - * anyvariable (gdb) b somesubroutine ... (gdb) r ... (gdb) up ^done,frame={level="1",.... ^^^^^^^^^ (gdb) -var-update * ^done,changelist=[{name="var1",in_scope="false"}] (gdb) frame &"frame\n" ^done,frame={level="0",... ^^^^^^^^^ A conservative change would be to additionally restore the selected frame when GDB returns from varobj_update with a value of -1 because new == NULL but I think the frame only gets changed by value_of_root -> c_value_of_root -> reinit_frame_cache, so it's safe to just move the frame restoration forward. -- Nick http://www.inet.net.nz/~nickrob 2006-12-09 Nick Roberts * varobj.c (varobj_update): Ensure frame is restored when variable object is out of scope. *** varobj.c 09 Dec 2006 01:44:28 +1300 1.64 --- varobj.c 09 Dec 2006 01:47:18 +1300 *************** varobj_update (struct varobj **varp, str *** 1052,1057 **** --- 1052,1063 ---- has changed. */ type_changed = 1; new = value_of_root (varp, &type_changed); + + /* Restore selected frame */ + fi = frame_find_by_id (old_fid); + if (fi) + select_frame (fi); + if (new == NULL) { (*varp)->error = 1; *************** varobj_update (struct varobj **varp, str *** 1147,1157 **** *(*changelist + changed) = NULL; } - /* Restore selected frame */ - fi = frame_find_by_id (old_fid); - if (fi) - select_frame (fi); - if (type_changed) return -2; else