diff --git a/components/fpdebug/fpdbgcallcontextinfo.pas b/components/fpdebug/fpdbgcallcontextinfo.pas index c0799153c0..93e3188df8 100644 --- a/components/fpdebug/fpdbgcallcontextinfo.pas +++ b/components/fpdebug/fpdbgcallcontextinfo.pas @@ -10,7 +10,7 @@ uses FpdMemoryTools, FpDbgDwarfDataClasses, FpDbgDwarf, - FpDbgClasses; + FpDbgClasses, FpErrorMessages; type { TFpSymbolDwarfFunctionResult } @@ -28,8 +28,17 @@ type { TFpDbgInfoCallContext } TFpDbgInfoCallContext = class(TFpDbgAbstractCallContext) + private + FDbgProcess: TDbgProcess; + FLastError: TFpError; public - function CreateParamSymbol(AParamIndex: Integer; ASymbolType: TFpSymbol; ADbgProcess: TDbgProcess; AName: String = ''): TFpValue; virtual; + constructor Create(const ABaseContext: TFpDbgLocationContext; + AMemReader: TFpDbgMemReaderBase; + AMemConverter: TFpDbgMemConvertor; + ADbgProcess: TDbgProcess); + function CreateParamSymbol(AParamIndex: Integer; ASymbolType: TFpSymbol; AName: String = ''): TFpValue; virtual; + function AddParam(AParamIndex: Integer; AParamSymbolType: TFpSymbol; AValue: TFpValue): Boolean; + property LastError: TFpError read FLastError; end; implementation @@ -58,13 +67,21 @@ end; { TFpDbgInfoCallContext } +constructor TFpDbgInfoCallContext.Create( + const ABaseContext: TFpDbgLocationContext; AMemReader: TFpDbgMemReaderBase; + AMemConverter: TFpDbgMemConvertor; ADbgProcess: TDbgProcess); +begin + inherited Create(ABaseContext, AMemReader, AMemConverter); + FDbgProcess := ADbgProcess; +end; + function TFpDbgInfoCallContext.CreateParamSymbol(AParamIndex: Integer; - ASymbolType: TFpSymbol; ADbgProcess: TDbgProcess; AName: String): TFpValue; + ASymbolType: TFpSymbol; AName: String): TFpValue; var ParameterMemLocation: TFpDbgMemLocation; ParamSymbol: TFpSymbol;// TFpSymbolDwarfFunctionResult; begin - ParameterMemLocation := ADbgProcess.CallParamDefaultLocation(AParamIndex); + ParameterMemLocation := FDbgProcess.CallParamDefaultLocation(AParamIndex); if AName = '' then AName := ASymbolType.Name; ParamSymbol := TFpSymbolDwarfFunctionResult.Create(AName, ParameterMemLocation, ASymbolType.TypeInfo); @@ -76,5 +93,21 @@ begin TFpValueDwarf(Result).Context := Self; end; +function TFpDbgInfoCallContext.AddParam(AParamIndex: Integer; + AParamSymbolType: TFpSymbol; AValue: TFpValue): Boolean; +var + ParamSymbol: TFpValue; +begin + Result := False; + ParamSymbol := CreateParamSymbol(AParamIndex, AParamSymbolType); + try + ParamSymbol.AsCardinal := AValue.AsCardinal; + Result := not IsError(ParamSymbol.LastError); + FLastError := ParamSymbol.LastError; + finally + ParamSymbol.ReleaseReference; + end; +end; + end. diff --git a/components/fpdebug/fpdbgcontroller.pas b/components/fpdebug/fpdbgcontroller.pas index aea323e073..33dc705207 100644 --- a/components/fpdebug/fpdbgcontroller.pas +++ b/components/fpdebug/fpdbgcontroller.pas @@ -1939,7 +1939,7 @@ function TDbgController.Call(const FunctionAddress: TFpDbgMemLocation; var Context: TFpDbgInfoCallContext; begin - Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, AMemConverter); + Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, AMemConverter, FCurrentProcess); Context.AddReference; InitializeCommand(TDbgControllerCallRoutineCmd.Create(self, FunctionAddress, Context)); Result := Context; diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebuggerworkthreads.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebuggerworkthreads.pas index d386054062..8e8e5e4193 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebuggerworkthreads.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebuggerworkthreads.pas @@ -781,7 +781,7 @@ function TFpThreadWorkerEvaluate.DoWatchFunctionCall( var FunctionSymbolData, FunctionSymbolType, FunctionResultSymbolType, TempSymbol: TFpSymbol; - ParamSymbol, ExprParamVal: TFpValue; + ExprParamVal: TFpValue; ProcAddress: TFpDbgMemLocation; FunctionResultDataSize: TFpDbgValueSize; ParameterSymbolArr: array of TFpSymbol; @@ -903,19 +903,15 @@ begin try for i := 0 to High(ParameterSymbolArr) do begin - ParamSymbol := CallContext.CreateParamSymbol(i, ParameterSymbolArr[i], FDebugger.FDbgController.CurrentProcess); - try - if (ASelfValue <> nil) and (i = 0) then - ParamSymbol.AsCardinal := ASelfValue.AsCardinal - else - ParamSymbol.AsCardinal := AParams.Items[i + ItemsOffs].ResultValue.AsCardinal; - if IsError(ParamSymbol.LastError) then begin - DebugLn('Internal error for arg %d ', [i]); - AnError := ParamSymbol.LastError; - exit; - end; - finally - ParamSymbol.ReleaseReference; + if (ASelfValue <> nil) and (i = 0) then + ExprParamVal := ASelfValue + else + ExprParamVal := AParams.Items[i + ItemsOffs].ResultValue; + + if not CallContext.AddParam(i, ParameterSymbolArr[i], ExprParamVal) then begin + DebugLn('Internal error for arg %d ', [i]); + AnError := CallContext.LastError; + exit; end; end; @@ -927,8 +923,7 @@ begin exit; end; - AResult := CallContext.CreateParamSymbol(-1, FunctionSymbolType, - FDebugger.FDbgController.CurrentProcess, FunctionSymbolData.Name); + AResult := CallContext.CreateParamSymbol(-1, FunctionSymbolType, FunctionSymbolData.Name); Result := AResult <> nil; finally CallContext.ReleaseReference;