mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-08 08:59:38 +02:00
FpDebug: (Linux/Mac) Do not keep files open longer than needed. Systems may limit max files open. (Mac opens many files)
git-svn-id: trunk@59729 -
This commit is contained in:
parent
f9abff2df4
commit
f09614b9a8
@ -2948,6 +2948,7 @@ begin
|
||||
FFiles[i].Sections[Section].Size := p^.Size;
|
||||
FFiles[i].Sections[Section].VirtualAddress := p^.VirtualAddress;
|
||||
end;
|
||||
ALoaderList[i].CloseFileLoader;
|
||||
end;
|
||||
end;
|
||||
|
||||
|
@ -77,6 +77,7 @@ type
|
||||
constructor Create(AFileHandle: THandle; ADebugMap: TObject = nil);
|
||||
{$endif}
|
||||
destructor Destroy; override;
|
||||
procedure CloseFileLoader;
|
||||
procedure AddToLoaderList(ALoaderList: TDbgImageLoaderList);
|
||||
function IsValid: Boolean;
|
||||
property FileName: String read FFileName; // Empty if using USE_WIN_FILE_MAPPING
|
||||
@ -220,6 +221,11 @@ begin
|
||||
inherited Destroy;
|
||||
end;
|
||||
|
||||
procedure TDbgImageLoader.CloseFileLoader;
|
||||
begin
|
||||
FFileLoader.Close;
|
||||
end;
|
||||
|
||||
procedure TDbgImageLoader.AddToLoaderList(ALoaderList: TDbgImageLoaderList);
|
||||
begin
|
||||
ALoaderList.Add(Self);
|
||||
|
@ -52,6 +52,7 @@ type
|
||||
FMapHandle: THandle;
|
||||
FModulePtr: Pointer;
|
||||
{$else}
|
||||
FFileName: String;
|
||||
FStream: TStream;
|
||||
FList: TList;
|
||||
{$endif}
|
||||
@ -61,6 +62,7 @@ type
|
||||
constructor Create(AFileHandle: THandle);
|
||||
{$endif}
|
||||
destructor Destroy; override;
|
||||
procedure Close;
|
||||
function Read(AOffset, ASize: QWord; AMem: Pointer): QWord;
|
||||
function LoadMemory(AOffset, ASize: QWord; out AMem: Pointer): QWord;
|
||||
procedure UnloadMemory({%H-}AMem: Pointer);
|
||||
@ -122,6 +124,7 @@ begin
|
||||
try
|
||||
if cls.isValid(ASource) then begin
|
||||
Result := cls.Create(ASource, ADebugMap, OwnSource);
|
||||
ASource.Close;
|
||||
Exit;
|
||||
end
|
||||
else
|
||||
@ -132,6 +135,7 @@ begin
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
ASource.Close;
|
||||
Result := nil;
|
||||
end;
|
||||
|
||||
@ -162,6 +166,7 @@ begin
|
||||
if (FileExists(s)) then AFileName := s
|
||||
end;
|
||||
{$ENDIF}
|
||||
FFileName := AFileName;
|
||||
FStream := TFileStreamUTF8.Create(AFileName, fmOpenRead or fmShareDenyNone);
|
||||
inherited Create;
|
||||
{$endif}
|
||||
@ -212,6 +217,13 @@ begin
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure TDbgFileLoader.Close;
|
||||
begin
|
||||
{$ifNdef USE_WIN_FILE_MAPPING}
|
||||
FreeAndNil(FStream);
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
function TDbgFileLoader.Read(AOffset, ASize: QWord; AMem: Pointer): QWord;
|
||||
begin
|
||||
{$ifdef USE_WIN_FILE_MAPPING}
|
||||
@ -221,6 +233,8 @@ begin
|
||||
Result := 0;
|
||||
if AMem = nil then
|
||||
exit;
|
||||
if FStream = nil then
|
||||
FStream := TFileStreamUTF8.Create(FFileName, fmOpenRead or fmShareDenyNone);
|
||||
FStream.Position := AOffset;
|
||||
Result := FStream.Read(AMem^, ASize);
|
||||
{$endif}
|
||||
@ -236,6 +250,8 @@ begin
|
||||
AMem := AllocMem(ASize);
|
||||
if AMem = nil then
|
||||
exit;
|
||||
if FStream = nil then
|
||||
FStream := TFileStreamUTF8.Create(FFileName, fmOpenRead or fmShareDenyNone);
|
||||
FList.Add(AMem);
|
||||
FStream.Position := AOffset;
|
||||
Result := FStream.Read(AMem^, ASize);
|
||||
|
Loading…
Reference in New Issue
Block a user