summaryrefslogtreecommitdiff
path: root/gdb/blockframe.c
diff options
context:
space:
mode:
authorPaul N. Hilfinger <hilfinger@adacore.com>2012-01-11 10:34:19 +0000
committerPaul N. Hilfinger <hilfinger@adacore.com>2012-01-11 10:34:19 +0000
commit3358f06ef6a0456a218970c5d7fc8512a90961ea (patch)
treea10c9c2a5cd05852c604edef7a0f21e0950b1e9b /gdb/blockframe.c
parentc551b0d5bc62dafad1a873aea7e55b1441749657 (diff)
downloadgdb-3358f06ef6a0456a218970c5d7fc8512a90961ea.tar.gz
Have block_innermost_frame start from selected frame and document.
GDB used to search for the frame containing variables in a particular lexical block starting from the current (top) frame, ignoring any currently selected frame. It is not clear why this is desirable for variables that require a frame; why would a user deliberately select one frame and then expect to see the value of a variable in a more recent frame? This change causes block_innermost_frame to start looking from the selected frame, if there is one. It may be unnecessarily conservative: we use get_selected_frame_if_set rather than get_selected_frame in order to avoid the side effect of calling select_frame, which would probably be harmless. Expression-parsing routines previously made the unwarranted assumption that all block-qualified variables (written with the GDB extension <block>::<variable>) are static. As a result, they failed to update innermost_block, which confused the watch commands about when variables in watched expressions went out of scope, and also caused the wrong variables to be watched. This patch also modifies these routines to treat all local variables the same whether or not they are block-qualified. Finally, we add a paragraph to the "Program Variables" section of the texinfo documentation concerning the use of "::" for accessing non-static variables. 2012-01-11 Paul Hilfinger <hilfingr@adacore.com> * gdb/blockframe.c (block_innermost_frame): Start search from selected frame, if present, or otherwise the current frame. * gdb/c-exp.y (variable): Update innermost_block for 'block COLONCOLON NAME' clause. * gdb/m2-exp.y (variable): Ditto. * gdb/objc-exp.y (variable): Ditto. * gdb/doc/gdb.texinfo (Variables): Document use of :: for non-static variables.
Diffstat (limited to 'gdb/blockframe.c')
-rw-r--r--gdb/blockframe.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/gdb/blockframe.c b/gdb/blockframe.c
index 38973667cd2..cb61cf30c5d 100644
--- a/gdb/blockframe.c
+++ b/gdb/blockframe.c
@@ -352,8 +352,9 @@ find_pc_partial_function (CORE_ADDR pc, char **name, CORE_ADDR *address,
return find_pc_partial_function_gnu_ifunc (pc, name, address, endaddr, NULL);
}
-/* Return the innermost stack frame executing inside of BLOCK, or NULL
- if there is no such frame. If BLOCK is NULL, just return NULL. */
+/* Return the innermost stack frame that is executing inside of BLOCK and is
+ at least as old as the selected frame. Return NULL if there is no
+ such frame. If BLOCK is NULL, just return NULL. */
struct frame_info *
block_innermost_frame (const struct block *block)
@@ -368,7 +369,9 @@ block_innermost_frame (const struct block *block)
start = BLOCK_START (block);
end = BLOCK_END (block);
- frame = get_current_frame ();
+ frame = get_selected_frame_if_set ();
+ if (frame == NULL)
+ frame = get_current_frame ();
while (frame != NULL)
{
struct block *frame_block = get_frame_block (frame, NULL);