mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 11:49:22 +02:00
FpDebug: Improve fix for dangling pointer to FScanAllWorker.FScanScopeList.
This commit is contained in:
parent
becdd42b6d
commit
8baaf99684
@ -597,12 +597,15 @@ type
|
|||||||
{ TFpThreadWorkerComputeNameHashes }
|
{ TFpThreadWorkerComputeNameHashes }
|
||||||
|
|
||||||
TFpThreadWorkerComputeNameHashes = class(TFpThreadWorkerItem)
|
TFpThreadWorkerComputeNameHashes = class(TFpThreadWorkerItem)
|
||||||
protected
|
strict private
|
||||||
FCU: TDwarfCompilationUnit;
|
FCU: TDwarfCompilationUnit;
|
||||||
|
FScanScopeList: TDwarfScopeList;
|
||||||
FReadyToRun: Cardinal;
|
FReadyToRun: Cardinal;
|
||||||
|
protected
|
||||||
procedure DoExecute; override;
|
procedure DoExecute; override;
|
||||||
public
|
public
|
||||||
constructor Create(CU: TDwarfCompilationUnit);
|
constructor Create(CU: TDwarfCompilationUnit);
|
||||||
|
procedure SetScopeList(const AScanScopeList: TDwarfScopeList); // will queue to run on the 2nd call
|
||||||
procedure MarkReadyToRun; // will queue to run on the 2nd call
|
procedure MarkReadyToRun; // will queue to run on the 2nd call
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -617,7 +620,8 @@ type
|
|||||||
procedure DoExecute; override;
|
procedure DoExecute; override;
|
||||||
public
|
public
|
||||||
constructor Create(CU: TDwarfCompilationUnit; ACompNameHashWorker: TFpThreadWorkerComputeNameHashes);
|
constructor Create(CU: TDwarfCompilationUnit; ACompNameHashWorker: TFpThreadWorkerComputeNameHashes);
|
||||||
function FindCompileUnit: TDwarfScopeInfo; // To be called ONLY before the thread starts
|
function FindCompileUnit(var AScopeList: TDwarfScopeList): TDwarfScopeInfo; // To be called ONLY before the thread starts
|
||||||
|
procedure UpdateScopeList(var AScopeList: TDwarfScopeList); // To be called ONLY before the thread starts
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TDwarfCompilationUnit }
|
{ TDwarfCompilationUnit }
|
||||||
@ -4392,12 +4396,7 @@ begin
|
|||||||
FScanScopeList.BuildList(FCU.FAbbrevList, FCU.FInfoData, FCU.FLength,
|
FScanScopeList.BuildList(FCU.FAbbrevList, FCU.FInfoData, FCU.FLength,
|
||||||
FCU.FAddressSize, FCU.IsDwarf64, FCU.Version);
|
FCU.FAddressSize, FCU.IsDwarf64, FCU.Version);
|
||||||
|
|
||||||
// The other thread does WaitForScopeScan (if all is correct)
|
FCompNameHashWorker.SetScopeList(FScanScopeList);
|
||||||
// We must write them now, for the CompNameHashWorker
|
|
||||||
FCU.FScopeList := FScanScopeList;
|
|
||||||
FCU.FFirstScope.Init(@FCU.FScopeList);
|
|
||||||
FCU.FFirstScope.Index := 0;
|
|
||||||
|
|
||||||
FCompNameHashWorker.MarkReadyToRun;
|
FCompNameHashWorker.MarkReadyToRun;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -4408,23 +4407,32 @@ begin
|
|||||||
FCompNameHashWorker := ACompNameHashWorker;
|
FCompNameHashWorker := ACompNameHashWorker;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
function TFpThreadWorkerScanAll.FindCompileUnit: TDwarfScopeInfo;
|
function TFpThreadWorkerScanAll.FindCompileUnit(var AScopeList: TDwarfScopeList
|
||||||
|
): TDwarfScopeInfo;
|
||||||
begin
|
begin
|
||||||
Result := FScanScopeList.BuildList(FCU.FAbbrevList, FCU.FInfoData, FCU.FLength,
|
Result := FScanScopeList.BuildList(FCU.FAbbrevList, FCU.FInfoData, FCU.FLength,
|
||||||
FCU.FAddressSize, FCU.IsDwarf64, FCU.Version, DW_TAG_compile_unit);
|
FCU.FAddressSize, FCU.IsDwarf64, FCU.Version, DW_TAG_compile_unit);
|
||||||
|
|
||||||
FCU.FScopeList := FScanScopeList;
|
AScopeList := FScanScopeList;
|
||||||
Result.FScopeListPtr := @FCU.FScopeList;
|
Result.FScopeListPtr := @AScopeList;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFpThreadWorkerScanAll.UpdateScopeList(var AScopeList: TDwarfScopeList
|
||||||
|
);
|
||||||
|
begin
|
||||||
|
AScopeList := FScanScopeList;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFpThreadWorkerComputeNameHashes }
|
{ TFpThreadWorkerComputeNameHashes }
|
||||||
|
|
||||||
procedure TFpThreadWorkerComputeNameHashes.DoExecute;
|
procedure TFpThreadWorkerComputeNameHashes.DoExecute;
|
||||||
var
|
var
|
||||||
|
Scope: TDwarfScopeInfo;
|
||||||
InfoEntry: TDwarfInformationEntry;
|
InfoEntry: TDwarfInformationEntry;
|
||||||
begin
|
begin
|
||||||
InfoEntry := TDwarfInformationEntry.Create(FCU, nil);
|
Scope.Init(@FScanScopeList);
|
||||||
InfoEntry.ScopeIndex := FCU.FirstScope.Index;
|
Scope.Index := 0;
|
||||||
|
InfoEntry := TDwarfInformationEntry.Create(FCU, Scope);
|
||||||
InfoEntry.ComputeKnownHashes(@FCU.FKnownNameHashes);
|
InfoEntry.ComputeKnownHashes(@FCU.FKnownNameHashes);
|
||||||
InfoEntry.ReleaseReference;
|
InfoEntry.ReleaseReference;
|
||||||
end;
|
end;
|
||||||
@ -4434,6 +4442,12 @@ begin
|
|||||||
FCU := CU;
|
FCU := CU;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TFpThreadWorkerComputeNameHashes.SetScopeList(
|
||||||
|
const AScanScopeList: TDwarfScopeList);
|
||||||
|
begin
|
||||||
|
FScanScopeList := AScanScopeList;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TFpThreadWorkerComputeNameHashes.MarkReadyToRun;
|
procedure TFpThreadWorkerComputeNameHashes.MarkReadyToRun;
|
||||||
var
|
var
|
||||||
c: Cardinal;
|
c: Cardinal;
|
||||||
@ -4554,6 +4568,11 @@ begin
|
|||||||
if FWaitForScopeScanSection.EnterOrWait(CachedRtlEvent) then begin
|
if FWaitForScopeScanSection.EnterOrWait(CachedRtlEvent) then begin
|
||||||
if FScanAllWorker <> nil then begin
|
if FScanAllWorker <> nil then begin
|
||||||
FOwner.WorkQueue.WaitForItem(FScanAllWorker);
|
FOwner.WorkQueue.WaitForItem(FScanAllWorker);
|
||||||
|
|
||||||
|
FScanAllWorker.UpdateScopeList(FScopeList);
|
||||||
|
FFirstScope.Init(@FScopeList);
|
||||||
|
FFirstScope.Index := 0;
|
||||||
|
|
||||||
FScanAllWorker.DecRef;
|
FScanAllWorker.DecRef;
|
||||||
FScanAllWorker := nil;
|
FScanAllWorker := nil;
|
||||||
end;
|
end;
|
||||||
@ -4809,7 +4828,7 @@ begin
|
|||||||
FScanAllWorker := TFpThreadWorkerScanAll.Create(Self, FComputeNameHashesWorker);
|
FScanAllWorker := TFpThreadWorkerScanAll.Create(Self, FComputeNameHashesWorker);
|
||||||
FScanAllWorker.AddRef;
|
FScanAllWorker.AddRef;
|
||||||
|
|
||||||
Scope := FScanAllWorker.FindCompileUnit;
|
Scope := FScanAllWorker.FindCompileUnit(FScopeList);
|
||||||
if not Scope.IsValid then begin
|
if not Scope.IsValid then begin
|
||||||
DebugLn(FPDBG_DWARF_WARNINGS, ['WARNING compilation unit has no compile_unit tag']);
|
DebugLn(FPDBG_DWARF_WARNINGS, ['WARNING compilation unit has no compile_unit tag']);
|
||||||
Exit;
|
Exit;
|
||||||
|
Loading…
Reference in New Issue
Block a user