Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Daniel Jacobowitz <drow@false.org>
To: Andrew Cagney <cagney@gnu.org>
Cc: Michael Elizabeth Chastain <mec.gnu@mindspring.com>,
	gdb-patches@sources.redhat.com, vinschen@redhat.com
Subject: Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
Date: Fri, 19 Mar 2004 00:09:00 -0000	[thread overview]
Message-ID: <20040310005631.GA13440@nevyn.them.org> (raw)
In-Reply-To: <404E45EC.4030205@gnu.org>

On Tue, Mar 09, 2004 at 05:32:12PM -0500, Andrew Cagney wrote:
> >>Yes, the inner "i" should be in scope.  That line, which hasn't yet been 
> >>>executed, will destory the inner block.  I think that is covered by the 
> >>>GCC-O0 rule?
> >
> >
> >If that's right, it sounds like we should be using the address-in-block
> >hack to figure out what local variables are in scope for the top
> >frame.  But that runs the risk of, for instance, moving us back into a
> >preceeding function.
> 
> Er, that sounds like a theoretical address-in-block bug?  The value 
> returned should be floored by (as in can't be less than) the function 
> start.  Can you think of an edge case that makes this real?

Right now, frame_unwind_address_in_block returns PC for any frame,
whose next frame is a normal frame, other than the innermost.  If
you're here:

    {
      int i;
      stuff (i);
->  }

and you want to use something like the address-in-block hack to claim
to be inside the scope of i, that means you need to apply it to the
innermost frame.  If you apply it to the innermost frame, you might end
up applying it when we're at the beginning of a function, which is just
wrong.

BTW, I think the NORMAL_FRAME check is wrong too:

    {
      int i;
      stuff (i);
->  }

get signal

Use the sigtramp saved PC unmodified, and it leaves you in the right
function - but that doesn't mean it leaves you in the right block!

Maybe something like (considering recent discussion about
get_frame_func):

/* Return an address of that falls within the frame's code block.  */

CORE_ADDR
get_frame_address_in_block (struct frame_info *this_frame)
{ 
  /* A draft address.  */
  CORE_ADDR pc = get_frame_pc (this_frame);
  CORE_ADDR func = get_frame_func (this_frame);

  if (pc != func)
    pc--;

  return pc;
}

Note that this doesn't work for functions with discontiguous address
ranges, which GCC will soon be generating; but neither does anything
else in GDB, so we can tackle that with a fixme :)

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


WARNING: multiple messages have this Message-ID
From: Daniel Jacobowitz <drow@false.org>
To: Andrew Cagney <cagney@gnu.org>
Cc: Michael Elizabeth Chastain <mec.gnu@mindspring.com>,
	gdb-patches@sources.redhat.com, vinschen@redhat.com
Subject: Re: [RFC/RFA] gdb.cp/classes.exp: Don't try to print local variable out of scope
Date: Wed, 10 Mar 2004 00:56:00 -0000	[thread overview]
Message-ID: <20040310005631.GA13440@nevyn.them.org> (raw)
Message-ID: <20040310005600.WnFl5FcZvjm3iMmuQlWGNkW8Cbw1jJFtDd29cgCmJpQ@z> (raw)
In-Reply-To: <404E45EC.4030205@gnu.org>

On Tue, Mar 09, 2004 at 05:32:12PM -0500, Andrew Cagney wrote:
> >>Yes, the inner "i" should be in scope.  That line, which hasn't yet been 
> >>>executed, will destory the inner block.  I think that is covered by the 
> >>>GCC-O0 rule?
> >
> >
> >If that's right, it sounds like we should be using the address-in-block
> >hack to figure out what local variables are in scope for the top
> >frame.  But that runs the risk of, for instance, moving us back into a
> >preceeding function.
> 
> Er, that sounds like a theoretical address-in-block bug?  The value 
> returned should be floored by (as in can't be less than) the function 
> start.  Can you think of an edge case that makes this real?

Right now, frame_unwind_address_in_block returns PC for any frame,
whose next frame is a normal frame, other than the innermost.  If
you're here:

    {
      int i;
      stuff (i);
->  }

and you want to use something like the address-in-block hack to claim
to be inside the scope of i, that means you need to apply it to the
innermost frame.  If you apply it to the innermost frame, you might end
up applying it when we're at the beginning of a function, which is just
wrong.

BTW, I think the NORMAL_FRAME check is wrong too:

    {
      int i;
      stuff (i);
->  }

get signal

Use the sigtramp saved PC unmodified, and it leaves you in the right
function - but that doesn't mean it leaves you in the right block!

Maybe something like (considering recent discussion about
get_frame_func):

/* Return an address of that falls within the frame's code block.  */

CORE_ADDR
get_frame_address_in_block (struct frame_info *this_frame)
{ 
  /* A draft address.  */
  CORE_ADDR pc = get_frame_pc (this_frame);
  CORE_ADDR func = get_frame_func (this_frame);

  if (pc != func)
    pc--;

  return pc;
}

Note that this doesn't work for functions with discontiguous address
ranges, which GCC will soon be generating; but neither does anything
else in GDB, so we can tackle that with a fixme :)

-- 
Daniel Jacobowitz
MontaVista Software                         Debian GNU/Linux Developer


  parent reply	other threads:[~2004-03-10  0:56 UTC|newest]

Thread overview: 38+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-09 16:15 ` Michael Elizabeth Chastain
2004-03-19  0:09 ` Andrew Cagney
2004-03-09 20:38   ` Andrew Cagney
2004-03-09 21:27   ` Daniel Jacobowitz
2004-03-09 22:32     ` Andrew Cagney
2004-03-19  0:09       ` Andrew Cagney
2004-03-19  0:09       ` Daniel Jacobowitz [this message]
2004-03-10  0:56         ` Daniel Jacobowitz
2004-03-19  0:09         ` Andrew Cagney
2004-03-10  1:51           ` Andrew Cagney
2004-03-10  3:05           ` Daniel Jacobowitz
2004-03-19  0:09             ` Daniel Jacobowitz
2004-03-19  0:09             ` Daniel Jacobowitz
2004-03-10  3:23               ` Daniel Jacobowitz
2004-03-10 22:21               ` Andrew Cagney
2004-03-10 22:29                 ` Daniel Jacobowitz
2004-03-15 18:47                   ` Andrew Cagney
2004-03-19  0:09                     ` Andrew Cagney
2004-03-19  0:09                   ` Daniel Jacobowitz
2004-03-19  0:09                 ` Andrew Cagney
2004-03-19  0:09     ` Daniel Jacobowitz
  -- strict thread matches above, loose matches on Subject: below --
2004-03-19  0:09 Corinna Vinschen
2004-03-09 13:00 ` Corinna Vinschen
2004-03-19  0:09 ` Daniel Jacobowitz
2004-03-09 14:17   ` Daniel Jacobowitz
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-10 23:58 ` Michael Elizabeth Chastain
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-09 15:27 ` Michael Elizabeth Chastain
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-09 15:11 ` Michael Elizabeth Chastain
2004-03-09 15:40 ` Corinna Vinschen
2004-03-19  0:09   ` Corinna Vinschen
2004-03-19  0:09 ` Daniel Jacobowitz
2004-03-09 15:20   ` Daniel Jacobowitz
2004-03-19  0:09 Michael Elizabeth Chastain
2004-03-10  2:06 ` Michael Elizabeth Chastain

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=20040310005631.GA13440@nevyn.them.org \
    --to=drow@false.org \
    --cc=cagney@gnu.org \
    --cc=gdb-patches@sources.redhat.com \
    --cc=mec.gnu@mindspring.com \
    --cc=vinschen@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