mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-09-05 09:00:25 +02:00
LazDebuggerFp: linux, fix running process-access in debug-thread (needed when accessing outer vars for nested procs, for which stack has not yet been evaluated)
git-svn-id: trunk@59696 -
This commit is contained in:
parent
abec187707
commit
d5cfafb571
@ -150,6 +150,9 @@ type
|
|||||||
procedure DoRelease; override;
|
procedure DoRelease; override;
|
||||||
procedure DoState(const OldState: TDBGState); override;
|
procedure DoState(const OldState: TDBGState); override;
|
||||||
{$ifdef linux}
|
{$ifdef linux}
|
||||||
|
protected
|
||||||
|
FCallStackEntryListThread: TDbgThread;
|
||||||
|
FCallStackEntryListFrameRequired: Integer;
|
||||||
procedure DoAddBreakLine;
|
procedure DoAddBreakLine;
|
||||||
procedure DoAddBreakLocation;
|
procedure DoAddBreakLocation;
|
||||||
procedure DoReadData;
|
procedure DoReadData;
|
||||||
@ -161,7 +164,7 @@ type
|
|||||||
procedure FreeBreakpoint(const ABreakpoint: TFpInternalBreakpoint);
|
procedure FreeBreakpoint(const ABreakpoint: TFpInternalBreakpoint);
|
||||||
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean;
|
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean;
|
||||||
function ReadAddress(const AAdress: TDbgPtr; out AData: TDBGPtr): Boolean;
|
function ReadAddress(const AAdress: TDbgPtr; out AData: TDBGPtr): Boolean;
|
||||||
procedure PrepareCallStackEntryList;
|
procedure PrepareCallStackEntryList(AFrameRequired: Integer = -1; AThread: TDbgThread = nil);
|
||||||
|
|
||||||
property DebugInfo: TDbgInfo read GetDebugInfo;
|
property DebugInfo: TDbgInfo read GetDebugInfo;
|
||||||
public
|
public
|
||||||
@ -308,6 +311,13 @@ type
|
|||||||
TFpDbgMemReader = class(TDbgMemReader)
|
TFpDbgMemReader = class(TDbgMemReader)
|
||||||
private
|
private
|
||||||
FFpDebugDebugger: TFpDebugDebugger;
|
FFpDebugDebugger: TFpDebugDebugger;
|
||||||
|
{$ifdef linux}
|
||||||
|
FRegNum: Cardinal;
|
||||||
|
FRegValue: TDbgPtr;
|
||||||
|
FRegContext: TFpDbgAddressContext;
|
||||||
|
FRegResult: Boolean;
|
||||||
|
procedure DoReadRegister;
|
||||||
|
{$endif linux}
|
||||||
protected
|
protected
|
||||||
function GetDbgProcess: TDbgProcess; override;
|
function GetDbgProcess: TDbgProcess; override;
|
||||||
function GetDbgThread(AContext: TFpDbgAddressContext): TDbgThread; override;
|
function GetDbgThread(AContext: TFpDbgAddressContext): TDbgThread; override;
|
||||||
@ -315,6 +325,8 @@ type
|
|||||||
constructor create(AFpDebugDebuger: TFpDebugDebugger);
|
constructor create(AFpDebugDebuger: TFpDebugDebugger);
|
||||||
function ReadMemory(AnAddress: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean; override;
|
function ReadMemory(AnAddress: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean; override;
|
||||||
function ReadMemoryEx(AnAddress, AnAddressSpace: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean; override;
|
function ReadMemoryEx(AnAddress, AnAddressSpace: TDbgPtr; ASize: Cardinal; ADest: Pointer): Boolean; override;
|
||||||
|
function ReadRegister(ARegNum: Cardinal; out AValue: TDbgPtr;
|
||||||
|
AContext: TFpDbgAddressContext): Boolean; override;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ TFpWaitForConsoleOutputThread }
|
{ TFpWaitForConsoleOutputThread }
|
||||||
@ -366,7 +378,7 @@ begin
|
|||||||
ThreadArray := TFpDebugDebugger(Debugger).FDbgController.CurrentProcess.GetThreadArray;
|
ThreadArray := TFpDebugDebugger(Debugger).FDbgController.CurrentProcess.GetThreadArray;
|
||||||
for i := 0 to high(ThreadArray) do
|
for i := 0 to high(ThreadArray) do
|
||||||
begin
|
begin
|
||||||
ThreadArray[i].PrepareCallStackEntryList(1);
|
TFpDebugDebugger(Debugger).PrepareCallStackEntryList(1, ThreadArray[i]);
|
||||||
CallStack := ThreadArray[i].CallStackEntryList;
|
CallStack := ThreadArray[i].CallStackEntryList;
|
||||||
if ThreadArray[i].ID = TFpDebugDebugger(Debugger).FDbgController.CurrentThread.ID then
|
if ThreadArray[i].ID = TFpDebugDebugger(Debugger).FDbgController.CurrentThread.ID then
|
||||||
State := 'stopped'
|
State := 'stopped'
|
||||||
@ -506,6 +518,13 @@ begin
|
|||||||
Result := FFpDebugDebugger.FDbgController.CurrentThread;
|
Result := FFpDebugDebugger.FDbgController.CurrentThread;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
{$ifdef linux}
|
||||||
|
procedure TFpDbgMemReader.DoReadRegister;
|
||||||
|
begin
|
||||||
|
FRegResult := inherited ReadRegister(FRegNum, FRegValue, FRegContext);
|
||||||
|
end;
|
||||||
|
{$endif linux}
|
||||||
|
|
||||||
constructor TFpDbgMemReader.create(AFpDebugDebuger: TFpDebugDebugger);
|
constructor TFpDbgMemReader.create(AFpDebugDebuger: TFpDebugDebugger);
|
||||||
begin
|
begin
|
||||||
FFpDebugDebugger := AFpDebugDebuger;
|
FFpDebugDebugger := AFpDebugDebuger;
|
||||||
@ -522,6 +541,20 @@ begin
|
|||||||
result := FFpDebugDebugger.ReadData(AnAddress, ASize, ADest^);
|
result := FFpDebugDebugger.ReadData(AnAddress, ASize, ADest^);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TFpDbgMemReader.ReadRegister(ARegNum: Cardinal; out AValue: TDbgPtr;
|
||||||
|
AContext: TFpDbgAddressContext): Boolean;
|
||||||
|
begin
|
||||||
|
{$ifdef linux}
|
||||||
|
FRegNum := ARegNum;
|
||||||
|
FRegContext := AContext;
|
||||||
|
FFpDebugDebugger.ExecuteInDebugThread(@DoReadRegister);
|
||||||
|
AValue := FRegValue;
|
||||||
|
result := FRegResult;
|
||||||
|
{$else linux}
|
||||||
|
result := inherited ReadRegister(ARegNum, AValue, AContext);
|
||||||
|
{$endif linux}
|
||||||
|
end;
|
||||||
|
|
||||||
{ TFPCallStackSupplier }
|
{ TFPCallStackSupplier }
|
||||||
|
|
||||||
function TFPCallStackSupplier.FpDebugger: TFpDebugDebugger;
|
function TFPCallStackSupplier.FpDebugger: TFpDebugDebugger;
|
||||||
@ -718,7 +751,7 @@ begin
|
|||||||
|
|
||||||
if CurStackFrame > 0 then
|
if CurStackFrame > 0 then
|
||||||
begin
|
begin
|
||||||
AController.CurrentThread.PrepareCallStackEntryList(CurStackFrame);
|
TFpDebugDebugger(Debugger).PrepareCallStackEntryList(CurStackFrame);
|
||||||
AFrame := AController.CurrentThread.CallStackEntryList[CurStackFrame];
|
AFrame := AController.CurrentThread.CallStackEntryList[CurStackFrame];
|
||||||
if AFrame = nil then
|
if AFrame = nil then
|
||||||
begin
|
begin
|
||||||
@ -1332,7 +1365,7 @@ begin
|
|||||||
|
|
||||||
if StackFrame > 0 then
|
if StackFrame > 0 then
|
||||||
begin
|
begin
|
||||||
FDbgController.CurrentThread.PrepareCallStackEntryList(StackFrame);
|
PrepareCallStackEntryList(StackFrame);
|
||||||
AFrame := FDbgController.CurrentThread.CallStackEntryList[StackFrame];
|
AFrame := FDbgController.CurrentThread.CallStackEntryList[StackFrame];
|
||||||
if AFrame = nil then
|
if AFrame = nil then
|
||||||
begin
|
begin
|
||||||
@ -1967,7 +2000,7 @@ end;
|
|||||||
|
|
||||||
procedure TFpDebugDebugger.DoPrepareCallStackEntryList;
|
procedure TFpDebugDebugger.DoPrepareCallStackEntryList;
|
||||||
begin
|
begin
|
||||||
FDbgController.CurrentThread.PrepareCallStackEntryList;
|
FCallStackEntryListThread.PrepareCallStackEntryList(FCallStackEntryListFrameRequired);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFpDebugDebugger.DoFreeBreakpoint;
|
procedure TFpDebugDebugger.DoFreeBreakpoint;
|
||||||
@ -2046,12 +2079,22 @@ begin
|
|||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
procedure TFpDebugDebugger.PrepareCallStackEntryList;
|
procedure TFpDebugDebugger.PrepareCallStackEntryList(AFrameRequired: Integer;
|
||||||
|
AThread: TDbgThread);
|
||||||
begin
|
begin
|
||||||
|
if AThread = nil then
|
||||||
|
AThread := FDbgController.CurrentThread;
|
||||||
|
// In case of linux, check if required, before handind to other thread
|
||||||
|
if (AFrameRequired >= 0) and
|
||||||
|
(AThread.CallStackEntryList <> nil) and
|
||||||
|
(AFrameRequired < AThread.CallStackEntryList.Count) then
|
||||||
|
exit;
|
||||||
{$ifdef linux}
|
{$ifdef linux}
|
||||||
|
FCallStackEntryListThread := AThread;
|
||||||
|
FCallStackEntryListFrameRequired := AFrameRequired;
|
||||||
ExecuteInDebugThread(@DoPrepareCallStackEntryList);
|
ExecuteInDebugThread(@DoPrepareCallStackEntryList);
|
||||||
{$else linux}
|
{$else linux}
|
||||||
FDbgController.CurrentThread.PrepareCallStackEntryList;
|
AThread.PrepareCallStackEntryList(AFrameRequired);
|
||||||
{$endif linux}
|
{$endif linux}
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user