Re: MI: Another -var-update bug? [PATCH]

Nick Roberts
2006-12-13T06:32:41Z

> Variable objects appear to test scope on a frame basis (in c_value_of root).
> If we create a variable object for j in the inner block of the program below
> then doing -var-update on line 10 doesn't report it as being out of scope.
> But struct varobj_root has a member struct block *valid_block. Presumably
> the addresses in this structure can be used to test if the variable is still
> in scope or not

Something like below?

--
Nick http://www.inet.net.nz/~nickrob

2006-12-13 Nick Roberts <nickrob@snap.net.nz>

* varobj.c: Include block.h.
(c_value_of_root): Check scope within nested statements.

*** varobj.c 09 Dec 2006 10:59:12 +1300 1.65
--- varobj.c 13 Dec 2006 19:17:36 +1300
***************
*** 26,31 ****
--- 26,32 ----
#include "language.h"
#include "wrapper.h"
#include "gdbcmd.h"
+ #include "block.h"

#include "gdb_assert.h"
#include "gdb_string.h"
*************** c_value_of_root (struct varobj **var_han
*** 1958,1965 ****
fi = frame_find_by_id (var->root->frame);
within_scope = fi != NULL;
/* FIXME: select_frame could fail */
! if (within_scope)
! select_frame (fi);
}

if (within_scope)
--- 1959,1972 ----
fi = frame_find_by_id (var->root->frame);
within_scope = fi != NULL;
/* FIXME: select_frame could fail */
! if (fi)
! {
! CORE_ADDR pc = get_frame_pc (fi);
! if (pc < BLOCK_START (var->root->valid_block) ||
! pc >= BLOCK_END (var->root->valid_block))
! within_scope = 0;
! select_frame (fi);
! }
}

if (within_scope)