mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-21 01:39:10 +02:00
LazDebuggerFp/FpDebug: prevent mem-cache from hiding mem-read errors
git-svn-id: trunk@60014 -
This commit is contained in:
parent
0a14d8c4ae
commit
10ba71341c
@ -206,8 +206,10 @@ type
|
|||||||
FCacheAddress: TDBGPtr;
|
FCacheAddress: TDBGPtr;
|
||||||
FCacheSize: Cardinal;
|
FCacheSize: Cardinal;
|
||||||
FMem: Array of byte;
|
FMem: Array of byte;
|
||||||
|
FFailed: Boolean;
|
||||||
public
|
public
|
||||||
constructor Create(ACacheAddress: TDBGPtr; ACacheSize: Cardinal);
|
constructor Create(ACacheAddress: TDBGPtr; ACacheSize: Cardinal);
|
||||||
|
function ContainsMemory(AnAddress: TDbgPtr; ASize: Cardinal): Boolean;
|
||||||
function ReadMemory(AnAddress: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean;
|
function ReadMemory(AnAddress: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean;
|
||||||
property CacheAddress: TDBGPtr read FCacheAddress;
|
property CacheAddress: TDBGPtr read FCacheAddress;
|
||||||
property CacheSize: Cardinal read FCacheSize;
|
property CacheSize: Cardinal read FCacheSize;
|
||||||
@ -640,15 +642,28 @@ begin
|
|||||||
FCacheSize := ACacheSize;
|
FCacheSize := ACacheSize;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFpDbgMemCacheSimple.ContainsMemory(AnAddress: TDbgPtr; ASize: Cardinal
|
||||||
|
): Boolean;
|
||||||
|
begin
|
||||||
|
Result := (AnAddress >= FCacheAddress) or (AnAddress + ASize <= FCacheAddress + FCacheSize);
|
||||||
|
end;
|
||||||
|
|
||||||
function TFpDbgMemCacheSimple.ReadMemory(AnAddress: TDbgPtr; ASize: Cardinal;
|
function TFpDbgMemCacheSimple.ReadMemory(AnAddress: TDbgPtr; ASize: Cardinal;
|
||||||
ADest: Pointer): Boolean;
|
ADest: Pointer): Boolean;
|
||||||
begin
|
begin
|
||||||
if (AnAddress < FCacheAddress) or (AnAddress + ASize > FCacheAddress + FCacheSize) then
|
Result := False;
|
||||||
exit(False);
|
if (AnAddress < FCacheAddress) or (AnAddress + ASize > FCacheAddress + FCacheSize) or
|
||||||
|
FFailed
|
||||||
|
then
|
||||||
|
exit;
|
||||||
|
|
||||||
if FMem = nil then begin
|
if FMem = nil then begin
|
||||||
SetLength(FMem, FCacheSize);
|
SetLength(FMem, FCacheSize);
|
||||||
MemReader.ReadMemory(FCacheAddress, FCacheSize, @FMem[0]);
|
if not MemReader.ReadMemory(FCacheAddress, FCacheSize, @FMem[0]) then begin
|
||||||
|
FMem := nil;
|
||||||
|
FFailed := True;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Result := true;
|
Result := true;
|
||||||
@ -723,9 +738,10 @@ begin
|
|||||||
if Node = nil then
|
if Node = nil then
|
||||||
exit(inherited ReadMemory(AnAddress, ASize, ADest));
|
exit(inherited ReadMemory(AnAddress, ASize, ADest));
|
||||||
|
|
||||||
Result := TFpDbgMemCacheSimple(Node.Data).ReadMemory(AnAddress, ASize, ADest);
|
if TFpDbgMemCacheSimple(Node.Data).ContainsMemory(AnAddress, ASize) then begin
|
||||||
if Result then
|
Result := TFpDbgMemCacheSimple(Node.Data).ReadMemory(AnAddress, ASize, ADest);
|
||||||
exit;
|
exit;
|
||||||
|
end;
|
||||||
|
|
||||||
Result := inherited ReadMemory(AnAddress, ASize, ADest);
|
Result := inherited ReadMemory(AnAddress, ASize, ADest);
|
||||||
end;
|
end;
|
||||||
|
@ -689,10 +689,19 @@ end;
|
|||||||
|
|
||||||
function TFpLldbDbgMemCacheManagerSimple.ReadMemory(AnAddress: TDbgPtr;
|
function TFpLldbDbgMemCacheManagerSimple.ReadMemory(AnAddress: TDbgPtr;
|
||||||
ASize: Cardinal; ADest: Pointer): Boolean;
|
ASize: Cardinal; ADest: Pointer): Boolean;
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
begin
|
begin
|
||||||
|
i := -1;
|
||||||
if not HasMemory(AnAddress, ASize) then
|
if not HasMemory(AnAddress, ASize) then
|
||||||
FList.Add(AddCache(AnAddress, ASize));
|
i := FList.Add(AddCache(AnAddress, ASize));
|
||||||
Result := inherited ReadMemory(AnAddress, ASize, ADest);
|
Result := inherited ReadMemory(AnAddress, ASize, ADest);
|
||||||
|
|
||||||
|
// Only auto add caches, if success. May get a request for a subset later (pchar)
|
||||||
|
if (not Result) and (i >= 0) then begin
|
||||||
|
RemoveCache(TFpDbgMemCacheBase(FList[i]));
|
||||||
|
FList.Delete(i);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFpLldbDbgMemCacheManagerSimple.Clear;
|
procedure TFpLldbDbgMemCacheManagerSimple.Clear;
|
||||||
|
Loading…
Reference in New Issue
Block a user