mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-06-10 12:38:12 +02:00
GdbmiDebugger, Windows: Improved speed. Wait for gdb responses, with less sleep calls (increase cpu usage) / Option to disable for laptops/etc.
git-svn-id: trunk@61117 -
This commit is contained in:
parent
29735fe548
commit
a08b1f9560
@ -55,6 +55,9 @@ type
|
|||||||
|
|
||||||
TCmdLineDebugger = class(TDebuggerIntf)
|
TCmdLineDebugger = class(TDebuggerIntf)
|
||||||
private
|
private
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
FAggressiveWaitTime: Cardinal;
|
||||||
|
{$EndIf}
|
||||||
FDbgProcess: TProcessUTF8; // The process used to call the debugger
|
FDbgProcess: TProcessUTF8; // The process used to call the debugger
|
||||||
FLineEnds: TStringDynArray; // List of strings considered as lineends
|
FLineEnds: TStringDynArray; // List of strings considered as lineends
|
||||||
FOutputBuf: String;
|
FOutputBuf: String;
|
||||||
@ -89,6 +92,9 @@ type
|
|||||||
public
|
public
|
||||||
property DebugProcess: TProcessUTF8 read FDbgProcess;
|
property DebugProcess: TProcessUTF8 read FDbgProcess;
|
||||||
property DebugProcessRunning: Boolean read GetDebugProcessRunning;
|
property DebugProcessRunning: Boolean read GetDebugProcessRunning;
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
property AggressiveWaitTime: Cardinal read FAggressiveWaitTime write FAggressiveWaitTime;
|
||||||
|
{$EndIf}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -222,15 +228,17 @@ var
|
|||||||
TotalBytesAvailable: dword;
|
TotalBytesAvailable: dword;
|
||||||
R: LongBool;
|
R: LongBool;
|
||||||
n: integer;
|
n: integer;
|
||||||
Step: Integer;
|
Step, FullTimeOut: Integer;
|
||||||
t, t2, t3: DWord;
|
t, t2, t3: QWord;
|
||||||
CurCallStamp: Int64;
|
CurCallStamp: Int64;
|
||||||
begin
|
begin
|
||||||
Result := 0;
|
Result := 0;
|
||||||
CurCallStamp := FReadLineCallStamp;
|
CurCallStamp := FReadLineCallStamp;
|
||||||
Step:=IDLE_STEP_COUNT-1;
|
Step:=IDLE_STEP_COUNT-1;
|
||||||
if ATimeOut > 0
|
//if ATimeOut > 0
|
||||||
then t := GetTickCount;
|
//then
|
||||||
|
t := GetTickCount64;
|
||||||
|
FullTimeOut := ATimeOut;
|
||||||
|
|
||||||
while Result=0 do
|
while Result=0 do
|
||||||
begin
|
begin
|
||||||
@ -255,37 +263,54 @@ begin
|
|||||||
if CurCallStamp <> FReadLineCallStamp then
|
if CurCallStamp <> FReadLineCallStamp then
|
||||||
exit;
|
exit;
|
||||||
|
|
||||||
if (ATimeOut > 0) then begin
|
t2 := GetTickCount64;
|
||||||
t2 := GetTickCount;
|
if t2 < t
|
||||||
if t2 < t
|
then t3 := t2 + (High(t) - t)
|
||||||
then t3 := t2 + (High(t) - t)
|
else t3 := t2 - t;
|
||||||
else t3 := t2 - t;
|
|
||||||
if (t3 >= ATimeOut)
|
if (FullTimeOut > 0) then begin
|
||||||
|
if (t3 >= FullTimeOut)
|
||||||
then begin
|
then begin
|
||||||
ATimeOut := 0;
|
ATimeOut := 0;
|
||||||
break;
|
break;
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
ATimeOut := ATimeOut - t3;
|
ATimeOut := FullTimeOut - t3;
|
||||||
t := t2;
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
ProcessWhileWaitForHandles;
|
{$IFdef MSWindows}
|
||||||
// process messages
|
if (t3 > FAggressiveWaitTime) or (FAggressiveWaitTime = 0) then begin
|
||||||
inc(Step);
|
{$EndIf}
|
||||||
if Step=IDLE_STEP_COUNT then begin
|
ProcessWhileWaitForHandles;
|
||||||
Step:=0;
|
// process messages
|
||||||
Application.Idle(false);
|
inc(Step);
|
||||||
|
if Step=IDLE_STEP_COUNT then begin
|
||||||
|
Step:=0;
|
||||||
|
Application.Idle(false);
|
||||||
|
end;
|
||||||
|
try
|
||||||
|
Application.ProcessMessages;
|
||||||
|
except
|
||||||
|
Application.HandleException(Application);
|
||||||
|
end;
|
||||||
|
if Application.Terminated or not DebugProcessRunning then Break;
|
||||||
|
// sleep a bit
|
||||||
|
Sleep(10);
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if t3 div 64 > Step then begin;
|
||||||
|
ProcessWhileWaitForHandles;
|
||||||
|
inc(Step);
|
||||||
|
try
|
||||||
|
Application.ProcessMessages;
|
||||||
|
except
|
||||||
|
Application.HandleException(Application);
|
||||||
|
end;
|
||||||
end;
|
end;
|
||||||
try
|
{$EndIf}
|
||||||
Application.ProcessMessages;
|
|
||||||
except
|
|
||||||
Application.HandleException(Application);
|
|
||||||
end;
|
|
||||||
if Application.Terminated or not DebugProcessRunning then Break;
|
|
||||||
// sleep a bit
|
|
||||||
Sleep(10);
|
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
{$ELSE win32}
|
{$ELSE win32}
|
||||||
@ -351,6 +376,7 @@ begin
|
|||||||
{$endif windows}
|
{$endif windows}
|
||||||
FDbgProcess.ShowWindow := swoNone;
|
FDbgProcess.ShowWindow := swoNone;
|
||||||
FDbgProcess.Environment:=DebuggerEnvironment;
|
FDbgProcess.Environment:=DebuggerEnvironment;
|
||||||
|
FDbgProcess.PipeBufferSize:=64*1024;
|
||||||
except
|
except
|
||||||
FreeAndNil(FDbgProcess);
|
FreeAndNil(FDbgProcess);
|
||||||
end;
|
end;
|
||||||
@ -428,11 +454,12 @@ end;
|
|||||||
function TCmdLineDebugger.ReadLine(const APeek: Boolean; ATimeOut: Integer = -1): String;
|
function TCmdLineDebugger.ReadLine(const APeek: Boolean; ATimeOut: Integer = -1): String;
|
||||||
|
|
||||||
function ReadData(const AStream: TStream; var ABuffer: String): Integer;
|
function ReadData(const AStream: TStream; var ABuffer: String): Integer;
|
||||||
|
const READ_LEN = 32*1024;
|
||||||
var
|
var
|
||||||
S: String;
|
S: String;
|
||||||
begin
|
begin
|
||||||
SetLength(S, 8192);
|
SetLength(S, READ_LEN);
|
||||||
Result := AStream.Read(S[1], 8192);
|
Result := AStream.Read(S[1], READ_LEN);
|
||||||
if Result > 0
|
if Result > 0
|
||||||
then begin
|
then begin
|
||||||
SetLength(S, Result);
|
SetLength(S, Result);
|
||||||
|
@ -187,6 +187,10 @@ type
|
|||||||
FWarnOnSetBreakpointError: TGDBMIWarnOnSetBreakpointError;
|
FWarnOnSetBreakpointError: TGDBMIWarnOnSetBreakpointError;
|
||||||
FWarnOnInternalError: TGDBMIDebuggerShowWarning;
|
FWarnOnInternalError: TGDBMIDebuggerShowWarning;
|
||||||
FWarnOnTimeOut: Boolean;
|
FWarnOnTimeOut: Boolean;
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
FAggressiveWaitTime: Cardinal;
|
||||||
|
procedure SetAggressiveWaitTime(AValue: Cardinal);
|
||||||
|
{$EndIf}
|
||||||
procedure SetGdbLocalsValueMemLimit(AValue: Integer);
|
procedure SetGdbLocalsValueMemLimit(AValue: Integer);
|
||||||
procedure SetMaxDisplayLengthForStaticArray(AValue: Integer);
|
procedure SetMaxDisplayLengthForStaticArray(AValue: Integer);
|
||||||
procedure SetMaxDisplayLengthForString(AValue: Integer);
|
procedure SetMaxDisplayLengthForString(AValue: Integer);
|
||||||
@ -233,6 +237,9 @@ type
|
|||||||
property FixStackFrameForFpcAssert: Boolean read FFixStackFrameForFpcAssert
|
property FixStackFrameForFpcAssert: Boolean read FFixStackFrameForFpcAssert
|
||||||
write FFixStackFrameForFpcAssert default True;
|
write FFixStackFrameForFpcAssert default True;
|
||||||
property FixIncorrectStepOver: Boolean read FFixIncorrectStepOver write FFixIncorrectStepOver default False;
|
property FixIncorrectStepOver: Boolean read FFixIncorrectStepOver write FFixIncorrectStepOver default False;
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
property AggressiveWaitTime: Cardinal read FAggressiveWaitTime write SetAggressiveWaitTime default 100;
|
||||||
|
{$EndIf}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TGDBMIDebuggerProperties = class(TGDBMIDebuggerPropertiesBase)
|
TGDBMIDebuggerProperties = class(TGDBMIDebuggerPropertiesBase)
|
||||||
@ -262,6 +269,9 @@ type
|
|||||||
property DisableStartupShell;
|
property DisableStartupShell;
|
||||||
property FixStackFrameForFpcAssert;
|
property FixStackFrameForFpcAssert;
|
||||||
property FixIncorrectStepOver;
|
property FixIncorrectStepOver;
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
property AggressiveWaitTime;
|
||||||
|
{$EndIf}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TGDBMIDebuggerBase = class;
|
TGDBMIDebuggerBase = class;
|
||||||
@ -7614,6 +7624,16 @@ begin
|
|||||||
FGdbLocalsValueMemLimit := AValue;
|
FGdbLocalsValueMemLimit := AValue;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
procedure TGDBMIDebuggerPropertiesBase.SetAggressiveWaitTime(AValue: Cardinal);
|
||||||
|
begin
|
||||||
|
if AValue > 500 then
|
||||||
|
AValue := 500;
|
||||||
|
if FAggressiveWaitTime = AValue then Exit;
|
||||||
|
FAggressiveWaitTime := AValue;
|
||||||
|
end;
|
||||||
|
{$EndIf}
|
||||||
|
|
||||||
procedure TGDBMIDebuggerPropertiesBase.SetMaxLocalsLengthForStaticArray(AValue: Integer);
|
procedure TGDBMIDebuggerPropertiesBase.SetMaxLocalsLengthForStaticArray(AValue: Integer);
|
||||||
begin
|
begin
|
||||||
if FMaxLocalsLengthForStaticArray = AValue then Exit;
|
if FMaxLocalsLengthForStaticArray = AValue then Exit;
|
||||||
@ -7658,6 +7678,9 @@ begin
|
|||||||
FDisableStartupShell := False;
|
FDisableStartupShell := False;
|
||||||
FFixStackFrameForFpcAssert := True;
|
FFixStackFrameForFpcAssert := True;
|
||||||
FFixIncorrectStepOver := False;
|
FFixIncorrectStepOver := False;
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
FAggressiveWaitTime := 100;
|
||||||
|
{$EndIf}
|
||||||
inherited;
|
inherited;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -7689,6 +7712,9 @@ begin
|
|||||||
FDisableStartupShell := TGDBMIDebuggerPropertiesBase(Source).FDisableStartupShell;
|
FDisableStartupShell := TGDBMIDebuggerPropertiesBase(Source).FDisableStartupShell;
|
||||||
FFixStackFrameForFpcAssert := TGDBMIDebuggerPropertiesBase(Source).FFixStackFrameForFpcAssert;
|
FFixStackFrameForFpcAssert := TGDBMIDebuggerPropertiesBase(Source).FFixStackFrameForFpcAssert;
|
||||||
FFixIncorrectStepOver := TGDBMIDebuggerPropertiesBase(Source).FFixIncorrectStepOver;
|
FFixIncorrectStepOver := TGDBMIDebuggerPropertiesBase(Source).FFixIncorrectStepOver;
|
||||||
|
{$IFdef MSWindows}
|
||||||
|
FAggressiveWaitTime := TGDBMIDebuggerPropertiesBase(Source).FAggressiveWaitTime;
|
||||||
|
{$EndIf}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -9105,6 +9131,9 @@ begin
|
|||||||
{$ifNdef MSWindows}
|
{$ifNdef MSWindows}
|
||||||
DebuggerEnvironment.Values['LANG'] := 'C'; // try to prevent GDB from using localized messages
|
DebuggerEnvironment.Values['LANG'] := 'C'; // try to prevent GDB from using localized messages
|
||||||
{$ENDIF}
|
{$ENDIF}
|
||||||
|
{$ifdef MSWindows}
|
||||||
|
AggressiveWaitTime := TGDBMIDebuggerPropertiesBase(GetProperties).AggressiveWaitTime;
|
||||||
|
{$ENDIF}
|
||||||
|
|
||||||
if CreateDebugProcess(Options)
|
if CreateDebugProcess(Options)
|
||||||
then begin
|
then begin
|
||||||
|
Loading…
Reference in New Issue
Block a user