LazDebuggerFp: Ensure MemReader.RegisterSize is run in debug-thread. It currently needs the thread-state, as the size is read from the RegisterValue-list.

(cherry picked from commit 12b1484637)
This commit is contained in:
Martin 2021-10-13 19:33:40 +02:00
parent 30d615e33a
commit 357120fb44

View File

@ -560,6 +560,7 @@ type
FRegContext: TFpDbgLocationContext;
FRegResult: Boolean;
procedure DoReadRegister;
procedure DoRegisterSize;
protected
function GetDbgProcess: TDbgProcess; override;
function GetDbgThread(AContext: TFpDbgLocationContext): TDbgThread; override;
@ -571,6 +572,7 @@ type
function ReadMemoryEx(AnAddress, AnAddressSpace: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean; override;
function ReadRegister(ARegNum: Cardinal; out AValue: TDbgPtr;
AContext: TFpDbgLocationContext): Boolean; override;
function RegisterSize(ARegNum: Cardinal): Integer; override;
//WriteMemory is not overwritten. It must ONLY be called in the debug-thread
end;
@ -1402,6 +1404,11 @@ begin
FRegResult := inherited ReadRegister(FRegNum, FRegValue, FRegContext);
end;
procedure TFpDbgMemReader.DoRegisterSize;
begin
FRegValue := inherited RegisterSize(FRegNum);
end;
constructor TFpDbgMemReader.create(AFpDebugDebuger: TFpDebugDebugger);
begin
FFpDebugDebugger := AFpDebugDebuger;
@ -1439,6 +1446,17 @@ begin
result := FRegResult;
end;
function TFpDbgMemReader.RegisterSize(ARegNum: Cardinal): Integer;
begin
// Shortcut, if in debug-thread / do not use Self.F*
if ThreadID = FFpDebugDebugger.FWorkerThreadId then
exit(inherited RegisterSize(ARegNum));
FRegNum := ARegNum;
FFpDebugDebugger.ExecuteInDebugThread(@DoRegisterSize);
result := FRegValue;
end;
{ TFPCallStackSupplier }
function TFPCallStackSupplier.FpDebugger: TFpDebugDebugger;