DebuggerIntf, FpDebug: add boolean

This commit is contained in:
Martin 2022-05-12 19:48:42 +02:00
parent 19e0cbf641
commit 01a6b1dd5f
4 changed files with 95 additions and 2 deletions

View File

@ -31,6 +31,7 @@ type
function StringToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function WideStringToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function BoolToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function EnumToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function SetToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
@ -206,6 +207,14 @@ begin
AddTypeNameToResData(AnFpValue, AnResData);
end;
function TFpWatchResultConvertor.BoolToResData(AnFpValue: TFpValue;
AnResData: TLzDbgWatchDataIntf): Boolean;
begin
Result := True;
AnResData.CreateBoolValue(AnFpValue.AsCardinal, SizeToFullBytes(AnFpValue.DataSize));
AddTypeNameToResData(AnFpValue, AnResData);
end;
function TFpWatchResultConvertor.EnumToResData(AnFpValue: TFpValue;
AnResData: TLzDbgWatchDataIntf): Boolean;
var
@ -307,7 +316,7 @@ begin
skProcedureRef: ;
skFunctionRef: ;
skSimple: ;
skBoolean: ;
skBoolean: Result := BoolToResData(AnFpValue, AnResData);
skCurrency: ;
skVariant: ;
skEnum,

View File

@ -122,6 +122,7 @@ type
procedure CreateNumValue(ANumValue: QWord; ASigned: Boolean; AByteSize: Integer = 0);
procedure CreatePointerValue(AnAddrValue: TDbgPtr);
procedure CreateFloatValue(AFloatValue: Extended; APrecission: TLzDbgFloatPrecission);
procedure CreateBoolValue(AnOrdBoolValue: QWord; AByteSize: Integer = 0);
procedure CreateEnumValue(ANumValue: QWord; AName: String; AByteSize: Integer = 0; AnIsEnumIdent: Boolean = False);
procedure CreateSetValue(const ANames: TStringDynArray); //; const AOrdValues: array of Integer);

View File

@ -663,6 +663,7 @@ type
procedure CreateNumValue(ANumValue: QWord; ASigned: Boolean; AByteSize: Integer = 0);
procedure CreatePointerValue(AnAddrValue: TDbgPtr);
procedure CreateFloatValue(AFloatValue: Extended; APrecission: TLzDbgFloatPrecission);
procedure CreateBoolValue(AnOrdBoolValue: QWord; AByteSize: Integer = 0);
procedure CreateEnumValue(ANumValue: QWord; AName: String; AByteSize: Integer = 0; AnIsEnumIdent: Boolean = False);
procedure CreateSetValue(const ANames: TStringDynArray);
@ -3232,6 +3233,14 @@ begin
AfterDataCreated;
end;
procedure TCurrentResData.CreateBoolValue(AnOrdBoolValue: QWord;
AByteSize: Integer);
begin
assert(FNewResultData=nil, 'TCurrentResData.CreateBoolValue: FNewResultData=nil');
FNewResultData := TWatchResultDataBoolean.Create(AnOrdBoolValue, AByteSize);
AfterDataCreated;
end;
procedure TCurrentResData.CreateEnumValue(ANumValue: QWord; AName: String;
AByteSize: Integer; AnIsEnumIdent: Boolean);
begin

View File

@ -16,7 +16,7 @@ type
rdkError, rdkPrePrinted,
rdkString, rdkWideString, rdkChar,
rdkSignedNumVal, rdkUnsignedNumVal, rdkPointerVal, rdkFloatVal,
rdkEnum, rdkEnumVal, rdkSet
rdkBool, rdkEnum, rdkEnumVal, rdkSet
);
TWatchResultData = class;
@ -173,6 +173,15 @@ type
procedure SaveDataToXMLConfig(const AConfig: TXMLConfig; const APath: string);
end;
{ TWatchResultValueBoolean }
TWatchResultValueBoolean = object(TWatchResultValueOrdNumBase)
protected const
VKind = rdkBool;
protected
function GetAsString: String; inline;
end;
{ TWatchResultValueEnumBase }
TWatchResultValueEnumBase = object(TWatchResultValueOrdNumBase)
@ -228,6 +237,7 @@ type
wdUNum, // TWatchResultDataUnSignedNum
wdPtr, // TWatchResultDataPointer
wdFloat, // TWatchResultDataFloat
wdBool, // TWatchResultDataBoolean
wdEnum, // TWatchResultDataEnum
wdEnumVal, // TWatchResultDataEnumVal
wdSet, // TWatchResultDataSet
@ -402,6 +412,16 @@ type
constructor Create(AFloatValue: Extended; APrecission: TLzDbgFloatPrecission);
end;
{ TWatchResultDataBoolean }
TWatchResultDataBoolean = class(specialize TGenericWatchResultDataSizedNum<TWatchResultValueBoolean>)
private
function GetClassID: TWatchResultDataClassID; override;
public
constructor Create(AnOrdBoolValue: QWord; AByteSize: Integer = 0);
constructor Create(ABoolValue: Boolean);
end;
{ TWatchResultDataEnum }
TWatchResultDataEnum = class(specialize TGenericWatchResultDataSizedNum<TWatchResultValueEnum>)
@ -510,6 +530,23 @@ function PrintWatchValueEx(AResValue: TWatchResultData; ADispFormat: TWatchDispl
end;
end;
function PrintBool: String;
var
c: QWord;
begin
c := AResValue.GetAsQWord;
if c = 0 then
Result := 'False'
else
Result := 'True';
if (ADispFormat in [wdfDecimal, wdfUnsigned, wdfHex, wdfBinary]) then
Result := Result + '(' + PrintNumber(AResValue, False, ADispFormat) + ')'
else
if (c > 1) then
Result := Result + '(' + PrintNumber(AResValue, False, wdfDecimal) + ')';
end;
function PrintEnum: String;
begin
if (ADispFormat = wdfDefault) and (AResValue.ValueKind = rdkEnumVal) then
@ -618,6 +655,7 @@ begin
rdkChar: Result := PrintChar;
rdkString: Result := QuoteText(AResValue.AsString);
rdkWideString: Result := QuoteWideText(AResValue.AsWideString);
rdkBool: Result := PrintBool;
rdkEnum, rdkEnumVal:
Result := PrintEnum;
rdkSet: Result := PrintSet;
@ -639,6 +677,7 @@ const
TWatchResultDataUnSignedNum, // wdUNum
TWatchResultDataPointer, // wdPtr
TWatchResultDataFloat, // wdFloat
TWatchResultDataBoolean, // wdBool
TWatchResultDataEnum, // wdEnum
TWatchResultDataEnumVal, // wdEnumVal
TWatchResultDataSet, // wdSet
@ -892,6 +931,16 @@ begin
AConfig.SetDeleteValue(APath + 'Prec', FFloatPrecission, ord(dfpSingle), TypeInfo(TLzDbgFloatPrecission));
end;
{ TWatchResultValueBoolean }
function TWatchResultValueBoolean.GetAsString: String;
begin
if FNumValue <> 0 then
Result := 'True'
else
Result := 'False';
end;
{ TWatchResultValueEnumBase }
procedure TWatchResultValueEnumBase.LoadDataFromXMLConfig(
@ -1260,6 +1309,31 @@ begin
FType.FFloatPrecission := APrecission;
end;
{ TWatchResultDataBoolean }
function TWatchResultDataBoolean.GetClassID: TWatchResultDataClassID;
begin
Result := wdBool;
end;
constructor TWatchResultDataBoolean.Create(AnOrdBoolValue: QWord;
AByteSize: Integer);
begin
inherited Create;
FData.FNumValue := AnOrdBoolValue;
FType.FNumByteSize := AByteSize;
end;
constructor TWatchResultDataBoolean.Create(ABoolValue: Boolean);
begin
inherited Create;
if ABoolValue then
FData.FNumValue := 1
else
FData.FNumValue := 0;
FType.FNumByteSize := 0;
end;
{ TWatchResultDataEnum }
function TWatchResultDataEnum.GetClassID: TWatchResultDataClassID;