[RFA] Have block_innermost_frame start from selected frame

Paul Hilfinger Hilfinger@adacore.com
Mon Jan 9 07:17:00 GMT 2012


This is an update of my previous patch to address a problem that Eli
uncovered: references to BLOCK:LOCAL_VARIABLE did not work in watched
expressions.  In fact, due to a bug, a local variable referred to with
BLOCK:VAR has always been handled incorrectly in 'watch', even if it
is interpreted to refer to the innermost frame associated with BLOCK,
because no breakpoint would be set to remove the watch when the
variable's frame was deallocated.

Eli, your actual comment was a question about whether the syntax
applied to watch (given that all the examples used print).  On
consideration, I decided to keep things as they are, because if the
issue is that it is unclear where variables may be used, it is a
problem that extends to the entire chapter on "Examining Data", and
should be addressed by a rather larger editorial assault.

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.

This change is perhaps unnecessarily conservative.  It uses
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.

Second, 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 change 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.

Paul N. Hilfinger
(Hilfinger@adacore.com)


2011-12-27  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, gdb/m2-exp.y, gdb/objc-exp.y: Update innermost_block

  * gdb/doc/gdb.texinfo (Variables): Document use of :: for non-static
    variables.
---
 gdb/blockframe.c    |    9 ++++++---
 gdb/c-exp.y         |    7 +++++++
 gdb/doc/gdb.texinfo |   44 ++++++++++++++++++++++++++++++++++++++++++--
 gdb/m2-exp.y        |    7 +++++++
 gdb/objc-exp.y      |    7 +++++++
 5 files changed, 69 insertions(+), 5 deletions(-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: 0001-Have-block_innermost_frame-start-from-selected-frame.patch
Type: text/x-patch
Size: 4908 bytes
Desc: not available
URL: <http://sourceware.org/pipermail/gdb-patches/attachments/20120109/46f95602/attachment.bin>


More information about the Gdb-patches mailing list