Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [PATCH] MI: -var-update bug
@ 2006-12-08 19:38 Nick Roberts
  2006-12-08 19:43 ` Daniel Jacobowitz
  0 siblings, 1 reply; 7+ messages in thread
From: Nick Roberts @ 2006-12-08 19:38 UTC (permalink / raw)
  To: gdb-patches


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


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2006-12-09 20:47 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-12-08 19:38 [PATCH] MI: -var-update bug Nick Roberts
2006-12-08 19:43 ` Daniel Jacobowitz
2006-12-08 19:56   ` Nick Roberts
2006-12-08 20:04     ` Daniel Jacobowitz
2006-12-08 20:09       ` Nick Roberts
2006-12-08 20:23         ` Daniel Jacobowitz
2006-12-09 20:47           ` Nick Roberts

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox