Re: [RFC/RFA?] Should break FILE:LINENO skip prologue?

Joel Brobecker
2008-01-09T20:01:47Z

> > I would like to revive a discussion that started sometime in 2002.
> > The idea is the following: When breaking on a given source line, if
> > that line is inside a function prologue, skip the prologue (using
> > the linetable to do so).
>
> You've got me confused here. How can it be that if skipping using the
> line table helps, the breakpoint location (which I assume has been
> determined based on the line table) isn't right to begin with?

Actually, the line table *is* correct.

Assuming the following code:

1 void
2 call_me (int number)
3 {
4 dial (number);

Typically, the linetable will have the following entries:

line 3: <function prologue>
line 4:
etc...

What I'd like GDB to do is, when the user decides to break on line
2 or 3, to find the address of line 3, realize that it is in the
function prologue, and then skip line 3 until finding the "first
line of real code" (in this case, it's easy, line 4).

Since we are breaking by line number in this case, we know we have
a linetable for our function, and finding the "first line of real
code" (sic from symtab.c:find_function_start_sal description) is
more robust when you rely on debugging info than on prologue scanning.

> Ultimately, the problem is that GCC is (still) generating the wrong
> debug information, since either:

I completely agree, but I don't think the compiler is going to be
fixed anytime soon. I propose to be pragmatic and modify the GDB
behavior so that we do a more useful job with what we have now.
Eventually, when we have better debugging info, we can stop skipping
the function prologue in all cases if we want.

As an aside, I have to say that I find the prologue skipping extremely
convenient regardless of parameter display, because the large majority
of the time, I don't want to stop before the prologue only to have to
"next/step" over it right after. I'd rather stop in the function body
immediately. So removing the prologue skipping would be a regression
in usability in my opinion.

--
Joel