LazDebuggerFp (pure): Pass arguments to debuggee

git-svn-id: trunk@44928 -
This commit is contained in:
joost 2014-05-05 20:15:42 +00:00
parent 805a4e6542
commit 04283997b4
5 changed files with 24 additions and 7 deletions

View File

@ -263,7 +263,7 @@ type
function DoBreak(BreakpointAddress: TDBGPtr; AThreadID: integer): Boolean;
procedure MaskBreakpointsInReadData(const AAdress: TDbgPtr; const ASize: Cardinal; var AData);
public
class function StartInstance(AFileName: string; AParams: string): TDbgProcess; virtual;
class function StartInstance(AFileName: string; AParams: TStringList): TDbgProcess; virtual;
constructor Create(const AName: string; const AProcessID, AThreadID: Integer); virtual;
destructor Destroy; override;
function AddBreak(const ALocation: TDbgPtr): TDbgBreakpoint; overload;
@ -799,7 +799,7 @@ begin
FExitCode:=AValue;
end;
class function TDbgProcess.StartInstance(AFileName: string; AParams: string): TDbgProcess;
class function TDbgProcess.StartInstance(AFileName: string; AParams: TStringList): TDbgProcess;
begin
DebugLn('Debug support for this platform is not available.');
result := nil;

View File

@ -33,9 +33,11 @@ type
FProcessMap: TMap;
FExitCode: DWord;
FPDEvent: TFPDEvent;
FParams: TStringList;
procedure SetExecutableFilename(AValue: string);
procedure SetOnLog(AValue: TOnLog);
procedure DoOnDebugInfoLoaded(Sender: TObject);
procedure SetParams(AValue: TStringList);
protected
FMainProcess: TDbgProcess;
FCurrentProcess: TDbgProcess;
@ -61,6 +63,7 @@ type
property OnLog: TOnLog read FOnLog write SetOnLog;
property CurrentProcess: TDbgProcess read FCurrentProcess;
property MainProcess: TDbgProcess read FMainProcess;
property Params: TStringList read FParams write SetParams;
property OnCreateProcessEvent: TOnCreateProcessEvent read FOnCreateProcessEvent write FOnCreateProcessEvent;
property OnHitBreakpointEvent: TOnHitBreakpointEvent read FOnHitBreakpointEvent write FOnHitBreakpointEvent;
@ -79,6 +82,12 @@ begin
FOnDebugInfoLoaded(Self);
end;
procedure TDbgController.SetParams(AValue: TStringList);
begin
if FParams=AValue then Exit;
FParams.Assign(AValue);
end;
procedure TDbgController.SetExecutableFilename(AValue: string);
begin
if FExecutableFilename=AValue then Exit;
@ -96,6 +105,7 @@ end;
destructor TDbgController.Destroy;
begin
//FCurrentProcess.Free;
FParams.Free;
inherited Destroy;
end;
@ -120,7 +130,7 @@ begin
Exit;
end;
FCurrentProcess := OSDbgClasses.DbgProcessClass.StartInstance(FExecutableFilename, '');
FCurrentProcess := OSDbgClasses.DbgProcessClass.StartInstance(FExecutableFilename, FParams);
if assigned(FCurrentProcess) then
begin
FCurrentProcess.OnDebugInfoLoaded := @DoOnDebugInfoLoaded;
@ -321,6 +331,7 @@ end;
constructor TDbgController.Create;
begin
FParams := TStringList.Create;
FProcessMap := TMap.Create(itu4, SizeOf(TDbgProcess));
end;

View File

@ -68,7 +68,7 @@ type
protected
function InitializeLoader: TDbgImageLoader; override;
public
class function StartInstance(AFileName: string; AParams: string): TDbgProcess; override;
class function StartInstance(AFileName: string; AParams: TStringList): TDbgProcess; override;
constructor Create(const AName: string; const AProcessID, AThreadID: Integer); override;
destructor Destroy; override;
@ -290,7 +290,7 @@ begin
inherited Destroy;
end;
class function TDbgDarwinProcess.StartInstance(AFileName: string; AParams: string): TDbgProcess;
class function TDbgDarwinProcess.StartInstance(AFileName: string; AParams: TStringList): TDbgProcess;
var
PID: TPid;
stat: longint;
@ -320,6 +320,7 @@ begin
try
AProcess.OnForkEvent:=@OnForkEvent;
AProcess.Executable:=AnExecutabeFilename;
AProcess.Parameters:=AParams;
AProcess.Execute;
PID:=AProcess.ProcessID;

View File

@ -99,7 +99,7 @@ type
procedure Interrupt;
function HandleDebugEvent(const ADebugEvent: TDebugEvent): Boolean;
class function StartInstance(AFileName: string; AParams: string): TDbgProcess; override;
class function StartInstance(AFileName: string; AParams: TStringList): TDbgProcess; override;
function Continue(AProcess: TDbgProcess; AThread: TDbgThread): boolean; override;
function WaitForDebugEvent(out ProcessIdentifier, ThreadIdentifier: THandle): boolean; override;
function ResolveDebugEvent(AThread: TDbgThread): TFPDEvent; override;
@ -398,7 +398,7 @@ begin
end;
end;
class function TDbgWinProcess.StartInstance(AFileName: string; AParams: string): TDbgProcess;
class function TDbgWinProcess.StartInstance(AFileName: string; AParams: TStringList): TDbgProcess;
var
AProcess: TProcess;
begin
@ -406,6 +406,7 @@ begin
try
AProcess.Options:=[poDebugProcess, poNewProcessGroup];
AProcess.Executable:=AFilename;
AProcess.Parameters:=AParams;
AProcess.Execute;
result := TDbgWinProcess.Create(AFileName, AProcess.ProcessID, AProcess.ThreadID);

View File

@ -9,6 +9,7 @@ uses
SysUtils,
Forms,
Maps,
process,
LazLogger,
FpDbgClasses,
FpDbgInfo,
@ -858,6 +859,9 @@ begin
if not assigned(FDbgController.MainProcess) then
begin
FDbgController.ExecutableFilename:=FileName;
FDbgController.Params.Clear;
if Arguments<>'' then
CommandToList(Arguments, FDbgController.Params);
FFpDebugThread := TFpDebugThread.Create(Self);
RTLeventWaitFor(FFpDebugThread.DebugLoopStoppedEvent);
RTLeventResetEvent(FFpDebugThread.DebugLoopStoppedEvent);