diff --git a/components/fpdebug/fpdbglinuxclasses.pas b/components/fpdebug/fpdbglinuxclasses.pas index d486ca3739..e72c919e7d 100644 --- a/components/fpdebug/fpdbglinuxclasses.pas +++ b/components/fpdebug/fpdbglinuxclasses.pas @@ -854,14 +854,14 @@ begin FRegisterValueList.DbgRegisterAutoCreate['foo'].SetValue(FFpRegs.foo, IntToStr(FFpRegs.foo),4,516); FRegisterValueList.DbgRegisterAutoCreate['fos'].SetValue(FFpRegs.fos, IntToStr(FFpRegs.fos),4,517); - FRegisterValueList.DbgRegisterAutoCreate['Xmm0' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[0*4])^),16,600); - FRegisterValueList.DbgRegisterAutoCreate['Xmm1' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[1*4])^),16,601); - FRegisterValueList.DbgRegisterAutoCreate['Xmm2' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[2*4])^),16,602); - FRegisterValueList.DbgRegisterAutoCreate['Xmm3' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[3*4])^),16,603); - FRegisterValueList.DbgRegisterAutoCreate['Xmm4' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[4*4])^),16,604); - FRegisterValueList.DbgRegisterAutoCreate['Xmm5' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[5*4])^),16,605); - FRegisterValueList.DbgRegisterAutoCreate['Xmm6' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[6*4])^),16,606); - FRegisterValueList.DbgRegisterAutoCreate['Xmm7' ].SetValue(0, XmmToString(PM128A(@FFpRegs.xmm_space[7*4])^),16,607); + FRegisterValueList.DbgRegisterAutoCreate['Xmm0' ].SetValue(@FFpRegs.xmm_space[0*4],16,600, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm1' ].SetValue(@FFpRegs.xmm_space[1*4],16,601, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm2' ].SetValue(@FFpRegs.xmm_space[2*4],16,602, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm3' ].SetValue(@FFpRegs.xmm_space[3*4],16,603, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm4' ].SetValue(@FFpRegs.xmm_space[4*4],16,604, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm5' ].SetValue(@FFpRegs.xmm_space[5*4],16,605, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm6' ].SetValue(@FFpRegs.xmm_space[6*4],16,606, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm7' ].SetValue(@FFpRegs.xmm_space[7*4],16,607, @XmmToFormat); FRegisterValueList.DbgRegisterAutoCreate['mxcsr'].SetValue(FFpRegs.fos, IntToStr(FFpRegs.mxcsr),4,620); diff --git a/components/fpdebug/fpdbgutil.pp b/components/fpdebug/fpdbgutil.pp index 78d746b3b0..d6227ab0e1 100644 --- a/components/fpdebug/fpdbgutil.pp +++ b/components/fpdebug/fpdbgutil.pp @@ -36,13 +36,13 @@ unit FpDbgUtil; {$mode objfpc}{$H+} {$IFDEF INLINE_OFF}{$INLINE OFF}{$ENDIF} {$IF FPC_Fullversion=30202}{$Optimization NOPEEPHOLE}{$ENDIF} - +{$WARN 4066 off : Arithmetic "$1" on untyped pointer is unportable to ?$T+?, suggest typecast} interface uses {$IFDEF WINDOWS} Windows, {$ENDIF} - Classes, SysUtils, fgl, math, LazUTF8, lazCollections, - UTF8Process, {$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}, syncobjs; + Classes, SysUtils, fgl, math, LazUTF8, lazCollections, UTF8Process, LazLoggerBase, + DbgIntfDebuggerBase, FpdMemoryTools, LazDebuggerUtils, syncobjs; type TFPDMode = (dm32, dm64); @@ -240,6 +240,8 @@ type function XmmToString(const xmm: M128A): String; function YmmToString(const Xmm, Ymm: M128A): String; +function XmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat = rdDefault): String; +function YmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat = rdDefault): String; var ProcessMessagesProc: procedure of object; // Application.ProcessMessages, if needed. To be called while waiting. @@ -542,6 +544,99 @@ begin end; +function XmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat): String; +var + b: Integer; + p: String; +begin + b := 10; + p := ''; + case AFormat of + rdRaw, + rdDefault: + exit(XmmToString(PM128A(AReg.Data)^)); + rdHex: begin b := 16; p := '$'; end; + rdBinary: begin b := 2; p := '%'; end; + rdOctal: begin b := 8; p := '&'; end; + rdDecimal: begin b := 10; p := ''; end; + end; + + Result := format('{"I64": [%s, %s], "I32": [%s, %s, %s, %s], "I16": [%s, %s, %s, %s, %s, %s, %s, %s], "I8": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s]}', [ + p+Dec64ToNumb(PInt64(@AReg.Data+0)^,0,b), p+Dec64ToNumb(PInt64(@AReg.Data+8)^,0,b), + + p+Dec64ToNumb(PInt32(@AReg.Data+0)^,0,b), p+Dec64ToNumb(PInt32(@AReg.Data+4)^,0,b), + p+Dec64ToNumb(PInt32(@AReg.Data+8)^,0,b), p+Dec64ToNumb(PInt32(@AReg.Data+12)^,0,b), + + p+Dec64ToNumb(Pint16(@AReg.Data+ 0)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+ 2)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+ 4)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+ 6)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+ 8)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+10)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+12)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+14)^,0,b), + + p+Dec64ToNumb(PInt8(@AReg.Data+ 0)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 1)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 2)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 3)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 4)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 5)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 6)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 7)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 8)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 9)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+10)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+11)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+12)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+13)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+14)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+15)^,0,b) + ]); +end; + +function YmmToFormat(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat): String; +var + b: Integer; + p: String; +begin + b := 10; + p := ''; + case AFormat of + rdRaw, + rdDefault: + exit(YmmToString(PM128A(AReg.Data)^, PM128A(AReg.Data+16)^)); + rdHex: begin b := 16; p := '$'; end; + rdBinary: begin b := 2; p := '%'; end; + rdOctal: begin b := 8; p := '&'; end; + rdDecimal: begin b := 10; p := ''; end; + end; + + Result := format('{"I64": [%s, %s, %s, %s], "I32": [%s, %s, %s, %s, %s, %s, %s, %s], "I16": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s], "I8": [%s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s, %s]}', [ + p+Dec64ToNumb(PInt64(@AReg.Data+0)^,0,b), p+Dec64ToNumb(PInt64(@AReg.Data+8)^,0,b), + p+Dec64ToNumb(PInt64(@AReg.Data+16+0)^,0,b), p+Dec64ToNumb(PInt64(@AReg.Data+16+8)^,0,b), + + p+Dec64ToNumb(PInt32(@AReg.Data+0)^,0,b), p+Dec64ToNumb(PInt32(@AReg.Data+4)^,0,b), + p+Dec64ToNumb(PInt32(@AReg.Data+8)^,0,b), p+Dec64ToNumb(PInt32(@AReg.Data+12)^,0,b), + p+Dec64ToNumb(PInt32(@AReg.Data+16+0)^,0,b), p+Dec64ToNumb(PInt32(@AReg.Data+16+4)^,0,b), + p+Dec64ToNumb(PInt32(@AReg.Data+16+8)^,0,b), p+Dec64ToNumb(PInt32(@AReg.Data+16+12)^,0,b), + + p+Dec64ToNumb(Pint16(@AReg.Data+ 0)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+ 2)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+ 4)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+ 6)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+ 8)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+10)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+12)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+14)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+16+ 0)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+16+ 2)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+16+ 4)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+16+ 6)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+16+ 8)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+16+10)^,0,b), + p+Dec64ToNumb(Pint16(@AReg.Data+16+12)^,0,b), p+Dec64ToNumb(Pint16(@AReg.Data+16+14)^,0,b), + + p+Dec64ToNumb(PInt8(@AReg.Data+ 0)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 1)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 2)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 3)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 4)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 5)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 6)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 7)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+ 8)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+ 9)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+10)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+11)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+12)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+13)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+14)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+15)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+ 0)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+ 1)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+ 2)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+ 3)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+ 4)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+ 5)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+ 6)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+ 7)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+ 8)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+ 9)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+10)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+11)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+12)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+13)^,0,b), + p+Dec64ToNumb(PInt8(@AReg.Data+16+14)^,0,b), p+Dec64ToNumb(PInt8(@AReg.Data+16+15)^,0,b) + ]); +end; + type { TFpThreadWorkerTerminateItem } diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas index 39bfab3482..e1a9da0d48 100644 --- a/components/fpdebug/fpdbgwinclasses.pas +++ b/components/fpdebug/fpdbgwinclasses.pas @@ -1791,6 +1791,7 @@ var FeatureLength, FeatureLength2: DWORD; i: Integer; EM, SEM: TFPUExceptionMask; + r: TDbgRegisterValue; begin {$IFDEF FPDEBUG_THREAD_CHECK}AssertFpDebugThreadId('TDbgWinThread.LoadRegisterValues');{$ENDIF} assert(MDebugEvent.dwProcessId <> 0, 'TDbgWinThread.LoadRegisterValues: MDebugEvent.dwProcessId <> 0'); @@ -1851,14 +1852,14 @@ begin FRegisterValueList.DbgRegisterAutoCreate['fCr0NpxSt'].SetValue(FloatSave.Cr0NpxState, IntToStr(FloatSave.Cr0NpxState),4,518); if not FFailed_CONTEXT_EXTENDED_REGISTERS then begin - FRegisterValueList.DbgRegisterAutoCreate['Xmm0'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[10*16])^),16,600); - FRegisterValueList.DbgRegisterAutoCreate['Xmm1'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[11*16])^),16,601); - FRegisterValueList.DbgRegisterAutoCreate['Xmm2'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[12*16])^),16,602); - FRegisterValueList.DbgRegisterAutoCreate['Xmm3'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[13*16])^),16,603); - FRegisterValueList.DbgRegisterAutoCreate['Xmm4'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[14*16])^),16,604); - FRegisterValueList.DbgRegisterAutoCreate['Xmm5'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[15*16])^),16,605); - FRegisterValueList.DbgRegisterAutoCreate['Xmm6'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[16*16])^),16,606); - FRegisterValueList.DbgRegisterAutoCreate['Xmm7'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[17*16])^),16,607); + FRegisterValueList.DbgRegisterAutoCreate['Xmm0'].SetValue(@ExtendedRegisters[10*16],16,600, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm1'].SetValue(@ExtendedRegisters[11*16],16,601, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm2'].SetValue(@ExtendedRegisters[12*16],16,602, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm3'].SetValue(@ExtendedRegisters[13*16],16,603, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm4'].SetValue(@ExtendedRegisters[14*16],16,604, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm5'].SetValue(@ExtendedRegisters[15*16],16,605, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm6'].SetValue(@ExtendedRegisters[16*16],16,606, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm7'].SetValue(@ExtendedRegisters[17*16],16,607, @XmmToFormat); FRegisterValueList.DbgRegisterAutoCreate['MxCsr'].SetValue(PDWORD(@ExtendedRegisters[24])^, IntToStr(PDWORD(@ExtendedRegisters[24])^),4,620); end; @@ -1909,14 +1910,14 @@ begin FRegisterValueList.DbgRegisterAutoCreate['fCr0NpxSt'].SetValue(FloatSave.Cr0NpxState, IntToStr(FloatSave.Cr0NpxState),4,518); if not FFailed_CONTEXT_EXTENDED_REGISTERS then begin - FRegisterValueList.DbgRegisterAutoCreate['Xmm0'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[10*16])^),16,600); - FRegisterValueList.DbgRegisterAutoCreate['Xmm1'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[11*16])^),16,601); - FRegisterValueList.DbgRegisterAutoCreate['Xmm2'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[12*16])^),16,602); - FRegisterValueList.DbgRegisterAutoCreate['Xmm3'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[13*16])^),16,603); - FRegisterValueList.DbgRegisterAutoCreate['Xmm4'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[14*16])^),16,604); - FRegisterValueList.DbgRegisterAutoCreate['Xmm5'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[15*16])^),16,605); - FRegisterValueList.DbgRegisterAutoCreate['Xmm6'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[16*16])^),16,606); - FRegisterValueList.DbgRegisterAutoCreate['Xmm7'].SetValue(0, XmmToString(PM128A(@ExtendedRegisters[17*16])^),16,607); + FRegisterValueList.DbgRegisterAutoCreate['Xmm0'].SetValue(@ExtendedRegisters[10*16],16,600, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm1'].SetValue(@ExtendedRegisters[11*16],16,601, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm2'].SetValue(@ExtendedRegisters[12*16],16,602, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm3'].SetValue(@ExtendedRegisters[13*16],16,603, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm4'].SetValue(@ExtendedRegisters[14*16],16,604, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm5'].SetValue(@ExtendedRegisters[15*16],16,605, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm6'].SetValue(@ExtendedRegisters[16*16],16,606, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm7'].SetValue(@ExtendedRegisters[17*16],16,607, @XmmToFormat); FRegisterValueList.DbgRegisterAutoCreate['MxCsr'].SetValue(PDWORD(@ExtendedRegisters[24])^, IntToStr(PDWORD(@ExtendedRegisters[24])^),4,620); end; @@ -1973,22 +1974,22 @@ begin FRegisterValueList.DbgRegisterAutoCreate['fDatOff'].SetValue(FltSave.DataOffset, IntToStr(FltSave.DataOffset),4,516); FRegisterValueList.DbgRegisterAutoCreate['fDatSel'].SetValue(FltSave.DataSelector, IntToStr(FltSave.DataSelector),2,517); - FRegisterValueList.DbgRegisterAutoCreate['Xmm0' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 0]),16,600); - FRegisterValueList.DbgRegisterAutoCreate['Xmm1' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 1]),16,601); - FRegisterValueList.DbgRegisterAutoCreate['Xmm2' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 2]),16,602); - FRegisterValueList.DbgRegisterAutoCreate['Xmm3' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 3]),16,603); - FRegisterValueList.DbgRegisterAutoCreate['Xmm4' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 4]),16,604); - FRegisterValueList.DbgRegisterAutoCreate['Xmm5' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 5]),16,605); - FRegisterValueList.DbgRegisterAutoCreate['Xmm6' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 6]),16,606); - FRegisterValueList.DbgRegisterAutoCreate['Xmm7' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 7]),16,607); - FRegisterValueList.DbgRegisterAutoCreate['Xmm8' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 8]),16,608); - FRegisterValueList.DbgRegisterAutoCreate['Xmm9' ].SetValue(0, XmmToString(FltSave.XmmRegisters[ 9]),16,609); - FRegisterValueList.DbgRegisterAutoCreate['Xmm10'].SetValue(0, XmmToString(FltSave.XmmRegisters[10]),16,610); - FRegisterValueList.DbgRegisterAutoCreate['Xmm11'].SetValue(0, XmmToString(FltSave.XmmRegisters[11]),16,611); - FRegisterValueList.DbgRegisterAutoCreate['Xmm12'].SetValue(0, XmmToString(FltSave.XmmRegisters[12]),16,612); - FRegisterValueList.DbgRegisterAutoCreate['Xmm13'].SetValue(0, XmmToString(FltSave.XmmRegisters[13]),16,613); - FRegisterValueList.DbgRegisterAutoCreate['Xmm14'].SetValue(0, XmmToString(FltSave.XmmRegisters[14]),16,614); - FRegisterValueList.DbgRegisterAutoCreate['Xmm15'].SetValue(0, XmmToString(FltSave.XmmRegisters[15]),16,615); + FRegisterValueList.DbgRegisterAutoCreate['Xmm0' ].SetValue(@FltSave.XmmRegisters[ 0],16,600, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm1' ].SetValue(@FltSave.XmmRegisters[ 1],16,601, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm2' ].SetValue(@FltSave.XmmRegisters[ 2],16,602, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm3' ].SetValue(@FltSave.XmmRegisters[ 3],16,603, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm4' ].SetValue(@FltSave.XmmRegisters[ 4],16,604, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm5' ].SetValue(@FltSave.XmmRegisters[ 5],16,605, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm6' ].SetValue(@FltSave.XmmRegisters[ 6],16,606, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm7' ].SetValue(@FltSave.XmmRegisters[ 7],16,607, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm8' ].SetValue(@FltSave.XmmRegisters[ 8],16,608, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm9' ].SetValue(@FltSave.XmmRegisters[ 9],16,609, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm10'].SetValue(@FltSave.XmmRegisters[10],16,610, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm11'].SetValue(@FltSave.XmmRegisters[11],16,611, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm12'].SetValue(@FltSave.XmmRegisters[12],16,612, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm13'].SetValue(@FltSave.XmmRegisters[13],16,613, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm14'].SetValue(@FltSave.XmmRegisters[14],16,614, @XmmToFormat); + FRegisterValueList.DbgRegisterAutoCreate['Xmm15'].SetValue(@FltSave.XmmRegisters[15],16,615, @XmmToFormat); FRegisterValueList.DbgRegisterAutoCreate['MxCsr'].SetValue(FltSave.MxCsr, IntToStr(FltSave.MxCsr),4,620); FRegisterValueList.DbgRegisterAutoCreate['MxCsrM'].SetValue(FltSave.MxCsr_Mask, IntToStr(FltSave.MxCsr_Mask),4,621); @@ -2030,14 +2031,16 @@ begin then begin // AVX not init yet // upper half must be 0 for i := 0 to FeatureLength div SizeOf(M128A) - 1 do begin - FRegisterValueList.DbgRegisterAutoCreate['Ymm'+IntToStr(i)].SetValue - (0, YmmToString(Xmm[i], M128A_NULL),32,700+i); + r := FRegisterValueList.DbgRegisterAutoCreate['Ymm'+IntToStr(i)]; + r.SetValue(@Xmm[i],32,700+i, @YmmToFormat); + FillByte(PByte(r.Data+16)^, 16, 0); end; end else begin for i := 0 to FeatureLength div SizeOf(M128A) - 1 do begin - FRegisterValueList.DbgRegisterAutoCreate['Ymm'+IntToStr(i)].SetValue - (0, YmmToString(Xmm[i], Ymm[i]),32,700+i); + r := FRegisterValueList.DbgRegisterAutoCreate['Ymm'+IntToStr(i)]; + r.SetValue(@Xmm[i],32,700+i, @YmmToFormat); + move(Ymm[i], PByte(r.Data+16)^, 16); end; end; diff --git a/components/fpdebug/fpdmemorytools.pas b/components/fpdebug/fpdmemorytools.pas index 64e16cc0a6..dd36a4f398 100644 --- a/components/fpdebug/fpdmemorytools.pas +++ b/components/fpdebug/fpdmemorytools.pas @@ -26,8 +26,9 @@ unit FpdMemoryTools; interface uses - Classes, SysUtils, math, DbgIntfBaseTypes, FpErrorMessages, LazClasses, - AVL_Tree, {$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}; + Classes, SysUtils, math, DbgIntfBaseTypes, DbgIntfDebuggerBase, FpErrorMessages, LazClasses, + AVL_Tree, LazDebuggerUtils, + {$ifdef FORCE_LAZLOGGER_DUMMY} LazLoggerDummy {$else} LazLoggerBase {$endif}; const MINIMUM_MEMREAD_LIMIT = 1024; @@ -80,23 +81,34 @@ type { TDbgRegisterValue } + TDbgRegisterValue = class; + TRegisterFormatterProc = function(AReg: TDbgRegisterValue; AFormat: TRegisterDisplayFormat = rdDefault): String; + TDbgRegisterValue = class private FDwarfIdx: cardinal; FName: string; FNumValue: TDBGPtr; FSize: byte; + FMem: Pointer; FStrValue: string; + FFormatter: TRegisterFormatterProc; + function GetStrFormatted(AFormat: TRegisterDisplayFormat): string; + function GetStrValue: string; public constructor Create(const AName: String); + destructor Destroy; override; procedure Assign(ASource: TDbgRegisterValue); function HasEqualVal(AnOther: TDbgRegisterValue): Boolean; procedure SetValue(ANumValue: TDBGPtr; const AStrValue: string; ASize: byte; ADwarfIdx: cardinal); + procedure SetValue(const AData: Pointer; ASize: byte; ADwarfIdx: cardinal; AFormatter: TRegisterFormatterProc); procedure Setx86EFlagsValue(ANumValue: TDBGPtr); property Name: string read FName; property NumValue: TDBGPtr read FNumValue; - property StrValue: string read FStrValue; + property StrValue: string read GetStrValue; + property StrFormatted[AFormat: TRegisterDisplayFormat]: string read GetStrFormatted; property Size: byte read FSize; + property Data: Pointer read FMem; property DwarfIdx: cardinal read FDwarfIdx; end; @@ -1016,11 +1028,43 @@ end; { TDbgRegisterValue } +function TDbgRegisterValue.GetStrFormatted(AFormat: TRegisterDisplayFormat): string; +begin + if FFormatter <> nil then + exit(FFormatter(Self, AFormat)); + if FStrValue <> '' then + exit(FStrValue); + + case AFormat of + rdDefault: Result := IntToStr(FNumValue); + rdHex: Result := '$'+IntToHex(FNumValue); + rdBinary: Result := '%'+Dec64ToNumb(FNumValue, 0, 2); + rdOctal: Result := '&'+Dec64ToNumb(FNumValue, 0, 8); + rdDecimal: Result := IntToStr(FNumValue); + rdRaw: Result := IntToStr(FNumValue); + end; +end; + +function TDbgRegisterValue.GetStrValue: string; +begin + if (FStrValue = '') and (FFormatter <> nil) then + FStrValue := FFormatter(Self); + if (FStrValue = '') then + FStrValue := '?'; + Result := FStrValue; +end; + constructor TDbgRegisterValue.Create(const AName: String); begin FName:=AName; end; +destructor TDbgRegisterValue.Destroy; +begin + inherited Destroy; + Freemem(FMem); +end; + procedure TDbgRegisterValue.Assign(ASource: TDbgRegisterValue); begin FDwarfIdx := ASource.FDwarfIdx; @@ -1047,6 +1091,21 @@ begin FDwarfIdx:=ADwarfIdx; end; +procedure TDbgRegisterValue.SetValue(const AData: Pointer; ASize: byte; ADwarfIdx: cardinal; + AFormatter: TRegisterFormatterProc); +begin + FStrValue:=''; + FNumValue:=0; + FSize := ASize; + FDwarfIdx:=ADwarfIdx; + FFormatter := AFormatter; + if FMem <> nil then + FMem := ReAllocMem(FMem, ASize) + else + FMem := AllocMem(ASize); + move(AData^, FMem^, ASize); +end; + procedure TDbgRegisterValue.Setx86EFlagsValue(ANumValue: TDBGPtr); var FlagS: string; diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index 26028f2442..b336c34769 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -2477,8 +2477,9 @@ begin for i := 0 to ARegisterList.Count-1 do begin ARegisterValue := ARegisters.EntriesByName[ARegisterList[i].Name]; - ARegisterValue.ValueObj.SetAsNum(ARegisterList[i].NumValue, ARegisterList[i].Size); - ARegisterValue.ValueObj.SetAsText(ARegisterList[i].StrValue); + if ARegisterList[i].Size <= 8 then + ARegisterValue.ValueObj.SetAsNum(ARegisterList[i].NumValue, ARegisterList[i].Size); + ARegisterValue.ValueObj.SetAsText(ARegisterList[i].StrFormatted[ARegisterValue.DisplayFormat]); ARegisterValue.Modified := ARegisterList.IsModified[ARegisterList[i]]; ARegisterValue.DataValidity:=ddsValid; end; diff --git a/components/lazdebuggers/lazdebuggerintf/lazdebuggerintf.lpk b/components/lazdebuggers/lazdebuggerintf/lazdebuggerintf.lpk index f7bba11a1a..8cf6b1eb22 100644 --- a/components/lazdebuggers/lazdebuggerintf/lazdebuggerintf.lpk +++ b/components/lazdebuggers/lazdebuggerintf/lazdebuggerintf.lpk @@ -43,7 +43,11 @@ See LCL license for details."/> - + + + + + diff --git a/components/lazdebuggers/lazdebuggerintf/lazdebuggerintfpackage.pas b/components/lazdebuggers/lazdebuggerintf/lazdebuggerintfpackage.pas index 2939623fc3..23227aea5f 100644 --- a/components/lazdebuggers/lazdebuggerintf/lazdebuggerintfpackage.pas +++ b/components/lazdebuggers/lazdebuggerintf/lazdebuggerintfpackage.pas @@ -8,8 +8,8 @@ unit lazdebuggerintfpackage; interface uses - LazDebuggerIntf, LazDebuggerTemplate, LazDebuggerIntfBaseTypes, - LazDebuggerValueConverter, DbgUtilsTypePatternList; + LazDebuggerIntf, LazDebuggerTemplate, LazDebuggerIntfBaseTypes, LazDebuggerValueConverter, + DbgUtilsTypePatternList, LazDebuggerUtils; implementation diff --git a/components/lazdebuggers/lazdebuggerintf/lazdebuggerutils.pas b/components/lazdebuggers/lazdebuggerintf/lazdebuggerutils.pas new file mode 100644 index 0000000000..4e4fea3420 --- /dev/null +++ b/components/lazdebuggers/lazdebuggerintf/lazdebuggerutils.pas @@ -0,0 +1,46 @@ +unit LazDebuggerUtils; + +{$mode objfpc}{$H+} + +interface + +uses + Classes, SysUtils, StrUtils; + +function Dec64ToNumb(N: QWord; Len, Base: Byte): string; overload; +function Dec64ToNumb(N: Int64; Len, Base: Byte): string; inline; overload; + +implementation + +function Dec64ToNumb(N: QWord; Len, Base: Byte): string; overload; +var + C: Integer; + Number: QWord; +begin + if N=0 then + Result:='0' + else + begin + Number:=N; + Result:=''; + while Number>0 do begin + C := Number mod Base; + if C>9 then + C:=C+55 + else + C:=C+48; + Result:=Chr(C)+Result; + Number:=Number div Base; + end; + end; + if (Result<>'') then + Result:=AddChar('0',Result,Len); +end; + +function Dec64ToNumb(N: Int64; Len, Base: Byte): string; inline; overload; +begin + Result := Dec64ToNumb(QWord(N), Len, Base); +end; + +end. + diff --git a/ide/packages/idedebugger/idedebuggerwatchresprinter.pas b/ide/packages/idedebugger/idedebuggerwatchresprinter.pas index 730b99aaa0..c41a08a18e 100644 --- a/ide/packages/idedebugger/idedebuggerwatchresprinter.pas +++ b/ide/packages/idedebugger/idedebuggerwatchresprinter.pas @@ -8,7 +8,7 @@ interface uses Classes, SysUtils, Math, IdeDebuggerWatchResult, IdeDebuggerUtils, IdeDebuggerDisplayFormats, IdeDebuggerBase, IdeDebuggerStringConstants, IdeDebuggerValueFormatter, LazDebuggerIntf, LazUTF8, - IdeDebuggerWatchValueIntf, StrUtils; + IdeDebuggerWatchValueIntf, StrUtils, LazDebuggerUtils; type @@ -150,36 +150,6 @@ const SeparatorHexBin: vdfhsNone; ); -function Dec64ToNumb(N: QWord; Len, Base: Byte): string; overload; -var - C: Integer; - Number: QWord; -begin - if N=0 then - Result:='0' - else - begin - Number:=N; - Result:=''; - while Number>0 do begin - C := Number mod Base; - if C>9 then - C:=C+55 - else - C:=C+48; - Result:=Chr(C)+Result; - Number:=Number div Base; - end; - end; - if (Result<>'') then - Result:=AddChar('0',Result,Len); -end; - -function Dec64ToNumb(N: Int64; Len, Base: Byte): string; inline; overload; -begin - Result := Dec64ToNumb(QWord(N), Len, Base); -end; - { TResolvedDisplayFormatNum } class operator TResolvedDisplayFormatNum. = (a, b: TResolvedDisplayFormatNum): boolean;