mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-15 19:39:28 +02:00
LazDebuggerFPDServer: Added support for dcEvaluate
git-svn-id: trunk@49168 -
This commit is contained in:
parent
6f07e65533
commit
0c5739b43a
@ -33,15 +33,17 @@ type
|
|||||||
protected
|
protected
|
||||||
FCommandUID: integer;
|
FCommandUID: integer;
|
||||||
FServerDebugger: TFPDServerDebugger;
|
FServerDebugger: TFPDServerDebugger;
|
||||||
|
FAutomaticFree: boolean;
|
||||||
function GetAsString: string; virtual;
|
function GetAsString: string; virtual;
|
||||||
procedure ComposeJSon(AJsonObject: TJSONObject); virtual;
|
procedure ComposeJSon(AJsonObject: TJSONObject); virtual;
|
||||||
public
|
public
|
||||||
constructor create; virtual;
|
constructor create(AnAutomaticFree: boolean=true); virtual;
|
||||||
procedure DoOnCommandSuccesfull(ACommandResponse: TJSonObject); virtual;
|
procedure DoOnCommandSuccesfull(ACommandResponse: TJSonObject); virtual;
|
||||||
procedure DoOnCommandReceived(ACommandResponse: TJSonObject); virtual;
|
procedure DoOnCommandReceived(ACommandResponse: TJSonObject); virtual;
|
||||||
procedure DoOnCommandFailed(ACommandResponse: TJSonObject); virtual;
|
procedure DoOnCommandFailed(ACommandResponse: TJSonObject); virtual;
|
||||||
property CommandUID: integer read FCommandUID;
|
property CommandUID: integer read FCommandUID;
|
||||||
property AsString: string read GetAsString;
|
property AsString: string read GetAsString;
|
||||||
|
property AutomaticFree: boolean read FAutomaticFree;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFPDSendCommandList }
|
{ TFPDSendCommandList }
|
||||||
@ -164,6 +166,23 @@ type
|
|||||||
procedure DoOnCommandSuccesfull(ACommandResponse: TJSonObject); override;
|
procedure DoOnCommandSuccesfull(ACommandResponse: TJSonObject); override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{ TFPDSendEvaluateCommand }
|
||||||
|
|
||||||
|
TFPDSendEvaluateCommand = class(TFPDSendCommand)
|
||||||
|
private
|
||||||
|
FExpression: string;
|
||||||
|
FValidity: TDebuggerDataState;
|
||||||
|
FMessage: string;
|
||||||
|
protected
|
||||||
|
procedure ComposeJSon(AJsonObject: TJSONObject); override;
|
||||||
|
public
|
||||||
|
constructor create(AnAutomaticFree: boolean; AnExpression: string);
|
||||||
|
procedure DoOnCommandSuccesfull(ACommandResponse: TJSonObject); override;
|
||||||
|
procedure DoOnCommandFailed(ACommandResponse: TJSonObject); override;
|
||||||
|
property Validity: TDebuggerDataState read FValidity;
|
||||||
|
property Message: string read FMessage;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFPDSocketThread }
|
{ TFPDSocketThread }
|
||||||
|
|
||||||
TFPDSocketThread = class(TThread)
|
TFPDSocketThread = class(TThread)
|
||||||
@ -276,6 +295,45 @@ end;
|
|||||||
|
|
||||||
var GCommandUID: integer = 0;
|
var GCommandUID: integer = 0;
|
||||||
|
|
||||||
|
{ TFPDSendEvaluateCommand }
|
||||||
|
|
||||||
|
procedure TFPDSendEvaluateCommand.ComposeJSon(AJsonObject: TJSONObject);
|
||||||
|
begin
|
||||||
|
inherited ComposeJSon(AJsonObject);
|
||||||
|
AJsonObject.Add('command','evaluate');
|
||||||
|
AJsonObject.Add('expression',FExpression);
|
||||||
|
end;
|
||||||
|
|
||||||
|
constructor TFPDSendEvaluateCommand.create(AnAutomaticFree: boolean; AnExpression: string);
|
||||||
|
begin
|
||||||
|
FExpression:=AnExpression;
|
||||||
|
FValidity:=ddsRequested;
|
||||||
|
inherited create(AnAutomaticFree);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPDSendEvaluateCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
|
||||||
|
var
|
||||||
|
s: string;
|
||||||
|
i: TDebuggerDataState;
|
||||||
|
begin
|
||||||
|
inherited DoOnCommandSuccesfull(ACommandResponse);
|
||||||
|
FMessage:=ACommandResponse.Get('message','');
|
||||||
|
s := ACommandResponse.Get('validity','');
|
||||||
|
FValidity:=ddsError;
|
||||||
|
for i := low(TDebuggerDataState) to high(TDebuggerDataState) do
|
||||||
|
if DebuggerDataStateStr[i]=s then
|
||||||
|
begin
|
||||||
|
FValidity:=i;
|
||||||
|
break;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure TFPDSendEvaluateCommand.DoOnCommandFailed(ACommandResponse: TJSonObject);
|
||||||
|
begin
|
||||||
|
inherited DoOnCommandFailed(ACommandResponse);
|
||||||
|
FValidity:=ddsInvalid;
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFPDSendQuitDebugServerCommand }
|
{ TFPDSendQuitDebugServerCommand }
|
||||||
|
|
||||||
procedure TFPDSendQuitDebugServerCommand.ComposeJSon(AJsonObject: TJSONObject);
|
procedure TFPDSendQuitDebugServerCommand.ComposeJSon(AJsonObject: TJSONObject);
|
||||||
@ -319,10 +377,11 @@ begin
|
|||||||
AJsonObject.Add('uid', FCommandUID);
|
AJsonObject.Add('uid', FCommandUID);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
constructor TFPDSendCommand.create;
|
constructor TFPDSendCommand.create(AnAutomaticFree: boolean);
|
||||||
begin
|
begin
|
||||||
inc(GCommandUID);
|
inc(GCommandUID);
|
||||||
FCommandUID := GCommandUID;
|
FCommandUID := GCommandUID;
|
||||||
|
FAutomaticFree:=AnAutomaticFree;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDSendCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
|
procedure TFPDSendCommand.DoOnCommandSuccesfull(ACommandResponse: TJSonObject);
|
||||||
@ -776,7 +835,7 @@ end;
|
|||||||
|
|
||||||
function TFPDServerDebugger.GetSupportedCommands: TDBGCommands;
|
function TFPDServerDebugger.GetSupportedCommands: TDBGCommands;
|
||||||
begin
|
begin
|
||||||
Result:=[dcRun, dcStepOver, dcStepInto, dcStepOut, dcStepOverInstr, dcStepIntoInstr, dcStop];
|
Result:=[dcRun, dcStepOver, dcStepInto, dcStepOut, dcStepOverInstr, dcStepIntoInstr, dcStop, dcEvaluate];
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFPDServerDebugger.DoHandleCreateProcessEvent(AnEvent: TJSONObject);
|
procedure TFPDServerDebugger.DoHandleCreateProcessEvent(AnEvent: TJSONObject);
|
||||||
@ -842,12 +901,18 @@ begin
|
|||||||
'ExecutedCommand':
|
'ExecutedCommand':
|
||||||
begin
|
begin
|
||||||
SendCommand.DoOnCommandSuccesfull(ANotification);
|
SendCommand.DoOnCommandSuccesfull(ANotification);
|
||||||
FCommandList.Remove(SendCommand);
|
if SendCommand.AutomaticFree then
|
||||||
|
FCommandList.Remove(SendCommand)
|
||||||
|
else
|
||||||
|
FCommandList.Extract(SendCommand);
|
||||||
end;
|
end;
|
||||||
'FailedCommand' :
|
'FailedCommand' :
|
||||||
begin
|
begin
|
||||||
SendCommand.DoOnCommandFailed(ANotification);
|
SendCommand.DoOnCommandFailed(ANotification);
|
||||||
FCommandList.Remove(SendCommand);
|
if SendCommand.AutomaticFree then
|
||||||
|
FCommandList.Remove(SendCommand)
|
||||||
|
else
|
||||||
|
FCommandList.Extract(SendCommand);
|
||||||
end;
|
end;
|
||||||
'ReceivedCommand':
|
'ReceivedCommand':
|
||||||
SendCommand.DoOnCommandReceived(ANotification);
|
SendCommand.DoOnCommandReceived(ANotification);
|
||||||
@ -941,6 +1006,9 @@ begin
|
|||||||
end;
|
end;
|
||||||
|
|
||||||
function TFPDServerDebugger.RequestCommand(const ACommand: TDBGCommand; const AParams: array of const): Boolean;
|
function TFPDServerDebugger.RequestCommand(const ACommand: TDBGCommand; const AParams: array of const): Boolean;
|
||||||
|
var
|
||||||
|
ASendCommand: TFPDSendEvaluateCommand;
|
||||||
|
tc: qword;
|
||||||
begin
|
begin
|
||||||
result := true;
|
result := true;
|
||||||
case ACommand of
|
case ACommand of
|
||||||
@ -994,6 +1062,19 @@ begin
|
|||||||
QueueCommand(TFPDSendStopCommand.create);
|
QueueCommand(TFPDSendStopCommand.create);
|
||||||
if state=dsPause then
|
if state=dsPause then
|
||||||
SetState(dsRun);
|
SetState(dsRun);
|
||||||
|
end;
|
||||||
|
dcEvaluate:
|
||||||
|
begin
|
||||||
|
ASendCommand := TFPDSendEvaluateCommand.create(False, String(AParams[0].VAnsiString));
|
||||||
|
QueueCommand(ASendCommand);
|
||||||
|
tc := GetTickCount64;
|
||||||
|
repeat
|
||||||
|
sleep(5);
|
||||||
|
Application.ProcessMessages;
|
||||||
|
until (ASendCommand.Validity<>ddsRequested) or ((GetTickCount64-tc)>2000);
|
||||||
|
String(AParams[1].VPointer^) := ASendCommand.Message;
|
||||||
|
TDBGType(AParams[2].VPointer^) := nil;
|
||||||
|
ASendCommand.Free;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
result := false;
|
result := false;
|
||||||
|
Loading…
Reference in New Issue
Block a user