[ZeroBrane Studio] Re: Remote debugging: IDE project path vs. actual file path

  • From: jan@xxxxxxxxxxx
  • To: zerobrane@xxxxxxxxxxxxx
  • Date: Fri, 24 Oct 2014 11:00:04 +0200



However, this only works when the file name is known. For example, if
you run "lua.exe d:\foo\bar.lua", the interpreter reports
"d:\foo\bar.lua" as the file path, so the IDE knows exactly what file
to check for. However, in your case you load it as
"../../startdebug.lua", which is likely the path that IDE gets, but
when this path is combined with the project dir "..gamedir\scripts\",
the combined path is "..gamedir\scripts\..\..\startdebug.lua", so the
IDE checks for that file outside of "gamedir" folder and the file is
(obviously) not there. Then the IDE falls back to the last resort,
which is to check the name of the currently opened file and if it
happens to be startdebug.lua, it will happily assume that this is the
one you wanted to debug and remap the paths based on that information
(which probably makes the breakpoints to work in the case as well).

This is the same effect as can be achieved with the solution I sent
you earlier, which also avoid the need to startdebug.lua. Hope the
explanation sheds some light on what may be going on in your case.


Ah, okay, I think I understand how the path confusion happens.
However, I also tried out your solution with:
ide:GetDebugger().options = {basedir = [[C:\SurvivorRepo\own_projects\TwoSuns\bin\Debug_Win\..\..\scripts]]}

And I would say it almost works. When setting the scripts folder as the project directory and running the script "../../scripts/startdebug.lua" (I prefer having an own file for that so this does not "pollute" the actual gameplay scripts), I get this message: Mapped remote request for '../' to 'C:\SurvivorRepo\own_projects\TwoSuns\bin\Debug_Win\..\..\scripts\'. Debugging session started in 'C:\SurvivorRepo\own_projects\TwoSuns\bin\Debug_Win\..\..\scripts\'.

Almost, because it would need to be "../../", not "../". Is there any way to print how ZBS "calculates" that mapping? Because Debug_Win/../../scripts really is the correct path, so something else probably goes wrong.

And again, it will only work like that at all if the debugstart.lua file is the one currently being viewed. While autoactivate lets it start debugging even if debugstart.lua is not open, breakpoints do not work, I get no "Mapped..." message and it starts the debugging in whatever path the currently viewed file is in.

Again, I would seriously propose a possibility to just point ZBS not only to the project directory, but also using package.path and pointing it to a working directory. By default, this could be the same as the project directory, to avoid hassle for non embedded usage. But in my case, if ZBS just "knew" that the project directory is not the running directory, it could calculate the correct path itself, especially when also taking the package.path into account. All other IDEs also assume a separate working/running directory that the user must give (which is set to the project dir by default, but never works like that and must be changed). So, any combination of project directory, running directory and package.path should always yield the correct file. As that is exactly what Lua itself does.

At the moment I feel that ZBS tries to be smart and fails, and such a case always calls for either making the program even smarter (which can be hard). Or just point it in the right direction, for example by telling it to ignore the paths it gets from mobdebug (I guess?) and just use the files with the same name in the project directory, even if ít thinks the paths don't match.

I know, I got a lot of proposals with this and the extra tooltip window ;) But I really feel that this is needed. Even if we find a way to make it work without such a proposal, it would probably be a bit hacky.

Other related posts: