DebuggerIntf, FpDebug: add char/widechar

This commit is contained in:
Martin 2022-05-12 16:45:08 +02:00
parent 25c54a7e4e
commit 19e0cbf641
4 changed files with 77 additions and 3 deletions

View File

@ -27,6 +27,7 @@ type
function PointerToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function NumToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function CharToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function StringToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
function WideStringToResData(AnFpValue: TFpValue; AnResData: TLzDbgWatchDataIntf): Boolean;
@ -181,6 +182,14 @@ begin
AddTypeNameToResData(AnFpValue, AnResData);
end;
function TFpWatchResultConvertor.CharToResData(AnFpValue: TFpValue;
AnResData: TLzDbgWatchDataIntf): Boolean;
begin
Result := True;
AnResData.CreateCharValue(AnFpValue.AsCardinal, SizeToFullBytes(AnFpValue.DataSize));
AddTypeNameToResData(AnFpValue, AnResData);
end;
function TFpWatchResultConvertor.StringToResData(AnFpValue: TFpValue;
AnResData: TLzDbgWatchDataIntf): Boolean;
begin
@ -280,7 +289,7 @@ begin
skCardinal: Result := NumToResData(AnFpValue, AnResData);
skFloat: Result := FloatToResData(AnFpValue, AnResData);
skChar: ;
skChar: Result := CharToResData(AnFpValue, AnResData);
skString,
skAnsiString: Result := StringToResData(AnFpValue, AnResData);
skWideString: Result := WideStringToResData(AnFpValue, AnResData);

View File

@ -118,6 +118,7 @@ type
procedure CreatePrePrinted(AVal: String); // ATypes: TLzDbgWatchDataTypes);
procedure CreateString(AVal: String);// AnEncoding // "pchar data" // shortstring
procedure CreateWideString(AVal: WideString);
procedure CreateCharValue(ACharValue: QWord; AByteSize: Integer = 0);
procedure CreateNumValue(ANumValue: QWord; ASigned: Boolean; AByteSize: Integer = 0);
procedure CreatePointerValue(AnAddrValue: TDbgPtr);
procedure CreateFloatValue(AFloatValue: Extended; APrecission: TLzDbgFloatPrecission);

View File

@ -659,6 +659,7 @@ type
procedure CreatePrePrinted(AVal: String); // ATypes: TLzDbgWatchDataTypes);
procedure CreateString(AVal: String);// AnEncoding // "pchar data"
procedure CreateWideString(AVal: WideString);
procedure CreateCharValue(ACharValue: QWord; AByteSize: Integer = 0);
procedure CreateNumValue(ANumValue: QWord; ASigned: Boolean; AByteSize: Integer = 0);
procedure CreatePointerValue(AnAddrValue: TDbgPtr);
procedure CreateFloatValue(AFloatValue: Extended; APrecission: TLzDbgFloatPrecission);
@ -3198,6 +3199,13 @@ begin
AfterDataCreated;
end;
procedure TCurrentResData.CreateCharValue(ACharValue: QWord; AByteSize: Integer);
begin
assert(FNewResultData=nil, 'TCurrentResData.CreateCharValue: FNewResultData=nil');
FNewResultData := TWatchResultDataChar.Create(ACharValue, AByteSize);
AfterDataCreated;
end;
procedure TCurrentResData.CreateNumValue(ANumValue: QWord; ASigned: Boolean;
AByteSize: Integer);
begin

View File

