Mirror of the gdb mailing list
 help / color / mirror / Atom feed
From: Vladimir Prus <ghost@cs.msu.su>
To: gdb@sources.redhat.com
Subject: -var-list --locals proposal
Date: Fri, 05 Jan 2007 20:04:00 -0000	[thread overview]
Message-ID: <200701052303.59465.ghost@cs.msu.su> (raw)


As promised, I have a proposal how to improve local variables
display in MI. At the moment, varobjs for locals should be created
by frontend, presumably after getting the list of local via -stack-list-locals.

That's good, but the list of locals generally change when stepping though
the program:

1. When entering or leaving a function, the list of locals changes
completely.

2. When entering a nested scope, new locals appear. A variable in a 
nested scope may have the same name as a variable in an inner scope.

3. When leaving a nested scope, some locals disappears.

At the moment, to reliably show all locals, the frontend is forced to emit
-stack-list-locals on each step. To handle the case where a new variable
is in nested scope and has the same name as a variable in outer scope,
the frontend should compute addresses of all variables on each step,
and notice when they change. This is rather nasty.

I propose to introduce a new command:

	-var-list --locals <frame>

This command returns variable objects corresponding to every local
variable that is "live" at the current position in the program. If at all
possible, the command tries to return previously returned variable object.

So, on each step, the frontend emits -var-list --locals and:

	1. For all variable objects it never seen, create new GUI
	elements.
	2. For all variable objects that were reported previously,
	but are no longer reported, delete GUI elements.

The 'frame' parameter specifies whose frame's locals should be
returned. I envision that varobjs be reused across frames. So,
if you invoke:

	-var-list --locals 1
	-exec-finish
	-var-list --locals 0

the second -var-list will try to return the same varobjs that were
returned by the first -var-list.

The question is what exactly can be considered "live" variables by
-var-list. I think that to avoid creating and destroying variable
objects as we step though inner blocks, -var-list should construct
varobjs for all variables in all blocks of a function.

Then, at each point in the function each varobj can be in one
of three states:

	1. Accessible in the current scope.
	2. Accessible in some of the outer scopes (hidden
	variable).
	3. Not accessible (variable in a scope we've not
	entered).

Transition between those states can be reported via -var-update. The
differences between (1) and (3) is already reported via "in_scope" attribute.
I'm not sure if we need to expose the difference between (2) and (3),
and if so, if it's better to introduce another attribute -- "hidden" with
values "true" and "false", or new attribute "visibility", with values of:

	"yes"
	"hidden"
	"out_of_scope"

In any way, this is rather small detail that can be changed later.

Comments?

- Volodya


             reply	other threads:[~2007-01-05 20:04 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-01-05 20:04 Vladimir Prus [this message]
2007-01-06 10:39 ` Eli Zaretskii
2007-01-06 11:14   ` Vladimir Prus
2007-01-06 11:24     ` Eli Zaretskii
2007-01-06 12:28       ` Vladimir Prus
2007-01-06 21:51         ` Nick Roberts
2007-01-16  6:57           ` Vladimir Prus
2007-01-10  3:38 ` Daniel Jacobowitz
2007-01-16  7:01   ` Vladimir Prus
2007-01-16  7:18     ` Daniel Jacobowitz
2007-01-16 16:20       ` Vladimir Prus
2007-01-16 22:52         ` Nick Roberts
2007-01-16 23:12           ` Vladimir Prus
2007-01-17  7:54             ` Nick Roberts
2007-01-17 21:34               ` Vladimir Prus

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=200701052303.59465.ghost@cs.msu.su \
    --to=ghost@cs.msu.su \
    --cc=gdb@sources.redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox