FpDebug: Watch-Function-Eval, support QWord parameters on 32 bit targets

This commit is contained in:
Martin 2022-09-25 19:49:42 +02:00
parent c0fbe886a0
commit 9e813a6a78
3 changed files with 55 additions and 14 deletions

View File

@ -43,6 +43,7 @@ type
constructor Create(const AName: String;
const AAddress: TFpDbgMemLocation;
ATypeSymbol: TFpSymbol); overload;
property NewAddress: TFpDbgMemLocation write SetAddress;
end;
{ TFpDbgInfoCallContext }
@ -63,6 +64,7 @@ type
function AllocStack(ASize: Integer): TDbgPtr;
function CreatePreparedStackLocation(ASize: Integer): TFpDbgMemLocation;
function InternalGetLocation(AParamIndex: Integer; ASize: Integer = 0): TFpDbgMemLocation;
function InternalCreateParamSymbol(ParameterMemLocation: TFpDbgMemLocation; ASymbolType: TFpSymbol; AName: String): TFpValue;
function InternalCreateParamSymbol(AParamIndex: Integer; ASymbolType: TFpSymbol; AName: String): TFpValue; inline;
function AddRecordParam(AParamSymbolType: TFpSymbol; AValue: TFpValue): Boolean;
@ -203,6 +205,23 @@ begin
Result := SelfLoc(@FPreparedStack[l]);
end;
function TFpDbgInfoCallContext.InternalGetLocation(AParamIndex: Integer;
ASize: Integer): TFpDbgMemLocation;
begin
if (FDbgProcess.Mode = dm32) and (ASize = 8) then begin
Result := CreatePreparedStackLocation(ASize);
exit;
end;
Result := FDbgProcess.CallParamDefaultLocation(AParamIndex);
if IsValidLoc(Result) then
exit;
if ASize = 0 then
ASize := SizeOfAddress;
Result := CreatePreparedStackLocation(ASize);
end;
function TFpDbgInfoCallContext.InternalCreateParamSymbol(
ParameterMemLocation: TFpDbgMemLocation; ASymbolType: TFpSymbol; AName: String
): TFpValue;
@ -225,13 +244,8 @@ end;
function TFpDbgInfoCallContext.InternalCreateParamSymbol(AParamIndex: Integer;
ASymbolType: TFpSymbol; AName: String): TFpValue;
var
Loc: TFpDbgMemLocation;
begin
Loc := FDbgProcess.CallParamDefaultLocation(AParamIndex);
if not IsValidLoc(Loc) then
Loc := CreatePreparedStackLocation(SizeOfAddress);
Result := InternalCreateParamSymbol(Loc, ASymbolType, AName);
Result := InternalCreateParamSymbol(InternalGetLocation(AParamIndex), ASymbolType, AName);
end;
function TFpDbgInfoCallContext.AddRecordParam(AParamSymbolType: TFpSymbol;
@ -486,7 +500,9 @@ end;
function TFpDbgInfoCallContext.AddParam(AParamSymbolType: TFpSymbol; AValue: TFpValue): Boolean;
var
ParamSymbol: TFpValue;
ParamSymbol: TFpSymbolDwarfFunctionResult;
ParamValue: TFpValue;
s: TFpDbgValueSize;
begin
if AValue.Kind = skRecord then begin
Result := AddRecordParam(AParamSymbolType, AValue);
@ -494,18 +510,29 @@ begin
end;
Result := False;
ParamSymbol := InternalCreateParamSymbol(FNextParamRegister, AParamSymbolType, '');
Result := ParamSymbol <> nil;
if not Result then
exit;
// ParamValue := InternalCreateParamSymbol(FNextParamRegister, AParamSymbolType, '');
ParamValue := nil;
ParamSymbol := TFpSymbolDwarfFunctionResult.Create('', InvalidLoc, AParamSymbolType);
try
ParamValue := ParamSymbol.Value;
TFpValueDwarf(ParamValue).Context := Self;
if (FDbgProcess.Mode = dm32) and (ParamValue.GetSize(s)) and (SizeToFullBytes(s) = 8) then
ParamSymbol.NewAddress := InternalGetLocation(FNextParamRegister, SizeToFullBytes(s))
else
ParamSymbol.NewAddress := InternalGetLocation(FNextParamRegister);
Result := ParamValue <> nil;
if not Result then
exit;
if Length(FPreparedStack) > 0 then
MemManager.SetWritableSeflMem(TDBGPtr(@FPreparedStack[0]), Length(FPreparedStack));
ParamSymbol.AsCardinal := AValue.AsCardinal;
Result := not IsError(ParamSymbol.LastError);
FLastError := ParamSymbol.LastError;
ParamValue.AsCardinal := AValue.AsCardinal;
Result := not IsError(ParamValue.LastError);
FLastError := ParamValue.LastError;
finally
ParamSymbol.ReleaseReference;
ParamValue.ReleaseReference;
MemManager.ClearWritableSeflMem;
end;
inc(FNextParamRegister);

View File

@ -121,6 +121,7 @@ begin
FuncWord1(1);
FuncWord2(1,2);
FuncWord12(1,2,3,4,5,6,7,8,9,10,11,12);
FuncInt1(1);
FuncInt2(1,2);
FuncInt12(1,2,3,4,5,6,7,8,9,10,11,12);
FuncQWord1(1);

View File

@ -1758,6 +1758,19 @@ begin
AddTest('FuncByte2(11,99)', '1199', weInteger(4, #1, 4));
AddTest('FuncByte12(1,2,3,4,5,6,7,8,9,11,99,0)', '12345678911990', weInteger(14, #1, 4));
AddTest('FuncWord1(191)', '191', weInteger(3, #1, 4));
AddTest('FuncWord2(2211,99)', '221199', weInteger(6, #1, 4));
AddTest('FuncWord12(991,2,3,4,5,6,7,8,9,11,799,0)', '99123456789117990', weInteger(17, #1, 4));
AddTest('FuncInt1(191)', '191', weInteger(3, #1, 4));
AddTest('FuncInt2(11,99)', '1199', weInteger(4, #1, 4));
AddTest('FuncInt12(3000001,2,3,4,5,6,7,8,9,11,2000099,0)', '3000001234567891120000990', weInteger(25, #1, 4));
AddTest('FuncQWord1(191)', '191', weInteger(3, #1, 4));
AddTest('FuncQWord2(11,99)', '1199', weInteger(4, #1, 4));
AddTest('FuncQWord12(40000000000001,2,3,4,5,6,7,8,9,11,300000000000099,0)', '4000000000000123456789113000000000000990', weInteger(40, #1, 4));
AddTest('foo.FuncInt12(1,2,3,4,5,6,7,8,9,11,99,0)', '12345678911990201', weInteger(17, #1, 4));