diff --git a/components/fpdebug/fpdbgclasses.pp b/components/fpdebug/fpdbgclasses.pp index 224826e005..3ed0c7897d 100644 --- a/components/fpdebug/fpdbgclasses.pp +++ b/components/fpdebug/fpdbgclasses.pp @@ -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; diff --git a/components/fpdebug/fpdbgcontroller.pas b/components/fpdebug/fpdbgcontroller.pas index af181ebd75..4221e1ca6b 100644 --- a/components/fpdebug/fpdbgcontroller.pas +++ b/components/fpdebug/fpdbgcontroller.pas @@ -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; diff --git a/components/fpdebug/fpdbgdarwinclasses.pas b/components/fpdebug/fpdbgdarwinclasses.pas index 0f6c1a994b..cb13d07f33 100644 --- a/components/fpdebug/fpdbgdarwinclasses.pas +++ b/components/fpdebug/fpdbgdarwinclasses.pas @@ -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; diff --git a/components/fpdebug/fpdbgwinclasses.pas b/components/fpdebug/fpdbgwinclasses.pas index 5a34d5be8f..30052b7050 100644 --- a/components/fpdebug/fpdbgwinclasses.pas +++ b/components/fpdebug/fpdbgwinclasses.pas @@ -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); diff --git a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas index a31a2d65b9..4f08d1e95a 100644 --- a/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas +++ b/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas @@ -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);