View Issue Details

IDProjectCategoryView StatusLast Update
0037069FPCCompilerpublic2020-05-14 02:45
ReporterMartin Friebe Assigned To 
Status newResolutionopen 
Platform64bit IntelOSwin 10 
Product Version3.3.1 
Summary0037069: Wrong dwarf in nested proc for "var FOO: integer absolute FOO_IN_OUTER"
DescriptionSee code below and,49795.msg362072/topicseen.html#new

In a nested procedure, have a variable that is absolute to a variable in the outer proc.
      ProcedureBVariable : integer absolute ProcedureAVariable;

A normal local var has dwarf info like:
  DW_AT_location, DW_FORM_block1 => DW_OP_breg5, SLEB(-4)
(The offset "-4" varies for the location on the stackframe)

For the "absolute" var, fpc copies the dwarf info. But the nested procedure has its own stackframe. So the copy points to the wrong location.
Steps To Reproduceprogram Project1;

  procedure ProcedureA();
    ProcedureAVariable : integer = 5;

    procedure ProcedureB();
      { absolute clause on nested variable }
      ProcedureBVariable : integer absolute ProcedureAVariable;
      writeln; // set break here - hover over ProcedureBVariable now


  ProcedureA(); { output is correct. The compiler handles "absolute" correctly. }
  writeln('Press enter/return to end this program');
Additional InformationI have not tested this, but if memory serves:

Lets say the "parentFp" passed to the nested is at -4
and the variable is at -8 on the outer frame

  DW_AT_location, DW_FORM_block1 =>

With this it may be possible to also include all "visible outer var" as locals.
In the example ProcedureAVariable could be added as local var to ProcedureB.

Currently a debugger must recognize parentFp, follow it and find local vars from the outer proc.
However, a debugger has no means to know which of them are declared before or after the nested proc. This causes visibility issue

TagsNo tags attached.
Fixed in Revision
Attached Files


There are no notes attached to this issue.

Issue History

Date Modified Username Field Change
2020-05-14 02:45 Martin Friebe New Issue