LazDebuggerGdbmiFp: Improve workaround for FPC issue 37658 / Check both: full-path, and no-path.

(cherry picked from commit ca16a22cea)
This commit is contained in:
Martin 2025-01-31 01:23:45 +01:00
parent de33a8216c
commit aeb382738d

View File

@ -693,8 +693,10 @@ end;
function TFpGDBMILineInfo.HasAddress(const AIndex: Integer; const ALine: Integer
): Boolean;
var
Map: PDWarfLineMap;
Map, Map2: PDWarfLineMap;
dummy: TDBGPtrArray;
FullName, BaseName: String;
i: Integer;
begin
Result := False;
if not FpDebugger.HasDwarf then
@ -703,6 +705,21 @@ begin
Map := PDWarfLineMap(FRequestedSources.Objects[AIndex]);
if Map <> nil then
Result := Map^.GetAddressesForLine(ALine, dummy, True);
if map = nil then begin
FullName := FRequestedSources[AIndex];
BaseName := ExtractFileName(FullName);
if (FullName <> BaseName) then begin
i := FRequestedSources.IndexOf(BaseName);
if i >= 0 then begin
Map2 := PDWarfLineMap(FRequestedSources.Objects[i]);
if (Map2 <> nil) and (Map2 <> Map) then begin
dummy:=nil;
Result := Map2^.GetAddressesForLine(ALine, dummy, True);
end;
end;
end;
end;
end;
function TFpGDBMILineInfo.GetInfo(AAdress: TDbgPtr; out ASource, ALine,
@ -722,10 +739,15 @@ begin
end;
procedure TFpGDBMILineInfo.Request(const ASource: String);
var
BaseName: String;
begin
if not FpDebugger.HasDwarf then
exit;
FRequestedSources.AddObject(ASource, TObject(FpDebugger.FDwarfInfo.GetLineAddressMap(ASource)));
BaseName := ExtractFileName(ASource);
if (ASource <> BaseName) and (IndexOf(BaseName) < 0) then
FRequestedSources.AddObject(ASource, TObject(FpDebugger.FDwarfInfo.GetLineAddressMap(BaseName)));
DoChange(ASource);
end;