Forum > Debugger

How to set HostApplication with a relative path or something similar?

<< < (2/4) > >>

EMBarbosa:
I commented this in the issue. But as I'm not familiar with the the IDE code, I'm not sure if it is right.

EMBarbosa:

--- Quote from: Martin_fr on December 26, 2022, 10:05:57 pm ---I have not tested, but it is possible that the "patch" https://gitlab.com/freepascal.org/lazarus/lazarus/-/issues/32331#note_638205833 still works.
It may not be the final solution, but it may at least give you some workaround.

--- End quote ---

Hi Martin. It doesn't work anymore. Now there is a code in TMainIDE.DoInitProjectRun that validate if the application exists using FileExists.
line 7258 of Main.pp:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  // Check project build  ProgramFilename := MainBuildBoss.GetProjectTargetFilename(Project1);  if ConsoleVerbosity>0 then    DebugLn(['Hint: (lazarus) [TMainIDE.DoInitProjectRun] ProgramFilename=',ProgramFilename]);  if ((DebugClass = nil) or DebugClass.RequiresLocalExecutable)     and not FileExistsUTF8(ProgramFilename)  then begin    debugln(['Info: (lazarus) [TMainIDE.DoInitProjectRun] File TargetFile found: "',ProgramFilename,'"']);    IDEMessageDialog(lisFileNotFound,      Format(lisNoProgramFileSFound, [ProgramFilename]),      mtError,[mbCancel]);    Exit;  end;  

Martin_fr:
Haven't looked at any related code for some time...

The file that the debugger will run, is set in
unit DebugManager

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TDebugManager.InitDebugger(AFlags: TDbgInitFlags): Boolean;...  if not(difInitForAttach in AFlags) then begin...  else    GetLaunchPathAndExe(LaunchingCmdLine, LaunchingApplication, LaunchingParams, False);...      if FDebugger <> nil      then FDebugger.FileName := LaunchingApplication;
But I haven't tracked where the values from the settings are retrieved.

Also, all of this code has been written for gdb (and much of it in the old days, for older gdb, and for really old Linux terminals).

Not sure how much of it was updated over time. And most of it want have been tested with FpDebug.

There are several issues debugging libraries, when it comes to setting breakpoints (including those internally set by the IDE to catch exceptions). IIRC There is a bit about it somewhere on the wiki.... It may work with current versions of gdb.


Currently my time goes to work on the debugger frontend and fpdebug for general debugging.
Depending what comes up, some fixes and work outside the debugger.
And then hopefully improve debugging of libraries. (fixing the breakpoint issue, and at that time - if not forgotten - look at the hosting app)

EMBarbosa:

--- Quote from: Martin_fr on December 27, 2022, 05:57:08 pm ---Haven't looked at any related code for some time...
But I haven't tracked where the values from the settings are retrieved.

--- End quote ---
I've debugged the IDE. And this code is never executed if the settings has a relative path, "macro" or "environment var". The error message I've mentioned in original post is launched by this code in Main.pp:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---            // Check project build      ProgramFilename := MainBuildBoss.GetProjectTargetFilename(Project1);...      if ((DebugClass = nil) or DebugClass.RequiresLocalExecutable)         and not FileExistsUTF8(ProgramFilename) // <---- HERE! This code should not validate the EXE before parse relatives paths/macros/envvar... IMHO      then begin        debugln(['Info: (lazarus) [TMainIDE.DoInitProjectRun] File TargetFile found: "',ProgramFilename,'"']);        IDEMessageDialog(lisFileNotFound,          Format(lisNoProgramFileSFound, [ProgramFilename]),          mtError,[mbCancel]);        Exit;      end; 

--- Quote from: Martin_fr on December 27, 2022, 05:57:08 pm ---
The file that the debugger will run, is set in
unit DebugManager

--- End quote ---
Yes... but the IDE doesn't execute this code. The execution is halted in Main.pp as said before.

I want to help, but I'm not familiar with the IDE code and I'm struggling in find any direction. If there is anything I could do, please guide me.

Thanks you for your time 'til now.

EMBarbosa:
ok... I did investigate a little more... and apparently found a patch for solve this.

The file checked by the IDE is mounted in MainBuildBoss.GetProjectTargetFilename().
There, the code checks for macros, but only some IDE functions macros (the ones listed in https://wiki.freepascal.org/IDE_Macros_in_paths_and_filenames#Filename_Parts except MakeEXE and MakeLib).

This is the actual code:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TBuildManager.GetProjectTargetFilename(aProject: TProject): string;var  AMode: TRunParamsOptionsMode;begin  Result:='';  if aProject=nil then exit;  AMode := aProject.RunParameterOptions.GetActiveMode;  if AMode<>nil then    Result:=AMode.HostApplicationFilename;  GlobalMacroList.SubstituteStr(Result);  if (Result='') and (aProject.MainUnitID>=0) then begin    Result := aProject.CompilerOptions.CreateTargetFilename;  end;end;
So I changed the code to:


--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---function TBuildManager.GetProjectTargetFilename(aProject: TProject): string;var  AMode: TRunParamsOptionsMode;  PathTarget: string;begin  Result:='';  if aProject=nil then exit;  AMode := aProject.RunParameterOptions.GetActiveMode;  if AMode<>nil then    Result:=AMode.HostApplicationFilename;  GlobalMacroList.SubstituteStr(Result);  if (Result <> '') and (not FilenameIsAbsolute(Result)) then  begin    //alow relatives paths in HostApplicationFilename    PathTarget := ExtractFilePath(aProject.CompilerOptions.CreateTargetFilename);    Result := CreateAbsolutePath(Result, PathTarget);  end;  if (Result='') and (aProject.MainUnitID>=0) then begin    Result := aProject.CompilerOptions.CreateTargetFilename;  end;end;
Got a "works in my machine" seal of approval. :)


I'm not sure it should be implemented this way, as it raise the following questions:
1) The path should be relative to what? The project Dir or the target file dir?
2) Shouldn't other macros, "env var", etc... be checked too?
3)??

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version