FpDebug: Remove TWatchDisplayFormat from PascalBuilder

This commit is contained in:
Martin 2024-02-21 21:50:38 +01:00
parent be31fbc4ad
commit be387c3f21
5 changed files with 52 additions and 32 deletions

View File

@ -11,9 +11,20 @@ uses
FpdMemoryTools, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarf, FpdMemoryTools, FpErrorMessages, FpDbgDwarfDataClasses, FpDbgDwarf,
FpDbgClasses, FpDbgClasses,
{$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}, {$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif},
LazUTF8, LazClasses, LazDebuggerIntf; LazUTF8, LazClasses;
type type
TDataDisplayFormat =
(ddfDefault,
ddfStructure,
ddfChar, ddfString,
ddfDecimal, ddfUnsigned, ddfHex, ddfBinary,
ddfPointer,
ddfMemDump
);
TTypeNameFlag = ( TTypeNameFlag = (
tnfOnlyDeclared, // do not return a substitute with ^ symbol tnfOnlyDeclared, // do not return a substitute with ^ symbol
tnfNoSubstitute // do not return "{record}" if debug info has no type name tnfNoSubstitute // do not return "{record}" if debug info has no type name
@ -60,7 +71,7 @@ type
AnAddressSize: Integer; AnAddressSize: Integer;
AFlags: TFpPrettyPrintValueFlags; AFlags: TFpPrettyPrintValueFlags;
ANestLevel: Integer; AnIndent: String; ANestLevel: Integer; AnIndent: String;
ADisplayFormat: TWatchDisplayFormat; ADisplayFormat: TDataDisplayFormat;
ARepeatCount: Integer = -1; ARepeatCount: Integer = -1;
ADBGTypeInfo: PDBGType = nil; ADBGTypeInfo: PDBGType = nil;
AOptions: TFpPrettyPrintOptions = [] AOptions: TFpPrettyPrintOptions = []
@ -69,7 +80,7 @@ type
constructor Create(AnAddressSize: Integer); constructor Create(AnAddressSize: Integer);
function PrintValue(out APrintedValue: String; function PrintValue(out APrintedValue: String;
AValue: TFpValue; AValue: TFpValue;
ADisplayFormat: TWatchDisplayFormat = wdfDefault; ADisplayFormat: TDataDisplayFormat = ddfDefault;
ARepeatCount: Integer = -1; ARepeatCount: Integer = -1;
AOptions: TFpPrettyPrintOptions = []; AOptions: TFpPrettyPrintOptions = [];
AFlags: TFpPrettyPrintValueFlags = [] AFlags: TFpPrettyPrintValueFlags = []
@ -77,7 +88,7 @@ type
function PrintValue(out APrintedValue: String; function PrintValue(out APrintedValue: String;
out ADBGTypeInfo: TDBGType; out ADBGTypeInfo: TDBGType;
AValue: TFpValue; AValue: TFpValue;
ADisplayFormat: TWatchDisplayFormat = wdfDefault; ADisplayFormat: TDataDisplayFormat = ddfDefault;
ARepeatCount: Integer = -1 ARepeatCount: Integer = -1
): Boolean; ): Boolean;
property AddressSize: Integer read FAddressSize write FAddressSize; property AddressSize: Integer read FAddressSize write FAddressSize;
@ -129,7 +140,7 @@ begin
for i := 0 to ProcVal.MemberCount - 1 do begin for i := 0 to ProcVal.MemberCount - 1 do begin
m := ProcVal.Member[i]; m := ProcVal.Member[i];
if (m <> nil) and (sfParameter in m.DbgSymbol.Flags) then begin if (m <> nil) and (sfParameter in m.DbgSymbol.Flags) then begin
APrettyPrinter.PrintValue(v, m, wdfDefault, -1, [ppoStackParam]); APrettyPrinter.PrintValue(v, m, ddfDefault, -1, [ppoStackParam]);
if result <> '' then result := result + ', '; if result <> '' then result := result + ', ';
result := result + v; result := result + v;
end; end;
@ -767,7 +778,7 @@ end;
function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String; function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
AValue: TFpValue; AnAddressSize: Integer; AFlags: TFpPrettyPrintValueFlags; AValue: TFpValue; AnAddressSize: Integer; AFlags: TFpPrettyPrintValueFlags;
ANestLevel: Integer; AnIndent: String; ADisplayFormat: TWatchDisplayFormat; ANestLevel: Integer; AnIndent: String; ADisplayFormat: TDataDisplayFormat;
ARepeatCount: Integer; ADBGTypeInfo: PDBGType; AOptions: TFpPrettyPrintOptions): Boolean; ARepeatCount: Integer; ADBGTypeInfo: PDBGType; AOptions: TFpPrettyPrintOptions): Boolean;
@ -792,8 +803,8 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
v: QWord; v: QWord;
m: TFpValue; m: TFpValue;
begin begin
if ((ADisplayFormat = wdfDefault) and (ANestLevel=0)) or // default for unested: with typename if ((ADisplayFormat = ddfDefault) and (ANestLevel=0)) or // default for unested: with typename
(ADisplayFormat = wdfStructure) (ADisplayFormat = ddfStructure)
then then
s := ResTypeName s := ResTypeName
else else
@ -809,9 +820,9 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
end; end;
case ADisplayFormat of case ADisplayFormat of
wdfDecimal, wdfUnsigned: APrintedValue := IntToStr(v); ddfDecimal, ddfUnsigned: APrintedValue := IntToStr(v);
wdfHex: APrintedValue := '$'+IntToHex(v, AnAddressSize*2); ddfHex: APrintedValue := '$'+IntToHex(v, AnAddressSize*2);
else begin //wdfPointer/Default ; else begin //ddfPointer/Default ;
if v = 0 then if v = 0 then
APrintedValue := 'nil' APrintedValue := 'nil'
else else
@ -820,7 +831,7 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
end; end;
if ADisplayFormat = wdfPointer then begin if ADisplayFormat = ddfPointer then begin
if s <> '' then if s <> '' then
APrintedValue := s + '(' + APrintedValue + ')'; APrintedValue := s + '(' + APrintedValue + ')';
exit; // no data exit; // no data
@ -945,8 +956,8 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
ValSize: TFpDbgValueSize; ValSize: TFpDbgValueSize;
begin begin
case ADisplayFormat of case ADisplayFormat of
wdfUnsigned: APrintedValue := IntToStr(QWord(AValue.AsInteger)); ddfUnsigned: APrintedValue := IntToStr(QWord(AValue.AsInteger));
wdfHex: begin ddfHex: begin
if (svfSize in AValue.FieldFlags) and AValue.GetSize(ValSize) then if (svfSize in AValue.FieldFlags) and AValue.GetSize(ValSize) then
n := SizeToFullBytes(ValSize)* 2 n := SizeToFullBytes(ValSize)* 2
else begin else begin
@ -957,7 +968,7 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
end; end;
APrintedValue := '$'+IntToHex(QWord(AValue.AsInteger), n); APrintedValue := '$'+IntToHex(QWord(AValue.AsInteger), n);
end; end;
// TODO wdfChar: // TODO ddfChar:
else else
APrintedValue := IntToStr(AValue.AsInteger); APrintedValue := IntToStr(AValue.AsInteger);
end; end;
@ -975,8 +986,8 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
ValSize: TFpDbgValueSize; ValSize: TFpDbgValueSize;
begin begin
case ADisplayFormat of case ADisplayFormat of
wdfDecimal: APrintedValue := IntToStr(Int64(AValue.AsCardinal)); ddfDecimal: APrintedValue := IntToStr(Int64(AValue.AsCardinal));
wdfHex: begin ddfHex: begin
if (svfSize in AValue.FieldFlags) and AValue.GetSize(ValSize) then if (svfSize in AValue.FieldFlags) and AValue.GetSize(ValSize) then
n := SizeToFullBytes(ValSize)* 2 n := SizeToFullBytes(ValSize)* 2
else begin else begin
@ -987,7 +998,7 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
end; end;
APrintedValue := '$'+IntToHex(AValue.AsCardinal, n); APrintedValue := '$'+IntToHex(AValue.AsCardinal, n);
end; end;
// TODO wdfChar: // TODO ddfChar:
else else
APrintedValue := IntToStr(AValue.AsCardinal); APrintedValue := IntToStr(AValue.AsCardinal);
end; end;
@ -1159,7 +1170,7 @@ function TFpPascalPrettyPrinter.InternalPrintValue(out APrintedValue: String;
end; end;
end; end;
if ((ADisplayFormat = wdfPointer) or (ppoStackParam in AOptions)) and (AValue.Kind in [skClass, skInterface]) then begin if ((ADisplayFormat = ddfPointer) or (ppoStackParam in AOptions)) and (AValue.Kind in [skClass, skInterface]) then begin
if not (ppvCreateDbgType in AFlags) then if not (ppvCreateDbgType in AFlags) then
s := ResTypeName; s := ResTypeName;
APrintedValue := '$'+IntToHex(AValue.AsCardinal, AnAddressSize*2); APrintedValue := '$'+IntToHex(AValue.AsCardinal, AnAddressSize*2);
@ -1376,7 +1387,7 @@ begin
AnIndent := AnIndent + ' '; AnIndent := AnIndent + ' ';
end; end;
if ADisplayFormat = wdfMemDump then begin if ADisplayFormat = ddfMemDump then begin
if FContext <> nil then begin if FContext <> nil then begin
MemAddr := UnInitializedLoc; MemAddr := UnInitializedLoc;
if svfDataAddress in AValue.FieldFlags then begin if svfDataAddress in AValue.FieldFlags then begin
@ -1467,7 +1478,7 @@ begin
end; end;
function TFpPascalPrettyPrinter.PrintValue(out APrintedValue: String; function TFpPascalPrettyPrinter.PrintValue(out APrintedValue: String;
AValue: TFpValue; ADisplayFormat: TWatchDisplayFormat; ARepeatCount: Integer; AValue: TFpValue; ADisplayFormat: TDataDisplayFormat; ARepeatCount: Integer;
AOptions: TFpPrettyPrintOptions; AFlags: TFpPrettyPrintValueFlags): Boolean; AOptions: TFpPrettyPrintOptions; AFlags: TFpPrettyPrintValueFlags): Boolean;
begin begin
Result := InternalPrintValue(APrintedValue, AValue, Result := InternalPrintValue(APrintedValue, AValue,
@ -1475,7 +1486,7 @@ begin
end; end;
function TFpPascalPrettyPrinter.PrintValue(out APrintedValue: String; out function TFpPascalPrettyPrinter.PrintValue(out APrintedValue: String; out
ADBGTypeInfo: TDBGType; AValue: TFpValue; ADisplayFormat: TWatchDisplayFormat; ADBGTypeInfo: TDBGType; AValue: TFpValue; ADisplayFormat: TDataDisplayFormat;
ARepeatCount: Integer): Boolean; ARepeatCount: Integer): Boolean;
begin begin
Result := InternalPrintValue(APrintedValue, AValue, Result := InternalPrintValue(APrintedValue, AValue,

View File

@ -888,7 +888,7 @@ begin
if FRecurseCnt > 0 then begin if FRecurseCnt > 0 then begin
PrettyPrinter := TFpPascalPrettyPrinter.Create(Context.SizeOfAddress); PrettyPrinter := TFpPascalPrettyPrinter.Create(Context.SizeOfAddress);
PrettyPrinter.Context := Context; PrettyPrinter.Context := Context;
PrettyPrinter.PrintValue(s, AnFpValue, wdfDefault, 1, [], [ppvSkipClassBody]); PrettyPrinter.PrintValue(s, AnFpValue, ddfDefault, 1, [], [ppvSkipClassBody]);
AnResData.CreatePrePrinted(s); AnResData.CreatePrePrinted(s);
PrettyPrinter.Free; PrettyPrinter.Free;
Result := True; Result := True;

View File

@ -1127,6 +1127,7 @@ var
WatchResConv: TFpLazDbgWatchResultConvertor; WatchResConv: TFpLazDbgWatchResultConvertor;
ResData: IDbgWatchDataIntf; ResData: IDbgWatchDataIntf;
i: Integer; i: Integer;
ddf: TDataDisplayFormat;
begin begin
Result := False; Result := False;
AResText := ''; AResText := '';
@ -1245,10 +1246,12 @@ begin
PrettyPrinter := TFpPascalPrettyPrinter.Create(FExpressionScope.SizeOfAddress); PrettyPrinter := TFpPascalPrettyPrinter.Create(FExpressionScope.SizeOfAddress);
PrettyPrinter.Context := FExpressionScope.LocationContext; PrettyPrinter.Context := FExpressionScope.LocationContext;
ddf := ddfDefault;
if ADispFormat = wdfMemDump then ddf := ddfMemDump;
if defNoTypeInfo in AnEvalFlags then if defNoTypeInfo in AnEvalFlags then
Result := PrettyPrinter.PrintValue(AResText, ResValue, ADispFormat, ARepeatCnt) Result := PrettyPrinter.PrintValue(AResText, ResValue, ddf, ARepeatCnt)
else else
Result := PrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, ADispFormat, ARepeatCnt); Result := PrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, ddf, ARepeatCnt);
// PCHAR/String // PCHAR/String
if Result and APasExpr.HasPCharIndexAccess and not IsError(ResValue.LastError) then begin if Result and APasExpr.HasPCharIndexAccess and not IsError(ResValue.LastError) then begin
@ -1256,7 +1259,7 @@ begin
APasExpr.FixPCharIndexAccess := True; APasExpr.FixPCharIndexAccess := True;
APasExpr.ResetEvaluation; APasExpr.ResetEvaluation;
ResValue := APasExpr.ResultValue; ResValue := APasExpr.ResultValue;
if (ResValue=nil) or (not PrettyPrinter.PrintValue(ResText2, ResValue, ADispFormat, ARepeatCnt)) then if (ResValue=nil) or (not PrettyPrinter.PrintValue(ResText2, ResValue, ddf, ARepeatCnt)) then
ResText2 := 'Failed'; ResText2 := 'Failed';
AResText := 'PChar: '+AResText+ LineEnding + 'String: '+ResText2; AResText := 'PChar: '+AResText+ LineEnding + 'String: '+ResText2;
end; end;

View File

@ -1040,6 +1040,7 @@ var
var var
CastName: String; CastName: String;
WatchResConv: TFpWatchResultConvertor; WatchResConv: TFpWatchResultConvertor;
ddf: TDataDisplayFormat;
begin begin
Result := False; Result := False;
ATypeInfo := nil; ATypeInfo := nil;
@ -1135,6 +1136,8 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
end; end;
ddf := ddfDefault;
if DispFormat = wdfMemDump then ddf := ddfMemDump;
TiSym := ResValue.DbgSymbol; TiSym := ResValue.DbgSymbol;
if (ResValue.Kind = skNone) and (TiSym <> nil) and (TiSym.SymbolType = stType) then begin if (ResValue.Kind = skNone) and (TiSym <> nil) and (TiSym.SymbolType = stType) then begin
if GetTypeAsDeclaration(AResText, TiSym) then if GetTypeAsDeclaration(AResText, TiSym) then
@ -1154,9 +1157,9 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
end end
else begin else begin
if defNoTypeInfo in EvalFlags then if defNoTypeInfo in EvalFlags then
FPrettyPrinter.PrintValue(AResText, ResValue, DispFormat, RepeatCnt) FPrettyPrinter.PrintValue(AResText, ResValue, ddf, RepeatCnt)
else else
FPrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, DispFormat, RepeatCnt); FPrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, ddf, RepeatCnt);
end; end;
if not IsWatchValueAlive then exit; if not IsWatchValueAlive then exit;
@ -1165,7 +1168,7 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
PasExpr.FixPCharIndexAccess := True; PasExpr.FixPCharIndexAccess := True;
PasExpr.ResetEvaluation; PasExpr.ResetEvaluation;
ResValue := PasExpr.ResultValue; ResValue := PasExpr.ResultValue;
if (ResValue=nil) or (not FPrettyPrinter.PrintValue(s, ResValue, DispFormat, RepeatCnt)) then if (ResValue=nil) or (not FPrettyPrinter.PrintValue(s, ResValue, ddf, RepeatCnt)) then
s := 'Failed'; s := 'Failed';
AResText := 'PChar: '+AResText+ LineEnding + 'String: '+s; AResText := 'PChar: '+AResText+ LineEnding + 'String: '+s;
end end

View File

@ -1671,6 +1671,7 @@ var
ClassAddr, CNameAddr: TFpDbgMemLocation; ClassAddr, CNameAddr: TFpDbgMemLocation;
NameLen: QWord; NameLen: QWord;
WatchResConv: TFpWatchResultConvertor; WatchResConv: TFpWatchResultConvertor;
ddf: TDataDisplayFormat;
begin begin
Result := False; Result := False;
@ -1781,6 +1782,8 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
end; end;
ddf := ddfDefault;
if DispFormat = wdfMemDump then ddf := ddfMemDump;
case ResValue.Kind of case ResValue.Kind of
skNone: begin skNone: begin
// maybe type // maybe type
@ -1805,9 +1808,9 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
else else
begin begin
if defNoTypeInfo in EvalFlags then if defNoTypeInfo in EvalFlags then
FPrettyPrinter.PrintValue(AResText, ResValue, DispFormat, RepeatCnt) FPrettyPrinter.PrintValue(AResText, ResValue, ddf, RepeatCnt)
else else
FPrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, DispFormat, RepeatCnt); FPrettyPrinter.PrintValue(AResText, ATypeInfo, ResValue, ddf, RepeatCnt);
end; end;
end; end;
if not IsWatchValueAlive then exit; if not IsWatchValueAlive then exit;
@ -1817,7 +1820,7 @@ DebugLn(DBG_VERBOSE, [ErrorHandler.ErrorAsString(PasExpr.Error)]);
PasExpr.FixPCharIndexAccess := True; PasExpr.FixPCharIndexAccess := True;
PasExpr.ResetEvaluation; PasExpr.ResetEvaluation;
ResValue := PasExpr.ResultValue; ResValue := PasExpr.ResultValue;
if (ResValue=nil) or (not FPrettyPrinter.PrintValue(s, ResValue, DispFormat, RepeatCnt)) then if (ResValue=nil) or (not FPrettyPrinter.PrintValue(s, ResValue, ddf, RepeatCnt)) then
s := 'Failed'; s := 'Failed';
AResText := 'PChar: '+AResText+ LineEnding + 'String: '+s; AResText := 'PChar: '+AResText+ LineEnding + 'String: '+s;
end end