From 2950785bd767bea2b75fde2b77368a18d8d1b263 Mon Sep 17 00:00:00 2001 From: Joost van der Sluis Date: Sun, 22 May 2022 01:09:41 +0200 Subject: [PATCH] * 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 --- compiler/dbgdwarf.pas | 17 ++++++++++++++--- tests/test/tdwarfproperties1.pp | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 47 insertions(+), 3 deletions(-) create mode 100644 tests/test/tdwarfproperties1.pp diff --git a/compiler/dbgdwarf.pas b/compiler/dbgdwarf.pas index c663a267b1..232a319ced 100644 --- a/compiler/dbgdwarf.pas +++ b/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 diff --git a/tests/test/tdwarfproperties1.pp b/tests/test/tdwarfproperties1.pp new file mode 100644 index 0000000000..0283bd5a95 --- /dev/null +++ b/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. +