[fpc-devel] DWARF CIEs and FDEs on Linux x86_64
Markus Beth
markus.beth at zkrd.de
Sun Feb 4 23:58:47 CET 2018
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
-------------- next part --------------
A non-text attachment was scrubbed...
Name: fpc-dwarf.patch
Type: text/x-patch
Size: 1972 bytes
Desc: not available
URL: <http://lists.freepascal.org/pipermail/fpc-devel/attachments/20180204/3ed3eae0/attachment.bin>
More information about the fpc-devel
mailing list