llvmdbg: fixes for method debug info

Mark "self" parameter as artificial

Add methods to the scope of the class/record rather than to the file scope

Add the vmt field, strip the "($)hidden" prefix from its name, and emit its
real type
This commit is contained in:
Jonas Maebe 2022-11-06 16:09:45 +01:00
parent c5cdfbd9c0
commit 95f94a279c

View File

@ -590,6 +590,8 @@ implementation
dilocalvar.addmetadatarefto('scope',functionscope); dilocalvar.addmetadatarefto('scope',functionscope);
try_add_file_metaref(dilocalvar,sym.fileinfo,false); try_add_file_metaref(dilocalvar,sym.fileinfo,false);
dilocalvar.addmetadatarefto('type',def_meta_node(sym.vardef)); dilocalvar.addmetadatarefto('type',def_meta_node(sym.vardef));
if vo_is_self in sym.varoptions then
dilocalvar.addenum('flags','DIFlagArtificial');
end end
else else
begin begin
@ -1161,12 +1163,14 @@ implementation
i, varindex: longint; i, varindex: longint;
field: tfieldvarsym; field: tfieldvarsym;
bitoffset: asizeuint; bitoffset: asizeuint;
bpackedrecst: boolean; bpackedrecst,
classorobject: boolean;
begin begin
recst:=tabstractrecordsymtable(def.symtable); recst:=tabstractrecordsymtable(def.symtable);
bpackedrecst:=recst.fieldalignment=bit_alignment; bpackedrecst:=recst.fieldalignment=bit_alignment;
scope:=defdinode; scope:=defdinode;
variantinfolist:=nil; variantinfolist:=nil;
classorobject:=is_class_or_interface_or_object(def);
fieldlist:=initialfieldlist; fieldlist:=initialfieldlist;
list.concat(fieldlist); list.concat(fieldlist);
@ -1178,8 +1182,7 @@ implementation
continue; continue;
field:=tfieldvarsym(recst.symlist[i]); field:=tfieldvarsym(recst.symlist[i]);
if (sp_static in field.symoptions) or if (sp_static in field.symoptions) then
(field.visibility=vis_hidden) then
exit; exit;
{ start of a new variant part? } { start of a new variant part? }
@ -1286,6 +1289,12 @@ implementation
fielddi.addstring('name',symname(field,false)); fielddi.addstring('name',symname(field,false));
fielddi.addmetadatarefto('scope',scope); fielddi.addmetadatarefto('scope',scope);
try_add_file_metaref(fielddi,field.fileinfo,false); try_add_file_metaref(fielddi,field.fileinfo,false);
{ the vmt field's type is voidpointerdef, because when it gets
inserted we can't build the vmt's def yet }
if classorobject and
(field=tobjectdef(def).vmt_field) then
fielddi.addmetadatarefto('baseType',def_meta_node(cpointerdef.getreusable(tobjectdef(def).vmt_def)))
else
fielddi.addmetadatarefto('baseType',def_meta_node(field.vardef)); fielddi.addmetadatarefto('baseType',def_meta_node(field.vardef));
if bpackedrecst and if bpackedrecst and
is_ordinal(field.vardef) then is_ordinal(field.vardef) then
@ -1295,7 +1304,9 @@ implementation
bitoffset:=bitoffsetfromvariantstart(field,variantinfolist,cappedsize); bitoffset:=bitoffsetfromvariantstart(field,variantinfolist,cappedsize);
if bitoffset<>0 then if bitoffset<>0 then
fielddi.addqword('offset',bitoffset); fielddi.addqword('offset',bitoffset);
{ currently only vmt }
if field.visibility=vis_hidden then
fielddi.addenum('flags','DIFlagArtificial');
fieldlist.addvalue(llvm_getmetadatareftypedconst(fielddi)); fieldlist.addvalue(llvm_getmetadatareftypedconst(fielddi));
list.concat(fielddi); list.concat(fielddi);
end; end;
@ -1714,6 +1725,16 @@ implementation
end; end;
dinode.addstring('name',symdebugname(def.procsym)); dinode.addstring('name',symdebugname(def.procsym));
if assigned(def.struct) and
not is_objc_class_or_protocol(def.struct) then
begin
if is_implicit_pointer_object_type(def.struct) then
dinode.addmetadatarefto('scope',def_meta_class_struct(tobjectdef(def.struct)))
else
dinode.addmetadatarefto('scope',def_meta_node(def.struct));
try_add_file_metaref(dinode,def.fileinfo,false);
end
else
try_add_file_metaref(dinode,def.fileinfo,true); try_add_file_metaref(dinode,def.fileinfo,true);
if not(cs_debuginfo in current_settings.moduleswitches) then if not(cs_debuginfo in current_settings.moduleswitches) then
begin begin
@ -2529,12 +2550,19 @@ implementation
function TDebugInfoLLVM.symdebugname(sym: tsym): TSymStr; function TDebugInfoLLVM.symdebugname(sym: tsym): TSymStr;
begin begin
if ds_dwarf_cpp in current_settings.debugswitches then if ds_dwarf_cpp in current_settings.debugswitches then
begin
if sym.visibility=vis_hidden then
result:=copy(sym.RealName,length('$hidden')+1,length(sym.RealName))
else
begin begin
result:=sym.RealName; result:=sym.RealName;
if (result<>'') and if (result<>'') and
(result[1]='$') then (result[1]='$') then
delete(result,1,1); delete(result,1,1);
end end
end
else if sym.visibility=vis_hidden then
result:=copy(sym.name,length('hidden')+1,length(sym.name))
else else
result:=sym.name result:=sym.name
end; end;