From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 26748 invoked by alias); 24 May 2007 22:17:30 -0000 Received: (qmail 26740 invoked by uid 22791); 24 May 2007 22:17:30 -0000 X-Spam-Check-By: sourceware.org Received: from mail.codesourcery.com (HELO mail.codesourcery.com) (65.74.133.4) by sourceware.org (qpsmtpd/0.31) with ESMTP; Thu, 24 May 2007 22:17:28 +0000 Received: (qmail 6714 invoked from network); 24 May 2007 22:17:26 -0000 Received: from unknown (HELO localhost) (jimb@127.0.0.2) by mail.codesourcery.com with ESMTPA; 24 May 2007 22:17:26 -0000 To: gdb@sourceware.org Subject: Questions about MI variable objects From: Jim Blandy Date: Thu, 24 May 2007 22:17:00 -0000 Message-ID: User-Agent: Gnus/5.11 (Gnus v5.11) Emacs/22.0.50 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-IsSubscribed: yes Mailing-List: contact gdb-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: gdb-owner@sourceware.org X-SW-Source: 2007-05/txt/msg00150.txt.bz2 I have some questions for GUI implementors. Suppose I have the following program: void foo (int x) { if (x > 0) foo (x - 1); } void bar (int x) { foo (x - 1); } int main (int argc, char **argv) { foo (2); bar (10); return 0; } Suppose I'm stopped where the stack is like this: main -> foo (2) -> foo (1) -> foo (0) Suppose the top frame is selected, and the user adds a display for 'x'. Clearly, it should show '0'. These are questions about what the GUI should display --- not what GDB or MI or varobjs should do. They're about what you want the user to see. 1) If the user selects the 'foo (1)' frame, what should happen to the display of 'x'? Should it grey out? Should it now show 1? (I'd say it should show 1.) 2) If the user lets the 'foo (0)' call run to completion (as with a GDB CLI 'finish' command), what should happen to the display of 'x'? Should it disappear altogether? Should it grey out? Should it show 1? (I'd say it should show 1.) 3) If the user lets control go all the way back to main, what should happen to the display? (I'd say it should grey out.) 4) If the user lets control run to 'foo' again, so the stack now looks like: main -> bar (10) -> foo (9) what should happen to the display of 'x'? (I'd say it should show '9'.) If there's some general agreement on how these ought to behave (not necessarily my guesses, just any agreement) then maybe we could make MI varobjs match that behavior, so that each GUI variable display could be backed by exactly one varobj, and GDB's reports on changes to the varobj's state would correspond closely to changes in the GUI's display. Varobjs exist to help GUIs, and GDB shouldn't be making GUIs jump through hoops to get the behavior they want. The principle behind my guesses is that a display should refer to a particular variable in the source code --- a particular declaration --- and should show its value whenever that declaration is in scope in the selected frame. This is less specific than having the display refer to a particular frame's instance of that variable, and more specific than having it refer to any variable that happens to be in scope under that name. But it's what I'd expect from a GUI. At the moment, GDB tries to associate each varobj with a specific function invocation. It's so easy to concoct a case where frame ID's collide that in casual testing, the varobj code may appear to implement something more like my suggested behavior. But it doesn't.