Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-devel / 2018-02

DWARF CIEs and FDEs on Linux x86_64

2 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Markus Beth

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

Reply by email

Tomas Hajny
to Markus Beth

On Sun, February 4, 2018 23:58, Markus Beth wrote:

Hi,

.
.

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.

Thanks for your patch. I can't assess the patch myself, but as a general rule, creating a bug tracker entry and attaching the patch there (and possibly sending reference to the bug tracker entry to the mailing list afterwards) is better than just sending the patch to the mailing list.

Tomas

Reply by email