mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-18 04:19:12 +02:00
First attempt: Name threads for debugging
This commit is contained in:
parent
1e5bed4b73
commit
db21b090a6
@ -211,11 +211,13 @@ type
|
|||||||
FStoreStepStartAddr, FStoreStepEndAddr: TDBGPtr;
|
FStoreStepStartAddr, FStoreStepEndAddr: TDBGPtr;
|
||||||
FStoreStepSrcLineNo: integer;
|
FStoreStepSrcLineNo: integer;
|
||||||
FStoreStepFuncAddr: TDBGPtr;
|
FStoreStepFuncAddr: TDBGPtr;
|
||||||
|
FThreadNum: Integer;
|
||||||
procedure LoadRegisterValues; virtual;
|
procedure LoadRegisterValues; virtual;
|
||||||
property Process: TDbgProcess read FProcess;
|
property Process: TDbgProcess read FProcess;
|
||||||
function ResetInstructionPointerAfterBreakpoint: boolean; virtual; abstract;
|
function ResetInstructionPointerAfterBreakpoint: boolean; virtual; abstract;
|
||||||
procedure DoBeforeBreakLocationMapChange; // A new location added / or a location removed => memory will change
|
procedure DoBeforeBreakLocationMapChange; // A new location added / or a location removed => memory will change
|
||||||
procedure ValidateRemovedBreakPointInfo;
|
procedure ValidateRemovedBreakPointInfo;
|
||||||
|
function GetName: String; virtual;
|
||||||
public
|
public
|
||||||
constructor Create(const AProcess: TDbgProcess; const AID: Integer; const AHandle: THandle); virtual;
|
constructor Create(const AProcess: TDbgProcess; const AID: Integer; const AHandle: THandle); virtual;
|
||||||
procedure DoBeforeProcessLoop;
|
procedure DoBeforeProcessLoop;
|
||||||
@ -260,6 +262,8 @@ type
|
|||||||
procedure StoreStepInfo(AnAddr: TDBGPtr = 0);
|
procedure StoreStepInfo(AnAddr: TDBGPtr = 0);
|
||||||
property ID: Integer read FID;
|
property ID: Integer read FID;
|
||||||
property Handle: THandle read FHandle;
|
property Handle: THandle read FHandle;
|
||||||
|
property Name: String read GetName;
|
||||||
|
property ThreadNum: Integer read FThreadNum;
|
||||||
property NextIsSingleStep: boolean read FNextIsSingleStep write FNextIsSingleStep;
|
property NextIsSingleStep: boolean read FNextIsSingleStep write FNextIsSingleStep;
|
||||||
property RegisterValueList: TDbgRegisterValueList read GetRegisterValueList;
|
property RegisterValueList: TDbgRegisterValueList read GetRegisterValueList;
|
||||||
property CallStackEntryList: TDbgCallstackEntryList read FCallStackEntryList;
|
property CallStackEntryList: TDbgCallstackEntryList read FCallStackEntryList;
|
||||||
@ -2910,6 +2914,11 @@ begin
|
|||||||
FPausedAtRemovedBreakPointState := rbUnknown;
|
FPausedAtRemovedBreakPointState := rbUnknown;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDbgThread.GetName: String;
|
||||||
|
begin
|
||||||
|
Result := 'Thread ' + IntToStr(FID);
|
||||||
|
end;
|
||||||
|
|
||||||
constructor TDbgThread.Create(const AProcess: TDbgProcess; const AID: Integer; const AHandle: THandle);
|
constructor TDbgThread.Create(const AProcess: TDbgProcess; const AID: Integer; const AHandle: THandle);
|
||||||
begin
|
begin
|
||||||
FID := AID;
|
FID := AID;
|
||||||
|
@ -122,6 +122,8 @@ uses
|
|||||||
FpDbgCommon, FpdMemoryTools, FpErrorMessages;
|
FpDbgCommon, FpdMemoryTools, FpErrorMessages;
|
||||||
|
|
||||||
type
|
type
|
||||||
|
PPWSTR = ^PWSTR;
|
||||||
|
TGetThreadDescription = function(threadHandle: THandle; name: PPWSTR): HResult; stdcall;
|
||||||
|
|
||||||
TFpWinCtxFlags = (cfSkip, cfControl, cfFull);
|
TFpWinCtxFlags = (cfSkip, cfControl, cfFull);
|
||||||
TFpContextChangeFlag = (ccfControl, ccfInteger);
|
TFpContextChangeFlag = (ccfControl, ccfInteger);
|
||||||
@ -143,6 +145,7 @@ type
|
|||||||
procedure LoadRegisterValues; override;
|
procedure LoadRegisterValues; override;
|
||||||
function GetFpThreadContext(var AStorage: TFpContext; out ACtxPtr: PFpContext; ACtxFlags: TFpWinCtxFlags): Boolean;
|
function GetFpThreadContext(var AStorage: TFpContext; out ACtxPtr: PFpContext; ACtxFlags: TFpWinCtxFlags): Boolean;
|
||||||
function SetFpThreadContext(ACtxPtr: PFpContext; ACtxFlags: TFpWinCtxFlags = cfSkip): Boolean;
|
function SetFpThreadContext(ACtxPtr: PFpContext; ACtxFlags: TFpWinCtxFlags = cfSkip): Boolean;
|
||||||
|
function GetName: String; override;
|
||||||
public
|
public
|
||||||
procedure Suspend;
|
procedure Suspend;
|
||||||
procedure SuspendForStepOverBreakPoint;
|
procedure SuspendForStepOverBreakPoint;
|
||||||
@ -237,6 +240,8 @@ implementation
|
|||||||
|
|
||||||
var
|
var
|
||||||
DBG_VERBOSE, DBG_WARNINGS, FPDBG_WINDOWS: PLazLoggerLogGroup;
|
DBG_VERBOSE, DBG_WARNINGS, FPDBG_WINDOWS: PLazLoggerLogGroup;
|
||||||
|
KernelHandle : THandle;
|
||||||
|
GetThreadDescription: TGetThreadDescription;
|
||||||
|
|
||||||
{$ifdef cpux86_64}
|
{$ifdef cpux86_64}
|
||||||
const
|
const
|
||||||
@ -1594,6 +1599,22 @@ begin
|
|||||||
DebugLn(DBG_WARNINGS and (not Result), ['Unable to set Context for ', ID, ': ', GetLastErrorText]);
|
DebugLn(DBG_WARNINGS and (not Result), ['Unable to set Context for ', ID, ': ', GetLastErrorText]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
function TDbgWinThread.GetName: String;
|
||||||
|
var
|
||||||
|
n: PWSTR;
|
||||||
|
begin
|
||||||
|
if Assigned(GetThreadDescription) then begin
|
||||||
|
if Succeeded(GetThreadDescription(Handle, @n)) then begin
|
||||||
|
Result := WideCharToString(n);
|
||||||
|
LocalFree(HLOCAL(n));
|
||||||
|
if Result = '' then
|
||||||
|
Result := inherited GetName;
|
||||||
|
end else
|
||||||
|
Result := inherited GetName;
|
||||||
|
end else
|
||||||
|
Result := inherited GetName;
|
||||||
|
end;
|
||||||
|
|
||||||
procedure TDbgWinThread.Suspend;
|
procedure TDbgWinThread.Suspend;
|
||||||
var
|
var
|
||||||
r: DWORD;
|
r: DWORD;
|
||||||
@ -1925,5 +1946,9 @@ initialization
|
|||||||
TX86AsmDecoder
|
TX86AsmDecoder
|
||||||
));
|
));
|
||||||
|
|
||||||
|
KernelHandle := GetModuleHandle(KernelDLL);
|
||||||
|
if KernelHandle <> 0 then
|
||||||
|
GetThreadDescription := TGetThreadDescription(GetProcAddress(KernelHandle, 'GetThreadDescription'));
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
|
@ -916,21 +916,21 @@ begin
|
|||||||
if Assigned(CallStack) and (CallStack.Count > 0) then begin
|
if Assigned(CallStack) and (CallStack.Count > 0) then begin
|
||||||
c := CallStack.Items[0];
|
c := CallStack.Items[0];
|
||||||
if t = nil then begin
|
if t = nil then begin
|
||||||
n := Threads.CurrentThreads.CreateEntry(c.AnAddress, nil, c.FunctionName, c.SourceFile, '', c.Line, FpThr.ID, 'Thread ' + IntToStr(FpThr.ID), 'paused');
|
n := Threads.CurrentThreads.CreateEntry(c.AnAddress, nil, c.FunctionName, c.SourceFile, '', c.Line, FpThr.ID, FpThr.Name, 'paused');
|
||||||
Threads.CurrentThreads.Add(n);
|
Threads.CurrentThreads.Add(n);
|
||||||
n.Free;
|
n.Free;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
t.Init(c.AnAddress, nil, c.FunctionName, c.SourceFile, '', c.Line, FpThr.ID, 'Thread ' + IntToStr(FpThr.ID), 'paused');
|
t.Init(c.AnAddress, nil, c.FunctionName, c.SourceFile, '', c.Line, FpThr.ID, FpThr.Name, 'paused');
|
||||||
end
|
end
|
||||||
else begin
|
else begin
|
||||||
if t = nil then begin
|
if t = nil then begin
|
||||||
n := Threads.CurrentThreads.CreateEntry(0, nil, '', '', '', 0, FpThr.ID, 'Thread ' + IntToStr(FpThr.ID), 'paused');
|
n := Threads.CurrentThreads.CreateEntry(0, nil, '', '', '', 0, FpThr.ID, FpThr.Name, 'paused');
|
||||||
Threads.CurrentThreads.Add(n);
|
Threads.CurrentThreads.Add(n);
|
||||||
n.Free;
|
n.Free;
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
t.Init(0, nil, '', '', '', 0, FpThr.ID, 'Thread ' + IntToStr(FpThr.ID), 'paused');
|
t.Init(0, nil, '', '', '', 0, FpThr.ID, FpThr.Name, 'paused');
|
||||||
end;
|
end;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user