diff --git a/components/fpdebug/fpdbgclasses.pp b/components/fpdebug/fpdbgclasses.pp
index 2008434e26..e4b28951a8 100644
--- a/components/fpdebug/fpdbgclasses.pp
+++ b/components/fpdebug/fpdbgclasses.pp
@@ -739,7 +739,7 @@ TDbgInstance = class(TObject)
function GetOSDbgClasses: TOSDbgClasses;
function GetPointerSize: Integer;
- function GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray): Boolean;
+ function GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray; AMaxFindLineBelow: integer = 0): Boolean;
function FindProcSymbol(const AName: String; AIgnoreCase: Boolean = False): TFpSymbol; overload;
function FindProcSymbol(AAdress: TDbgPtr): TFpSymbol; overload;
protected
@@ -941,7 +941,7 @@ TDbgProcess = class(TDbgInstance)
function FindSymbolScope(AThreadId, AStackFrame: Integer): TFpDbgSymbolScope;
function FindProcStartEndPC(const AAdress: TDbgPtr; out AStartPC, AEndPC: TDBGPtr): boolean;
- function GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance = nil): Boolean;
+ function GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance = nil; AMaxFindLineBelow: integer = 0): Boolean;
//function ContextFromProc(AThreadId, AStackFrame: Integer; AProcSym: TFpSymbol): TFpDbgLocationContext; inline; deprecated 'use TFpDbgSimpleLocationContext.Create';
function GetLib(const AHandle: THandle; out ALib: TDbgLibrary): Boolean;
property LibMap: TLibraryMap read FLibMap;
@@ -2198,12 +2198,20 @@ destructor TDbgInstance.Destroy;
inherited;
end;
-function TDbgInstance.GetLineAddresses(AFileName: String; ALine: Cardinal; var AResultList: TDBGPtrArray): Boolean;
+function TDbgInstance.GetLineAddresses(AFileName: String; ALine: Cardinal;
+ var AResultList: TDBGPtrArray; AMaxFindLineBelow: integer): Boolean;
var
FoundLine: Integer;
begin
- if Assigned(DbgInfo) and DbgInfo.HasInfo then
- Result := DbgInfo.GetLineAddresses(AFileName, ALine, AResultList, fsNone, @FoundLine, @FLastLineAddressesFoundFile)
+ if Assigned(DbgInfo) and DbgInfo.HasInfo then begin
+ if AMaxFindLineBelow > 0 then begin
+ Result := DbgInfo.GetLineAddresses(AFileName, ALine, AResultList, fsNext, @FoundLine, @FLastLineAddressesFoundFile);
+ if Result then
+ Result := (FoundLine >= ALine) and (FoundLine <= ALine + AMaxFindLineBelow);
+ end
+ else
+ Result := DbgInfo.GetLineAddresses(AFileName, ALine, AResultList, fsNone, @FoundLine, @FLastLineAddressesFoundFile);
+ end
else
Result := False;
end;
@@ -2596,24 +2604,24 @@ function TDbgProcess.FindProcStartEndPC(const AAdress: TDbgPtr; out AStartPC,
end;
function TDbgProcess.GetLineAddresses(AFileName: String; ALine: Cardinal;
- var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance): Boolean;
+ var AResultList: TDBGPtrArray; ASymInstance: TDbgInstance; AMaxFindLineBelow: integer): Boolean;
var
Lib: TDbgLibrary;
begin
if ASymInstance <> nil then begin
if ASymInstance = self then begin
- Result := inherited GetLineAddresses(AFileName, ALine, AResultList);
+ Result := inherited GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow);
end
else begin
- Result := ASymInstance.GetLineAddresses(AFileName, ALine, AResultList);
+ Result := ASymInstance.GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow);
FLastLineAddressesFoundFile := ASymInstance.FLastLineAddressesFoundFile;
end;
exit;
end;
- Result := inherited GetLineAddresses(AFileName, ALine, AResultList);
+ Result := inherited GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow);
for Lib in FLibMap do begin
- if Lib.GetLineAddresses(AFileName, ALine, AResultList) then
+ if Lib.GetLineAddresses(AFileName, ALine, AResultList, AMaxFindLineBelow) then
Result := True;
if Lib.FLastLineAddressesFoundFile then
FLastLineAddressesFoundFile := True;
@@ -4187,7 +4195,7 @@ constructor TFpInternalBreakpointAtFileLine.Create(const AProcess: TDbgProcess;
FSymInstance := ASymInstance;
addr := nil;
- AProcess.GetLineAddresses(AFileName, ALine, addr, ASymInstance);
+ AProcess.GetLineAddresses(AFileName, ALine, addr, ASymInstance, 1);
FFoundFileWithoutLine := AProcess.FLastLineAddressesFoundFile and (Length(addr) = 0);
inherited Create(AProcess, addr, AnEnabled);
end;