Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add. debugger.pathmap settings to manually map remote and local paths #849

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

moteus
Copy link
Contributor

@moteus moteus commented Dec 27, 2017

Settings like

-- relative path from the project dir
-- NOTE. This is not regexp but just starts of path
debugger.pathmap = {
    {'/usr/share/userverlua/userver', '../userverlua/lua/userver'}
}

I need this because I need map 2 remote dirs.
../ maps to may project automatically by ZBS.
But I also has different project on remote side which should map to
different local path. So full map should looks like:
../ -> ~/project/client (done by ZBS)
/usr/share/server -> ~/project/server (done by this new settings)

May be there better name for this optioms

@pkulchenko
Copy link
Owner

Since we discuss it in #846, I'll copy the relevant part here for the discussion:

In my case I have actually 2 project one of which I develop and second one is server part. I can not edit this server project and install script installs it from repo on docker during configure test env. So in docket I have ~/myproject which map to my project and /usr/share/server which should map on second project. And some time when I debug my project I want to be able to step in in to a server code.

I still don't see how this works with one project, since this requires two different environments in your applications and in the IDE. Can you provide more details on how you "step in to a server code", because this is one of the things I don't quite follow in the discussion. Do you have the same code in your application and in your server code? Because if not, then it's two different projects and probably need to be debugged from two different instances of the IDE (which is possible to setup).

@moteus
Copy link
Contributor Author

moteus commented Dec 28, 2017

Server side is applicatin server with set of libraries, This is separate project written on Lua,
Server creates Lua coroutine and calls client code via pcall function. Say main function from /usr/share/server/main.lua calls action function from ~/project/client/main.lua.
And Client and Server are different projects. I edit only client side but whant to be able step it to
the server side some times.
In debug environment there some predefined Server version installed in /usr/share/server and
current client code (in docker just mount ~/ dir from host system).
On my local machine I separatly checkout server project to ~/project/server. Code match
because I know version on dev system.

@pkulchenko
Copy link
Owner

pkulchenko commented May 16, 2020

@moteus, I see from the discussion in #998 that you have a mapping that looks like the following:

local maps = {
    {'/usr/share/userverlua/userver/wssp', '/home/amelnichuk/projects/wssp/lua/userver/wssp'},
    {'/usr/share/userverlua/userver',      '/home/amelnichuk/projects/userverlua/lua/userver'},
}

I agree, this configuration is not supported by the current setup, as its assumption is that one source tree is present on both the client and the server (even though the paths to that tree may be different and will be remapped as needed). In you case subdirectories are mapped to different trees, which require explicit remapping.

I'm more inclined to merge it, even though it's likely to be a rare case. Let me think about the name (it's likely to be dirmap or pathmap to stay consistent with the rest of the settings).

Do you think it will help to address #998 as well?

@pkulchenko pkulchenko self-assigned this May 16, 2020
@moteus
Copy link
Contributor Author

moteus commented May 16, 2020

There need map to the both ways. First one to support step by step debugging and second one to support breakpoints.
This PR only support the first one.
Support the second one I made this in this commit
I still have no idea about the best way to configure this. I do not like to have 2 maps, but not sure that one map like local maps in my current config can solve all cases. In fact I use such maps per project because different projects uses different versions of thouse libraries so I hase separate dirs for each one

@moteus moteus changed the title Add. debugger.dir_map settings to manually map remote and local paths Add. debugger.pathmap settings to manually map remote and local paths May 19, 2020
@moteus
Copy link
Contributor Author

moteus commented May 25, 2020

With the last update, config looks like

debugger.pathmap = {
    {'/usr/share/userverlua/userver/wssp', '../wssp/lua/userver/wssp'},
    {'/usr/share/userverlua/userver',      '../userverlua/lua/userver'},
}

This allows to use the same config on all platforma (Win/Linux) and by several users (because the not full path to the home directory).

@pkulchenko
Copy link
Owner

@moteus, I pushed several changes to Mobdebug (to address pkulchenko/MobDebug#51) and suspect that they may help with the remapping you are looking for as well.

Can you do the following experiment if you have few minutes:

  1. Get the updated version of mobdebug (it hasn't been integrated into ZBS yet)
  2. Get the unmodified version of ZBS (without the changes in this PR)
  3. Set the project directory to a directory that is a parent to both your client and server code
  4. Try debugging of both the client and the server code

Another option is to replace step 3 with: Set the project directory to a directory that only has the client code, but open the server/main.lua in the IDE (or whatever other server file you want to debug). I'd be interested if stepping/debugging works in these cases. Thanks!

@rulatir
Copy link

rulatir commented Jul 21, 2020

Another case for multiple mappings: tests. Spec files will likely reside in a different tree than code under test, so there are at least two source roots to map. One particular test runner, busted, definitely has a notion of "tests root", and I can see that when trying to debug, the paths to spec files under the tests root are reported relatively to the tests root. It may be possible to define LUA_PATH relatively to the tests root as well just for busted, but it would be inconvenient and unnatural at best, and it would add another point of divergence between testing and operation environment - something that should be avoided.

@rulatir
Copy link

rulatir commented Sep 29, 2020

Please just merge this? Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants