Hi,
I am using FPC (3.0.4 and the fixes_3_0 branch) to create a shared library for Linux x86_64. When it comes to debugging (with gdb) or profiling, I always had problems getting valuable stacktraces from withing the pascal functions. I now tracked this problem down to the .debug_frame section generated by the -gw option of fpc.
In my opinion fpc (fixes_3_0 branch) generates a mix-up of the 32-bit DWARF format and the 64-bit DWARF format (which only exists for DWARF version 3 and later). The generated initial length fields are 32 bit (32-bit DWARF) and not 96 bit (64-bit DWARF) and the CID_id fields in the CIEs are 32 bit (32-bit DWARF) and not 64 bit (64-bit DWARF) but the CIE_pointer fields in the FDEs are 64 bit (64-bit DWARF) and not 32 bit (32-bit DWARF).
The attached patch (for the fixes_3_0 branch) fixes the CIE_pointer length to be 32 bit. In addition I had to change the alignment of .debug_frame sections to 4 bytes. Otherwise the concatenation of multiple .debug_frame sections would result in corrupt entries.
During my investigations I stumbled over the calling convention DW_CC_GNU_borland_fastcall_i386. I think this is a bit weird on a non-i386 platform. Therefore the patch changes this to DW_CC_normal on the other platforms.
Please give this patch a thorough review as I am neither a DWARF nor a compiler expert. But for me (on Linux x86_64) the debugging and profiling situation is much better now.
Markus
