IDE: Run/Debug, search for LaunchApp and HostApp in Project-dir and %Path. issue #32331

- Search in %PATH was done by "run without debug", but not by debug.
- Checking for an exe relative to the project-dir was added for both.
- A plain file-name will be first checked in the project-dir, and after that in %PATH
This commit is contained in:
Martin 2023-02-03 17:13:19 +01:00
parent 66bc8c9281
commit a1b61028fa
2 changed files with 26 additions and 9 deletions

View File

@ -55,7 +55,7 @@ uses
IdeDebuggerStringConstants,
// IDE
CompilerOptions, EnvironmentOpts, SourceEditor, ProjectDefs, Project,
InputHistory, Debugger, LazarusIDEStrConsts, TransferMacros, MainBar,
InputHistory, LazConf, Debugger, LazarusIDEStrConsts, TransferMacros, MainBar,
MainIntf, MainBase, BaseBuildManager, SourceMarks, DebuggerDlg, Watchesdlg,
BreakPointsdlg, BreakPropertyDlg, LocalsDlg, WatchPropertyDlg, CallStackDlg,
EvaluateDlg, RegistersDlg, AssemblerDlg, DebugOutputForm, ExceptionDlg,
@ -308,6 +308,7 @@ function GetDebugManager: TDebugManager;
property DebugBossMgr: TDebugManager read GetDebugManager;
function DBGDateTimeFormatter(const aValue: string): string;
function ResolveLocationForLaunchApplication(ALaunchApp: String): String;
implementation
@ -340,6 +341,25 @@ begin
Result := aValue;
end;
function ResolveLocationForLaunchApplication(ALaunchApp: String): String;
var
tmp: String;
begin
Result := ALaunchApp;
if not FilenameIsAbsolute(ALaunchApp) then begin
tmp := CreateAbsolutePath(ALaunchApp, Project1.Directory);
if FileIsExecutable(tmp) then begin
Result := tmp;
end
else
if ExtractFilePath(ALaunchApp) = '' then begin
tmp := FindDefaultExecutablePath(ALaunchApp);
if tmp <> '' then
Result := tmp;
end;
end;
end;
type
{ TManagedBreakPoint }
@ -2514,6 +2534,9 @@ begin
LaunchingCmdLine := BuildBoss.GetRunCommandLine;
SplitCmdLine(LaunchingCmdLine, LaunchingApplication, LaunchingParams);
if NewDebuggerClass.RequiresLocalExecutable then
LaunchingApplication := ResolveLocationForLaunchApplication(LaunchingApplication);
(* TODO: workaround for http://bugs.freepascal.org/view.php?id=21834
Se Debugger.RequiresLocalExecutable
*)

View File

@ -7402,7 +7402,7 @@ begin
if ConsoleVerbosity>0 then
DebugLn(['Hint: (lazarus) [TMainIDE.DoInitProjectRun] ProgramFilename=',ProgramFilename]);
if ((DebugClass = nil) or DebugClass.RequiresLocalExecutable)
and not FileExistsUTF8(ProgramFilename)
and not FileExistsUTF8(ResolveLocationForLaunchApplication(ProgramFilename))
then begin
debugln(['Info: (lazarus) [TMainIDE.DoInitProjectRun] File TargetFile found: "',ProgramFilename,'"']);
IDEMessageDialog(lisFileNotFound,
@ -7520,13 +7520,7 @@ begin
ExeFile := Params[0];
Params.Delete(0);
//debugln('TMainIDE.DoRunProjectWithoutDebug ExeFile=',ExeFile);
if not FilenameIsAbsolute(ExeFile) then
begin
aFilename:=FindDefaultExecutablePath(ExeFile);
if aFilename<>'' then
ExeFile:=aFilename;
end;
ExeFile := ResolveLocationForLaunchApplication(ExeFile);
Process.Executable := ExeFile;
Process.Parameters.Assign(Params);