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

Bruce Tulloch bruce at causal.com
Wed Sep 12 05:13:56 CEST 2007


I've refined the definition of this problem and attach an
updated toy project that demonstrates it reliably.

I've also found some apparently simple ways to avoid it.

See the testbutton.pas file for full details.

To me it looks very much like a there is something very
subtle but still wrong with with FPC 2.3.1 SVN 8427 STAB
debug data.

Both gdb 6.6 and objdump 2.17 complain about it.

Apparently in 99% of cases the consequences are benign.

Unfortunately in my case it isn't but it does appear I
can work around it by swapping the order of two lines
of code (see testbutton.pas).

Note that in no event does this problem ever appear to
effect the execution of the application itself; the FPC
generated executable does appear be always correct.

It is simply an issue of the generated STAB debug data.

Bruce.

Bruce Tulloch wrote:
> I've managed to distill this problem into a trivial Lazarus project.
> 
> Unpack the tarball, and build this project as .compiled indicates.
> 
> Run it under gdb 6.6 with a break-point placed as commented.
> 
> Try and step into TChild.Create at this point - gdb SEGV.
> 
> Rebuild with DWARF2 and it run without crashing gdb.
> 
> At least that's what I'm seeing here (Debian Etch, FPC SVN 8427, GDB 6.6).
> 
> I hope this helps. I will try and isolate it further.
> 
> Cheers, Bruce.
> 
> Bruce Tulloch wrote:
>> Hi Jonas,
>>
>> Unfortunately GDB (6.6) still barfs on FPC (SVN 8427) generated stabs
>> sometimes when performing a backtrace or printing certain objects in
>> our application. As mentioned earlier, we'll do what we can to abstract
>> the problem into the small demonstration program we can send you. For
>> the time being we'll use DWARF2 as despite some remaining problems with
>> that (reported in another email) it does not crash GDB.
>>
>> Cheers, Bruce.
>>
>> 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.
>>>
>>> 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).
>>>
>>> If the program is compiled with -gd (DBX format) or -gw (dwarf) GDB
>>> works correctly without crashing but reference to source files that
>>> are in directories other than the current directory have a (relative)
>>> path prepended to the name which breaks other things (notably the
>>> emacs/GUD and Lazarus front ends).
>>>
>>> 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.
>>>
>>> When the program is compiled with stabs I get:
>>>
>>>   (gdb) info source
>>>   Current source file is Widget.pas
>>>   Compilation directory is src/
>>>   Located in /home/bruce/vc/src/Widget.pas
>>>   Contains 637 lines.
>>>   Source language is pascal.
>>>   Compiled with stabs debugging format.
>>>   Does not include preprocessor macro info.
>>>
>>> which is correct (but GDB is otherwise unusable due the stabs problem).
>>>
>>> My (2) questions are:
>>>
>>>  [1] has anyone else seen the GDB crashing problem when a program is
>>>      compiled with stabs info?
>>>
>>>  [2] is the filename problem with dwarf encoded symbols an FPC bug or
>>>      is there some configuration I'm missing somehere.
>>>
>>> Note that in all cases I've compiled the program (which is a port of a
>>> a working Delphi application) with no optimizations or other bells and
>>> whistles enabled.
>>>
>>> Many thanks for any advice about what I might be doing wrong.
>>>
>>> Otherwise consider this a bug report :-)
>>>
>>> Cheers, Bruce Tulloch.
>>> _______________________________________________
>>> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>>> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>>>
>> _______________________________________________
>> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-devel
>>
>>
>> ------------------------------------------------------------------------
>>
>> _______________________________________________
>> fpc-devel maillist  -  fpc-devel at lists.freepascal.org
>> http://lists.freepascal.org/mailman/listinfo/fpc-devel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: gdb-bomb.tgz
Type: application/x-compressed
Size: 3054 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20070912/8e596c4e/attachment.bin>


More information about the fpc-devel mailing list