mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 03:38:26 +02:00
FpDebug: Refactor TFpDbgInfoCallContext (add "AddParam" / remove Dbg-Process from "CreateParamSymbol")
This commit is contained in:
parent
bba0a43742
commit
ae8bbb1cd6
@ -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.
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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,20 +903,16 @@ 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
|
||||
ExprParamVal := ASelfValue
|
||||
else
|
||||
ParamSymbol.AsCardinal := AParams.Items[i + ItemsOffs].ResultValue.AsCardinal;
|
||||
if IsError(ParamSymbol.LastError) then begin
|
||||
ExprParamVal := AParams.Items[i + ItemsOffs].ResultValue;
|
||||
|
||||
if not CallContext.AddParam(i, ParameterSymbolArr[i], ExprParamVal) then begin
|
||||
DebugLn('Internal error for arg %d ', [i]);
|
||||
AnError := ParamSymbol.LastError;
|
||||
AnError := CallContext.LastError;
|
||||
exit;
|
||||
end;
|
||||
finally
|
||||
ParamSymbol.ReleaseReference;
|
||||
end;
|
||||
end;
|
||||
|
||||
FDebugger.FDbgController.ProcessLoop;
|
||||
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user