[fpc-devel] gdb and stopping at the begin line

Pierre Free Pascal pierre at freepascal.org
Mon Jun 6 16:54:25 CEST 2011

> -----Message d'origine-----
> De : fpc-devel-bounces at lists.freepascal.org [mailto:fpc-devel-
> bounces at lists.freepascal.org] 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.

More information about the fpc-devel mailing list