FpDebug: Load libraries on Linux, and skip incompatible binaries. Also on Windows, for consistency and stability

This commit is contained in:
Joost van der Sluis 2021-12-08 22:17:45 +01:00
parent baa12a8519
commit e9f1ffb855
2 changed files with 31 additions and 2 deletions

View File

@ -371,6 +371,8 @@ type
{ tDbgLinuxLibrary }
tDbgLinuxLibrary = class(TDbgLibrary)
protected
procedure InitializeLoaders; override;
public
constructor Create(const AProcess: TDbgProcess; const AFileName: string; const AModuleHandle: THandle; const ABaseAddr: TDbgPtr);
end;
@ -390,6 +392,21 @@ end;
{ tDbgLinuxLibrary }
procedure tDbgLinuxLibrary.InitializeLoaders;
var
Loader: TDbgImageLoader;
begin
Loader := TDbgImageLoader.Create(Name, nil, BaseAddr);
// The dynamic-loader (dl) on Linux also loads other stuff then ELF-
// formatted libraries.
// So it is reasonable likely that the loaded 'library' can not be handled
// by the detault readers from the loader.
if Loader.IsValid then
Loader.AddToLoaderList(LoaderList)
else
Loader.Free;
end;
constructor tDbgLinuxLibrary.Create(const AProcess: TDbgProcess; const AFileName: string; const AModuleHandle: THandle; const ABaseAddr: TDbgPtr);
begin
Inherited Create(AProcess, AFileName, AModuleHandle, ABaseAddr);
@ -867,8 +884,14 @@ begin
end;
procedure TDbgLinuxProcess.InitializeLoaders;
var
Loader: TDbgImageLoader;
begin
TDbgImageLoader.Create(Name).AddToLoaderList(LoaderList);
Loader := TDbgImageLoader.Create(Name);
if Loader.IsValid then
Loader.AddToLoaderList(LoaderList)
else
Loader.Free;
end;
function TDbgLinuxProcess.CreateThread(AthreadIdentifier: THandle; out IsMainThread: boolean): TDbgThread;

View File

@ -478,8 +478,14 @@ begin
end;
procedure TDbgWinProcess.InitializeLoaders;
var
Loader: TDbgImageLoader;
begin
TDbgImageLoader.Create(FInfo.hFile).AddToLoaderList(LoaderList);
Loader := TDbgImageLoader.Create(FInfo.hFile);
if Loader.IsValid then
AddToLoaderList(LoaderList)
else
Loader.Free;
end;
function TDbgWinProcess.CreateWatchPointData: TFpWatchPointData;