mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-11-07 21:49:38 +01:00
GdbmiServerDebugger: Added stop on disconnect. Issue #0036076
git-svn-id: trunk@61886 -
This commit is contained in:
parent
eea7a8300f
commit
e35fc25db7
@ -942,6 +942,9 @@ type
|
|||||||
function GetCommands: TDBGCommands; override;
|
function GetCommands: TDBGCommands; override;
|
||||||
function GetTargetWidth: Byte; override;
|
function GetTargetWidth: Byte; override;
|
||||||
procedure InterruptTarget; virtual;
|
procedure InterruptTarget; virtual;
|
||||||
|
procedure ProcessLineWhileRunning(const ALine: String; AnInLogWarning: boolean;
|
||||||
|
var AHandled, AForceStop: Boolean; var AStoppedParams: String; var AResult: TGDBMIExecResult); virtual;
|
||||||
|
|
||||||
function ParseInitialization: Boolean; virtual;
|
function ParseInitialization: Boolean; virtual;
|
||||||
function CreateCommandInit: TGDBMIDebuggerCommandInitDebugger; virtual;
|
function CreateCommandInit: TGDBMIDebuggerCommandInitDebugger; virtual;
|
||||||
function CreateCommandStartDebugging(AContinueCommand: TGDBMIDebuggerCommand): TGDBMIDebuggerCommandStartDebugging; virtual;
|
function CreateCommandStartDebugging(AContinueCommand: TGDBMIDebuggerCommand): TGDBMIDebuggerCommandStartDebugging; virtual;
|
||||||
@ -2925,22 +2928,19 @@ var
|
|||||||
Delete(Warning, 1, 2);
|
Delete(Warning, 1, 2);
|
||||||
if Copy(Warning, Length(Warning) - 2, 3) = '\n"' then
|
if Copy(Warning, Length(Warning) - 2, 3) = '\n"' then
|
||||||
Delete(Warning, Length(Warning) - 2, 3);
|
Delete(Warning, Length(Warning) - 2, 3);
|
||||||
if LowerCase(Copy(Warning, 1, Length(LogWarning))) = LogWarning then
|
if InLogWarning then
|
||||||
begin
|
begin
|
||||||
InLogWarning := True;
|
|
||||||
Delete(Warning, 1, Length(LogWarning));
|
|
||||||
Warning := MakePrintable(UnEscapeBackslashed(Trim(Warning), [uefOctal, uefTab, uefNewLine]));
|
Warning := MakePrintable(UnEscapeBackslashed(Trim(Warning), [uefOctal, uefTab, uefNewLine]));
|
||||||
DoDbgEvent(ecOutput, etOutputDebugString, Format(gdbmiEventLogDebugOutput, [Warning]));
|
DoDbgEvent(ecOutput, etOutputDebugString, Format(gdbmiEventLogDebugOutput, [Warning]));
|
||||||
end;
|
end;
|
||||||
if InLogWarning then
|
if InLogWarning then
|
||||||
FLogWarnings := FLogWarnings + Warning + LineEnding;
|
FLogWarnings := FLogWarnings + Warning + LineEnding;
|
||||||
if Line = '&"\n"' then
|
|
||||||
InLogWarning := False;
|
|
||||||
|
|
||||||
if FTheDebugger.CheckForInternalError(Line, '') then begin
|
if FTheDebugger.CheckForInternalError(Line, '') then begin
|
||||||
AResult.State := dsStop;
|
AResult.State := dsStop;
|
||||||
ForceStop := True;
|
ForceStop := True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
(*
|
(*
|
||||||
<< TCmdLineDebugger.ReadLn "&"Warning:\n""
|
<< TCmdLineDebugger.ReadLn "&"Warning:\n""
|
||||||
<< TCmdLineDebugger.ReadLn "&"Cannot insert breakpoint 11.\n""
|
<< TCmdLineDebugger.ReadLn "&"Cannot insert breakpoint 11.\n""
|
||||||
@ -2954,12 +2954,35 @@ var
|
|||||||
*)
|
*)
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure CheckMultiLineLogWarning(const Line: String; var AInLogWarning: Boolean);
|
||||||
|
const
|
||||||
|
LogWarning = 'warning:';
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
if (Line = '') or (Line[1] <> '&') then
|
||||||
|
InLogWarning := False;
|
||||||
|
if Length(Line) < Length(LogWarning) then
|
||||||
|
exit;
|
||||||
|
|
||||||
|
i := 1;
|
||||||
|
if (Line[1] = '&') and (Line[2] = '"') then
|
||||||
|
i := 3;
|
||||||
|
if LowerCase(Copy(Line, i, Length(LogWarning))) = LogWarning then
|
||||||
|
AInLogWarning := True;
|
||||||
|
//Delete(Line, 1, Length(LogWarning));
|
||||||
|
|
||||||
|
if Line = '&"\n"' then
|
||||||
|
InLogWarning := False;
|
||||||
|
end;
|
||||||
|
|
||||||
var
|
var
|
||||||
S, s2: String;
|
S, s2: String;
|
||||||
idx: Integer;
|
idx: Integer;
|
||||||
{$IFDEF DBG_ASYNC_WAIT}
|
{$IFDEF DBG_ASYNC_WAIT}
|
||||||
GotPrompt: integer;
|
GotPrompt: integer;
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
LineHandled: Boolean;
|
||||||
begin
|
begin
|
||||||
{$IFDEF DBG_ASYNC_WAIT}
|
{$IFDEF DBG_ASYNC_WAIT}
|
||||||
GotPrompt := 0;
|
GotPrompt := 0;
|
||||||
@ -3013,8 +3036,11 @@ begin
|
|||||||
|
|
||||||
while S <> '' do
|
while S <> '' do
|
||||||
begin
|
begin
|
||||||
if S[1] <> '&' then
|
CheckMultiLineLogWarning(S, InLogWarning);
|
||||||
InLogWarning := False;
|
|
||||||
|
LineHandled := False;
|
||||||
|
FTheDebugger.ProcessLineWhileRunning(S, InLogWarning, LineHandled, ForceStop, AStoppedParams, AResult);
|
||||||
|
if not LineHandled then begin
|
||||||
case S[1] of
|
case S[1] of
|
||||||
'^': DoResultRecord(S);
|
'^': DoResultRecord(S);
|
||||||
'~': DoConsoleStream(S);
|
'~': DoConsoleStream(S);
|
||||||
@ -3039,6 +3065,7 @@ begin
|
|||||||
DebugLn(DBG_VERBOSE, '[DBGTGT] ', S);
|
DebugLn(DBG_VERBOSE, '[DBGTGT] ', S);
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
if not (tfPidDetectionDone in FTheDebugger.FTargetInfo.TargetFlags) then begin
|
if not (tfPidDetectionDone in FTheDebugger.FTargetInfo.TargetFlags) then begin
|
||||||
s2 := GetPart(['Switching to process '], [' local', ']'], S, True);
|
s2 := GetPart(['Switching to process '], [' local', ']'], S, True);
|
||||||
@ -9346,6 +9373,13 @@ begin
|
|||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGDBMIDebuggerBase.ProcessLineWhileRunning(const ALine: String;
|
||||||
|
AnInLogWarning: boolean; var AHandled, AForceStop: Boolean;
|
||||||
|
var AStoppedParams: String; var AResult: TGDBMIExecResult);
|
||||||
|
begin
|
||||||
|
//
|
||||||
|
end;
|
||||||
|
|
||||||
function TGDBMIDebuggerBase.ParseInitialization: Boolean;
|
function TGDBMIDebuggerBase.ParseInitialization: Boolean;
|
||||||
var
|
var
|
||||||
Line, S: String;
|
Line, S: String;
|
||||||
|
|||||||
@ -47,6 +47,9 @@ type
|
|||||||
function CreateCommandInit: TGDBMIDebuggerCommandInitDebugger; override;
|
function CreateCommandInit: TGDBMIDebuggerCommandInitDebugger; override;
|
||||||
function CreateCommandStartDebugging(AContinueCommand: TGDBMIDebuggerCommand): TGDBMIDebuggerCommandStartDebugging; override;
|
function CreateCommandStartDebugging(AContinueCommand: TGDBMIDebuggerCommand): TGDBMIDebuggerCommandStartDebugging; override;
|
||||||
procedure InterruptTarget; override;
|
procedure InterruptTarget; override;
|
||||||
|
procedure ProcessLineWhileRunning(const ALine: String; AnInLogWarning: boolean;
|
||||||
|
var AHandled, AForceStop: Boolean; var AStoppedParams: String;
|
||||||
|
var AResult: TGDBMIExecResult); override;
|
||||||
procedure StopInitProc;
|
procedure StopInitProc;
|
||||||
public
|
public
|
||||||
InitProc: TProcessUTF8;
|
InitProc: TProcessUTF8;
|
||||||
@ -333,6 +336,29 @@ begin
|
|||||||
inherited InterruptTarget;
|
inherited InterruptTarget;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
procedure TGDBMIServerDebugger.ProcessLineWhileRunning(const ALine: String;
|
||||||
|
AnInLogWarning: boolean; var AHandled, AForceStop: Boolean;
|
||||||
|
var AStoppedParams: String; var AResult: TGDBMIExecResult);
|
||||||
|
const
|
||||||
|
LogDisconnect = 'remote connection closed';
|
||||||
|
var
|
||||||
|
i: Integer;
|
||||||
|
begin
|
||||||
|
inherited ProcessLineWhileRunning(ALine, AnInLogWarning, AHandled, AForceStop,
|
||||||
|
AStoppedParams, AResult);
|
||||||
|
|
||||||
|
// If remote connection terminated then this debugging session is over
|
||||||
|
i := 1;
|
||||||
|
if (ALine[1] = '&') and (ALine[2] = '"') then
|
||||||
|
i := 3;
|
||||||
|
if (not AnInLogWarning) and (LowerCase(Copy(ALine, i, Length(LogDisconnect))) = LogDisconnect) then begin
|
||||||
|
AHandled := True;
|
||||||
|
AForceStop := True;
|
||||||
|
AStoppedParams := '';
|
||||||
|
SetState(dsStop);
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TGDBMIServerDebugger.StopInitProc;
|
procedure TGDBMIServerDebugger.StopInitProc;
|
||||||
begin
|
begin
|
||||||
if not Assigned(InitProc) then Exit;
|
if not Assigned(InitProc) then Exit;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user