mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-06 18:38:23 +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,
|
FpdMemoryTools,
|
||||||
FpDbgDwarfDataClasses,
|
FpDbgDwarfDataClasses,
|
||||||
FpDbgDwarf,
|
FpDbgDwarf,
|
||||||
FpDbgClasses;
|
FpDbgClasses, FpErrorMessages;
|
||||||
|
|
||||||
type
|
type
|
||||||
{ TFpSymbolDwarfFunctionResult }
|
{ TFpSymbolDwarfFunctionResult }
|
||||||
@ -28,8 +28,17 @@ type
|
|||||||
{ TFpDbgInfoCallContext }
|
{ TFpDbgInfoCallContext }
|
||||||
|
|
||||||
TFpDbgInfoCallContext = class(TFpDbgAbstractCallContext)
|
TFpDbgInfoCallContext = class(TFpDbgAbstractCallContext)
|
||||||
|
private
|
||||||
|
FDbgProcess: TDbgProcess;
|
||||||
|
FLastError: TFpError;
|
||||||
public
|
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;
|
end;
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
@ -58,13 +67,21 @@ end;
|
|||||||
|
|
||||||
{ TFpDbgInfoCallContext }
|
{ 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;
|
function TFpDbgInfoCallContext.CreateParamSymbol(AParamIndex: Integer;
|
||||||
ASymbolType: TFpSymbol; ADbgProcess: TDbgProcess; AName: String): TFpValue;
|
ASymbolType: TFpSymbol; AName: String): TFpValue;
|
||||||
var
|
var
|
||||||
ParameterMemLocation: TFpDbgMemLocation;
|
ParameterMemLocation: TFpDbgMemLocation;
|
||||||
ParamSymbol: TFpSymbol;// TFpSymbolDwarfFunctionResult;
|
ParamSymbol: TFpSymbol;// TFpSymbolDwarfFunctionResult;
|
||||||
begin
|
begin
|
||||||
ParameterMemLocation := ADbgProcess.CallParamDefaultLocation(AParamIndex);
|
ParameterMemLocation := FDbgProcess.CallParamDefaultLocation(AParamIndex);
|
||||||
if AName = '' then
|
if AName = '' then
|
||||||
AName := ASymbolType.Name;
|
AName := ASymbolType.Name;
|
||||||
ParamSymbol := TFpSymbolDwarfFunctionResult.Create(AName, ParameterMemLocation, ASymbolType.TypeInfo);
|
ParamSymbol := TFpSymbolDwarfFunctionResult.Create(AName, ParameterMemLocation, ASymbolType.TypeInfo);
|
||||||
@ -76,5 +93,21 @@ begin
|
|||||||
TFpValueDwarf(Result).Context := Self;
|
TFpValueDwarf(Result).Context := Self;
|
||||||
end;
|
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.
|
end.
|
||||||
|
|
||||||
|
@ -1939,7 +1939,7 @@ function TDbgController.Call(const FunctionAddress: TFpDbgMemLocation;
|
|||||||
var
|
var
|
||||||
Context: TFpDbgInfoCallContext;
|
Context: TFpDbgInfoCallContext;
|
||||||
begin
|
begin
|
||||||
Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, AMemConverter);
|
Context := TFpDbgInfoCallContext.Create(ABaseContext, AMemReader, AMemConverter, FCurrentProcess);
|
||||||
Context.AddReference;
|
Context.AddReference;
|
||||||
InitializeCommand(TDbgControllerCallRoutineCmd.Create(self, FunctionAddress, Context));
|
InitializeCommand(TDbgControllerCallRoutineCmd.Create(self, FunctionAddress, Context));
|
||||||
Result := Context;
|
Result := Context;
|
||||||
|
@ -781,7 +781,7 @@ function TFpThreadWorkerEvaluate.DoWatchFunctionCall(
|
|||||||
var
|
var
|
||||||
FunctionSymbolData, FunctionSymbolType, FunctionResultSymbolType,
|
FunctionSymbolData, FunctionSymbolType, FunctionResultSymbolType,
|
||||||
TempSymbol: TFpSymbol;
|
TempSymbol: TFpSymbol;
|
||||||
ParamSymbol, ExprParamVal: TFpValue;
|
ExprParamVal: TFpValue;
|
||||||
ProcAddress: TFpDbgMemLocation;
|
ProcAddress: TFpDbgMemLocation;
|
||||||
FunctionResultDataSize: TFpDbgValueSize;
|
FunctionResultDataSize: TFpDbgValueSize;
|
||||||
ParameterSymbolArr: array of TFpSymbol;
|
ParameterSymbolArr: array of TFpSymbol;
|
||||||
@ -903,19 +903,15 @@ begin
|
|||||||
|
|
||||||
try
|
try
|
||||||
for i := 0 to High(ParameterSymbolArr) do begin
|
for i := 0 to High(ParameterSymbolArr) do begin
|
||||||
ParamSymbol := CallContext.CreateParamSymbol(i, ParameterSymbolArr[i], FDebugger.FDbgController.CurrentProcess);
|
if (ASelfValue <> nil) and (i = 0) then
|
||||||
try
|
ExprParamVal := ASelfValue
|
||||||
if (ASelfValue <> nil) and (i = 0) then
|
else
|
||||||
ParamSymbol.AsCardinal := ASelfValue.AsCardinal
|
ExprParamVal := AParams.Items[i + ItemsOffs].ResultValue;
|
||||||
else
|
|
||||||
ParamSymbol.AsCardinal := AParams.Items[i + ItemsOffs].ResultValue.AsCardinal;
|
if not CallContext.AddParam(i, ParameterSymbolArr[i], ExprParamVal) then begin
|
||||||
if IsError(ParamSymbol.LastError) then begin
|
DebugLn('Internal error for arg %d ', [i]);
|
||||||
DebugLn('Internal error for arg %d ', [i]);
|
AnError := CallContext.LastError;
|
||||||
AnError := ParamSymbol.LastError;
|
exit;
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
finally
|
|
||||||
ParamSymbol.ReleaseReference;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -927,8 +923,7 @@ begin
|
|||||||
exit;
|
exit;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
AResult := CallContext.CreateParamSymbol(-1, FunctionSymbolType,
|
AResult := CallContext.CreateParamSymbol(-1, FunctionSymbolType, FunctionSymbolData.Name);
|
||||||
FDebugger.FDbgController.CurrentProcess, FunctionSymbolData.Name);
|
|
||||||
Result := AResult <> nil;
|
Result := AResult <> nil;
|
||||||
finally
|
finally
|
||||||
CallContext.ReleaseReference;
|
CallContext.ReleaseReference;
|
||||||
|
Loading…
Reference in New Issue
Block a user