[fpc-devel] GDB barfs on FPC generated stabs.

Bruce Tulloch bruce at causal.com
Sun Sep 9 13:36:23 CEST 2007

Thanks for the feedback Jonas.

I've since downloaded and built gdb 6.6 and both problems remain the same
so I don't think it's gdb per se. This latest GDB version still produces a
SEGV on stabs symbols from time to time and it still produces bad filenames
when dwarf symbols are used instead of stabs.

With reference to the latter problem, I'm porting a (former Delphi) project
with Lazarus (SVN) and FPC (2.1.4). For units that are in the same directory
as the .lpr file, the dwarf reported filenames are correct.

However for units that are in a directory specified via an -Fu argument the
names are corrupted as I described before. Eg, -Fusrc/ produces a filename
for the "Widget" unit as "src//Widget.pas" instead of just "Widget.pas". In
the case of stabs the filename is reported correctly regardless of where
the unit is located.

Is there something else you can suggest I try? At this point is looks like
FPC is either generating incorrect names in the dwarf encoded symbolic
data or something else is preventing gdb (6.6) from reading it correctly.

Is there another tool I can use than gdb to dump the dwarf data from the

Any clues much appreciated and let me know if there is other information
I might be able to provide which helps get to the bottom of this.

Cheers, Bruce.

Jonas Maebe wrote:
> On 09 Sep 2007, at 10:07, Bruce Tulloch wrote:
>> I have encountered a problem using GDB (6.4.90-debian) with FPC (2.0.4
>> or 2.1.4). In a nutshell, GDB sometimes barfs on FPC generated stabs.
> That is a quite old gdb version. I would recommend at least gdb 6.5, and
> preferably gdb 6.6.
>> If the program is compiled with -g (stabs format) the debugger works
>> but attempts to print some data structures or produce a back-trace
>> can result in a SEGV in GDB (ie, GDB itself crashes).
> Sounds like a bug in the gdb version you are using.
>> By way of example, with GDB run in the (project home) directory
>>   /home/bruce/vc/
>> with dwarf symbols GDB reports:
>>   (gdb) info source
>>   Current source file is src//Widget.pas
>>   Compilation directory is src/
>>   Located in /home/bruce/vc/src/Widget.pas
>>   Contains 637 lines.
>>   Source language is pascal.
>>   Compiled with unknown debugging format.
>>   Does not include preprocessor macro info.
> That's gdb which is doing that. We do not say in the debug information
> that the source file is called "src//Widget.pas"; we set the compilation
> dir to ./src/ and the file name to Widget.pas, just like when generating
> stabs.
> In fact, it appears this bug is not present in Apple's fork of gdb. It
> is present in gdb 6.5-15.fc6rh (on Fedora Core 6) though.
>>  [1] has anyone else seen the GDB crashing problem when a program is
>>      compiled with stabs info?
> I haven't, but as I said you're using a really old version of gdb.
>>  [2] is the filename problem with dwarf encoded symbols an FPC bug or
>>      is there some configuration I'm missing somehere.
> It's a gdb bug.
> Jonas
> _______________________________________________
> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-devel

More information about the fpc-devel mailing list