mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 23:59:27 +02:00
FpDebug: Refactor OsDbgClasses => move as field to DbgController and DbgProcess / Prepare for target specific classes
git-svn-id: trunk@62747 -
This commit is contained in:
parent
676c17f1cf
commit
2e1bd02f2d
@ -48,7 +48,12 @@ uses
|
||||
FPDLoop,
|
||||
FpDbgClasses,
|
||||
FpDbgDwarfConst,
|
||||
FpDbgDwarf;
|
||||
FpDbgDwarf
|
||||
// The debug classes auto register with initialization, so include them somewhere
|
||||
// The $ifdef below will not work for cross debugging of a remote target
|
||||
{$ifdef DARWIN}, FpDbgDarwinClasses,{$endif}
|
||||
{$ifdef LINUX}, FpDbgLinuxClasses,{$endif}
|
||||
;
|
||||
|
||||
{$ifdef windows}
|
||||
function CtrlCHandler(CtrlType: Cardinal): BOOL; stdcall;
|
||||
|
@ -87,6 +87,7 @@ type
|
||||
TDbgThread = class;
|
||||
TFPDThreadArray = array of TDbgThread;
|
||||
TDbgLibrary = class;
|
||||
TOSDbgClasses = class;
|
||||
|
||||
TDbgCallstackEntry = class
|
||||
private
|
||||
@ -353,6 +354,7 @@ type
|
||||
FProcess: TDbgProcess;
|
||||
FSymbolTableInfo: TFpSymbolInfo;
|
||||
FLoaderList: TDbgImageLoaderList;
|
||||
function GetOSDbgClasses: TOSDbgClasses;
|
||||
function GetPointerSize: Integer;
|
||||
|
||||
protected
|
||||
@ -372,6 +374,7 @@ type
|
||||
procedure LoadInfo; virtual;
|
||||
|
||||
property Process: TDbgProcess read FProcess;
|
||||
property OSDbgClasses: TOSDbgClasses read GetOSDbgClasses;
|
||||
property DbgInfo: TDbgInfo read FDbgInfo;
|
||||
property SymbolTableInfo: TFpSymbolInfo read FSymbolTableInfo;
|
||||
property Mode: TFPDMode read FMode;
|
||||
@ -433,6 +436,7 @@ type
|
||||
FExitCode: DWord;
|
||||
FGotExitProcess: Boolean;
|
||||
FLastLibraryUnloaded: TDbgLibrary;
|
||||
FOSDbgClasses: TOSDbgClasses;
|
||||
FProcessID: Integer;
|
||||
FThreadID: Integer;
|
||||
FWatchPointData: TFpWatchPointData;
|
||||
@ -481,9 +485,11 @@ type
|
||||
|
||||
function CreateWatchPointData: TFpWatchPointData; virtual;
|
||||
public
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags): TDbgProcess; virtual;
|
||||
class function AttachToInstance(AFileName: string; APid: Integer): TDbgProcess; virtual;
|
||||
constructor Create(const AFileName: string; const AProcessID, AThreadID: Integer); virtual;
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings;
|
||||
AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags;
|
||||
AnOsClasses: TOSDbgClasses): TDbgProcess; virtual;
|
||||
class function AttachToInstance(AFileName: string; APid: Integer; AnOsClasses: TOSDbgClasses): TDbgProcess; virtual;
|
||||
constructor Create(const AFileName: string; const AProcessID, AThreadID: Integer; AnOsClasses: TOSDbgClasses); virtual;
|
||||
destructor Destroy; override;
|
||||
function AddInternalBreak(const ALocation: TDBGPtr): TFpInternalBreakpoint; overload;
|
||||
function AddInternalBreak(const ALocation: TDBGPtrArray): TFpInternalBreakpoint; overload;
|
||||
@ -545,6 +551,7 @@ public
|
||||
procedure TerminateProcess; virtual; abstract;
|
||||
function Detach(AProcess: TDbgProcess; AThread: TDbgThread): boolean; virtual;
|
||||
|
||||
property OSDbgClasses: TOSDbgClasses read FOSDbgClasses;
|
||||
property Handle: THandle read GetHandle;
|
||||
property Name: String read FFileName write SetFileName;
|
||||
property ProcessID: integer read FProcessID;
|
||||
@ -595,13 +602,23 @@ public
|
||||
property Owner[AnIndex: Integer]: Pointer read GetOwner;
|
||||
end;
|
||||
|
||||
{ TOSDbgClasses }
|
||||
|
||||
TOSDbgClasses = class
|
||||
public
|
||||
DbgProcessClass : TDbgProcessClass;
|
||||
DbgThreadClass : TDbgThreadClass;
|
||||
DbgDisassemblerClass : TDbgDisassemblerClass;
|
||||
DbgBreakpointClass : TFpInternalBreakpointClass;
|
||||
DbgWatchpointClass : TFpInternalWatchpointClass;
|
||||
DbgProcessClass : TDbgProcessClass;
|
||||
DbgDisassemblerClass : TDbgDisassemblerClass;
|
||||
constructor Create(
|
||||
ADbgProcessClass: TDbgProcessClass;
|
||||
ADbgThreadClass: TDbgThreadClass;
|
||||
ADbgDisassemblerClass: TDbgDisassemblerClass;
|
||||
ADbgBreakpointClass: TFpInternalBreakpointClass = nil;
|
||||
ADbgWatchpointClass: TFpInternalWatchpointClass = nil
|
||||
);
|
||||
function Equals(AnOther: TOSDbgClasses): Boolean;
|
||||
end;
|
||||
|
||||
var
|
||||
@ -615,7 +632,9 @@ const
|
||||
DBGPTRSIZE: array[TFPDMode] of Integer = (4, 8);
|
||||
FPDEventNames: array[TFPDEvent] of string = ('deExitProcess', 'deFinishedStep', 'deBreakpoint', 'deException', 'deCreateProcess', 'deLoadLibrary', 'deUnloadLibrary', 'deInternalContinue');
|
||||
|
||||
function OSDbgClasses: TOSDbgClasses;
|
||||
function GetDbgProcessClass: TOSDbgClasses;
|
||||
|
||||
procedure RegisterDbgOsClasses(ADbgOsClasses: TOSDbgClasses);
|
||||
|
||||
implementation
|
||||
|
||||
@ -632,30 +651,65 @@ uses
|
||||
FpDbgLinuxClasses;
|
||||
{$endif}
|
||||
|
||||
type
|
||||
TOSDbgClassesList = class(specialize TFPGObjectList<TOSDbgClasses>)
|
||||
public
|
||||
function Find(a: TOSDbgClasses): Integer;
|
||||
end;
|
||||
var
|
||||
GOSDbgClasses : TOSDbgClasses;
|
||||
DBG_VERBOSE, DBG_WARNINGS, DBG_BREAKPOINTS, FPDBG_COMMANDS: PLazLoggerLogGroup;
|
||||
RegisteredDbgProcessClasses: TOSDbgClassesList;
|
||||
|
||||
function OSDbgClasses: TOSDbgClasses;
|
||||
function GetDbgProcessClass: TOSDbgClasses;
|
||||
begin
|
||||
if GOSDbgClasses=nil then
|
||||
begin
|
||||
GOSDbgClasses := TOSDbgClasses.create;
|
||||
GOSDbgClasses.DbgThreadClass := TDbgThread;
|
||||
GOSDbgClasses.DbgBreakpointClass := TFpInternalBreakpoint;
|
||||
GOSDbgClasses.DbgWatchpointClass := TFpInternalWatchpoint;
|
||||
GOSDbgClasses.DbgProcessClass := TDbgProcess;
|
||||
{$ifdef windows}
|
||||
RegisterDbgClasses;
|
||||
{$endif windows}
|
||||
{$ifdef darwin}
|
||||
RegisterDbgClasses;
|
||||
{$endif darwin}
|
||||
{$ifdef linux}
|
||||
RegisterDbgClasses;
|
||||
{$endif linux}
|
||||
end;
|
||||
result := GOSDbgClasses;
|
||||
Result := nil;
|
||||
if RegisteredDbgProcessClasses.Count = 1 then
|
||||
Result := RegisteredDbgProcessClasses[0];
|
||||
end;
|
||||
|
||||
procedure RegisterDbgOsClasses(ADbgOsClasses: TOSDbgClasses);
|
||||
begin
|
||||
if not Assigned(RegisteredDbgProcessClasses) then
|
||||
RegisteredDbgProcessClasses := TOSDbgClassesList.Create;
|
||||
if RegisteredDbgProcessClasses.Find(ADbgOsClasses) < 0 then // TODO: by content
|
||||
RegisteredDbgProcessClasses.Add(ADbgOsClasses);
|
||||
end;
|
||||
|
||||
{ TOSDbgClasses }
|
||||
|
||||
constructor TOSDbgClasses.Create(ADbgProcessClass: TDbgProcessClass;
|
||||
ADbgThreadClass: TDbgThreadClass;
|
||||
ADbgDisassemblerClass: TDbgDisassemblerClass;
|
||||
ADbgBreakpointClass: TFpInternalBreakpointClass;
|
||||
ADbgWatchpointClass: TFpInternalWatchpointClass);
|
||||
begin
|
||||
DbgProcessClass := ADbgProcessClass;
|
||||
DbgThreadClass := ADbgThreadClass;
|
||||
DbgDisassemblerClass := ADbgDisassemblerClass;
|
||||
DbgBreakpointClass := ADbgBreakpointClass;
|
||||
DbgWatchpointClass := ADbgWatchpointClass;
|
||||
if DbgBreakpointClass = nil then
|
||||
DbgBreakpointClass := TFpInternalBreakpoint;
|
||||
if DbgWatchpointClass = nil then
|
||||
DbgWatchpointClass := TFpInternalWatchpoint;
|
||||
end;
|
||||
|
||||
function TOSDbgClasses.Equals(AnOther: TOSDbgClasses): Boolean;
|
||||
begin
|
||||
Result := (DbgThreadClass = AnOther.DbgThreadClass) and
|
||||
(DbgBreakpointClass = AnOther.DbgBreakpointClass) and
|
||||
(DbgWatchpointClass = AnOther.DbgWatchpointClass) and
|
||||
(DbgProcessClass = AnOther.DbgProcessClass) and
|
||||
(DbgDisassemblerClass = AnOther.DbgDisassemblerClass);
|
||||
end;
|
||||
|
||||
{ TOSDbgClassesList }
|
||||
|
||||
function TOSDbgClassesList.Find(a: TOSDbgClasses): Integer;
|
||||
begin
|
||||
Result := Count - 1;
|
||||
while (Result >= 0) and not (Items[Result].Equals(a)) do
|
||||
dec(Result);
|
||||
end;
|
||||
|
||||
{ TThreadMapEnumerator }
|
||||
@ -1331,6 +1385,11 @@ begin
|
||||
Result := PTRSZ[FMode];
|
||||
end;
|
||||
|
||||
function TDbgInstance.GetOSDbgClasses: TOSDbgClasses;
|
||||
begin
|
||||
Result := FProcess.OSDbgClasses;
|
||||
end;
|
||||
|
||||
procedure TDbgInstance.InitializeLoaders;
|
||||
begin
|
||||
// Do nothing;
|
||||
@ -1394,7 +1453,7 @@ begin
|
||||
end;
|
||||
|
||||
constructor TDbgProcess.Create(const AFileName: string; const AProcessID,
|
||||
AThreadID: Integer);
|
||||
AThreadID: Integer; AnOsClasses: TOSDbgClasses);
|
||||
const
|
||||
{.$IFDEF CPU64}
|
||||
MAP_ID_SIZE = itu8;
|
||||
@ -1404,6 +1463,7 @@ const
|
||||
begin
|
||||
FProcessID := AProcessID;
|
||||
FThreadID := AThreadID;
|
||||
FOSDbgClasses := AnOsClasses;
|
||||
|
||||
FBreakpointList := TFpInternalBreakpointList.Create(False);
|
||||
FWatchPointList := TFpInternalBreakpointList.Create(False);
|
||||
@ -1803,15 +1863,16 @@ begin
|
||||
FExitCode:=AValue;
|
||||
end;
|
||||
|
||||
class function TDbgProcess.StartInstance(AFileName: string; AParams, AnEnvironment: TStrings;
|
||||
AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags): TDbgProcess;
|
||||
class function TDbgProcess.StartInstance(AFileName: string; AParams,
|
||||
AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string;
|
||||
AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
begin
|
||||
DebugLn(DBG_VERBOSE, 'Debug support is not available for this platform.');
|
||||
result := nil;
|
||||
end;
|
||||
|
||||
class function TDbgProcess.AttachToInstance(AFileName: string; APid: Integer
|
||||
): TDbgProcess;
|
||||
class function TDbgProcess.AttachToInstance(AFileName: string; APid: Integer;
|
||||
AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
begin
|
||||
DebugLn(DBG_VERBOSE, 'Attach not supported');
|
||||
Result := nil;
|
||||
@ -2707,14 +2768,13 @@ begin
|
||||
end;
|
||||
|
||||
initialization
|
||||
GOSDbgClasses := nil;
|
||||
|
||||
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
|
||||
DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_WARNINGS' {$IFDEF DBG_WARNINGS} , True {$ENDIF} );
|
||||
DBG_BREAKPOINTS := DebugLogger.FindOrRegisterLogGroup('DBG_BREAKPOINTS' {$IFDEF DBG_BREAKPOINTS} , True {$ENDIF} );
|
||||
FPDBG_COMMANDS := DebugLogger.FindOrRegisterLogGroup('FPDBG_COMMANDS' {$IFDEF FPDBG_COMMANDS} , True {$ENDIF} );
|
||||
|
||||
|
||||
finalization
|
||||
GOSDbgClasses.Free;
|
||||
if assigned(RegisteredDbgProcessClasses) then
|
||||
FreeAndNil(RegisteredDbgProcessClasses);
|
||||
|
||||
end.
|
||||
|
@ -183,6 +183,7 @@ type
|
||||
FOnLibraryUnloadedEvent: TOnLibraryUnloadedEvent;
|
||||
FOnThreadBeforeProcessLoop: TNotifyEvent;
|
||||
FOnThreadProcessLoopCycleEvent: TOnProcessLoopCycleEvent;
|
||||
FOsDbgClasses: TOSDbgClasses;
|
||||
FRunning, FPauseRequest: cardinal;
|
||||
FAttachToPid: Integer;
|
||||
FDetaching: cardinal;
|
||||
@ -207,6 +208,8 @@ type
|
||||
procedure SetExecutableFilename(AValue: string);
|
||||
procedure DoOnDebugInfoLoaded(Sender: TObject);
|
||||
procedure SetParams(AValue: TStringList);
|
||||
|
||||
procedure CheckExecutableAndLoadClasses;
|
||||
protected
|
||||
FMainProcess: TDbgProcess;
|
||||
FCurrentProcess: TDbgProcess;
|
||||
@ -232,6 +235,7 @@ type
|
||||
procedure ProcessLoop;
|
||||
procedure SendEvents(out continue: boolean);
|
||||
property CurrentCommand: TDbgControllerCmd read FCommand;
|
||||
property OsDbgClasses: TOSDbgClasses read FOsDbgClasses;
|
||||
|
||||
property ExecutableFilename: string read FExecutableFilename write SetExecutableFilename;
|
||||
property AttachToPid: Integer read FAttachToPid write FAttachToPid;
|
||||
@ -869,6 +873,11 @@ begin
|
||||
FParams.Assign(AValue);
|
||||
end;
|
||||
|
||||
procedure TDbgController.CheckExecutableAndLoadClasses;
|
||||
begin
|
||||
FOsDbgClasses := FpDbgClasses.GetDbgProcessClass;
|
||||
end;
|
||||
|
||||
procedure TDbgController.SetExecutableFilename(AValue: string);
|
||||
begin
|
||||
if FExecutableFilename=AValue then Exit;
|
||||
@ -975,13 +984,22 @@ begin
|
||||
Exit;
|
||||
end;
|
||||
|
||||
// Get exe info, load classes
|
||||
CheckExecutableAndLoadClasses;
|
||||
if not Assigned(OsDbgClasses) then
|
||||
begin
|
||||
result := false;
|
||||
DebugLn(DBG_WARNINGS, 'Error - No support registered for debug target');
|
||||
exit;
|
||||
end;
|
||||
|
||||
Flags := [];
|
||||
if RedirectConsoleOutput then Include(Flags, siRediretOutput);
|
||||
if ForceNewConsoleWin then Include(Flags, siForceNewConsole);
|
||||
if AttachToPid <> 0 then
|
||||
FCurrentProcess := OSDbgClasses.DbgProcessClass.AttachToInstance(FExecutableFilename, AttachToPid)
|
||||
FCurrentProcess := OSDbgClasses.DbgProcessClass.AttachToInstance(FExecutableFilename, AttachToPid, OsDbgClasses)
|
||||
else
|
||||
FCurrentProcess := OSDbgClasses.DbgProcessClass.StartInstance(FExecutableFilename, Params, Environment, WorkingDirectory, FConsoleTty, Flags);
|
||||
FCurrentProcess := OSDbgClasses.DbgProcessClass.StartInstance(FExecutableFilename, Params, Environment, WorkingDirectory, FConsoleTty, Flags, OsDbgClasses);
|
||||
if assigned(FCurrentProcess) then
|
||||
begin
|
||||
FProcessMap.Add(FCurrentProcess.ProcessID, FCurrentProcess);
|
||||
|
@ -12,7 +12,7 @@ uses
|
||||
termio,
|
||||
process,
|
||||
FpDbgClasses,
|
||||
FpDbgLoader,
|
||||
FpDbgLoader, FpDbgDisasX86,
|
||||
DbgIntfBaseTypes, DbgIntfDebuggerBase,
|
||||
FpDbgLinuxExtra,
|
||||
FpDbgDwarfDataClasses,
|
||||
@ -145,8 +145,8 @@ type
|
||||
function AnalyseDebugEvent(AThread: TDbgThread): TFPDEvent; override;
|
||||
function CreateWatchPointData: TFpWatchPointData; override;
|
||||
public
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags): TDbgProcess; override;
|
||||
constructor Create(const AName: string; const AProcessID, AThreadID: Integer); override;
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess; override;
|
||||
constructor Create(const AName: string; const AProcessID, AThreadID: Integer; AnOsClasses: TOSDbgClasses); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override;
|
||||
@ -163,8 +163,6 @@ type
|
||||
function Pause: boolean; override;
|
||||
end;
|
||||
|
||||
procedure RegisterDbgClasses;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
@ -226,13 +224,6 @@ function ptsname(__fd:longint):Pchar;cdecl;external 'c' name 'ptsname';
|
||||
function grantpt(__fd:longint):longint;cdecl;external 'c' name 'grantpt';
|
||||
function unlockpt(__fd:longint):longint;cdecl;external 'c' name 'unlockpt';
|
||||
|
||||
procedure RegisterDbgClasses;
|
||||
begin
|
||||
OSDbgClasses.DbgProcessClass:=TDbgDarwinProcess;
|
||||
OSDbgClasses.DbgThreadClass:=TDbgDarwinThread;
|
||||
OSDbgClasses.DbgDisassemblerClass := TX86Disassembler;
|
||||
end;
|
||||
|
||||
Function WIFSTOPPED(Status: Integer): Boolean;
|
||||
begin
|
||||
WIFSTOPPED:=((Status and $FF)=$7F);
|
||||
@ -626,11 +617,11 @@ begin
|
||||
end;
|
||||
|
||||
constructor TDbgDarwinProcess.Create(const AName: string; const AProcessID,
|
||||
AThreadID: Integer);
|
||||
AThreadID: Integer; AnOsClasses: TOSDbgClasses);
|
||||
var
|
||||
aKernResult: kern_return_t;
|
||||
begin
|
||||
inherited Create(AName, AProcessID, AThreadID);
|
||||
inherited Create(AName, AProcessID, AThreadID, AnOsClasses);
|
||||
|
||||
GetDebugAccessRights;
|
||||
aKernResult:=task_for_pid(mach_task_self, AProcessID, FTaskPort);
|
||||
@ -648,7 +639,7 @@ end;
|
||||
|
||||
class function TDbgDarwinProcess.StartInstance(AFileName: string; AParams,
|
||||
AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string;
|
||||
AFlags: TStartInstanceFlags): TDbgProcess;
|
||||
AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
var
|
||||
PID: TPid;
|
||||
AProcess: TProcessUTF8;
|
||||
@ -705,7 +696,7 @@ begin
|
||||
PID:=AProcess.ProcessID;
|
||||
|
||||
sleep(100);
|
||||
result := TDbgDarwinProcess.Create(AFileName, Pid, -1);
|
||||
result := TDbgDarwinProcess.Create(AFileName, Pid, -1, AnOsClasses);
|
||||
TDbgDarwinProcess(result).FMasterPtyFd := AMasterPtyFd;
|
||||
TDbgDarwinProcess(result).FProcProcess := AProcess;
|
||||
TDbgDarwinProcess(result).FExecutableFilename := AnExecutabeFilename;
|
||||
@ -958,4 +949,10 @@ initialization
|
||||
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
|
||||
DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_WARNINGS' {$IFDEF DBG_WARNINGS} , True {$ENDIF} );
|
||||
|
||||
RegisterDbgOsClasses(TOSDbgClasses.Create(
|
||||
TDbgDarwinProcess,
|
||||
TDbgDarwinThread,
|
||||
TX86Disassembler
|
||||
));
|
||||
|
||||
end.
|
||||
|
@ -14,7 +14,7 @@ uses
|
||||
termio, fgl,
|
||||
process,
|
||||
FpDbgClasses,
|
||||
FpDbgLoader,
|
||||
FpDbgLoader, FpDbgDisasX86,
|
||||
DbgIntfBaseTypes, DbgIntfDebuggerBase,
|
||||
FpDbgLinuxExtra,
|
||||
FpDbgInfo,
|
||||
@ -292,10 +292,10 @@ type
|
||||
function CreateWatchPointData: TFpWatchPointData; override;
|
||||
public
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings;
|
||||
AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags): TDbgProcess; override;
|
||||
class function AttachToInstance(AFileName: string; APid: Integer
|
||||
AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess; override;
|
||||
class function AttachToInstance(AFileName: string; APid: Integer; AnOsClasses: TOSDbgClasses
|
||||
): TDbgProcess; override;
|
||||
constructor Create(const AName: string; const AProcessID, AThreadID: Integer); override;
|
||||
constructor Create(const AName: string; const AProcessID, AThreadID: Integer; AnOsClasses: TOSDbgClasses); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override;
|
||||
@ -313,8 +313,6 @@ type
|
||||
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
|
||||
end;
|
||||
|
||||
procedure RegisterDbgClasses;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
@ -322,13 +320,6 @@ var
|
||||
GConsoleTty: string;
|
||||
GSlavePTyFd: cint;
|
||||
|
||||
procedure RegisterDbgClasses;
|
||||
begin
|
||||
OSDbgClasses.DbgProcessClass:=TDbgLinuxProcess;
|
||||
OSDbgClasses.DbgThreadClass:=TDbgLinuxThread;
|
||||
OSDbgClasses.DbgDisassemblerClass := TX86Disassembler;
|
||||
end;
|
||||
|
||||
Function WIFSTOPPED(Status: Integer): Boolean;
|
||||
begin
|
||||
WIFSTOPPED:=((Status and $FF)=$7F);
|
||||
@ -735,11 +726,11 @@ begin
|
||||
end;
|
||||
|
||||
constructor TDbgLinuxProcess.Create(const AName: string; const AProcessID,
|
||||
AThreadID: Integer);
|
||||
AThreadID: Integer; AnOsClasses: TOSDbgClasses);
|
||||
begin
|
||||
FMasterPtyFd:=-1;
|
||||
FPostponedSignals := TFpDbgLinuxSignalQueue.Create;
|
||||
inherited Create(AName, AProcessID, AThreadID);
|
||||
inherited Create(AName, AProcessID, AThreadID, AnOsClasses);
|
||||
end;
|
||||
|
||||
destructor TDbgLinuxProcess.Destroy;
|
||||
@ -751,7 +742,7 @@ end;
|
||||
|
||||
class function TDbgLinuxProcess.StartInstance(AFileName: string; AParams,
|
||||
AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string;
|
||||
AFlags: TStartInstanceFlags): TDbgProcess;
|
||||
AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
var
|
||||
PID: TPid;
|
||||
AProcess: TProcessUTF8;
|
||||
@ -800,7 +791,7 @@ begin
|
||||
PID:=AProcess.ProcessID;
|
||||
|
||||
sleep(100);
|
||||
result := TDbgLinuxProcess.Create(AFileName, Pid, -1);
|
||||
result := TDbgLinuxProcess.Create(AFileName, Pid, -1, AnOsClasses);
|
||||
TDbgLinuxProcess(result).FMasterPtyFd := AMasterPtyFd;
|
||||
TDbgLinuxProcess(result).FProcProcess := AProcess;
|
||||
except
|
||||
@ -818,12 +809,12 @@ begin
|
||||
end;
|
||||
|
||||
class function TDbgLinuxProcess.AttachToInstance(AFileName: string;
|
||||
APid: Integer): TDbgProcess;
|
||||
APid: Integer; AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
begin
|
||||
Result := nil;
|
||||
fpPTrace(PTRACE_ATTACH, APid, nil, Pointer(PTRACE_O_TRACECLONE));
|
||||
|
||||
result := TDbgLinuxProcess.Create(AFileName, APid, 0);
|
||||
result := TDbgLinuxProcess.Create(AFileName, APid, 0, AnOsClasses);
|
||||
|
||||
// TODO: change the filename to the actual exe-filename. Load the correct dwarf info
|
||||
end;
|
||||
@ -1367,4 +1358,11 @@ end;
|
||||
initialization
|
||||
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
|
||||
DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_WARNINGS' {$IFDEF DBG_WARNINGS} , True {$ENDIF} );
|
||||
|
||||
RegisterDbgOsClasses(TOSDbgClasses.Create(
|
||||
TDbgLinuxProcess,
|
||||
TDbgLinuxThread,
|
||||
TX86Disassembler
|
||||
));
|
||||
|
||||
end.
|
||||
|
@ -177,7 +177,7 @@ type
|
||||
procedure InitializeLoaders; override;
|
||||
function CreateWatchPointData: TFpWatchPointData; override;
|
||||
public
|
||||
constructor Create(const AFileName: string; const AProcessID, AThreadID: Integer); override;
|
||||
constructor Create(const AFileName: string; const AProcessID, AThreadID: Integer; AnOsClasses: TOSDbgClasses); override;
|
||||
destructor Destroy; override;
|
||||
|
||||
function ReadData(const AAdress: TDbgPtr; const ASize: Cardinal; out AData): Boolean; override;
|
||||
@ -188,8 +188,8 @@ type
|
||||
procedure Interrupt; // required by app/fpd
|
||||
function HandleDebugEvent(const ADebugEvent: TDebugEvent): Boolean;
|
||||
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags): TDbgProcess; override;
|
||||
class function AttachToInstance(AFileName: string; APid: Integer): TDbgProcess; override;
|
||||
class function StartInstance(AFileName: string; AParams, AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string; AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess; override;
|
||||
class function AttachToInstance(AFileName: string; APid: Integer; AnOsClasses: TOSDbgClasses): TDbgProcess; override;
|
||||
function Continue(AProcess: TDbgProcess; AThread: TDbgThread; SingleStep: boolean): boolean; override;
|
||||
function Detach(AProcess: TDbgProcess; AThread: TDbgThread): boolean; override;
|
||||
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
|
||||
@ -220,8 +220,6 @@ type
|
||||
end;
|
||||
|
||||
|
||||
procedure RegisterDbgClasses;
|
||||
|
||||
implementation
|
||||
|
||||
var
|
||||
@ -336,14 +334,6 @@ begin
|
||||
{$endif}
|
||||
end;
|
||||
|
||||
procedure RegisterDbgClasses;
|
||||
begin
|
||||
OSDbgClasses.DbgThreadClass:=TDbgWinThread;
|
||||
OSDbgClasses.DbgBreakpointClass:=TFpInternalBreakpoint;
|
||||
OSDbgClasses.DbgProcessClass:=TDbgWinProcess;
|
||||
OSDbgClasses.DbgDisassemblerClass := TX86Disassembler;
|
||||
end;
|
||||
|
||||
procedure TDbgWinProcess.LogLastError;
|
||||
begin
|
||||
if not GotExitProcess then
|
||||
@ -483,14 +473,14 @@ begin
|
||||
end;
|
||||
|
||||
constructor TDbgWinProcess.Create(const AFileName: string; const AProcessID,
|
||||
AThreadID: Integer);
|
||||
AThreadID: Integer; AnOsClasses: TOSDbgClasses);
|
||||
begin
|
||||
{$ifdef cpui386}
|
||||
FBitness := b32;
|
||||
{$else}
|
||||
FBitness := b64;
|
||||
{$endif}
|
||||
inherited Create(AFileName, AProcessID, AThreadID);
|
||||
inherited Create(AFileName, AProcessID, AThreadID, AnOsClasses);
|
||||
end;
|
||||
|
||||
destructor TDbgWinProcess.Destroy;
|
||||
@ -619,7 +609,7 @@ end;
|
||||
|
||||
class function TDbgWinProcess.StartInstance(AFileName: string; AParams,
|
||||
AnEnvironment: TStrings; AWorkingDirectory, AConsoleTty: string;
|
||||
AFlags: TStartInstanceFlags): TDbgProcess;
|
||||
AFlags: TStartInstanceFlags; AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
var
|
||||
AProcess: TProcessUTF8;
|
||||
begin
|
||||
@ -635,7 +625,7 @@ begin
|
||||
AProcess.CurrentDirectory:=AWorkingDirectory;
|
||||
AProcess.Execute;
|
||||
|
||||
result := TDbgWinProcess.Create(AFileName, AProcess.ProcessID, AProcess.ThreadID);
|
||||
result := TDbgWinProcess.Create(AFileName, AProcess.ProcessID, AProcess.ThreadID, AnOsClasses);
|
||||
TDbgWinProcess(result).FProcProcess := AProcess;
|
||||
except
|
||||
on E: Exception do
|
||||
@ -653,8 +643,8 @@ begin
|
||||
end;
|
||||
end;
|
||||
|
||||
class function TDbgWinProcess.AttachToInstance(AFileName: string; APid: Integer
|
||||
): TDbgProcess;
|
||||
class function TDbgWinProcess.AttachToInstance(AFileName: string;
|
||||
APid: Integer; AnOsClasses: TOSDbgClasses): TDbgProcess;
|
||||
begin
|
||||
Result := nil;
|
||||
if _DebugActiveProcess = nil then
|
||||
@ -662,7 +652,7 @@ begin
|
||||
if not _DebugActiveProcess(APid) then
|
||||
exit;
|
||||
|
||||
result := TDbgWinProcess.Create(AFileName, APid, 0);
|
||||
result := TDbgWinProcess.Create(AFileName, APid, 0, AnOsClasses);
|
||||
// TODO: change the filename to the actual exe-filename. Load the correct dwarf info
|
||||
end;
|
||||
|
||||
@ -1742,5 +1732,12 @@ initialization
|
||||
|
||||
DBG_VERBOSE := DebugLogger.FindOrRegisterLogGroup('DBG_VERBOSE' {$IFDEF DBG_VERBOSE} , True {$ENDIF} );
|
||||
DBG_WARNINGS := DebugLogger.FindOrRegisterLogGroup('DBG_WARNINGS' {$IFDEF DBG_WARNINGS} , True {$ENDIF} );
|
||||
|
||||
RegisterDbgOsClasses(TOSDbgClasses.Create(
|
||||
TDbgWinProcess,
|
||||
TDbgWinThread,
|
||||
TX86Disassembler
|
||||
));
|
||||
|
||||
end.
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user