This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: stabs at function entry point?


Dale Johannesen <dalej@apple.com> writes:

> Our gdb guy, Jim Ingham, pointed out that gcc3 on Darwin (which uses
> dbx-style debug info [stabs]) is generating the first line-number
> stab in a function before the prologue.  Jim argues that it should
> be after the prologue, and has convinced Stan and me.  Meanwhile,
> comments in function.c:thread_prologue_and_epilogue_insns() suggest
> that this was the intent all along:
> 
>            GDB handles `break f' by setting a breakpoint on the first
>            line note after the prologue.  Which means (1) that if
>            there are line number notes before where we inserted the
>            prologue we should move them, and (2) we should generate a
>            note before the end of the first basic block, if there isn't
>            one already there.
> 
> but a comment in init_function_start suggests otherwise:
> 
>       Also tell final how to output a linenum before the function prologue.
> 
> OK, I can fix this:  easiest is simply to change
> dbx_debug_hooks.begin_prologue so it doesn't emit the line
> number.  What I don't know is how widely this change is applicable.
> Is this an appropriate thing to do for gdb on other targets?  Will
> it break a real dbx, and if so do we care?  Which of the above-quoted
> comments correctly indicates the intent?

Line number comments are also used for the reverse mapping: Given a
location, what source line corresponds to it?

So, suppose the user stops at the first instruction of a function.
What line should the debugger display?  Hopefully, some line in the
function.  Thus, there should be at least one line-number stab at the
very start of the function.

If the prologue is intermixed with the code for statements the
function, I'd like to think that we'd also get correct line numbers
for the statements, even though the prologue hasn't finished executing
yet.  Otherwise it's possible to have no way to set a breakpoint on
some lines even though there are instructions corresponding to those
lines.  In fact, if the epilogue is treated similarly, and the
prologue and epilogue overlap (theoretically possible), there might be
no line number notes at all.

-- 
- Geoffrey Keating <geoffk@geoffk.org> <geoffk@redhat.com>


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]