Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2011-06

gdb and stopping at the begin line

4 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Martin

Having just reported http://bugs.freepascal.org/view.php?id=19466 I started wondering (to late, should have done before the report) and googled.

It appears that gdb has a "feature" to skip function prologue and epilogue. However I could not find any info on what info gdb uses to know what is the prologue.
So it is possible that something tells gdb that the code on which no stop occurs is the proluge.

does FPC declare this proluge in some form?

References to proluge that I found:
http://sourceware.org/bugzilla/show_bug.cgi?id=12644 http://lists.gnu.org/archive/html/avr-gcc-list/2003-06/msg00011.html

this one sounds like gdb tries to be (too) smart:
http://sourceware.org/gdb/onlinedocs/gdbint/Algorithms.html

Reply by email

Marc Weustink
to Martin
Martin wrote 9 lines
Having just reported http://bugs.freepascal.org/view.php?id=19466 I started wondering (to late, should have done before the report) and googled. It appears that gdb has a "feature" to skip function prologue and epilogue. However I could not find any info on what info gdb uses to know what is the prologue. So it is possible that something tells gdb that the code on which no stop occurs is the proluge.

:)
Thats why we in lazarus query the address of a procedure first and set the breakpoint on that address. This way you always get a break on the start of the procedure (otherwise it depends on debug symbols beeing present or not (for exported functions))

Marc

Reply by email

Martin
to Marc Weustink
Marc Weustink wrote 16 lines
Martin wrote: > Having just reported http://bugs.freepascal.org/view.php?id=19466 > I started wondering (to late, should have done before the report) and > googled. > > It appears that gdb has a "feature" to skip function prologue and > epilogue. However I could not find any info on what info gdb uses to > know what is the prologue. > So it is possible that something tells gdb that the code on which no > stop occurs is the proluge. :) Thats why we in lazarus query the address of a procedure first and set the breakpoint on that address. This way you always get a break on the start of the procedure (otherwise it depends on debug symbols beeing present or not (for exported functions))

Ah well, but that is for the internal breakpoints...

user breakpoints aren't always by start-of-proc, they are by unit + line number. => and in this case gdb does it's own interpretation.....

Also it would need investigation. Since a line can have more thna one statement, and since in conditional code, the first statement is not necessarily executed, I do not know how smart gdb is on this. But if you translated that to address first, it would certainly limit to the 1st statement on the line (or to which ever statement picked...)

Anyway, so does that mean the stopping (or not stopping) at begin, is a feature (if we call it that) in gdb, and fpc does nothing wrong?

Reply by email

Pierre Free Pascal
to Martin: Having just reported http://bugs.freepascal.org/view.php?id=19466 I started wondering (to…
Show quoted text 14 lines
-----Message d'origine----- De : [mailto:fpc-devel- De la part de Martin Envoyé : vendredi 3 juin 2011 01:03 À : FPC developers' list Objet : [fpc-devel] gdb and stopping at the begin line Having just reported http://bugs.freepascal.org/view.php?id=19466 I started wondering (to late, should have done before the report) and googled. It appears that gdb has a "feature" to skip function prologue and epilogue. However I could not find any info on what info gdb uses to know what is the prologue.

Yes, there is code inside GDB that analyses the start instructions to skip the first instructions if GDB recognizes a "prologue" What GDB recognizes as a prologue can be rather complicated, it of course depends on CPU (as it is sometimes based on assembly instruction analysis), but DWARF might provide other info for debuggers... (I still know about nothing about DWARF :( )

So it is possible that something tells gdb that the code on which no stop occurs is the proluge. does FPC declare this proluge in some form?

Not for stabs debugging information,
for DWARF I don't really know...

I do remember that I had problems once with
methods that called other methods on i386:
the method call started by an ESI register push
(push of SELF value) which was interpreted by GDB as being part of the register local saves an integrated into the prologue part. This was then further complicated by the fact that all the remaining assembler code until the next line information was also skipped, leading to a breakpoint that was put past the first method call...

Prologue of main is a special case for which GDB tries to find and skip a possible call to C __main function,
this might lead to GDB skipping the call to
the code that loads all startup code of all used units. (But again, I am not sure this is true for all version of GDB nor all version of Free Pascal or cpu/os pairs...)

Pierre Muller

Free Pascal core member (not very active lately :() and pascal language maintainer for GDB.

Reply by email