Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: Joel Brobecker <brobecker@adacore.com>
To: gdb-patches@sourceware.org
Subject: Re: [RFC/RFA] continue stepping if landed in new range of same line
Date: Thu, 20 Dec 2007 05:40:00 -0000	[thread overview]
Message-ID: <20071220052617.GE6154@adacore.com> (raw)
In-Reply-To: <20071219141812.GA21072@caradoc.them.org>

> I don't like your patch very much, since it assumes things about code
> based on the structure of the source (and there are some pathological
> cases, like functions which start in one file and end in another).

To be honest, I didn't like it very much either. I didn't know about
functions that start and end in different files! Is that through
inlining?

> I'd rather figure out if the above quoted code is still necessary.
> If we were on the last line of the function and told to step, why
> shouldn't we step out of it?

I am guessing that this is to handle the following situation:

    void foo (void) { bar (); baz (); }

When you break on foo, and then do a next:

    (gdb) break foo
    (gdb) cont
    [landing in foo, after function prologue]
    (gdb) next
    [executes "bar ();" statement, stops at call to baz]
    (gdb) next
    [executes "baz ();" statement, stops at epilogue]
    (gdb) next
    [step out of function]

Personally, I have always considered that "next" was supposed to
step until reaching a different line.  But a discussion that we had
internally at AdaCore a while back about something slightly different
made me realize that it's not that obvious. Just to explain a bit
more, we had some code like this:

    10. Foo (Parameter_1 => 2.0,
    11.      Parameter_2 => Call_Me (Argument => 1),
    12.      Parameter_3 => Do_Nothing (Ignore => 3));

Some of the engineers were arguing that if we were stopped at line 10,
then "next" should first get us to line 11 (call to Call_Me), and then
line 11 (call to Do_Nothing), and then back to line 10 for the actual
call to Foo. On the other hand, I was arguing that I expect the first
next to land past the call to Foo.

The debugger is actually not in complete control of what it does,
since it depends on how the compiler generates the line info.  But
this illustrates why what I no longer see the semantics of the "next"
command as obvious anymore.

Back to our case above, I personally would argue that the first
next should step all the way to out of the function. But whether
this would be the most useful behavior depends on the user (type
of code that he usually debugs, and how he likes to debug).
I hope that one-lines above are very rare, and perhaps we should
not worry about them.

-- 
Joel


  reply	other threads:[~2007-12-20  5:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-19 12:59 Joel Brobecker
2007-12-19 14:18 ` Daniel Jacobowitz
2007-12-20  5:40   ` Joel Brobecker [this message]
2007-12-20 14:08     ` Daniel Jacobowitz
2007-12-21  6:28       ` Joel Brobecker
2007-12-21 14:01         ` Daniel Jacobowitz
2007-12-22  6:03           ` Joel Brobecker
2007-12-22 18:05             ` Daniel Jacobowitz
2007-12-24  6:41               ` Joel Brobecker

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=20071220052617.GE6154@adacore.com \
    --to=brobecker@adacore.com \
    --cc=gdb-patches@sourceware.org \
    /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