@ -14,7 +14,7 @@ type
TWatchResultDataKind = (
rdkUnknown,
rdkError, rdkPrePrinted,
rdkString, rdkWideString,
rdkString, rdkWideString, rdkChar,
rdkSignedNumVal, rdkUnsignedNumVal, rdkPointerVal, rdkFloatVal,
rdkEnum, rdkEnumVal, rdkSet
);
@ -122,6 +122,15 @@ type
function GetAsString: String; inline;
end;
{ TWatchResultValueChar }
TWatchResultValueChar = object(TWatchResultValueOrdNumBase)
protected const
VKind = rdkChar;
protected
function GetAsString: String; inline;
end;
{ TWatchResultValuePointer }
TWatchResultValuePointer = object(TWatchResultValueOrdNumBase)
@ -214,6 +223,7 @@ type
wdPrePrint, // TWatchResultDataPrePrinted
wdString, // TWatchResultDataString
wdWString, // TWatchResultDataWideString
wdChar, // TWatchResultDataChar
wdSNum, // TWatchResultDataSignedNum
wdUNum, // TWatchResultDataUnSignedNum
wdPtr, // TWatchResultDataPointer
@ -345,6 +355,15 @@ type
function GetAsInt64: Int64; override;
end;
{ TWatchResultDataChar }
TWatchResultDataChar = class(specialize TGenericWatchResultDataSizedNum<TWatchResultValueChar>)
private
function GetClassID: TWatchResultDataClassID; override;
public
constructor Create(ANumValue: QWord; AByteSize: Integer = 0);
end;
{ TWatchResultDataSignedNum }
TWatchResultDataSignedNum = class(specialize TGenericWatchResultDataSizedNum<TWatchResultValueSignedNum>)
@ -477,6 +496,20 @@ function PrintWatchValueEx(AResValue: TWatchResultData; ADispFormat: TWatchDispl
end;
end;
function PrintChar: String;
begin
if ADispFormat in [wdfDecimal, wdfUnsigned, wdfHex, wdfBinary] then begin
Result := '#' + PrintNumber(AResValue, False, ADispFormat);
exit;
end;
case AResValue.ByteSize of
//1: Result := QuoteText(SysToUTF8(char(Byte(AResValue.AsQWord))));
1: Result := QuoteText(char(Byte(AResValue.AsQWord)));
2: Result := QuoteWideText(WideChar(Word(AResValue.AsQWord)));
else Result := '#' + PrintNumber(AResValue, False, wdfDecimal);
end;
end;
function PrintEnum: String;
begin
if (ADispFormat = wdfDefault) and (AResValue.ValueKind = rdkEnumVal) then
@ -582,6 +615,7 @@ begin
dfpExtended: Result := FloatToStrF(AResValue.AsFloat, ffGeneral, 15, 0);
end;
end;
rdkChar: Result := PrintChar;
rdkString: Result := QuoteText(AResValue.AsString);
rdkWideString: Result := QuoteWideText(AResValue.AsWideString);
rdkEnum, rdkEnumVal:
@ -600,6 +634,7 @@ const
TWatchResultDataPrePrinted, // wdPrePrint
TWatchResultDataString, // wdString
TWatchResultDataWideString, // wdWString
TWatchResultDataChar, // wdChar
TWatchResultDataSignedNum, // wdSNum
TWatchResultDataUnSignedNum, // wdUNum
TWatchResultDataPointer, // wdPtr
@ -768,7 +803,14 @@ end;
function TWatchResultValueUnsignedNum.GetAsString: String;
begin
Result := IntToStr(QWord(FNumValue))
Result := IntToStr(QWord(FNumValue));
end;
{ TWatchResultValueChar }
function TWatchResultValueChar.GetAsString: String;
begin
Result := WideChar(FNumValue);
end;
{ TWatchResultValuePointer }
@ -1140,6 +1182,20 @@ begin
end;
end;
{ TWatchResultDataChar }
function TWatchResultDataChar.GetClassID: TWatchResultDataClassID;
begin
Result := wdChar;
end;
constructor TWatchResultDataChar.Create(ANumValue: QWord; AByteSize: Integer);
begin
inherited Create();
FData.FNumValue := QWord(ANumValue);
FType.FNumByteSize := AByteSize;
end;
{ TWatchResultDataSignedNum }
function TWatchResultDataSignedNum.GetClassID: TWatchResultDataClassID;