mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-16 11:39:39 +02:00
llvmdbg: build hashtable to lookup llvmdecl belonging to a global variable
We need to attach the debug info to it
This commit is contained in:
parent
e865ab4c3a
commit
d0bf7acc18
@ -76,10 +76,20 @@ interface
|
|||||||
al_objc_pools,
|
al_objc_pools,
|
||||||
al_end
|
al_end
|
||||||
);
|
);
|
||||||
|
{$push}{$j-}
|
||||||
|
const
|
||||||
|
globaldataasmlisttypes: array[1..5] of TAsmListType = (
|
||||||
|
al_globals,
|
||||||
|
al_const,
|
||||||
|
al_typedconsts,
|
||||||
|
al_rotypedconsts,
|
||||||
|
al_threadvars
|
||||||
|
);
|
||||||
|
{$pop}
|
||||||
|
|
||||||
{ Type of constant 'pools'. Mostly for string types, but usable for
|
{ Type of constant 'pools'. Mostly for string types, but usable for
|
||||||
floating point and large set constants, too. }
|
floating point and large set constants, too. }
|
||||||
|
type
|
||||||
TConstPoolType = (
|
TConstPoolType = (
|
||||||
sp_invalid,
|
sp_invalid,
|
||||||
sp_conststr,
|
sp_conststr,
|
||||||
|
@ -35,7 +35,7 @@ interface
|
|||||||
uses
|
uses
|
||||||
cclasses,globtype,
|
cclasses,globtype,
|
||||||
cgbase,
|
cgbase,
|
||||||
aasmbase,aasmtai,aasmdata,aasmcnst,aasmllvmmetadata,
|
aasmbase,aasmtai,aasmdata,aasmcnst,aasmllvm,aasmllvmmetadata,
|
||||||
symbase,symconst,symtype,symdef,symsym,
|
symbase,symconst,symtype,symdef,symsym,
|
||||||
finput,
|
finput,
|
||||||
DbgBase, dbgdwarfconst;
|
DbgBase, dbgdwarfconst;
|
||||||
@ -75,6 +75,8 @@ interface
|
|||||||
flocationmeta: THashSet;
|
flocationmeta: THashSet;
|
||||||
{ lookup table for scope,file -> LLVMMeta info (DILexicalBlockFile, for include files) }
|
{ lookup table for scope,file -> LLVMMeta info (DILexicalBlockFile, for include files) }
|
||||||
flexicalblockfilemeta: THashSet;
|
flexicalblockfilemeta: THashSet;
|
||||||
|
{ lookup table for tsym -> taillvmdecl }
|
||||||
|
fsymdecl: THashSet;
|
||||||
|
|
||||||
fcunode: tai_llvmspecialisedmetadatanode;
|
fcunode: tai_llvmspecialisedmetadatanode;
|
||||||
fenums: tai_llvmunnamedmetadatanode;
|
fenums: tai_llvmunnamedmetadatanode;
|
||||||
@ -96,6 +98,9 @@ interface
|
|||||||
function filepos_getmetanode(const filepos: tfileposinfo; const functionfileinfo: tfileposinfo; const functionscope: tai_llvmspecialisedmetadatanode; nolineinfo: boolean): tai_llvmspecialisedmetadatanode;
|
function filepos_getmetanode(const filepos: tfileposinfo; const functionfileinfo: tfileposinfo; const functionscope: tai_llvmspecialisedmetadatanode; nolineinfo: boolean): tai_llvmspecialisedmetadatanode;
|
||||||
function get_def_metatai(def:tdef): PLLVMMetaDefHashSetItem;
|
function get_def_metatai(def:tdef): PLLVMMetaDefHashSetItem;
|
||||||
|
|
||||||
|
procedure sym_set_decl(sym: tsym; decl: tai);
|
||||||
|
function sym_get_decl(sym: tsym): taillvmdecl;
|
||||||
|
|
||||||
procedure appenddef_array_internal(list: TAsmList; fordef: tdef; eledef: tdef; lowrange, highrange: asizeint);
|
procedure appenddef_array_internal(list: TAsmList; fordef: tdef; eledef: tdef; lowrange, highrange: asizeint);
|
||||||
function getabstractprocdeftypes(list: TAsmList; def:tabstractprocdef): tai_llvmbasemetadatanode;
|
function getabstractprocdeftypes(list: TAsmList; def:tabstractprocdef): tai_llvmbasemetadatanode;
|
||||||
|
|
||||||
@ -145,6 +150,8 @@ interface
|
|||||||
|
|
||||||
procedure ensuremetainit;
|
procedure ensuremetainit;
|
||||||
procedure resetfornewmodule;
|
procedure resetfornewmodule;
|
||||||
|
|
||||||
|
procedure collectglobalsyms;
|
||||||
public
|
public
|
||||||
constructor Create;override;
|
constructor Create;override;
|
||||||
destructor Destroy;override;
|
destructor Destroy;override;
|
||||||
@ -162,7 +169,7 @@ implementation
|
|||||||
cpubase,cpuinfo,paramgr,
|
cpubase,cpuinfo,paramgr,
|
||||||
fmodule,
|
fmodule,
|
||||||
defutil,symtable,symcpu,ppu,
|
defutil,symtable,symcpu,ppu,
|
||||||
llvminfo,llvmbase,aasmllvm
|
llvminfo,llvmbase
|
||||||
;
|
;
|
||||||
|
|
||||||
{$push}
|
{$push}
|
||||||
@ -298,6 +305,26 @@ implementation
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDebugInfoLLVM.sym_set_decl(sym: tsym; decl: tai);
|
||||||
|
var
|
||||||
|
entry: PHashSetItem;
|
||||||
|
begin
|
||||||
|
entry:=fsymdecl.FindOrAdd(@sym,sizeof(sym));
|
||||||
|
if assigned(entry^.Data) then
|
||||||
|
internalerror(2022051701);
|
||||||
|
entry^.Data:=decl;
|
||||||
|
end;
|
||||||
|
|
||||||
|
function TDebugInfoLLVM.sym_get_decl(sym: tsym): taillvmdecl;
|
||||||
|
var
|
||||||
|
entry: PHashSetItem;
|
||||||
|
begin
|
||||||
|
result:=nil;
|
||||||
|
entry:=fsymdecl.Find(@sym,sizeof(sym));
|
||||||
|
if assigned(entry) then
|
||||||
|
result:=taillvmdecl(entry^.Data);
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDebugInfoLLVM.appenddef_array_internal(list: TAsmList; fordef: tdef; eledef: tdef; lowrange, highrange: asizeint);
|
procedure TDebugInfoLLVM.appenddef_array_internal(list: TAsmList; fordef: tdef; eledef: tdef; lowrange, highrange: asizeint);
|
||||||
var
|
var
|
||||||
dinode,
|
dinode,
|
||||||
@ -389,6 +416,7 @@ implementation
|
|||||||
flocationmeta:=thashset.Create(10000,true,false);
|
flocationmeta:=thashset.Create(10000,true,false);
|
||||||
flexicalblockfilemeta:=thashset.Create(100,true,false);
|
flexicalblockfilemeta:=thashset.Create(100,true,false);
|
||||||
fdefmeta:=TLLVMMetaDefHashSet.Create(10000,true,false);
|
fdefmeta:=TLLVMMetaDefHashSet.Create(10000,true,false);
|
||||||
|
fsymdecl:=thashset.create(10000,true,false);
|
||||||
|
|
||||||
defnumberlist:=TFPObjectList.create(false);
|
defnumberlist:=TFPObjectList.create(false);
|
||||||
deftowritelist:=TFPObjectList.create(false);
|
deftowritelist:=TFPObjectList.create(false);
|
||||||
@ -408,6 +436,8 @@ implementation
|
|||||||
flexicalblockfilemeta:=nil;
|
flexicalblockfilemeta:=nil;
|
||||||
fdefmeta.free;
|
fdefmeta.free;
|
||||||
fdefmeta:=nil;
|
fdefmeta:=nil;
|
||||||
|
fsymdecl.free;
|
||||||
|
fsymdecl:=nil;
|
||||||
defnumberlist.free;
|
defnumberlist.free;
|
||||||
defnumberlist:=nil;
|
defnumberlist:=nil;
|
||||||
deftowritelist.free;
|
deftowritelist.free;
|
||||||
@ -461,6 +491,7 @@ implementation
|
|||||||
flocationmeta.Clear;
|
flocationmeta.Clear;
|
||||||
flexicalblockfilemeta.Clear;
|
flexicalblockfilemeta.Clear;
|
||||||
fdefmeta.free;
|
fdefmeta.free;
|
||||||
|
fsymdecl.Clear;
|
||||||
{ one item per def, plus some extra space in case of nested types,
|
{ one item per def, plus some extra space in case of nested types,
|
||||||
externally used types etc (it will grow further if necessary) }
|
externally used types etc (it will grow further if necessary) }
|
||||||
i:=current_module.localsymtable.DefList.count*4;
|
i:=current_module.localsymtable.DefList.count*4;
|
||||||
@ -475,6 +506,25 @@ implementation
|
|||||||
fretainedtypes:=nil;
|
fretainedtypes:=nil;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TDebugInfoLLVM.collectglobalsyms;
|
||||||
|
var
|
||||||
|
i: TAsmListType;
|
||||||
|
hp: tai;
|
||||||
|
begin
|
||||||
|
for i in globaldataasmlisttypes do
|
||||||
|
begin
|
||||||
|
if not assigned(current_asmdata.AsmLists[i]) then
|
||||||
|
continue;
|
||||||
|
hp:=tai(current_asmdata.AsmLists[i].First);
|
||||||
|
while assigned(hp) do
|
||||||
|
begin
|
||||||
|
if (hp.typ=ait_llvmdecl) and
|
||||||
|
assigned(taillvmdecl(hp).sym) then
|
||||||
|
sym_set_decl(taillvmdecl(hp).sym,hp);
|
||||||
|
hp:=tai(hp.next);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
function TDebugInfoLLVM.file_getmetanode(moduleindex: tfileposmoduleindex; fileindex: tfileposfileindex): tai_llvmspecialisedmetadatanode;
|
function TDebugInfoLLVM.file_getmetanode(moduleindex: tfileposmoduleindex; fileindex: tfileposfileindex): tai_llvmspecialisedmetadatanode;
|
||||||
var
|
var
|
||||||
@ -2233,13 +2283,14 @@ implementation
|
|||||||
if assigned(vardatatype) then
|
if assigned(vardatatype) then
|
||||||
vardatadef:=trecorddef(vardatatype.typedef);
|
vardatadef:=trecorddef(vardatatype.typedef);
|
||||||
|
|
||||||
(*
|
collectglobalsyms;
|
||||||
|
|
||||||
{ write all global/local variables. This will flag all required tdefs }
|
{ write all global/local variables. This will flag all required tdefs }
|
||||||
if assigned(current_module.globalsymtable) then
|
if assigned(current_module.globalsymtable) then
|
||||||
write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
|
write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
|
||||||
if assigned(current_module.localsymtable) then
|
if assigned(current_module.localsymtable) then
|
||||||
write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.localsymtable);
|
write_symtable_syms(current_asmdata.asmlists[al_dwarf_info],current_module.localsymtable);
|
||||||
*)
|
|
||||||
{ write all procedures and methods. This will flag all required tdefs }
|
{ write all procedures and methods. This will flag all required tdefs }
|
||||||
if assigned(current_module.globalsymtable) then
|
if assigned(current_module.globalsymtable) then
|
||||||
write_symtable_procdefs(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
|
write_symtable_procdefs(current_asmdata.asmlists[al_dwarf_info],current_module.globalsymtable);
|
||||||
|
Loading…
Reference in New Issue
Block a user