From 15dd0562070f2e27872b0b7fbb5c3c08fb4b4e83 Mon Sep 17 00:00:00 2001 From: martin Date: Wed, 30 Apr 2014 12:42:54 +0000 Subject: [PATCH] FpGdbmiDebugger: add/sub int to/from pointer / tests git-svn-id: trunk@44850 - --- components/fpdebug/fppascalparser.pas | 123 +++++++++++------ .../test/TestApps/TestWatchesUnitArray.pas | 125 ++++++++++++++++- .../lazdebuggerfpgdbmi/test/testwatches.pas | 126 +++++++++++++++++- 3 files changed, 327 insertions(+), 47 deletions(-) diff --git a/components/fpdebug/fppascalparser.pas b/components/fpdebug/fppascalparser.pas index f1f6d554fe..cee35d42cd 100644 --- a/components/fpdebug/fppascalparser.pas +++ b/components/fpdebug/fppascalparser.pas @@ -1032,15 +1032,6 @@ begin end // Kind = skArray else if (TmpVal.Kind = skPointer) then begin - //if (TmpVal.TypeInfo = nil) or (TmpVal.TypeInfo.TypeInfo = nil) or - // (TmpVal.TypeInfo.TypeInfo.Size <= 0) - //then begin - // SetError('Can not dereference an untyped pointer'); - // TmpVal.ReleaseReference; - // exit; - //end; - // TODO: check svfDataAddress / readable ? (see normal pointer deref); - //ti := TmpVal.TypeInfo.TypeInfo; if (svfInteger in TmpIndex.FieldFlags) then Offs := TmpIndex.AsInteger else @@ -1058,12 +1049,6 @@ begin if IsError(TmpVal.LastError) then SetError('Error dereferencing'); // TODO: set correct error if TmpVal2 <> nil then TmpVal2.AddReference; - //{$PUSH}{$R-}{$Q-} // TODO: check overflow - //Offs := Offs * ti.Size; - //{$POP} - //TmpDeref := TFpPasParserValueDerefPointer.Create(TmpVal, Expression, Offs); - //TmpVal2 := ti.TypeCastValue(TmpDeref); - //TmpDeref.ReleaseReference; end else if (TmpVal.Kind = skString) then begin @@ -2333,6 +2318,84 @@ begin end; function TFpPascalExpressionPartOperatorPlusMinus.DoGetResultValue: TFpDbgValue; +{$PUSH}{$R-}{$Q-} + function AddSubValueToPointer(APointerVal, AOtherVal: TFpDbgValue; ADoSubtract: Boolean = False): TFpDbgValue; + var + Idx: Int64; + f: Integer; + ti: TFpDbgSymbol; + TmpVal: TFpDbgValue; + begin + Result := nil; + case AOtherVal.Kind of + // skPointer: Result := nil; + skInteger: Idx := AOtherVal.AsInteger; + skCardinal: begin + Idx := AOtherVal.AsInteger; + if Idx > High(Int64) then + exit; // TODO: error + end; + else + exit; // TODO: error + end; + if ADoSubtract then begin + if Idx < -(High(Int64)) then + exit; // TODO: error + Idx := -Idx; + end; + TmpVal := APointerVal.Member[Idx]; + if IsError(APointerVal.LastError) then begin + SetError('Error dereferencing'); // TODO: set correct error + exit; + end; + Result := TFpPasParserValueAddressOf.Create(TmpVal, Expression.Context); + end; + function AddValueToInt(AIntVal, AOtherVal: TFpDbgValue): TFpDbgValue; + begin + Result := nil; + case AOtherVal.Kind of + skPointer: Result := AddSubValueToPointer(AOtherVal, AIntVal); + skInteger: Result := TFpDbgValueConstNumber.Create(AIntVal.AsInteger + AOtherVal.AsInteger, True); + skCardinal: Result := TFpDbgValueConstNumber.Create(AIntVal.AsInteger + AOtherVal.AsCardinal, True); + else SetError('Addition not supported'); + end; + end; + function AddValueToCardinal(ACardinalVal, AOtherVal: TFpDbgValue): TFpDbgValue; + begin + Result := nil; + case AOtherVal.Kind of + skPointer: Result := AddSubValueToPointer(AOtherVal, ACardinalVal); + skInteger: Result := TFpDbgValueConstNumber.Create(ACardinalVal.AsCardinal + AOtherVal.AsInteger, True); + skCardinal: Result := TFpDbgValueConstNumber.Create(ACardinalVal.AsCardinal + AOtherVal.AsCardinal, False); + else SetError('Addition not supported'); + end; + end; + + function SubPointerFromValue(APointerVal, AOtherVal: TFpDbgValue): TFpDbgValue; + begin + Result := nil; // Error + end; + function SubValueFromInt(AIntVal, AOtherVal: TFpDbgValue): TFpDbgValue; + begin + Result := nil; + case AOtherVal.Kind of + skPointer: Result := SubPointerFromValue(AOtherVal, AIntVal); + skInteger: Result := TFpDbgValueConstNumber.Create(AIntVal.AsInteger - AOtherVal.AsInteger, True); + skCardinal: Result := TFpDbgValueConstNumber.Create(AIntVal.AsInteger - AOtherVal.AsCardinal, True); + else SetError('Subtraction not supported'); + end; + end; + function SubValueFromCardinal(ACardinalVal, AOtherVal: TFpDbgValue): TFpDbgValue; + begin + Result := nil; + case AOtherVal.Kind of + skPointer: Result := SubPointerFromValue(AOtherVal, ACardinalVal); + skInteger: Result := TFpDbgValueConstNumber.Create(ACardinalVal.AsCardinal - AOtherVal.AsInteger, True); + skCardinal: Result := TFpDbgValueConstNumber.Create(ACardinalVal.AsCardinal - AOtherVal.AsCardinal, False); + else SetError('Subtraction not supported'); + end; + end; +{$POP} var tmp1, tmp2: TFpDbgValue; IsAdd: Boolean; @@ -2346,38 +2409,20 @@ begin IsAdd := GetText = '+'; if (tmp1 = nil) or (tmp2 = nil) then exit; - {$PUSH}{$R-}{$Q-} if IsAdd then begin case tmp1.Kind of - skPointer: ; - skInteger: case tmp2.Kind of - skPointer: ; - skInteger: Result := TFpDbgValueConstNumber.Create(tmp1.AsInteger + tmp2.AsInteger, True); - skCardinal: Result := TFpDbgValueConstNumber.Create(tmp1.AsInteger + tmp2.AsCardinal, True); - end; - skCardinal: case tmp2.Kind of - skPointer: ; - skInteger: Result := TFpDbgValueConstNumber.Create(tmp1.AsCardinal + tmp2.AsInteger, True); - skCardinal: Result := TFpDbgValueConstNumber.Create(tmp1.AsCardinal + tmp2.AsCardinal, False); - end; + skPointer: Result := AddSubValueToPointer(tmp1, tmp2); + skInteger: Result := AddValueToInt(tmp1, tmp2); + skCardinal: Result := AddValueToCardinal(tmp1, tmp2); end; end else begin case tmp1.Kind of - skPointer: ; - skInteger: case tmp2.Kind of - skPointer: ; - skInteger: Result := TFpDbgValueConstNumber.Create(tmp1.AsInteger - tmp2.AsInteger, True); - skCardinal: Result := TFpDbgValueConstNumber.Create(tmp1.AsInteger - tmp2.AsCardinal, True); - end; - skCardinal: case tmp2.Kind of - skPointer: ; - skInteger: Result := TFpDbgValueConstNumber.Create(tmp1.AsCardinal - tmp2.AsInteger, True); - skCardinal: Result := TFpDbgValueConstNumber.Create(tmp1.AsCardinal - tmp2.AsCardinal, True); - end; + skPointer: Result := AddSubValueToPointer(tmp1, tmp2, True); + skInteger: Result := SubValueFromInt(tmp1, tmp2); + skCardinal: Result := SubValueFromCardinal(tmp1, tmp2); end; end; - {$POP} {$IFDEF WITH_REFCOUNT_DEBUG}if Result <> nil then Result.DbgRenameReference(nil, 'DoGetResultValue');{$ENDIF} diff --git a/components/lazdebuggers/lazdebuggerfpgdbmi/test/TestApps/TestWatchesUnitArray.pas b/components/lazdebuggers/lazdebuggerfpgdbmi/test/TestApps/TestWatchesUnitArray.pas index 02a31a0d30..3933171797 100644 --- a/components/lazdebuggers/lazdebuggerfpgdbmi/test/TestApps/TestWatchesUnitArray.pas +++ b/components/lazdebuggers/lazdebuggerfpgdbmi/test/TestApps/TestWatchesUnitArray.pas @@ -1,4 +1,4 @@ -unit TestWatchesUnitArray; +unit TestWatchesUnitArray; // Array and Pointer {$mode objfpc}{$H+}{$NOTES off} interface @@ -68,6 +68,10 @@ type PArrayStatDynClass = ^TArrayStatDynClass; PArrayStatDynRec = ^TArrayStatDynRec; + PInteger = ^Integer; + PPInteger = ^PInteger; + PWord = ^Word; + PPWord = ^PWord; // TYPES fol param TArrayStatIntParam1 = array [4..9] of Integer; @@ -75,6 +79,7 @@ type PArrayStatIntParam1 = ^TArrayStatIntParam1; PArrayStatIntParam2 = ^TArrayStatIntParam2; + PPointer = ^Pointer; { TArrayClass1 } @@ -110,6 +115,10 @@ type Field_StatDynClass1: TArrayStatDynClass; Field_StatDynRec1: TArrayStatDynRec; + Field_IntPointer: PInteger; + Field_WordPointer: PWord; + Field_Pointer: Pointer; + // Pointer Field_PDynAInt1: PArrayDynInt; Field_PStatAInt1: PArrayStatIntParam1; @@ -140,6 +149,10 @@ type Field_PStatDynClass1: PArrayStatDynClass; Field_PStatDynRec1: PArrayStatDynRec; + Field_PIntPointer: PPInteger; + Field_PWordPointer: PPWord; + Field_PPointer: PPointer; + procedure Test1Method( Arg_DynAInt1: array of Integer; @@ -171,6 +184,10 @@ type Arg_StatDynClass1: TArrayStatDynClass; Arg_StatDynRec1: TArrayStatDynRec; + Arg_IntPointer: PInteger; + Arg_WordPointer: PWord; + Arg_Pointer: Pointer; + // Pointer Arg_PDynAInt1: PArrayDynInt; Arg_PStatAInt1: PArrayStatIntParam1; @@ -201,6 +218,10 @@ type Arg_PStatDynClass1: PArrayStatDynClass; Arg_PStatDynRec1: PArrayStatDynRec; + Arg_PIntPointer: PPInteger; + Arg_PWordPointer: PPWord; + Arg_PPointer: PPointer; + var VArg_DynAInt1: array of Integer; var VArg_StatAInt1: TArrayStatIntParam1; @@ -231,6 +252,10 @@ type var VArg_StatDynClass1: TArrayStatDynClass; var VArg_StatDynRec1: TArrayStatDynRec; + var VArg_IntPointer: PInteger; + var VArg_WordPointer: PWord; + var VArg_Pointer: Pointer; + // Pointer var VArg_PDynAInt1: PArrayDynInt; var VArg_PStatAInt1: PArrayStatIntParam1; @@ -259,7 +284,11 @@ type var VArg_PStatDynInt1: PArrayStatDynInt; var VArg_PStatDynClass1: PArrayStatDynClass; - var VArg_PStatDynRec1: PArrayStatDynRec + var VArg_PStatDynRec1: PArrayStatDynRec; + + var VArg_PIntPointer: PPInteger; + var VArg_PWordPointer: PPWord; + var VArg_PPointer: PPointer ); end; @@ -293,6 +322,10 @@ var ArrayGlob_StatDynClass1: TArrayStatDynClass; ArrayGlob_StatDynRec1: TArrayStatDynRec; + ArrayGlob_IntPointer: PInteger; + ArrayGlob_WordPointer: PWord; + ArrayGlob_Pointer: Pointer; + // Pointer ArrayGlob_PDynAInt1: PArrayDynInt; ArrayGlob_PStatAInt1: PArrayStatIntParam1; @@ -323,6 +356,10 @@ var ArrayGlob_PStatDynClass1: PArrayStatDynClass; ArrayGlob_PStatDynRec1: PArrayStatDynRec; + ArrayGlob_PIntPointer: PPInteger; + ArrayGlob_PWordPointer: PPWord; + ArrayGlob_PPointer: PPointer; + // copy of Pointers, to be used as Var Param ArrayGlob_P2DynAInt1: PArrayDynInt; ArrayGlob_P2StatAInt1: PArrayStatIntParam1; @@ -353,10 +390,16 @@ var ArrayGlob_P2StatDynClass1: PArrayStatDynClass; ArrayGlob_P2StatDynRec1: PArrayStatDynRec; + ArrayGlob_P2IntPointer: PPInteger; + ArrayGlob_P2WordPointer: PPWord; + ArrayGlob_P2Pointer: PPointer; + // dummy, ensure "pointer" is in debug info ArrayGlob_DummyPointer: Pointer; ArrayGlob_DummyPInteger: PInteger; + ArrayAdd0, ArrayAdd1, ArrayAdd2, ArraySub1, ArraySub2 : Int64; + procedure Test1; implementation @@ -374,6 +417,7 @@ procedure TArrayClass1.Test1Method(Arg_DynAInt1: array of Integer; Arg_StatStatInt1: TArrayStatStatInt; Arg_StatStatClass1: TArrayStatStatClass; Arg_StatStatRec1: TArrayStatStatRec; Arg_StatDynInt1: TArrayStatDynInt; Arg_StatDynClass1: TArrayStatDynClass; Arg_StatDynRec1: TArrayStatDynRec; + Arg_IntPointer: PInteger; Arg_WordPointer: PWord; Arg_Pointer: Pointer; Arg_PDynAInt1: PArrayDynInt; Arg_PStatAInt1: PArrayStatIntParam1; Arg_PStatAInt2: PArrayStatIntParam2; Arg_PDynInt1, Arg_PDynInt2: PArrayDynInt; Arg_PDynClass1: PArrayDynClass; Arg_PDynRec1: PArrayDynRec; Arg_PDynRec2: PArrayDynRec2; @@ -384,7 +428,8 @@ procedure TArrayClass1.Test1Method(Arg_DynAInt1: array of Integer; Arg_PStatRec1: PArrayStatRec; Arg_PStatStatInt1: PArrayStatStatInt; Arg_PStatStatClass1: PArrayStatStatClass; Arg_PStatStatRec1: PArrayStatStatRec; Arg_PStatDynInt1: PArrayStatDynInt; Arg_PStatDynClass1: PArrayStatDynClass; - Arg_PStatDynRec1: PArrayStatDynRec; var VArg_DynAInt1: array of Integer; + Arg_PStatDynRec1: PArrayStatDynRec; Arg_PIntPointer: PPInteger; Arg_PWordPointer: PPWord; + Arg_PPointer: PPointer; var VArg_DynAInt1: array of Integer; var VArg_StatAInt1: TArrayStatIntParam1; var VArg_StatAInt2: TArrayStatIntParam2; var VArg_DynInt1, VArg_DynInt2: TArrayDynInt; var VArg_DynClass1: TArrayDynClass; var VArg_DynRec1: TArrayDynRec; var VArg_DynRec2: array of TArrayRec2; @@ -395,7 +440,8 @@ procedure TArrayClass1.Test1Method(Arg_DynAInt1: array of Integer; var VArg_StatRec1: TArrayStatRec; var VArg_StatStatInt1: TArrayStatStatInt; var VArg_StatStatClass1: TArrayStatStatClass; var VArg_StatStatRec1: TArrayStatStatRec; var VArg_StatDynInt1: TArrayStatDynInt; var VArg_StatDynClass1: TArrayStatDynClass; - var VArg_StatDynRec1: TArrayStatDynRec; var VArg_PDynAInt1: PArrayDynInt; + var VArg_StatDynRec1: TArrayStatDynRec; var VArg_IntPointer: PInteger; + var VArg_WordPointer: PWord; var VArg_Pointer: Pointer; var VArg_PDynAInt1: PArrayDynInt; var VArg_PStatAInt1: PArrayStatIntParam1; var VArg_PStatAInt2: PArrayStatIntParam2; var VArg_PDynInt1, VArg_PDynInt2: PArrayDynInt; var VArg_PDynClass1: PArrayDynClass; var VArg_PDynRec1: PArrayDynRec; var VArg_PDynRec2: PArrayDynRec2; @@ -406,7 +452,8 @@ procedure TArrayClass1.Test1Method(Arg_DynAInt1: array of Integer; var VArg_PStatRec1: PArrayStatRec; var VArg_PStatStatInt1: PArrayStatStatInt; var VArg_PStatStatClass1: PArrayStatStatClass; var VArg_PStatStatRec1: PArrayStatStatRec; var VArg_PStatDynInt1: PArrayStatDynInt; var VArg_PStatDynClass1: PArrayStatDynClass; - var VArg_PStatDynRec1: PArrayStatDynRec); + var VArg_PStatDynRec1: PArrayStatDynRec; var VArg_PIntPointer: PPInteger; + var VArg_PWordPointer: PPWord; var VArg_PPointer: PPointer); var Local_DynAInt1: array of Integer; Local_StatAInt1: array [4..9] of Integer; @@ -437,6 +484,10 @@ var Local_StatDynClass1: TArrayStatDynClass; Local_StatDynRec1: TArrayStatDynRec; + Local_IntPointer: PInteger; + Local_WordPointer: PWord; + Local_Pointer: Pointer; + // Pointer Local_PDynAInt1: PArrayDynInt; Local_PStatAInt1: PArrayStatIntParam1; @@ -467,6 +518,10 @@ var Local_PStatDynClass1: PArrayStatDynClass; Local_PStatDynRec1: PArrayStatDynRec; + Local_PIntPointer: PPInteger; + Local_PWordPointer: PPWord; + Local_PPointer: PPointer; + begin {%region Fields } @@ -497,6 +552,10 @@ begin Field_DynInt1[19] := 5500; Field_DynInt2 := nil; + Field_IntPointer := @Field_DynInt1[2]; + Field_WordPointer := @Field_DynInt1[2]; + Field_Pointer := @Field_DynInt1[2]; + SetLength(Field_DynClass1, 6); Field_DynClass1[0] := TArrayClass1.Create; Field_DynClass1[0].Field_Int1 := 98700; @@ -618,6 +677,10 @@ begin Field_PStatDynClass1 := @Field_StatDynClass1; Field_PStatDynRec1 := @Field_StatDynRec1; + Field_PIntPointer := @Field_IntPointer; + Field_PWordPointer := @Field_WordPointer; + Field_PPointer := @Field_Pointer; + {%endregion Fields } @@ -649,6 +712,10 @@ begin Local_DynInt1[19] := 5500; Local_DynInt2 := nil; + Local_IntPointer := @Local_DynInt1[2]; + Local_WordPointer := @Local_DynInt1[2]; + Local_Pointer := @Local_DynInt1[2]; + SetLength(Local_DynClass1, 6); Local_DynClass1[0] := TArrayClass1.Create; Local_DynClass1[0].Field_Int1 := 98700; @@ -770,6 +837,10 @@ begin Local_PStatDynClass1 := @Local_StatDynClass1; Local_PStatDynRec1 := @Local_StatDynRec1; + Local_PIntPointer := @Local_IntPointer; + Local_PWordPointer := @Local_WordPointer; + Local_PPointer := @Local_Pointer; + {%endregion Local } @@ -804,6 +875,10 @@ begin Arg_PStatDynInt1 := @Arg_StatDynInt1; Arg_PStatDynClass1 := @Arg_StatDynClass1; Arg_PStatDynRec1 := @Arg_StatDynRec1; + + Arg_PIntPointer := @Arg_IntPointer; + Arg_PWordPointer := @Arg_WordPointer; + Arg_PPointer := @Arg_Pointer; {%endregion ARG} {%region ARG } @@ -837,6 +912,10 @@ begin VArg_PStatDynInt1 := @VArg_StatDynInt1; VArg_PStatDynClass1 := @VArg_StatDynClass1; VArg_PStatDynRec1 := @VArg_StatDynRec1; + + VArg_PIntPointer := @VArg_IntPointer; + VArg_PWordPointer := @VArg_WordPointer; + VArg_PPointer := @VArg_Pointer; {%endregion ARG} ArrayGlob_DynInt1[9] := -5511; // BREAK @@ -874,6 +953,10 @@ begin ArrayGlob_DynInt1[19] := 5500; ArrayGlob_DynInt2 := nil; + ArrayGlob_IntPointer := @ArrayGlob_DynInt1[2]; + ArrayGlob_WordPointer := @ArrayGlob_DynInt1[2]; + ArrayGlob_Pointer := @ArrayGlob_DynInt1[2]; + SetLength(ArrayGlob_DynClass1, 6); ArrayGlob_DynClass1[0] := TArrayClass1.Create; ArrayGlob_DynClass1[0].Field_Int1 := 98700; @@ -995,6 +1078,10 @@ begin ArrayGlob_PStatDynClass1 := @ArrayGlob_StatDynClass1; ArrayGlob_PStatDynRec1 := @ArrayGlob_StatDynRec1; + ArrayGlob_PIntPointer := @ArrayGlob_IntPointer; + ArrayGlob_PWordPointer := @ArrayGlob_WordPointer; + ArrayGlob_PPointer := @ArrayGlob_Pointer; + {%endregion ArrayGlob } // copy for var param @@ -1028,6 +1115,16 @@ begin ArrayGlob_P2StatDynClass1 := ArrayGlob_PStatDynClass1; ArrayGlob_P2StatDynRec1 := ArrayGlob_PStatDynRec1; + ArrayGlob_P2IntPointer := ArrayGlob_PIntPointer; + ArrayGlob_P2WordPointer := ArrayGlob_PWordPointer; + ArrayGlob_P2Pointer := ArrayGlob_PPointer; + + + ArrayAdd0 := 0; + ArrayAdd1 := 1; + ArrayAdd2 := 2; + ArraySub1 := -1; + ArraySub2 := -2; ArrayClass1 := TArrayClass1.Create; ArrayClass1.Test1Method( @@ -1060,6 +1157,10 @@ begin ArrayGlob_StatDynClass1, ArrayGlob_StatDynRec1, + ArrayGlob_IntPointer, + ArrayGlob_WordPointer, + ArrayGlob_Pointer, + // Pointer ArrayGlob_PDynAInt1, ArrayGlob_PStatAInt1, @@ -1091,6 +1192,10 @@ begin ArrayGlob_PStatDynClass1, ArrayGlob_PStatDynRec1, + ArrayGlob_PIntPointer, + ArrayGlob_PWordPointer, + ArrayGlob_PPointer, + // VAR ArrayGlob_DynAInt1, ArrayGlob_StatAInt1, @@ -1121,6 +1226,10 @@ begin ArrayGlob_StatDynClass1, ArrayGlob_StatDynRec1, + ArrayGlob_IntPointer, + ArrayGlob_WordPointer, + ArrayGlob_Pointer, + // Pointer ArrayGlob_P2DynAInt1, ArrayGlob_P2StatAInt1, @@ -1150,7 +1259,11 @@ begin ArrayGlob_P2StatDynInt1, ArrayGlob_P2StatDynClass1, - ArrayGlob_P2StatDynRec1 + ArrayGlob_P2StatDynRec1, + + ArrayGlob_P2IntPointer, + ArrayGlob_P2WordPointer, + ArrayGlob_P2Pointer ); end; diff --git a/components/lazdebuggers/lazdebuggerfpgdbmi/test/testwatches.pas b/components/lazdebuggers/lazdebuggerfpgdbmi/test/testwatches.pas index 23bbb711c7..fc6124ebef 100644 --- a/components/lazdebuggers/lazdebuggerfpgdbmi/test/testwatches.pas +++ b/components/lazdebuggers/lazdebuggerfpgdbmi/test/testwatches.pas @@ -42,7 +42,7 @@ const BL_TW10 // 17: Class0.Test0Method > Nested0 ); - BREAK_LINE_TestWatchesUnitArray = 842; + BREAK_LINE_TestWatchesUnitArray = 921; type @@ -589,7 +589,7 @@ end; procedure TTestWatches.AddExpectArray_1; var i, i2: Integer; - s,s2: String; + s, s2: String; r: PWatchExpectation; begin FCurrentExpect := @ExpectBreakArray_1; @@ -760,6 +760,128 @@ if not (i in [2,3]) then // open array / TODO r := AddSimpleInt(Format('TArrayStatStatInt(%sStatStatInt1%1:s)[-9,1]', [s,s2]), 4091, M_Int); if i in [3] then UpdResMinFpc(r, stSymAll, 020600); + {%region Pointer } + AddSimpleInt(Format('(%sIntPointer%1:s-2)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s+(-2))^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s+ArraySub2)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s-ArrayAdd2)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(ArraySub2+%sIntPointer%1:s)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(-2+%sIntPointer%1:s)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(-1+%sIntPointer%1:s-1)^', [s,s2]), 5511, M_Int); + + AddSimpleInt(Format('(%sIntPointer%1:s-1)^', [s,s2]), 5512, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s+(-1))^', [s,s2]), 5512, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s+0)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s-0)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s+1)^', [s,s2]), 5514, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s+2)^', [s,s2]), -5511, M_Int); + + AddSimpleInt(Format('%sIntPointer%1:s[-2]', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s[ArraySub2]', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s[-ArrayAdd2]', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s[-1]', [s,s2]), 5512, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s[0]', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s[1]', [s,s2]), 5514, M_Int); + AddSimpleInt(Format('%sIntPointer%1:s[2]', [s,s2]), -5511, M_Int); + + AddSimpleInt(Format('(PInteger(@%sIntPointer%1:s[-1])-1)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(%sIntPointer%1:s-1)[-1]', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(PInteger(@Pointer(%sIntPointer%1:s)[-4])-1)^', [s,s2]), 5511, M_Int); + AddSimpleInt(Format('(PInteger(@Pointer(%sIntPointer%1:s)[-2]-6))^', [s,s2]), 5511, M_Int); + + // add 2 each for word pointer + AddSimpleInt(Format('PInteger(%sWordPointer%1:s)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('PInteger(%sWordPointer%1:s+0)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('PInteger(%sWordPointer%1:s+2)^', [s,s2]), 5514, M_Int); + AddSimpleInt(Format('PInteger(%sWordPointer%1:s+ArrayAdd2)^', [s,s2]), 5514, M_Int); + AddSimpleInt(Format('PInteger(%sWordPointer%1:s-ArraySub2)^', [s,s2]), 5514, M_Int); + + // add 4 each for pointer + AddSimpleInt(Format('PInteger(%sPointer%1:s)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('PInteger(%sPointer%1:s+0)^', [s,s2]), 5513, M_Int); + AddSimpleInt(Format('PInteger(%sPointer%1:s+4)^', [s,s2]), 5514, M_Int); + + // deref generic: error + //AddFmtDef(Format('%sPointer%1:s^', [s,s2]), 'GDB|Error', skNone, '', [fTpMtch, IgnKind, fTExpectError]); // ERROR + //AddFmtDef(Format('(%sPointer%1:s)^', [s,s2]), 'GDB|Error', skNone, '', [fTpMtch, IgnKind, fTExpectError]); // ERROR + //AddFmtDef(Format('(%sPointer%1:s+0)^', [s,s2]), 'GDB|Error', skNone, '', [fTpMtch, IgnKind, fTExpectError]); // ERROR + //AddFmtDef(Format('(%sPointer%1:s+4)^', [s,s2]), 'GDB|Error', skNone, '', [fTpMtch, IgnKind, fTExpectError]); // ERROR + //AddFmtDef(Format('(%sPointer%1:s-4)^', [s,s2]), 'GDB|Error', skNone, '', [fTpMtch, IgnKind, fTExpectError]); // ERROR + + + if i2 = 0 then begin + {%region address of } + r := AddFmtDef(Format('%sIntPointer', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[2]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + r := AddFmtDef(Format('(%sIntPointer+0)', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[2]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + r := AddFmtDef(Format('@(%sIntPointer^)', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[2]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + r := AddFmtDef(Format('(%sIntPointer+1)', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[3]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + r := AddFmtDef(Format('(%sIntPointer-1)', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[1]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + // Add/SUb to word pointer + r := AddFmtDef(Format('(%sWordPointer+2)', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[3]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + // Add/SUb to generic pointer + r := AddFmtDef(Format('%sPointer', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[2]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + r := AddFmtDef(Format('%sPointer+4', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[3]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + r := AddFmtDef(Format('%sPointer-4', [s]), '\REPLACEME', skPointer, '', [fTpMtch]); + if i = 3 then UpdResMinFpc(r, stSymAll, 020600); + r^.OnBeforeTest := @AdjustArrayExpectToAddress; + r^.UserData := pointer(ptruint(Length(FCurrentExpect^))); + r^.UserData2 := FCurrentExpect; + AddFmtDef(Format('@%sDynInt1[1]', [s]), '\$[0-9A-F]', skPointer, '', [fTpMtch]); + + {%endregion address of } + end; + + {%endregion Pointer } end; // i2 end; // i