Browse Source

* Only write access-info for properties when the actual underlying method
belongs to an odt_class or odt_helper, because others do not have debug
info included

Joost van der Sluis 3 years ago
parent
commit
2950785bd7
2 changed files with 47 additions and 3 deletions
  1. 14 3
      compiler/dbgdwarf.pas
  2. 33 0
      tests/test/tdwarfproperties1.pp

+ 14 - 3
compiler/dbgdwarf.pas

@@ -2955,9 +2955,20 @@ implementation
         if assigned(accesslist.procdef) then
           begin
             memberdef := accesslist.procdef;
-            memberowner := memberdef.owner;
-            dwarfoffset := (accesslist.procdef as tcpuprocdef).dwarfoffset;
-            memberdef_or_sym := memberdef;
+            // Debuginfo for procdefs is only written for members of an odt_helper
+            // or odt_class. (So, among others, not for interfaces.)
+            // It is not possible to reference something that is not there, so
+            // omit te reference.
+            if Assigned(memberdef.owner.defowner) and (memberdef.owner.defowner.typ=objectdef) and
+               (tobjectdef(memberdef.owner.defowner).objecttype in [odt_helper, odt_class]) then
+              begin
+                if Assigned(tprocdef(memberdef).localst) then
+                  begin
+                    memberowner := memberdef.owner;
+                    dwarfoffset := (accesslist.procdef as tcpuprocdef).dwarfoffset;
+                    memberdef_or_sym := memberdef;
+                  end;
+              end;
           end
         // Note that the returned 'dwarfoffset' is not used and not a dwarf-offset
         else if get_symlist_sym_offset(accesslist.firstsym, membersym, dwarfoffset) then

+ 33 - 0
tests/test/tdwarfproperties1.pp

@@ -0,0 +1,33 @@
+{ %OPT=-gw -godwarfproperties }
+program tdwarfproperties1;
+
+{$mode objfpc}{$H+}
+
+type
+  ITestIntf = interface(IUnknown)
+    function GetCurrent: TObject;
+  end;
+
+  ITestIntf2 = interface(ITestIntf)
+    property Current2: TObject read GetCurrent;
+  end;
+
+  { TGenEvaluationIdentifierList }
+
+  TGenEvaluationIdentifierList = class(TInterfacedObject, ITestIntf2)
+    function GetCurrent: TObject;
+    property Current2: TObject read GetCurrent;
+  end;
+
+function TGenEvaluationIdentifierList.GetCurrent: TObject;
+begin
+
+end;
+
+var
+  s: ITestIntf;
+
+begin
+  s := ITestIntf(nil);
+end.
+