diff --git a/components/fpdebug/fpdbgloader.pp b/components/fpdebug/fpdbgloader.pp index 50cf013432..4b7bf7431f 100644 --- a/components/fpdebug/fpdbgloader.pp +++ b/components/fpdebug/fpdbgloader.pp @@ -68,6 +68,7 @@ type constructor Create(AFileHandle: THandle); {$endif} destructor Destroy; override; + function IsValid: Boolean; property ImageBase: QWord read FImageBase; unimplemented; Property Image64Bit: Boolean read FImage64Bit; unimplemented; property Section[const AName: String]: PDbgImageSection read GetSection; @@ -81,7 +82,10 @@ implementation function TDbgImageLoader.GetSection(const AName: String): PDbgImageSection; begin - Result := FImgReader.Section[AName]; + if FImgReader <> nil then + Result := FImgReader.Section[AName] + else + Result := nil; end; constructor TDbgImageLoader.Create; @@ -109,5 +113,10 @@ begin inherited Destroy; end; +function TDbgImageLoader.IsValid: Boolean; +begin + Result := FImgReader <> nil; +end; + end. diff --git a/debugger/fpgdbmidebugger.pp b/debugger/fpgdbmidebugger.pp index 626f16bae2..08ca58f2ee 100644 --- a/debugger/fpgdbmidebugger.pp +++ b/debugger/fpgdbmidebugger.pp @@ -376,6 +376,10 @@ begin UnLoadDwarf; debugln(['TFpGDBMIDebugger.LoadDwarf ']); FImageLoader := TDbgImageLoader.Create(FileName); + if not FImageLoader.IsValid then begin + FreeAndNil(FImageLoader); + exit; + end;; FDwarfInfo := TDbgDwarf.Create(FImageLoader); FDwarfInfo.LoadCompilationUnits; end;