This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[PATCH] MI: -var-update bug
- From: Nick Roberts <nickrob at snap dot net dot nz>
- To: gdb-patches at sources dot redhat dot com
- Date: Sat, 9 Dec 2006 08:34:09 +1300
- Subject: [PATCH] MI: -var-update bug
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 <nickrob@snap.net.nz>
* 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