This is the mail archive of the
mailing list for the GDB project.
Re: When isn't there a selected frame?
> Daniel Jacobowitz writes:
> > On Sun, Apr 14, 2002 at 10:04:51PM -0400, Andrew Cagney wrote:
> > > Hello,
> > > > > Random bits of GDB contain code snipits like:
> > > > > if (selected_frame)
> > > ..
> > > else
> > > error ("No selected frame");
> > > > > Is there any time when it doesn't make sense to have a selected frame
> > > (except, say when current_frame() is also NULL)?
> > > Perhaps to handle when the target is not running? I am pretty sure
> > I've reached a couple of those messages.
> > Yes, so it seems. What about connecting to a remote target? Do you
> get a frame selected right away? How about attach? detach? Hmm, I
> just tried with a sim and a native attach, and current_frame and
> selected_frame seem to be in sync, i.e, not null at the same time.
So, provided the target has ``state'', there is a frame. This is
different to ``no stack''. Even with no stack, there can be a frame, it
is just that it can't do much :-(
Anyway, this means the change:
> get_selected_frame ()
> if (selected_frame)
> return selected_frame;
> return get_current_frame ()
if (selected_frame == NULL)
selected_frame = get_current_frame ();
Is looking reasonable as a first cut. Return what ever
get_current_frame() thinks is the current frame.
> BTW, I always got a bit confused by the 'No stack' vs. 'No selected
> frame' message. I know that No stack has to do with the capabilities
> of the target as opposed at what your inferior program is doing right
> now, but as a *user* I find it a bit confusing.
> And don't forget the variations on the theme:
> "No frame selected"
> "No selected stack frame"
> "no frame selected"
> Should we stick with just one message?
Yes. How to fix it, I'm not sure. I suspect no one is really sure
if/when selected_frame() can be null.