[RFC/RFA] continue stepping if landed in new range of same line

Daniel Jacobowitz drow@false.org
Thu Dec 20 14:08:00 GMT 2007

On Thu, Dec 20, 2007 at 09:26:17AM +0400, Joel Brobecker wrote:
> > 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?

Much simpler than that.

#define FN foo
#include "start-fn.h"
  retval = arg1 + arg2;
#include "end-fn.h"

Finagle the comments just right and this will open on line 2 of
start-fn.h and close on line 2 of end-fn.h.

You might be able to arrange this with inlining or macros, too.

> > 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 (); }

Amusingly, when you copy and paste this into Emacs, it winds up in
perfect GNU style on five lines...

I ran the experiment.  With the function on five lines, next goes from
bar() to baz() and then to }.  With the function on one line, it goes
all the way from bar() back to the caller.  So, maybe it was intended
to handle this case, but it doesn't.

My best guess is that it was design to handle a single-line function
without a call, to prevent us from skipping from the prologue all the
way out.  But I think other measures will prevent that too.

I think that code can probably change.  But you might want to try
debugging a couple of optimized cases to see if the behavior stays

Daniel Jacobowitz

More information about the Gdb-patches mailing list